We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What a nice tools! However, current codes has trouble dealing with logic expression with more than 2 terms, for example:
x, y, z = sympy.symbols("x,y,z") expr =x | y | z model = SymPyModule(expressions=[expr]) terms = { "x": torch.randint(0, 2, (10,)).bool(), "y": torch.randint(0, 2, (10,)).bool(), "z": torch.randint(0, 2, (10,)).bool(), } result = model(**terms)
Then it will raise an error:
TypeError: logical_or() takes 2 positional arguments but 3 were given
Here's the solution: modify
sympytorch/sympytorch/sympy_module.py
Lines 52 to 53 in ca3e3f4
sympy.And: _reduce(torch.logical_and), sympy.Or: _reduce(torch.logical_or),
, which is the same as mul and add.
mul
add
Also, besides the modification above, I suggest two more improvements:
Lines 7 to 10 in ca3e3f4
Line 158 in ca3e3f4
_func_lookup = co.ChainMap(extra_funcs, _global_func_lookup)
so that users can overload default lookup tables.
The text was updated successfully, but these errors were encountered:
That all sounds reasonable to me! I'd happily accept a PR on these.
(I probably wouldn't bother making reduce public though, that's a pretty small helper function.)
Sorry, something went wrong.
No branches or pull requests
What a nice tools! However, current codes has trouble dealing with logic expression with more than 2 terms, for example:
Then it will raise an error:
Here's the solution: modify
sympytorch/sympytorch/sympy_module.py
Lines 52 to 53 in ca3e3f4
to
, which is the same as
mul
andadd
.Also, besides the modification above, I suggest two more improvements:
sympytorch/sympytorch/sympy_module.py
Lines 7 to 10 in ca3e3f4
sympytorch/sympytorch/sympy_module.py
Line 158 in ca3e3f4
to
so that users can overload default lookup tables.
The text was updated successfully, but these errors were encountered: