From 016bf23a17a78cd702da48d20da80338d20d8a5c Mon Sep 17 00:00:00 2001 From: mcDandy Date: Wed, 13 May 2026 13:14:54 +0200 Subject: [PATCH 1/2] Refine README variables and remove grammar notes Updated common variables section and removed parser notes. --- README.md | 70 +------------------------------------------------------ 1 file changed, 1 insertion(+), 69 deletions(-) diff --git a/README.md b/README.md index 323522e..953ab0a 100644 --- a/README.md +++ b/README.md @@ -361,7 +361,7 @@ You can also get the node from comfy manager under the name of More math. ## Variables - - **Common variables (except FLOAT, MODEL, VAE and CLIP)**: + - **Common variables (except FLOAT)**: - - `D{N}` - position in n-th dimension of tensor, for example `D0`, `D1`, `D2` - - `S{N}` - size of n-th dimension of tensor, for example `S0`, `S1`, `S2` - - `V{N}` - value input, for example `V0`, `V1`, `V2` @@ -453,74 +453,6 @@ Runtime variables expose side information: The following variables are available in `Expression`. -## Parser / grammar notes - -The grammar in `MathExpr.g4` accepts: - -- expressions, statements, blocks, function definitions, and variable assignments, -- `exprList` for function arguments, -- function groups by arity: - - `func0` - - `func1` - - `func2` - - `func3` - - `func4` - - `func5` - - `funcN` - - `funcNoise` -- operator precedence: - - unary - - power - - shift - - multiply/divide/modulo - - add/subtract - - comparisons - - ternary -- literals: - - `NUMBER` - - `STRING` - - `CONSTANT` (`e`, `pi`) - - `NONE` - - `VARIABLE` - -## Behavioral notes from the visitor - -- `if`, `while`, and `for` are statement-level constructs, not expression operators. -- `return` may be used inside custom functions and top-level blocks. -- `break` and `continue` are supported in loop bodies. -- `print_shape(x)` prints a readable shape summary and returns the original value. -- `shape(x)` returns a Python list, not a tensor. -- `range(...)` returns a Python list of floats. -- `fft(x)` and `ifft(x)` use the current tensor shape and expose frequency helper variables during `ifft`. -- `crop`, `overlay`, `pad`, `replace`, `split`, `join`, `substring`, `find`, and `trim` also support string values where applicable. -- `rgb_to_hsv` and `hsv_to_rgb` support both packed values and separate channel arguments. -- `tensor(shape, [value, [type]])` creates a tensor filled with `value`. -- `stack_*` functions operate on persistent state shared across evaluations. - -## Practical examples - -```text -f(x)->x*x+1; -a=5; -f(a); -``` - -```text -if (a > 0) { b = a * 2; } else { b = 0; } -``` - -```text -topk([1, 9, 3, 7], 2) -``` - -```text -rgb_to_hsv([1.0, 0.5, 0.25], true) -``` - -```text -perlin(1234, 0.05, 4, [10, 20], [256, 256]) -``` - | Variable | Type | Description | |---|---|---| | `inp` | tensor | Current tensor received by the active hook. | From 0ed4e75ca9bd49ac93c8f729bb811c0fa9e0bd77 Mon Sep 17 00:00:00 2001 From: mcDandy Date: Wed, 13 May 2026 13:15:12 +0200 Subject: [PATCH 2/2] Bump version to 1.0.0 and update project description Updated version and description to include STRING and GUIDER types. --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 182149a..079a207 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "more_math" -version = "0.4.0" +version = "1.0.0" tooltip = "Adds math nodes for numbers and types which do not need it." authors = [ {name = "Daniel Martinek", email = "danda.martinek@gmail.com"} @@ -12,7 +12,7 @@ authors = [ readme = "README.md" license = {text = "GNU General Public License v3"} classifiers = [] -description = "Adds math nodes for FLOAT, CONDITIONING, LATENT, IMAGE, MASK, NOISE, AUDIO, VIDEO, MODEL, CLIP, VAE and SIGMAS types and allows usage of math expressions with large number of functions and variables, not limited to inputs. List of those is on github of this extension." +description = "Adds math nodes for FLOAT, STRING, CONDITIONING, LATENT, IMAGE, MASK, NOISE, AUDIO, VIDEO, MODEL, CLIP, VAE, SIGMAS, and GUIDER types and allows usage of math expressions with large number of functions and variables, not limited to inputs. List of those is on github of this extension." dependencies = [ ]