diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0f5752c563407832bb4a042b5468d390545448a2..06b696f40da969c819bb5bb734ee25dd5c55b66b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,26 +12,26 @@ image: gitlab.kwant-project.org:5005/qt/research-docker test minimal requirements: script: - - conda env create -f environment-minimal.yml + - mamba env create -f environment-minimal.yml - source activate qsymm-minimal - py.test qsymm/ --cov=qsymm --verbose --cov-report term stage: test test latest requirements: script: - - conda env create -f environment-latest.yml + - mamba env create -f environment-latest.yml - source activate qsymm-latest - py.test qsymm/ --cov=qsymm --verbose --cov-report term stage: test test kwant against latest qsymm: script: - - conda env create -f environment-latest.yml + - mamba env create -f environment-latest.yml - source activate qsymm-latest # Get bleeding-edge Kwant - - conda install cython + - mamba install cython - pip install . # need to install qsymm so that the kwant test can find it - - pip install git+https://gitlab.kwant-project.org/kwant/kwant.git + - pip install git+https://gitlab.kwant-project.org/kwant/kwant.git@stable - export KWANT_QSYMM_PATH=$(python -c "$KWANT_QSYMM_TEST_PATH_SCRIPT") - py.test $KWANT_QSYMM_PATH stage: test diff --git a/environment-latest.yml b/environment-latest.yml index b428f1e1c0bfc69b9d8bbb2b233e8739b071c774..985f2e0eef684ca827f6011d38fb467ae956aed6 100644 --- a/environment-latest.yml +++ b/environment-latest.yml @@ -2,7 +2,7 @@ name: qsymm-latest channels: - conda-forge dependencies: - - python=3.10 + - python=3.11 - numpy - scipy - sympy diff --git a/qsymm/kwant_continuum.py b/qsymm/kwant_continuum.py index c2e5695e4368bf838f4af8b4c57944831fdefdde..7d16e30635c8114d281f85d89a37b259a63c84cc 100644 --- a/qsymm/kwant_continuum.py +++ b/qsymm/kwant_continuum.py @@ -51,6 +51,7 @@ import warnings momentum_operators = sympy.symbols('k_x k_y k_z', commutative=False) position_operators = sympy.symbols('x y z', commutative=False) +e = sympy.symbols('e', positive=True) pauli = [sympy.eye(2), _msigma(1), _msigma(2), _msigma(3)] @@ -217,6 +218,8 @@ def sympify(expr, locals=None): # sympify we are getting list of sympy objects, so we call sympify # second time to obtain ``sympy`` matrices. hamiltonian = sympy.sympify(hamiltonian) + # A workaround for qsymm issue #48 + hamiltonian = hamiltonian.subs(sympy.sympify('e'), e) finally: if stored_value is not None: converter[list] = stored_value diff --git a/qsymm/model.py b/qsymm/model.py index 63b14587df641f2bf7d5faff378907dd08a410c3..aec6b4d33258236aea06e66a52c15dcf7198f58c 100644 --- a/qsymm/model.py +++ b/qsymm/model.py @@ -19,8 +19,8 @@ from . import kwant_continuum _commutative_momenta = [kwant_continuum.make_commutative(k, k) for k in kwant_continuum.momentum_operators] -e = kwant_continuum.sympify('e') -I = kwant_continuum.sympify('I') # noqa: E741 +e = kwant_continuum.e +I = sympy.I # noqa: E741 def substitute_exponents(expr): @@ -671,7 +671,7 @@ class Model(UserDict): an error is thrown. """ # Replace 'e' with the numerical value - expr = self.tosympy(nsimplify=nsimplify).subs({'e': np.e}) + expr = self.tosympy(nsimplify=nsimplify).subs({e: np.e}) # Needed if expr is an array with 1 element, because .tosympy # returns a scalar then. try: @@ -990,7 +990,7 @@ def _find_momenta(momenta): @lru_cache(maxsize=1000) def _symbol_normalizer(key): - return sympy.expand_power_exp(sympy.sympify(key)) + return sympy.expand_power_exp(sympy.sympify(key, locals={'e': e})) @lru_cache(maxsize=1000)