ComfyUI Node Runs on cloud

Evaluate Floats

Evaluate Floats

By jags111·Created 3 years ago·Updated 4 months ago· 1,485
Evaluate Floats
    • INT
    • FLOAT
    • STRING
    python_expression((a + b) - c) / 2
    print_to_console
    a0
    b0
    c0

    Sometimes you don't want another slider, you want math. Evaluate Floats lets you type a small Python expression - (a + b) / 2, max(a, b) * 1.5, whatever - and computes a number from up to three float inputs. It's the "just do the arithmetic" node for when a value in your workflow should be derived from other values instead of hand-set. Think dynamic upscale factors, computed step counts, or a strength that scales off some other parameter.

    How it works

    Under the hood it uses the simpleeval library, which evaluates simple Python expressions in a sandboxed way - so you get real operators and functions without handing your graph an arbitrary eval(). You write the expression, plug in your numbers, and it spits out the result in three formats at once so you can wire it into whatever the downstream node expects.

    The default expression is ((a + b) - c) / 2, which is really just there to show the shape. You'll replace it with your own.

    The inputs and outputs

    • python_expression (required) - the formula, as a string. Use a, b, c as your variables.
    • a, b, c (optional) - the float inputs, default 0. You can leave any unused; connect the ones your expression references.
    • print_to_console - True dumps the result to the ComfyUI console, which is genuinely useful for debugging a formula that's misbehaving.

    Three outputs come back from the same computation: INT, FLOAT, and STRING. That's the clever bit - a node downstream that wants an integer (step count, batch size) takes INT, one that wants a float (denoise, cfg) takes FLOAT, and STRING is there for labels or filenames. Note that INT is the result coerced to a whole number, so 7.8 becomes 7, not 8 - Python truncation, not rounding.

    Installing it

    ComfyUI Manager: search Efficiency Nodes for ComfyUI, install, restart. Manual:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jags111/efficiency-nodes-comfyui
    

    Then - and this is the part people miss - the Simple Eval nodes need the simpleeval library installed in ComfyUI's Python environment:

    pip install simpleeval
    

    If you installed the pack through Manager it usually pulls this in, but a manual clone won't, and the node will fail to appear until you add it.

    Common issues

    The one that trips everyone: the Simple Eval nodes silently don't load without simpleeval installed. If Evaluate Floats isn't in your node menu, run the pip install above into the correct environment (the same Python your ComfyUI uses - portable builds have their own embedded Python, so pip install in a random terminal won't reach it).

    Second, expression errors. simpleeval is deliberately restricted - it won't let you import modules or call arbitrary functions, so if you paste something exotic it'll just error. Stick to arithmetic, comparisons, and the handful of built-ins like min, max, abs. Flip print_to_console to True to see what it actually evaluated.

    And the pack-wide catch: if Efficiency Nodes throws IMPORT FAILED at startup - commonly a pip freeze non-zero exit - the entire pack drops out, this node included. Update ComfyUI and the node, and confirm the environment is healthy.

    CategoryEfficiency Nodes/Simple Eval

    Inputs (5)

    NameTypeDefaultDescription
    python_expressionSTRING((a + b) - c) / 2
    print_to_consoleCOMBO2 options: False, True
    aoptFLOAT0
    boptFLOAT0
    coptFLOAT0

    Outputs (3)

    NameTypeDescription
    INTINT
    FLOATFLOAT
    STRINGSTRING