Skip to content

Commit

Permalink
factorial exceptions
Browse files Browse the repository at this point in the history
cleaner reporting for math problems in op nodes
  • Loading branch information
Amorano committed Jun 2, 2024
1 parent 597db57 commit 458051f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions core/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class EnumBinaryOperation(Enum):
EnumUnaryOperation.TAN: lambda x: math.tan(x),
EnumUnaryOperation.NEGATE: lambda x: -x,
EnumUnaryOperation.RECIPROCAL: lambda x: 1 / x if x != 0 else 0,
EnumUnaryOperation.FACTORIAL: lambda x: math.factorial(int(x)),
EnumUnaryOperation.FACTORIAL: lambda x: math.factorial(math.abs(int(x))),
EnumUnaryOperation.EXP: lambda x: math.exp(x),
EnumUnaryOperation.NOT: lambda x: not x,
EnumUnaryOperation.BIT_NOT: lambda x: ~int(x),
Expand Down Expand Up @@ -215,7 +215,15 @@ def run(self, **kw) -> Tuple[bool]:
ret.append(v)
val = ret
convert = int if isinstance(A, (bool, int, np.uint8, np.uint16, np.uint32, np.uint64)) else float
val = [convert(v) for v in val]
ret = []
for v in val:
try:
ret.append(convert(v))
except OverflowError:
ret.append(0)
except Exception as e:
logger.error(f"{e} :: {op}")
ret.append(0)
val = parse_value(val, typ, 0)
results.append(val)
pbar.update_absolute(idx)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "jovimetrix"
description = "Compose like Substance Designer. Webcams, Media Streams (in/out), Tick animation, Color correction, Geometry manipulation, Pixel shader, Polygonal shape generator, Remap images gometry and color, Heavily inspired by WAS and MTB Node Suites."
version = "1.0.3"
version = "1.0.4"
license = "LICENSE"
dependencies = ["torch", "numpy", "matplotlib", "opencv-contrib-python", "ffmpeg-python", "librosa", "loguru", "moderngl", "mss", "requests", "Pillow", "pywin32==306; platform_system==\"Windows\"", "scikit-image", "blendmodes", "mido[ports-rtmidi]", "pyaudio", "daltonlens", "numba", "PyOpenGL", "PyOpenGL-accelerate", "SpoutGL; platform_system==\"Windows\"", "vnoise", "stereoscopy[auto_align]", "aenum<4,>=3.1.15"]

Expand Down

0 comments on commit 458051f

Please sign in to comment.