Skip to content

Commit

Permalink
Merge pull request #29 from greschd/dev
Browse files Browse the repository at this point in the history
Release/0.1.1
  • Loading branch information
greschd committed Mar 13, 2020
2 parents edaeeba + b205a5d commit 8608e70
Show file tree
Hide file tree
Showing 36 changed files with 197 additions and 118 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ tests/.cache
htmlcov
.pytest-score
htmlscore

# editor related
.vscode
8 changes: 5 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
repos:
- repo: git://github.com/pre-commit/mirrors-yapf
sha: v0.24.0
rev: v0.29.0
hooks:
- id: yapf
language: system

- repo: git://github.com/guykisel/prospector-mirror
sha: 7ff847e779347033ebbd9e3b88279e7f3a998b45
- repo: local
hooks:
- id: prospector
name: prospector
entry: prospector
types: [file, python]
language: system
exclude: '^(doc/)|(examples/)'
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ignore-patterns=

# Python code to execute, usually for sys.path manipulation such as
# pygtk.require().
#init-hook=
init-hook="import os, sys; from pylint.config import find_pylintrc; sys.path.append(os.path.join(os.path.dirname(find_pylintrc()), 'tests'))"

# Use multiple processes to speed up Pylint.
jobs=1
Expand Down
22 changes: 22 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the doc/ directory with Sphinx
sphinx:
configuration: doc/source/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
formats: []

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- method: pip
path: .
extra_requirements:
- doc
23 changes: 23 additions & 0 deletions .travis-data/install_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Author: Dominik Gresch <greschd@gmx.ch>

# Be verbose, and stop with error as soon there's one
set -ev

cd ${TRAVIS_BUILD_DIR}

pip install git+https://github.com/greschd/pytest-score.git

case "$INSTALL_TYPE" in
dev)
pip install .[dev]
;;
test)
pip install .[test]
;;
test_sdist)
python setup.py sdist
ls -1 dist/ | xargs -I % pip install dist/%[test]
;;
esac
16 changes: 16 additions & 0 deletions .travis-data/test_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# © 2017-2019, ETH Zurich, Institut für Theoretische Physik
# Author: Dominik Gresch <greschd@gmx.ch>

# Be verbose, and stop with error as soon there's one
set -ev

case "$TEST_TYPE" in
test)
cd ${TRAVIS_BUILD_DIR}/tests; pytest --no-plot-compare
;;
precommit)
pre-commit run --all-files
;;
esac
23 changes: 12 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
language: python
cache: pip
python:
- "3.5"
- "3.6"

- "3.7"
- "3.8"
env:
- TEST_TYPE="test"
matrix:
INSTALL_TYPE="test"
- TEST_TYPE="test"
INSTALL_TYPE="test_sdist"
jobs:
include:
- python: 3.6
env: TEST_TYPE="compliance"

- python: "3.7"
env:
- TEST_TYPE="precommit"
INSTALL_TYPE="dev"
install:
- pip install -U pytest
- pip install --process-dependency-links .[test]

- ./.travis-data/install_script.sh
script:
- if [ "$TEST_TYPE" == "compliance" ] ; then pip install .[dev]; pre-commit run --all-files ; fi
- if [ "$TEST_TYPE" == "test" ] ; then cd tests; pytest --no-plot-compare ; fi
- ./.travis-data/test_script.sh
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ The goal of this code is to identify nodal features in potential landscapes, usi

The initial use-case for this code is to find gapless features in three-dimensional materials.

Documentation: https://nodefinder.greschd.ch

[![Documentation Status](https://readthedocs.org/projects/nodefinder/badge/?version=latest)](https://nodefinder.greschd.ch/en/latest/?badge=latest)
[![Build Status](https://travis-ci.org/greschd/NodeFinder.svg?branch=master)](https://travis-ci.org/greschd/NodeFinder)
15 changes: 7 additions & 8 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# © 2017-2019, ETH Zurich, Institut für Theoretische Physik
# Author: Dominik Gresch <greschd@gmx.ch>

import os
import time
import sphinx_rtd_theme

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -54,11 +54,8 @@
# General information about the project.
project = u'NodeFinder'
year = time.localtime().tm_year
team = 'ETH Zurich'
if year == 2017:
copyright = u'2017, {}'.format(team)
else:
copyright = u'2017-{}, {}'.format(year, team)
team = 'ETH Zurich; Dominik Gresch'
copyright = u'2017-{}, {}'.format(year, team)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -115,8 +112,10 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#~ html_theme = 'basicstrap'
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
if not os.environ.get('READTHEDOCS', None) == 'True':
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down
22 changes: 12 additions & 10 deletions examples/kdotp_weyl/kdotp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@ class Pauli:
def Hamilton_general(k, *, a, b, c, d, e, f, g, h, j, l, m, n, o, p, q, r):
kx, ky, kz = k
H = (
a * np.kron(Pauli.zero, Pauli.zero) + b * np.kron(Pauli.z, Pauli.zero)
+ c * (kx + ky) * np.kron(Pauli.x, Pauli.z) +
d * (kx + ky) * np.kron(Pauli.y, Pauli.zero) + e * (kx - ky) *
np.kron(Pauli.x, Pauli.x) + f * (kx - ky) * np.kron(Pauli.x, Pauli.y) +
a * np.kron(Pauli.zero, Pauli.zero) +
b * np.kron(Pauli.z, Pauli.zero) + c *
(kx + ky) * np.kron(Pauli.x, Pauli.z) + d *
(kx + ky) * np.kron(Pauli.y, Pauli.zero) + e *
(kx - ky) * np.kron(Pauli.x, Pauli.x) + f *
(kx - ky) * np.kron(Pauli.x, Pauli.y) +
g * kz * np.kron(Pauli.x, Pauli.x) +
h * kz * np.kron(Pauli.x, Pauli.y) +
j * (kx**2 + ky**2) * np.kron(Pauli.zero, Pauli.zero) +
l * (kx**2 + ky**2) * np.kron(Pauli.z, Pauli.zero) +
h * kz * np.kron(Pauli.x, Pauli.y) + j *
(kx**2 + ky**2) * np.kron(Pauli.zero, Pauli.zero) + l *
(kx**2 + ky**2) * np.kron(Pauli.z, Pauli.zero) +
m * kx * ky * np.kron(Pauli.zero, Pauli.zero) +
n * kx * ky * np.kron(Pauli.z, Pauli.zero) +
o * (kx * kz - ky * kz) * np.kron(Pauli.zero, Pauli.zero) +
p * (kx * kz - ky * kz) * np.kron(Pauli.z, Pauli.zero) +
n * kx * ky * np.kron(Pauli.z, Pauli.zero) + o *
(kx * kz - ky * kz) * np.kron(Pauli.zero, Pauli.zero) + p *
(kx * kz - ky * kz) * np.kron(Pauli.z, Pauli.zero) +
q * kz**2 * np.kron(Pauli.zero, Pauli.zero) +
r * kz**2 * np.kron(Pauli.z, Pauli.zero)
)
Expand Down
3 changes: 2 additions & 1 deletion examples/kdotp_weyl/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ def get_chern(splitting, k):
loop = asyncio.get_event_loop()
executor = ProcessPoolExecutor(max_workers=4)
res = pm.run(
lambda pos: phase_func([pos[0], 0, pos[1]], loop=loop, executor=executor),
lambda pos:
phase_func([pos[0], 0, pos[1]], loop=loop, executor=executor),
limits=[(-0.3, 0.3)] * 2,
mesh=3,
num_steps=5,
Expand Down
8 changes: 4 additions & 4 deletions examples/kdotp_weyl/splitting_fct.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

def c00(k, a, j, m, o, q, **kwargs):
kx, ky, kz = k
return a + j * (kx**2 + ky**
2) + m * kx * ky + o * (kx * kz - ky * kz) + q * kz**2
return a + j * (kx**2 +
ky**2) + m * kx * ky + o * (kx * kz - ky * kz) + q * kz**2


def cxz(k, c, **kwargs):
Expand All @@ -32,8 +32,8 @@ def cy0(k, d, **kwargs):

def cz0(k, b, l, n, p, r, **kwargs):
kx, ky, kz = k
return b + l * (kx**2 + ky**
2) + n * kx * ky + p * (kx * kz - ky * kz) + r * kz**2
return b + l * (kx**2 +
ky**2) + n * kx * ky + p * (kx * kz - ky * kz) + r * kz**2


def cxx(k, e, g, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion nodefinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""A tool to find and identify nodal features in band structures.
"""

__version__ = '0.1.0'
__version__ = '0.1.1'

from . import coordinate_system
from . import search
Expand Down
4 changes: 2 additions & 2 deletions nodefinder/_common_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def _setup_plot(limits, axis=None):
"""Sets up the figure axes and handles options common to all plots."""
# import is here s.t. the import of the package does not fail
# if matplotlib is not present
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt # pylint: disable=import-outside-toplevel

dim = len(limits)
if dim == 3:
is_3d = True
from mpl_toolkits.mplot3d import Axes3D # pylint: disable=unused-variable
from mpl_toolkits.mplot3d import Axes3D # pylint: disable=import-outside-toplevel,unused-import
else:
is_3d = False
assert dim == 2
Expand Down
4 changes: 2 additions & 2 deletions nodefinder/identify/_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def create_clusters(positions, *, feature_size, coordinate_system):
coordinate_system=coordinate_system
)
return [
nx.freeze(subgraph)
for subgraph in nx.algorithms.connected_component_subgraphs(graph)
nx.freeze(graph.subgraph(nodes).copy())
for nodes in nx.algorithms.connected_components(graph)
]


Expand Down
5 changes: 2 additions & 3 deletions nodefinder/identify/_evaluate/_line/_ballistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class _BallisticLineImpl:
"""
Implementation class for the 'ballistic' line evaluation.
"""

def __init__(self, *, graph, coordinate_system, feature_size):
self.graph = graph
self.coordinate_system = coordinate_system
Expand Down Expand Up @@ -113,7 +112,7 @@ def find_loop(self, *, starting_node, initial_direction):
)
assert previous_direction is not None
break
elif new_node in self.result_graph:
if new_node in self.result_graph:
if on_graph:
IDENTIFY_LOGGER.debug(
"Loop search finished -- reached existing result nodes."
Expand All @@ -131,7 +130,7 @@ def get_next_pos(self, *, node, previous_direction): # pylint: disable=too-many
Determine the next node based on the current node and previous step
direction.
"""
neighbors_all = [nbr for nbr in self.graph.neighbors(node)]
neighbors_all = list(self.graph.neighbors(node))

deltas_all = self.coordinate_system.connecting_vector(
np.array(node), np.array(neighbors_all)
Expand Down
6 changes: 2 additions & 4 deletions nodefinder/identify/_evaluate/_line/_shortest_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ def _evaluate_line_shortest_path( # pylint: disable=too-many-locals,too-many-st

tmp_graph.remove_nodes_from(nodes_to_remove)

if num_paths > 0: # pylint: disable=undefined-loop-variable
if num_paths > 0:
IDENTIFY_LOGGER.debug(
'Found {} path(s) from point {} to point {}.'.format(
num_paths, # pylint: disable=undefined-loop-variable
start_pos,
end_pos
num_paths, start_pos, end_pos
)
)
else:
Expand Down
11 changes: 6 additions & 5 deletions nodefinder/identify/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _plot_positions(positions, *, axis, color):


@singledispatch
def _plot_result(shape, axis, color, feature_size): # pylint: disable=unused-argument
def _plot_result(shape, axis, color, feature_size):
raise NotImplementedError


Expand Down Expand Up @@ -103,9 +103,9 @@ def nodal_line(shape, *, axis, color, feature_size=None):

if paths:
for path in paths:
axis.plot(*np.array(path).T, color=color)
axis.plot(*np.array(path).T, color=color) # pylint: disable=not-an-iterable
else:
axis.scatter(*np.array(list(graph.nodes)).T, color=color)
axis.scatter(*np.array(list(graph.nodes)).T, color=color) # pylint: disable=not-an-iterable


def _get_graph_paths(graph, feature_size):
Expand All @@ -125,8 +125,9 @@ def _get_graph_paths(graph, feature_size):
except StopIteration:
paths.append(curr_path)
break
if la.norm(np.array(next_node) -
np.array(curr_node)) > 2 * feature_size:
if la.norm(
np.array(next_node) - np.array(curr_node)
) > 2 * feature_size:
paths.append(curr_path)
curr_path = [next_node]
else:
Expand Down
4 changes: 2 additions & 2 deletions nodefinder/identify/result/_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ def to_hdf5(self, hdf5_handle):
def from_hdf5(cls, hdf5_handle):
shape = from_hdf5(hdf5_handle['shape'])
try:
dimension = hdf5_handle['dimension'].value
dimension = hdf5_handle['dimension'][()]
except AttributeError:
dimension = from_hdf5(hdf5_handle['dimension'])
try:
positions = [tuple(x) for x in hdf5_handle['positions'].value]
positions = [tuple(x) for x in hdf5_handle['positions'][()]]
except AttributeError:
positions = from_hdf5(hdf5_handle['positions'])
return cls(positions=positions, dimension=dimension, shape=shape)
1 change: 0 additions & 1 deletion nodefinder/identify/result/_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class NodalLine(SimpleNamespace):
graph : networkx.Graph
A graph describing the line.
"""

def __init__(self, graph, degree_count):
self.graph = graph
self.degree_count = degree_count
Expand Down

0 comments on commit 8608e70

Please sign in to comment.