DB Float Expression
One text box instead of a pile of math nodes
- output
ComfyUI's stock way to compute a number is to chain primitive math nodes - add, multiply, divide - until your graph looks like a game of Snake. DBFloatExpression collapses all of that into a single node with one text box. If you've seen rgthree's Power Puter and wished for a simpler, floats-only version of the same idea, this is it.
How it works
The node takes four float inputs - a, b, c, d - and one expression string, evaluates the expression as Python with only those four variables in scope, and returns the result as a FLOAT. You write plain Python operators:
a ** b
(a + b / c) * d
(a * c) + (b * d)
That's the whole deal. Wire your values in, type the formula, done. In a DataBeast batch flow it slots in naturally after the DBConvert* nodes - say you want CFG to scale with a per-item value from your data file, or denoise to ramp down across a batch. And because DBGetBatchList drives iteration, the expression re-evaluates per item; that's the part that makes a per-run math node actually useful.
The traps
- Errors return 0, quietly. The node swallows exceptions. Divide by zero?
0. Typo in the expression?0. A mistyped formula won't pop an error - it will silently flatten your values to zero and wreck the batch. Test the expression in a Python REPL before trusting it. - You get operators, not functions. RestrictedPython limits what's reachable, and the README is explicit that expressions are "limited to the passed in values a,b,c,d." Don't expect
math.sqrtor helper functions to be available. If you need something fancy, precompute it in the data file with adb_execblock instead. - It returns
FLOATeven when the math looks integer.a * bwith two whole inputs still comes back as a float. If you need anINTdownstream, the expression node isn't rounding for you - go through a converter.
Installing
It ships with ComfyUI DataBeast, which is not in ComfyUI Manager yet:
cd ComfyUI/custom_nodes
git clone https://github.com/hanoixan/ComfyUI-DataBeast
cd ComfyUI-DataBeast
pip install -r requirements.txt
Restart and it's under the DataBeast category. Dependencies are only pyyaml and RestrictedPython - nothing heavy, no model downloads. Just be aware the pack is still alpha-ish and its README honestly admits the API took a pass between V0.1 and V0.2, so don't build a workflow so precious you can't rebuild it.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| expression | STRING | Python math expression taking any of inputs a,b,c,d. | |
| a | FLOAT | Input a. | |
| b | FLOAT | Input b. | |
| c | FLOAT | Input c. | |
| d | FLOAT | Input d. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | FLOAT | — |