Skip to content

Commit

Permalink
Merge pull request #5 from Z2PackDev/add_rtd_build
Browse files Browse the repository at this point in the history
Add rtd build
  • Loading branch information
greschd committed Feb 17, 2020
2 parents 027b22c + ee5824f commit 5dffe01
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 48 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ tests/.coverage

# Atom
.ropeproject

# VSCode
.vscode
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: git://github.com/pre-commit/mirrors-yapf
rev: v0.25.0
rev: v0.29.0
hooks:
- id: yapf
language: system
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
A simple tool to describe symmetry operations and their representations.

Documentation: http://z2pack.ethz.ch/symmetry-representation
Documentation: https://symmetry-representation.greschd.ch

[![Documentation Status](https://readthedocs.org/projects/symmetry-representation/badge/?version=latest)](https://symmetry-representation.greschd.ch/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/Z2PackDev/symmetry_representation.svg?branch=master)](https://travis-ci.org/Z2PackDev/symmetry_representation)
19 changes: 7 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@
# Author: Dominik Gresch <greschd@gmx.ch>

import re
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup, find_packages

import sys
if sys.version_info < (3, 5):
raise 'must use Python version 3.5 or higher'
if sys.version_info < (3, 6):
raise 'must use Python version 3.6 or higher'

README = """A tool to describe symmetry operations and their representation."""

Expand All @@ -23,8 +20,8 @@
EXTRAS_REQUIRE = {
'doc': ['sphinx', 'sphinx-rtd-theme', 'sphinx-click', 'ipython>=6.2'],
'dev': [
'pytest', 'pytest-cov', 'yapf==0.25', 'pre-commit==1.11.1',
'prospector==1.1.6.*', 'pylint==2.1.*'
'pytest', 'pytest-cov', 'yapf==0.29', 'pre-commit',
'prospector==1.2.0', 'pylint==2.4.4'
]
}

Expand All @@ -33,7 +30,7 @@
setup(
name='symmetry-representation',
version=VERSION,
url='http://z2pack.ethz.ch/symmetry-representation',
url='https://symmetry-representation.greschd.ch',
author='Dominik Gresch',
author_email='greschd@gmx.ch',
license='Apache 2.0',
Expand All @@ -56,9 +53,7 @@
'Topic :: Scientific/Engineering :: Physics',
'Development Status :: 4 - Beta'
],
packages=[
'symmetry_representation', 'symmetry_representation._get_repr_matrix'
],
packages=find_packages(),
entry_points='''
[console_scripts]
symmetry-repr=symmetry_representation._cli:cli
Expand Down
1 change: 1 addition & 0 deletions symmetry_representation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# (c) 2017-2018, ETH Zurich, Institut fuer Theoretische Physik
# Author: Dominik Gresch <greschd@gmx.ch>
# pylint: disable=cyclic-import
"""
A tool for describing symmetry operations and their representations.
"""
Expand Down
2 changes: 1 addition & 1 deletion symmetry_representation/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def filter_symmetries(symmetries, lattice, output):
click.echo("Loading structure from file '{}'...".format(lattice))
structure = mg.Structure.from_file(lattice)
click.echo("Filtering symmetries...")
filtered_symmetries = filter_compatible(symmetries, structure=structure) # pylint: disable=assignment-from-no-return
filtered_symmetries = filter_compatible(symmetries, structure=structure)
click.echo("Saving filtered symmetries to file '{}'...".format(output))
io.save(filtered_symmetries, output)
click.echo("Done!")
10 changes: 5 additions & 5 deletions symmetry_representation/_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def is_compatible(*, structure, symmetry):

@export
@singledispatch
def filter_compatible(symmetries, *, structure): # pylint: disable=unused-argument
def filter_compatible(symmetries, *, structure):
"""
Returns the symmetries which are compatible with the given structure.
Expand All @@ -61,24 +61,24 @@ def filter_compatible(symmetries, *, structure): # pylint: disable=unused-argum


@filter_compatible.register(Iterable)
def _(symmetries, *, structure): # pylint: disable=missing-docstring
def _(symmetries, *, structure): # pylint: disable=missing-function-docstring
filtered_syms = [
filter_compatible(s, structure=structure) for s in symmetries
]
return [s for s in filtered_syms if s is not None]


@filter_compatible.register(SymmetryOperation)
def _(symmetry, *, structure): # pylint: disable=missing-docstring
def _(symmetry, *, structure): # pylint: disable=missing-function-docstring
if is_compatible(symmetry=symmetry, structure=structure):
return symmetry
else:
return None


@filter_compatible.register(SymmetryGroup)
def _(symmetry_group, *, structure): # pylint: disable=missing-docstring
filtered_syms = filter_compatible( # pylint: disable=assignment-from-no-return
def _(symmetry_group, *, structure): # pylint: disable=missing-function-docstring
filtered_syms = filter_compatible(
symmetry_group.symmetries, structure=structure
)
if filtered_syms:
Expand Down
4 changes: 2 additions & 2 deletions symmetry_representation/_get_repr_matrix/_get_repr_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ def _get_repr_matrix_impl( # pylint: disable=too-many-locals
repr_matrix_numeric = np.array(repr_matrix).astype(complex)
if not np.allclose(
repr_matrix_numeric @ repr_matrix_numeric.conj().T,
np.eye(*repr_matrix_numeric.shape)
np.eye(*repr_matrix_numeric.shape) # pylint: disable=not-an-iterable
):
max_mismatch = np.max(
np.abs(
repr_matrix_numeric @ repr_matrix_numeric.conj().T -
np.eye(*repr_matrix_numeric.shape)
np.eye(*repr_matrix_numeric.shape) # pylint: disable=not-an-iterable
)
)
raise ValueError(
Expand Down
8 changes: 5 additions & 3 deletions symmetry_representation/_sym_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# (c) 2017-2018, ETH Zurich, Institut fuer Theoretische Physik
# Author: Dominik Gresch <greschd@gmx.ch>
# pylint: disable=cyclic-import
"""
Defines symmetry operations and groups.
"""
Expand Down Expand Up @@ -128,7 +129,7 @@ def from_orbitals(
Determines whether a numeric (numpy) or analytic (sympy)
representation matrix is constructed.
"""
from . import _get_repr_matrix
from . import _get_repr_matrix # pylint: disable=import-outside-toplevel
if kwargs.get('repr_has_cc', False):
raise NotImplementedError
repr_matrix = _get_repr_matrix.get_repr_matrix(
Expand Down Expand Up @@ -367,14 +368,15 @@ def __init__(self, matrix, has_cc=False, numeric=None):
if numeric:
matrix = np.array(matrix).astype(complex)
if not np.allclose(
matrix @ matrix.T.conjugate(), np.eye(matrix.shape[0])
matrix @ matrix.T.conjugate(),
np.eye(matrix.shape[0]) # pylint: disable=unsubscriptable-object
):
raise ValueError(
'Input matrix is not unitary: {}'.format(matrix)
)
else:
matrix = sp.Matrix(matrix)
if not sp.eye(*matrix.shape).equals(matrix @ matrix.H): # pylint: disable=not-an-iterable
if not sp.eye(*matrix.shape).equals(matrix @ matrix.H):
raise ValueError(
'Input matrix is not unitary: {}'.format(matrix)
)
Expand Down
5 changes: 1 addition & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def sample():
"""
Returns the path to the sample of the given name.
"""

def inner(name):
return os.path.join(
os.path.join(
Expand All @@ -40,7 +39,6 @@ def test_name(request):
@pytest.fixture
def compare_data(request, test_name, scope="session"): # pylint: disable=unused-argument,redefined-outer-name
"""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."""

def inner(compare_fct, data, tag=None):
full_name = test_name + (tag or '')

Expand All @@ -53,8 +51,7 @@ def inner(compare_fct, data, tag=None):
if val is None:
request.config.cache.set(full_name, data_str)
raise ValueError('Reference data does not exist.')
else:
assert compare_fct(val, data)
assert compare_fct(val, data)

return inner

Expand Down
8 changes: 4 additions & 4 deletions tests/sym_op/test_real_space_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

@pytest.mark.parametrize(['real_space_op', 'vec', 'res'], [
(
sr.RealSpaceOperator(np.eye(3), [0.1, 0.2, 0.3]), [0.2, 0.7, 0.1],
[0.3, 0.9, 0.4]
sr.RealSpaceOperator(np.eye(3), [0.1, 0.2, 0.3]), [0.2, 0.7, 0.1
], [0.3, 0.9, 0.4]
),
(
sr.RealSpaceOperator([[0, 1], [1, 1]], [0.1, 0.2]), [0.3, 0.6],
[0.7, 1.1]
sr.RealSpaceOperator([[0, 1], [1, 1]], [0.1, 0.2]), [0.3, 0.6
], [0.7, 1.1]
),
])
def test_apply(real_space_op, vec, res):
Expand Down
8 changes: 4 additions & 4 deletions tests/sym_op/test_representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
@pytest.mark.parametrize(
['mat_1', 'has_cc_1', 'mat_2', 'has_cc_2', 'mat_res', 'has_cc_res'],
[
([[0, 1], [1, 0]], False, [[0, 1], [1, 0]], True, [[1, 0], [0, 1]],
True),
([[1, 0], [0, 1]], True, [[0, sp.I], [-sp.I, 0]], False,
[[0, -sp.I], [sp.I, 0]], True),
([[0, 1], [1, 0]], False, [[0, 1], [1, 0]], True, [[1, 0], [0, 1]
], True),
([[1, 0], [0, 1]], True, [[0, sp.I], [-sp.I, 0]
], False, [[0, -sp.I], [sp.I, 0]], True),
] # pylint: disable=too-many-arguments
)
def test_representation_mul(
Expand Down
18 changes: 10 additions & 8 deletions tests/test_auto_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ def test_auto_repr(sample):
('orbitals', 'result_repr_matrix'),
[
([
sr.
Orbital(position=(0.1, 0.2, 0.3), function_string='1', spin=None)
sr.Orbital(
position=(0.1, 0.2, 0.3), function_string='1', spin=None
)
], sp.Matrix([[1]])),
([
sr.Orbital(
Expand All @@ -85,8 +86,9 @@ def test_auto_repr(sample):
)
], sp.Matrix([[0, -sp.I], [sp.I, 0]])),
([
sr.
Orbital(position=(0.1, 0.2, 0.3), function_string='x', spin=None)
sr.Orbital(
position=(0.1, 0.2, 0.3), function_string='x', spin=None
)
], sp.Matrix([[1]])),
],
)
Expand Down Expand Up @@ -132,8 +134,8 @@ def test_time_reversal(orbitals, result_repr_matrix, numeric):


@pytest.mark.parametrize(['orbitals', 'rotation_matrix', 'reference'], [
([sr.Orbital(position=(0, 0, 0), function_string='1', spin=None)],
np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1]]), sp.eye(1, 1)),
([sr.Orbital(position=(0, 0, 0), function_string='1', spin=None)
], np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1]]), sp.eye(1, 1)),
([
sr.Orbital(position=(0, 0, 0), function_string='x', spin=None),
sr.Orbital(position=(0, 0, 0), function_string='y', spin=None)
Expand Down Expand Up @@ -164,8 +166,8 @@ def test_time_reversal(orbitals, result_repr_matrix, numeric):
([
sr.Orbital(position=(0, 0, 0), function_string='1', spin=sr.SPIN_UP),
sr.Orbital(position=(0, 0, 0), function_string='1', spin=sr.SPIN_DOWN)
], np.array([[-1, 0, 0], [0, -1, 0], [0, 0, 1]]),
sp.Matrix([[-sp.I, 0], [0, sp.I]])),
], np.array([[-1, 0, 0], [0, -1, 0], [0, 0, 1]]
), sp.Matrix([[-sp.I, 0], [0, sp.I]])),
([
sr.Orbital(position=(0, 0, 0), function_string='1', spin=sr.SPIN_UP),
sr.Orbital(position=(0, 0, 0), function_string='1', spin=sr.SPIN_DOWN)
Expand Down
5 changes: 2 additions & 3 deletions tests/test_compatible.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ def check(sym):
return False

for sym in all_symmetries:
assert sr.is_compatible(
structure=strained_structure, symmetry=sym
) == check(sym)
assert sr.is_compatible(structure=strained_structure,
symmetry=sym) == check(sym)


def test_filter_compatible(unstrained_structure, all_symmetries): # pylint: disable=redefined-outer-name
Expand Down

0 comments on commit 5dffe01

Please sign in to comment.