Skip to content
Snippets Groups Projects
Commit bbf422d1 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

Merge branch 'issue-48' into 'master'

attempt to fix E

Closes #48

See merge request !28
parents f5f0faf6 5761c687
No related branches found
No related tags found
1 merge request!28attempt to fix E
Pipeline #158674 passed
......@@ -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
......@@ -2,7 +2,7 @@ name: qsymm-latest
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
- numpy
- scipy
- sympy
......
......@@ -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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment