Nodes/comfy-ovum/_.isFloat
ComfyUI Node

_.isFloat

An exact-type float check that numpy will trip over

By sfinktah·Created about a year ago·Updated 10 months ago· 7
_.isFloat
  • obj
  • *

_.isFloat checks whether an object is a float - and like _.isInt, it does it with an exact type check: type(self.obj) is float. In the sfinktah/comfy-ovum pack's ovum/underscore family (auto-generated wrappers around underscore3, a Python port of Underscore.js), this is one of the straightforward ones. The only reason to think twice is what ComfyUI actually hands you when it says "this is a float."

The family's README caveat is the usual one: work in progress, "not recommended for use in workflows." For a one-line type check that's mostly noise, but it's worth remembering these nodes are auto-generated and uneven - which is exactly why this one and its exact-type siblings behave the way they do.

What it does

The check is type(self.obj) is float. Exact type, no isinstance. So:

  • A plain Python float like 1.5 or 0.0True.
  • An int like 1False (different type, even though 1.0 == 1).
  • A boolFalse.
  • A numpy.float32 or numpy.float64False. This is the real gotcha. ComfyUI is built on torch and numpy, and a lot of computed values - CFG schedules, timesteps, anything a custom node math'd up - arrive as numpy floats or even 0-d tensors. Those are not the Python float type, so _.isFloat says False for values that are unmistakably floats.

If your floats only ever come from ComfyUI's FLOAT widgets, this works perfectly. The moment they come from a computed path, expect the check to lie.

Like everything in the family, feed it a plain value and get the boolean back, or feed it a _.CHAIN from _.chain and it runs on the wrapped object, passing the chain onward.

Inputs and outputs

  • obj - the only input, type *, optional.
  • Output - a single * socket holding a Python bool. Standard family quirk: the value is a real boolean, the socket type is generic.

Where it fits

Type validation and debugging, mostly. If a dynamic node can hand back either a number or a string and you need to distinguish them, _.isFloat tells you "this is a genuine Python float." If you're debugging why a numeric input isn't behaving, checking the exact type off the wire is genuinely useful - you'll often find the value is a numpy scalar that's masquerading as a float.

For "is this a number at all" questions, _.isFloat is narrower than you want; for "is this exactly a float," it's exactly right.

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 float32/float64 and 0-d torch tensors read as False even though they're floats. The exact-type check is the whole behavior.
  • 1.0 is a float, 1 is not - the value doesn't matter, the type does.
  • Output wire is *, not BOOLEAN.
Categoryovum/underscore

Inputs (1)

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

Outputs (1)

NameTypeDescription
**