Skip to content

Commit

Permalink
fix: lambdify to numpy, not numpy.__dict__
Browse files Browse the repository at this point in the history
Lambdifying to with modules=numpy.__dict__ does not work with
conditionals (sympy.Piecewise). If using numpy.__dict__, Piecewise is
lambdified to if-else (which doesn't worky with numpy arrays), while
it should convert to numpy.select
  • Loading branch information
redeboer committed May 7, 2021
1 parent dabfcb4 commit f0cbcaa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tensorwaves/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def get_backend_modules(

return (jnp, jsp.special)
if backend in {"numpy", "numba"}:
return np.__dict__
return (np, np.__dict__)
# returning only np.__dict__ does not work well with conditionals
if backend in {"tensorflow", "tf"}:
# pylint: disable=import-error
import tensorflow.experimental.numpy as tnp # pyright: reportMissingImports=false
Expand Down

0 comments on commit f0cbcaa

Please sign in to comment.