Skip to content

Commit ae4e665

Browse files
author
Dominik Gresch
committed
Update pre-commit tools and fix issues
1 parent 7d41630 commit ae4e665

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+110
-187
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: git://github.com/pre-commit/mirrors-yapf
3-
rev: v0.24.0
3+
rev: v0.29.0
44
hooks:
55
- id: yapf
66
language: system

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ confidence=
5050
# --enable=similarities". If you want to run only the classes checker, but have
5151
# no Warning level messages displayed, use"--disable=all --enable=classes
5252
# --disable=W"
53-
disable=too-few-public-methods,too-many-public-methods,bad-continuation,wrong-import-position,line-too-long,locally-disabled,wildcard-import,locally-enabled,too-many-instance-attributes
53+
disable=too-few-public-methods,too-many-public-methods,bad-continuation,wrong-import-position,line-too-long,locally-disabled,wildcard-import,locally-enabled,too-many-instance-attributes,cyclic-import
5454

5555
# Enable the message, report, category or checker with the given id(s). You can
5656
# either give multiple identifier separated by comma (,) or put this option

doc/source/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
# serve to show the default.
1414

1515
import os
16-
import sys
1716
import time
18-
import sphinx_rtd_theme
17+
import contextlib
1918

2019
# If extensions (or modules to document with autodoc) are in another directory,
2120
# add these directories to sys.path here. If the directory is relative to the
2221
# documentation root, use os.path.abspath to make it absolute, like shown here.
23-
#~ sys.path.insert(0, os.path.abspath('../../'))
2422
import z2pack
2523

2624
# -- General configuration ------------------------------------------------
@@ -119,9 +117,11 @@
119117

120118
# The theme to use for HTML and HTML Help pages. See the documentation for
121119
# a list of builtin themes.
122-
#~ html_theme = 'basicstrap'
123-
html_theme = 'sphinx_rtd_theme'
124-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
120+
if not os.environ.get('READTHEDOCS', None) == 'True':
121+
with contextlib.suppress(ImportError):
122+
import sphinx_rtd_theme
123+
html_theme = 'sphinx_rtd_theme'
124+
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
125125

126126
# Theme options are theme-specific and customize the look and feel of a theme
127127
# further. For a list of options available for each theme, see the

examples/hm/kane_mele_model/run.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def inner(k):
2626
y = (kx + ky) / 2
2727
return (
2828
t * (1 + 2 * cos(x) * cos(y)) * kron(pauli_x, identity) +
29-
lambda_v * kron(pauli_z, identity) +
30-
lambda_R * (1 - cos(x) * cos(y)) * kron(pauli_y, pauli_x) +
29+
lambda_v * kron(pauli_z, identity) + lambda_R *
30+
(1 - cos(x) * cos(y)) * kron(pauli_y, pauli_x) +
3131
-sqrt(3) * lambda_R * sin(x) * sin(y) * kron(pauli_y, pauli_y) +
3232
2 * t * cos(x) * sin(y) * kron(pauli_y, identity) + lambda_SO *
3333
(2 * sin(2 * x) - 4 * sin(x) * cos(y)) * kron(pauli_z, pauli_z) +

futures/tci.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ def tci_h(k):
2828
kz = k[2] * 2 * pi
2929
t1a, t1b, t2a, t2b, t1, t2, tz = (1.0, -1.0, 0.5, -0.5, 2.5, 0.5, 2.0)
3030
H = np.matrix([[
31-
2 * t1a * cos(kx) + 2 * t2a * cos(kx) * cos(ky),
32-
2 * t2a * sin(kx) * sin(ky),
33-
t1 + 2 * t2 * (cos(kx) + cos(ky)) + tz * exp(1j * kz), 0
31+
2 * t1a * cos(kx) + 2 * t2a * cos(kx) * cos(ky), 2 * t2a * sin(kx) *
32+
sin(ky), t1 + 2 * t2 * (cos(kx) + cos(ky)) + tz * exp(1j * kz), 0
3433
],
3534
[
3635
2 * t2a * sin(kx) * sin(ky),
@@ -43,9 +42,8 @@ def tci_h(k):
4342
2 * t2b * sin(kx) * sin(ky)
4443
],
4544
[
46-
0,
47-
t1 + 2 * t2 * (cos(kx) + cos(ky)) + tz * exp(-1j * kz),
48-
2 * t2b * sin(kx) * sin(ky),
45+
0, t1 + 2 * t2 * (cos(kx) + cos(ky)) +
46+
tz * exp(-1j * kz), 2 * t2b * sin(kx) * sin(ky),
4947
2 * t1b * cos(kx) + 2 * t2b * cos(kx) * cos(ky)
5048
]],
5149
dtype=complex)

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
EXTRAS = {
2727
'plot': ['matplotlib'],
2828
'tb': ['tbmodels>=1.1.1'],
29-
'doc': ['sphinx', 'sphinx_rtd_theme', 'sphinx-pyreverse', 'pylint==2.1.1'],
29+
'doc': ['sphinx', 'sphinx-rtd-theme', 'sphinx-pyreverse', 'pylint==2.4.4'],
3030
'dev': [
31-
'prospector==1.1.2', 'pytest>=3.4', 'pytest-cov', 'yapf==0.24',
32-
'pre-commit==1.11.1', 'pylint==2.1.1'
31+
'prospector==1.2.0', 'pytest>=3.4', 'pytest-cov', 'yapf==0.29',
32+
'pre-commit', 'pylint==2.4.4'
3333
],
3434
}
3535
EXTRAS['dev'] += EXTRAS['plot'] + EXTRAS['tb'] + EXTRAS['doc']

tests/conftest.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from z2pack._utils import _get_max_move
1616

1717

18-
def pytest_addoption(parser): # pylint: disable=missing-docstring
18+
def pytest_addoption(parser): # pylint: disable=missing-function-docstring
1919
parser.addoption('-A', action='store_true', help='run ABINIT tests')
2020
parser.addoption('-V', action='store_true', help='run VASP tests')
2121
parser.addoption(
@@ -28,7 +28,7 @@ def pytest_addoption(parser): # pylint: disable=missing-docstring
2828
)
2929

3030

31-
def pytest_configure(config): # pylint: disable=missing-docstring
31+
def pytest_configure(config): # pylint: disable=missing-function-docstring
3232
# register additional marker
3333
config.addinivalue_line(
3434
"markers", "abinit: mark tests which run with ABINIT"
@@ -39,7 +39,7 @@ def pytest_configure(config): # pylint: disable=missing-docstring
3939
)
4040

4141

42-
def pytest_runtest_setup(item): # pylint: disable=missing-docstring
42+
def pytest_runtest_setup(item): # pylint: disable=missing-function-docstring
4343
try:
4444
abinit_marker = item.get_marker("abinit")
4545
vasp_marker = item.get_marker("vasp")
@@ -68,7 +68,6 @@ def test_name(request):
6868
@pytest.fixture
6969
def compare_data(request, test_name, scope="session"):
7070
"""Returns a function which either saves some data to a file or (if that file exists already) compares it to pre-existing data using a given comparison function."""
71-
7271
def inner(compare_fct, data, tag=None):
7372
full_name = test_name + (tag or '')
7473
val = request.config.cache.get(full_name, None)
@@ -80,13 +79,10 @@ def inner(compare_fct, data, tag=None):
8079
)
8180
)
8281
raise ValueError('Reference data does not exist.')
83-
else:
84-
assert compare_fct(
85-
val,
86-
json.loads(
87-
json.dumps(data, default=z2pack.io._encoding.encode)
88-
)
89-
) # get rid of json-specific quirks
82+
assert compare_fct(
83+
val,
84+
json.loads(json.dumps(data, default=z2pack.io._encoding.encode))
85+
) # get rid of json-specific quirks
9086

9187
return inner
9288

@@ -99,7 +95,6 @@ def compare_equal(compare_data):
9995
@pytest.fixture
10096
def compare_wcc(compare_data):
10197
"""Checks whether two lists of WCC (or nested lists of WCC) are almost equal, up to a periodic shift."""
102-
10398
def check_wcc(wcc0, wcc1):
10499
"""
105100
Check that two sets of WCC are equal.
@@ -119,7 +114,6 @@ def sample():
119114
"""
120115
Returns the path to the sample of the given name.
121116
"""
122-
123117
def inner(name):
124118
return os.path.join(
125119
os.path.join(

tests/ctrl_base_tester.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ def test_ctrl_base():
1414
"""
1515
Test that a control class is a subclass of the right abstract classes.
1616
"""
17-
1817
def inner(ctrl):
1918
assert issubclass(ctrl, AbstractControl)
2019
if hasattr(ctrl, 'converged'):

tests/fp/test_abinit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def abinit_system(sample):
1717
"""
1818
Create ABINIT system.
1919
"""
20-
2120
def inner(build_dir):
2221
sample_dir = sample('abinit')
2322
input_files = [

tests/fp/test_espresso.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def qe_system(request, sample):
1919
"""
2020
Creates a QE system.
2121
"""
22-
2322
def inner(build_dir, num_wcc=None):
2423
sample_dir = sample('espresso')
2524
shutil.copytree(
@@ -37,8 +36,8 @@ def inner(build_dir, num_wcc=None):
3736
pw2wancmd = mpirun + qedir + '/pw2wannier90.x '
3837
wancmd = wandir + '/wannier90.x'
3938
z2cmd = (
40-
wancmd + ' bi -pp;' + pwcmd + '< bi.nscf.in >& pw.log;' + pw2wancmd
41-
+ '< bi.pw2wan.in >& pw2wan.log;'
39+
wancmd + ' bi -pp;' + pwcmd + '< bi.nscf.in >& pw.log;' +
40+
pw2wancmd + '< bi.pw2wan.in >& pw2wan.log;'
4241
)
4342

4443
return z2pack.fp.System(

0 commit comments

Comments
 (0)