Skip to content

Commit 15b3de3

Browse files
authored
Merge pull request #81 from Z2PackDev/add_readthedocs_build
Add readthedocs build
2 parents 6453f07 + 873403e commit 15b3de3

Some content is hidden

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

48 files changed

+139
-204
lines changed

.gitignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ MANIFEST
3838
*.tar.gz
3939
files*.txt
4040

41-
# ignoring the _ptools git
42-
z2pack/_ptools/.git
43-
z2pack/_ptools/.gitignore
44-
45-
# selectively choose _ptools
46-
z2pack/_ptools/*
47-
4841
# debug folder
4942
debug
5043

@@ -59,3 +52,6 @@ tests/.pytest_cache
5952
.coverage
6053
.coverage*
6154
htmlcov
55+
56+
# editors
57+
.vscode

.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

.readthedocs.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# .readthedocs.yml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Build documentation in the doc/ directory with Sphinx
9+
sphinx:
10+
configuration: doc/source/conf.py
11+
12+
# Optionally build your docs in additional formats such as PDF and ePub
13+
formats: []
14+
15+
# Optionally set the version of Python and requirements required to build your docs
16+
python:
17+
version: 3.7
18+
install:
19+
- method: pip
20+
path: .
21+
extra_requirements:
22+
- doc

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: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
"""Usage: pip install ."""
22

33
import re
4-
try:
5-
from setuptools import setup
6-
except ImportError:
7-
from distutils.core import setup
4+
from setuptools import setup, find_packages
85

96
import sys
107
if sys.version_info < (3, 5):
@@ -16,8 +13,7 @@
1613
1714
The Wannier charge centers are computed from overlap matrices that are obtained either directly (for tb) or via the Wannier90 code package (fp).
1815
19-
- `Documentation <http://z2pack.ethz.ch/doc>`_
20-
- `Online interface <http://z2pack.ethz.ch/online>`_ (tight-binding only)
16+
`Documentation: <http://z2pack.ethz.ch/doc>`_
2117
"""
2218

2319
with open('./z2pack/__init__.py', 'r') as f:
@@ -27,10 +23,10 @@
2723
EXTRAS = {
2824
'plot': ['matplotlib'],
2925
'tb': ['tbmodels>=1.1.1'],
30-
'doc': ['sphinx', 'sphinx_rtd_theme'],
26+
'doc': ['sphinx', 'sphinx-rtd-theme', 'sphinx-pyreverse', 'pylint==2.4.4'],
3127
'dev': [
32-
'prospector==1.1.2', 'pytest>=3.4', 'pytest-cov', 'yapf==0.24',
33-
'pre-commit==1.11.1', 'pylint==2.1.1'
28+
'prospector==1.2.0', 'pytest>=3.4', 'pytest-cov', 'yapf==0.29',
29+
'pre-commit', 'pylint==2.4.4'
3430
],
3531
}
3632
EXTRAS['dev'] += EXTRAS['plot'] + EXTRAS['tb'] + EXTRAS['doc']
@@ -57,6 +53,7 @@
5753
'Programming Language :: Python :: 3.5',
5854
'Programming Language :: Python :: 3.6',
5955
'Programming Language :: Python :: 3.7',
56+
'Programming Language :: Python :: 3.8',
6057
'Intended Audience :: Science/Research',
6158
'Topic :: Scientific/Engineering :: Physics',
6259
'Development Status :: 5 - Production/Stable'
@@ -66,8 +63,5 @@
6663
'topology', 'topological', 'invariant', 'bandstructure', 'chern', 'z2',
6764
'solid-state', 'tight-binding'
6865
],
69-
packages=[
70-
'z2pack', 'z2pack.io', 'z2pack.fp', 'z2pack.volume', 'z2pack.surface',
71-
'z2pack.line'
72-
]
66+
packages=find_packages()
7367
)

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'):

0 commit comments

Comments
 (0)