_.isInt
An exact-type integer check with a numpy gotcha
- obj
- *
_.isInt answers a deceptively simple question - "is this object an integer?" - with a deceptively strict implementation. It's type(self.obj) is int, the exact-type check, from the sfinktah/comfy-ovum pack's ovum/underscore family (auto-generated wrappers around underscore3, a Python port of Underscore.js). The strictness is the whole story here, because the thing that trips people up isn't the node - it's what counts as an int in a ComfyUI graph.
The family's README disclaimer applies: work in progress, "not recommended for use in workflows." Fair enough as a general caution. This particular node is trivial, though, and the behavior is fully predictable if you know one Python fact: type(x) is int is exact.
What it does
The check is type(self.obj) is int. Work through what that means:
- A plain Python
int(widget values,INT-typed node outputs) →True. - A
floatlike3.0→False(it's a float, not an int, even though it's mathematically integral). - A
bool→False. In Python,TrueandFalseare instances ofint, but their type isbool, so the exact check says no. If you want bools to count, use_.isIntegral. - A NumPy scalar like
numpy.int64(5)→False. This is the one that bites. Lots of ComfyUI custom nodes compute values with numpy or torch and hand back numpy scalars, which are not the Pythoninttype. A value that looks like5and acts like5reads as "not an int" here.
If your numbers only come from Comfy widgets, _.isInt works exactly as you'd expect. If they come from computed paths, expect surprises.
Like the rest of the family, it takes a plain value and returns the boolean, or takes a _.CHAIN from _.chain and keeps the chain going.
Inputs and outputs
obj- the only input, type*, optional.- Output - a single
*socket holding a Python bool (family quirk: value is boolean, socket is typed generic).
Where it fits
Honestly, this one's for validation and branching rather than day-to-day use. A typical case: a dynamic node returns a value that could be a string or a number, and you want to route it differently based on whether it's a genuine Python int. Or you're debugging why a numeric input isn't behaving and want to check the actual type coming off a wire. For "is this a whole number, roughly" questions, _.isIntegral is the better tool; for "is this literally a Python int," this is it.
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 is vendored in the repo, so no extra install for this node.
Gotchas
numpy.int64and torch tensor scalars read asFalseeven though they're integer-valued. If you're checking computed values, that's probably not what you wanted.- Bools read as
False-Trueis technically an int in Python, but not an exactinttype. 3.0reads asFalse; it's a float. Use_.isIntegralif you want "mathematically integral" to count.- The output wire is
*, notBOOLEAN.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| objopt | * | Primary input object. Also accepts _.CHAIN to continue chaining. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |