Commit a23b1c96 authored by Joseph Weston's avatar Joseph Weston
Browse files

Merge branch 'patch-1' into 'stable'

Fix behaviour of discretizer when locals contains numpy array values

See merge request kwant/kwant!344
parents 488ce42f ed3b4fa3
......@@ -180,7 +180,11 @@ def sympify(expr, locals=None):
"identifiers and may not be keywords".format(repr(k)))
# sympify values of locals before updating it with extra_ns
locals = {k: sympify(v) for k, v in locals.items()}
# Cast numpy array values in locals to sympy matrices to make sure they have
# correct format
locals = {k: (sympy.Matrix(v) if isinstance(v, np.ndarray) else sympify(v))
for k, v in locals.items()}
for k, v in extra_ns.items():
locals.setdefault(k, v)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment