Nodes/ComfyUI-JakeUpgrade/Evaluate Examples JK๐Ÿ‰
ComfyUI Node

Evaluate Examples JK๐Ÿ‰

The Evaluate Examples cheat sheet node

By jakechaiยทCreated 2 years agoยทUpdated 3 months agoยท 147
Evaluate Examples JK๐Ÿ‰
      โ—„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] ______________________________________________โ–บ

      Here's a node with zero outputs that's still worth knowing about, because it's the documentation for an entire family. Evaluate Examples JK is a reference card: drop it in your graph and its single models_text field shows a long, formatted list of expression examples for the Evaluate Ints JK, Evaluate Floats JK, and Evaluate Strings JK nodes. It computes nothing and passes nothing - RETURN_TYPES is empty, and the implementation is literally return ().

      The useful part is what the examples tell you about the family's engine. All the Evaluate nodes run on SimpleEval, the sandboxed expression evaluator (that's the simpleeval dependency in JakeUpgrade's requirements). Sandboxed is the operative word: unlike a raw eval(), SimpleEval only exposes a whitelist of operations and functions, so you can't accidentally (or deliberately) execute arbitrary code from inside a workflow. That's a real security feature given ComfyUI's history of custom-node malware - an expression evaluator that couldn't do damage was a deliberate choice.

      The example text is worth reading once because it defines what's actually available:

      • Numbers: a + b + c, a ** b, a // b, abs(a), max(a, b, c), bitwise & | ^ << >>, comparisons like a > b > c.
      • Strings: a + b + c, f-strings, len(a), .upper(), .lower(), .strip(), .find(), .replace(), .isnumeric(), .split(), slicing a[:5], reversing a[::-1].

      That's the honest ceiling of the family: it's expression evaluation with three named variables - a, b, c - plus a whitelisted function set. If you're comfortable with Python's basic syntax you already know how to use all three nodes; this node just saves you the tab lookup. The text loads from the pack's SimpleEval_Node_Examples.txt file at startup, so if you want custom crib notes you can edit that file and the node will show them.

      Install. It ships in ComfyUI-JakeUpgrade:

      cd ComfyUI/custom_nodes
      git clone https://github.com/jakechai/ComfyUI-JakeUpgrade
      cd ComfyUI-JakeUpgrade
      pip install -r requirements.txt
      

      Or ComfyUI Manager โ†’ "JakeUpgrade". Windows portable: install.bat or ../../../python_embeded/python.exe -s -m pip install -r requirements.txt. Restart.

      Gotchas: because it has no outputs, people drag it into a workflow, see nothing, and assume it's broken. It's not - it's a comment you can't miss. If you don't need the cheat sheet, don't use it. And the family rules apply: LOAD_DEPRECATED_NODES = True in config.ini if JK nodes go missing, and disable ComfyUI MultiGPU per the README to avoid CUDA errors. The one thing to remember when you move on to the real Evaluate nodes: SimpleEval is not full Python, and the moment you try something outside the whitelist you'll get a clean error instead of a result.

      Category๐Ÿ‰ JK/โœ–๏ธ Math

      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] ______________________________________________Examples of expressions for evaluation nodes

      Outputs (0)

      No outputs