Merge branch 'main' of https://github.com/mcDandy/more_math
This commit is contained in:
@@ -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. |
|
||||
|
||||
+2
-2
@@ -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 = [
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user