Skip to content

Commit 1b0f07a

Browse files
authored
Merge pull request #112 from Z2PackDev/fix/pymatgen_incompatibility
Fix pymatgen imports in symmetrization example
2 parents 9febeb9 + 5abafea commit 1b0f07a

File tree

9 files changed

+39
-27
lines changed

9 files changed

+39
-27
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Continuous Integration
2-
on: [push, pull_request]
2+
on: [pull_request]
33
jobs:
44
docs:
55
runs-on: ubuntu-latest
@@ -29,9 +29,7 @@ jobs:
2929
INSTALL_TYPE: ${{ matrix.install-type }}
3030
run: .ci/install_script.sh
3131
- name: Build documentation
32-
env:
33-
READTHEDOCS: 'True'
34-
run: SPHINXOPTS='-nW' make -C doc html
32+
run: make SPHINXOPTS='-nW' -C doc html
3533
- uses: actions/upload-artifact@v2
3634
with:
3735
name: doc-build
@@ -70,7 +68,7 @@ jobs:
7068
runs-on: ubuntu-latest
7169
strategy:
7270
matrix:
73-
python-version: [3.7, 3.8]
71+
python-version: ['3.7', '3.8', '3.9', '3.10']
7472
install-type: [dev]
7573
include:
7674
- python-version: 3.8

.github/workflows_source/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Continuous Integration
22

3-
on: [push, pull_request]
3+
on: [pull_request]
44

55
_anchors:
66
checkout: &CHECKOUT
@@ -46,9 +46,7 @@ jobs:
4646
- *PYTHON_SETUP
4747
- *INSTALL_PROJECT
4848
- name: Build documentation
49-
env:
50-
READTHEDOCS: "True"
51-
run: SPHINXOPTS='-nW' make -C doc html
49+
run: make SPHINXOPTS='-nW' -C doc html
5250
- uses: actions/upload-artifact@v2
5351
with:
5452
name: doc-build
@@ -72,7 +70,7 @@ jobs:
7270
runs-on: ubuntu-latest
7371
strategy:
7472
matrix:
75-
python-version: [3.7, 3.8]
73+
python-version: ["3.7", "3.8", "3.9", "3.10"]
7674
install-type: [dev]
7775
include:
7876
- python-version: 3.8

clean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# (c) 2015-2018, ETH Zurich, Institut fuer Theoretische Physik
2+
# Author: Dominik Gresch <[email protected]>
3+
4+
find -name "*.pyc" -delete;
5+
find -name "*.pyo" -delete;
6+
find -name "__pycache__" -delete;

doc/source/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,16 @@
4141

4242
intersphinx_mapping = {
4343
"python": ("https://docs.python.org/3", None),
44-
"symmetry-representation": ("http://z2pack.ethz.ch/symmetry-representation/", None),
44+
"numpy": ("https://numpy.org/devdocs/", None),
45+
"symmetry-representation": (
46+
"http://symmetry-representation.greschd.ch/en/latest",
47+
None,
48+
),
4549
"fsc.hdf5-io": ("http://frescolinogroup.github.io/frescolino/pyhdf5io/0.5/", None),
4650
}
4751

4852
nitpick_ignore = [("py:class", "array")]
53+
nitpick_ignore_regex = [("py:class", "numpy.*"), ("py:class", "ty.*")]
4954
ipython_warning_is_error = False
5055

5156
# Add any paths that contain templates here, relative to this directory.

doc/source/symmetrize.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The model is located in the ``examples`` directory of the TBmodels source. You w
3232
.. ipython::
3333

3434
In [0]: model_nosym = tbmodels.io.load(
35-
...: EXAMPLES_DIR / 'symmetrization' / 'nonsymmorphic_Si'/'data' / 'model_nosym.hdf5'
35+
...: EXAMPLES_DIR / 'symmetrization' / 'nonsymmorphic_Si' / 'data' / 'model_nosym.hdf5'
3636
...: )
3737

3838

@@ -114,14 +114,16 @@ Note that we use the ``numeric=True`` flag here. This keyword is used to switch
114114
Next, we use ``pymatgen`` to determine the space group symmetries of our crystal:
115115

116116
.. ipython::
117+
:okwarning:
117118

118-
In [0]: import pymatgen as mg
119+
In [0]: from pymatgen.core import Structure
120+
...: from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
119121

120-
In [0]: structure = mg.Structure(
122+
In [0]: structure = Structure(
121123
...: lattice=model_nosym.uc, species=['Si', 'Si'], coords=np.array(coords)
122124
...: )
123125

124-
In [0]: analyzer = mg.symmetry.analyzer.SpacegroupAnalyzer(structure)
126+
In [0]: analyzer = SpacegroupAnalyzer(structure)
125127

126128
In [0]: sym_ops = analyzer.get_symmetry_operations(cartesian=False)
127129

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ packages = find:
4444
kwant =
4545
kwant
4646
dev =
47-
kwant
47+
# kwant
4848
pytest~=6.0
4949
pytest-cov
5050
pythtb

tbmodels/_tb_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,7 @@ def to_kwant_lattice(self):
860860
861861
.. note :: The TBmodels - Kwant interface is experimental. Use it with caution.
862862
"""
863-
import kwant # pylint: disable=import-outside-toplevel
863+
import kwant # pylint: disable=import-outside-toplevel,import-error
864864

865865
sublattices = self._get_sublattices()
866866
uc = self.uc if self.uc is not None else np.eye(self.dim)
@@ -874,7 +874,7 @@ def add_hoppings_kwant(self, kwant_sys, kwant_sublattices=None):
874874
875875
.. note :: The TBmodels - Kwant interface is experimental. Use it with caution.
876876
"""
877-
import kwant # pylint: disable=import-outside-toplevel
877+
import kwant # pylint: disable=import-outside-toplevel,import-error
878878

879879
sublattices = self._get_sublattices()
880880
if kwant_sublattices is None:

tests/requirements_test.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/test_to_kwant.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@
1313
import numpy as np
1414
import scipy.linalg as la
1515

16-
with warnings.catch_warnings():
17-
warnings.simplefilter("ignore")
18-
import kwant
19-
from kwant import wraparound
16+
pytestmark = pytest.mark.xfail(
17+
reason="Kwant tests are disabled since kwant pip installation is broken."
18+
)
19+
20+
try:
21+
with warnings.catch_warnings():
22+
warnings.simplefilter("ignore")
23+
import kwant
24+
from kwant import wraparound
25+
except ImportError:
26+
# allow test collection
27+
pass
2028

2129
from parameters import T_VALUES, KPT
2230

0 commit comments

Comments
 (0)