From 9498a6f688eecefee641bcdc2e0fc8cae1acc759 Mon Sep 17 00:00:00 2001 From: Anton Akhmerov <anton.akhmerov@gmail.com> Date: Thu, 30 Jun 2022 20:14:03 +0200 Subject: [PATCH] take over sympy compatibility fixes from Kwant; closes #42 --- qsymm/kwant_continuum.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qsymm/kwant_continuum.py b/qsymm/kwant_continuum.py index 9a72052..842bf12 100644 --- a/qsymm/kwant_continuum.py +++ b/qsymm/kwant_continuum.py @@ -206,7 +206,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) try: -- GitLab