ComfyUI Node Runs on cloud

Simple Eval Examples

Simple Eval Examples

By jags111·Created 3 years ago·Updated 4 months ago· 1,485
Simple Eval Examples
      models_textThe Evaluate Integers, Floats, and Strings nodes now employ the SimpleEval library, enabling secure creation and execution of custom Python expressions. (https://github.com/danthedeckie/simpleeval) Below is a short list of what is possible. ______________________________________________ "EVALUATE INTEGERS/FLOATS" NODE EXPRESSION EXAMPLES: Addition: a + b + c Subtraction: a - b - c Multiplication: a * b * c Division: a / b / c Modulo: a % b % c Exponentiation: a ** b ** c Floor Division: a // b // c Absolute Value: abs(a) + abs(b) + abs(c) Maximum: max(a, b, c) Minimum: min(a, b, c) Sum of Squares: a**2 + b**2 + c**2 Bitwise And: a & b & c Bitwise Or: a | b | c Bitwise Xor: a ^ b ^ c Left Shift: a << 1 + b << 1 + c << 1 Right Shift: a >> 1 + b >> 1 + c >> 1 Greater Than Comparison: a > b > c Less Than Comparison: a < b < c Equal To Comparison: a == b == c Not Equal To Comparison: a != b != c ______________________________________________ "EVALUATE STRINGS" NODE EXPRESSION EXAMPLES: Concatenate: a + b + c Format: f'{a} {b} {c}' Length: len(a) + len(b) + len(c) Uppercase: a.upper() + b.upper() + c.upper() Lowercase: a.lower() + b.lower() + c.lower() Capitalize: a.capitalize() + b.capitalize() + c.capitalize() Title Case: a.title() + b.title() + c.title() Strip: a.strip() + b.strip() + c.strip() Find Substring: a.find('sub') + b.find('sub') + c.find('sub') Replace Substring: a.replace('old', 'new') + b.replace('old', 'new') + c.replace('old', 'new') Count Substring: a.count('sub') + b.count('sub') + c.count('sub') Check Numeric: a.isnumeric() + b.isnumeric() + c.isnumeric() Check Alphabetic: a.isalpha() + b.isalpha() + c.isalpha() Check Alphanumeric: a.isalnum() + b.isalnum() + c.isalnum() Check Start: a.startswith('prefix') + b.startswith('prefix') + c.startswith('prefix') Check End: a.endswith('suffix') + b.endswith('suffix') + c.endswith('suffix') Split: a.split(' ') + b.split(' ') + c.split(' ') Zero Fill: a.zfill(5) + b.zfill(5) + c.zfill(5) Slice: a[:5] + b[:5] + c[:5] Reverse: a[::-1] + b[::-1] + c[::-1] ______________________________________________

      This is a reference card, not a working node. Simple Eval Examples is a read-only cheat sheet for the pack's Evaluate Integers / Floats / Strings nodes - it lists the kinds of Python expressions you can write, so you don't have to guess what syntax those nodes accept. Drop it on your canvas next to an Evaluate node and you've got the whole menu of operators and string methods right there.

      How it works

      There's no computation and no output. The node is a single multiline text field, models_text, pre-filled with example expressions, and it connects to nothing. It exists purely as in-canvas documentation for the simpleeval-powered Evaluate nodes, which let you write small Python expressions over inputs a, b, and c.

      What's in the cheat sheet

      For the numeric Evaluate nodes (Integers and Floats), it shows the arithmetic and logic you'd expect:

      • Basic math - a + b + c, a - b - c, a * b * c, division, modulo, exponentiation (a ** b), floor division.
      • Functions - abs(a), max(a, b, c), min(a, b, c), sums of squares.
      • Bitwise and shift ops, plus comparisons (a > b > c, a == b == c).

      For Evaluate Strings, it covers text work:

      • Concatenation and f-string formatting (f'{a} {b} {c}'), len, case methods (upper, lower, capitalize, title), strip.
      • find, replace, count, the is* checks (isnumeric, isalpha, isalnum), startswith/endswith, split, zfill, slicing (a[:5]), and reversing (a[::-1]).

      It's a genuinely handy list if you're new to driving values with expressions - you can copy a line straight into an Evaluate node and adapt it.

      Installing it

      Ships with the pack. ComfyUI Manager → search Efficiency Nodes for ComfyUI, install, restart. Or:

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

      Restart ComfyUI. Note that the actual Evaluate nodes this documents need the simpleeval library (pip install simpleeval) in ComfyUI's Python environment - this reference card itself needs nothing, but the nodes it describes won't load without it.

      Common issues

      The only real confusion is expecting it to do something. It's documentation - it produces no output and wires to nothing. Read it, copy an expression, and type that expression into an Evaluate Integers/Floats/Strings node, which is where the work actually happens.

      If the Evaluate nodes it references aren't showing up in your menu, that's the simpleeval dependency - install it into the correct Python environment (portable ComfyUI builds have their own embedded Python, so a stray pip install won't reach them).

      Pack-wide: an IMPORT FAILED at startup (typically a pip freeze non-zero exit) drops the whole pack, this card included. Update ComfyUI, update the node, and verify the environment.

      CategoryEfficiency Nodes/Simple Eval

      Inputs (1)

      NameTypeDefaultDescription
      models_textSTRINGThe Evaluate Integers, Floats, and Strings nodes now employ the SimpleEval library, enabling secure creation and execution of custom Python expressions. (https://github.com/danthedeckie/simpleeval) Below is a short list of what is possible. ______________________________________________ "EVALUATE INTEGERS/FLOATS" NODE EXPRESSION EXAMPLES: Addition: a + b + c Subtraction: a - b - c Multiplication: a * b * c Division: a / b / c Modulo: a % b % c Exponentiation: a ** b ** c Floor Division: a // b // c Absolute Value: abs(a) + abs(b) + abs(c) Maximum: max(a, b, c) Minimum: min(a, b, c) Sum of Squares: a**2 + b**2 + c**2 Bitwise And: a & b & c Bitwise Or: a | b | c Bitwise Xor: a ^ b ^ c Left Shift: a << 1 + b << 1 + c << 1 Right Shift: a >> 1 + b >> 1 + c >> 1 Greater Than Comparison: a > b > c Less Than Comparison: a < b < c Equal To Comparison: a == b == c Not Equal To Comparison: a != b != c ______________________________________________ "EVALUATE STRINGS" NODE EXPRESSION EXAMPLES: Concatenate: a + b + c Format: f'{a} {b} {c}' Length: len(a) + len(b) + len(c) Uppercase: a.upper() + b.upper() + c.upper() Lowercase: a.lower() + b.lower() + c.lower() Capitalize: a.capitalize() + b.capitalize() + c.capitalize() Title Case: a.title() + b.title() + c.title() Strip: a.strip() + b.strip() + c.strip() Find Substring: a.find('sub') + b.find('sub') + c.find('sub') Replace Substring: a.replace('old', 'new') + b.replace('old', 'new') + c.replace('old', 'new') Count Substring: a.count('sub') + b.count('sub') + c.count('sub') Check Numeric: a.isnumeric() + b.isnumeric() + c.isnumeric() Check Alphabetic: a.isalpha() + b.isalpha() + c.isalpha() Check Alphanumeric: a.isalnum() + b.isalnum() + c.isalnum() Check Start: a.startswith('prefix') + b.startswith('prefix') + c.startswith('prefix') Check End: a.endswith('suffix') + b.endswith('suffix') + c.endswith('suffix') Split: a.split(' ') + b.split(' ') + c.split(' ') Zero Fill: a.zfill(5) + b.zfill(5) + c.zfill(5) Slice: a[:5] + b[:5] + c[:5] Reverse: a[::-1] + b[::-1] + c[::-1] ______________________________________________

      Outputs (0)

      No outputs