_.isIntegral
The loose 'whole number' check that includes bools
- obj
- *
_.isIntegral is the relaxed cousin of _.isInt. Where _.isInt demands the exact Python int type, this one asks "is this a whole number?" and counts ints and bools. It's part of the sfinktah/comfy-ovum pack's ovum/underscore family, the auto-generated wrappers around underscore3 (a Python port of Underscore.js), and it's a genuinely reasonable question to want answered in a graph.
The implementation is one line: isinstance(self.obj, (int, bool)). Since Python's bool is a subclass of int, that tuple is almost redundant - isinstance(True, int) is already True - but the author wrote it out explicitly anyway. The docstring is where things get weird: it's the text of C++11's std::is_integral standard paragraph, pasted almost verbatim, talking about char, wchar_t, and cv-qualified variants. Someone went to the C++ reference and brought back the spec. That's charming, and it tells you exactly where the author's head was: this is a Python port reaching for a C++ concept and landing somewhere reasonable anyway.
What it does
int→True.bool(True/False) →True.float, even3.0→False.numpy.int64→ hmm, actuallyisinstance(numpy.int64(5), int)isTruefor 64-bit numpy ints (numpy registers them as subclasses of Python int). So this one is more tolerant of numpy than_.isIntis.
The contrast with _.isInt is the useful mental model: _.isIntegral(True) is True, _.isInt(True) is False. If you want "is this a whole number and I don't care about the ceremony," use this one.
Like all family members, it takes a plain value and returns the boolean, or takes a _.CHAIN from _.chain and passes the chain onward.
Inputs and outputs
obj- the only input, type*, optional.- Output - a single
*socket holding a Python bool (the family's generic-typed output quirk; the value is correct).
Where it fits
Validation before math. If a node is about to do integer arithmetic and you need to confirm the incoming value is integral before feeding it in, _.isIntegral is the honest check - it won't reject a bool that a downstream int() call would happily handle, and it's lenient enough not to cry about numpy ints. It's a nicer "is this usable as an integer" gate than _.isInt's exact-type pedantry.
Installing it
Install the pack via ComfyUI Manager (search comfy-ovum) or:
cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum
Restart ComfyUI. underscore3 ships in the repo, so nothing extra to install for this node.
Gotchas
- Floats are never integral here, even
3.0. If "mathematically a whole number" including floats is what you want, this isn't the node. - The docstring is C++
std::is_integraltext and doesn't precisely describe the Python behavior - the actual semantics areisinstance(x, (int, bool)), which is simpler and slightly different (Python has no separatechar/shorttypes). - Output wire is
*, notBOOLEAN- connectable anywhere, but a strict boolean consumer may want a cast.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |