ComfyUI Node

_.isInt

An exact-type integer check with a numpy gotcha

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.isInt
  • 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 float like 3.0False (it's a float, not an int, even though it's mathematically integral).
  • A boolFalse. In Python, True and False are instances of int, but their type is bool, 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 Python int type. A value that looks like 5 and acts like 5 reads 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.int64 and torch tensor scalars read as False even though they're integer-valued. If you're checking computed values, that's probably not what you wanted.
  • Bools read as False - True is technically an int in Python, but not an exact int type.
  • 3.0 reads as False; it's a float. Use _.isIntegral if you want "mathematically integral" to count.
  • The output wire is *, not BOOLEAN.
Categoryovum/underscore

Inputs (1)

NameTypeDefaultDescription
objopt*Primary input object. Also accepts _.CHAIN to continue chaining.

Outputs (1)

NameTypeDescription
**