Skip to content

Commit

Permalink
Merge pull request #53 from JuDFTteam/release-0.4.8
Browse files Browse the repository at this point in the history
Release 0.4.8
  • Loading branch information
janssenhenning authored Jun 2, 2021
2 parents 291bbbd + 6d4f872 commit bc6d7f6
Show file tree
Hide file tree
Showing 621 changed files with 66,779 additions and 4,131 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.7
current_version = 0.4.8
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
24 changes: 18 additions & 6 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8

- name: Cache python dependencies
id: cache-pip
Expand All @@ -45,11 +45,23 @@ jobs:
run: |
SPHINXOPTS='-nW' make -C docs html
pre-commit:
runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
matrix:
include:
- name: pre-commit-errors
skip-hooks: pylint-warnings
strict: false
- name: pre-commit-warnings
skip-hooks: pylint-errors
strict: true

name: ${{ matrix.name }}
continue-on-error: ${{ matrix.strict }}

steps:
- uses: actions/checkout@v2

Expand All @@ -74,7 +86,7 @@ jobs:
- name: Run pre-commit
run: |
pre-commit run --all-files || (git status --short; git diff ; exit 1)
SKIP=${{ matrix.skip-hooks }} pre-commit run --all-files || (git status --short; git diff ; exit 1)
tests:

Expand Down Expand Up @@ -109,7 +121,7 @@ jobs:
- name: Run pytest
run: |
cd masci_tools/tests/ && ./run_all_cov.sh
cd tests/ && ./run_all_cov.sh
- name: Upload code coverage report
run: |
Expand All @@ -118,7 +130,7 @@ jobs:
publish:
name: Publish to PyPi
needs: [docs, tests] # pre-commit is not yet ready (so we cannot depend on it)
needs: [docs, tests, pre-commit] #pylint-warnings could be added at some later point
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
Expand Down
27 changes: 20 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8

- name: Cache python dependencies
id: cache-pip
Expand All @@ -40,10 +40,22 @@ jobs:
SPHINXOPTS='-nW' make -C docs html
pre-commit:

runs-on: ubuntu-latest
timeout-minutes: 30

strategy:
matrix:
include:
- name: pre-commit-errors
skip-hooks: pylint-warnings
strict: false
- name: pre-commit-warnings
skip-hooks: pylint-errors
strict: true

name: ${{ matrix.name }}
continue-on-error: ${{ matrix.strict }}

steps:
- uses: actions/checkout@v2

Expand All @@ -56,10 +68,10 @@ jobs:
restore-keys: |
pip-pre-commit-
- name: Set up Python 3.7
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.7
python-version: 3.8

- name: Install python dependencies
run: |
Expand All @@ -68,7 +80,8 @@ jobs:
- name: Run pre-commit
run: |
pre-commit run --all-files || (git status --short; git diff ; exit 1)
SKIP=${{ matrix.skip-hooks }} pre-commit run --all-files || (git status --short; git diff ; exit 1)
tests:

Expand Down Expand Up @@ -103,7 +116,7 @@ jobs:
- name: Run pytest
run: |
cd masci_tools/tests/ && ./run_all_cov.sh
cd tests/ && ./run_all_cov.sh
- name: Upload code coverage report
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ publish_to_pypi.sh
__pycache__/
*.py[cod]
*$py.class
*.py.bak

# C extensions
*.so
Expand Down
28 changes: 25 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ repos:
types: [python]
- id: trailing-whitespace
types: [python]
- id: check-yaml
- id: check-added-large-files
- id: forbid-new-submodules

- repo: git://github.com/pre-commit/mirrors-yapf
rev: v0.30.0
rev: v0.31.0
hooks:
- id: yapf
name: yapf
Expand All @@ -23,12 +26,31 @@ repos:
)$
args: ['-i']

- repo: https://github.com/ikamensh/flynt/
rev: '0.55'
hooks:
- id: flynt
args: [
'--line-length=120',
'--fail-on-change',
]

- repo: local
hooks:

- id: pylint
name: pylint
- id: pylint-errors
name: pylint-errors
entry: pylint
args: [-d, W, -d, R, -d, C]
verbose: true
types: [python]
language: system
exclude: '^(docs/)|(examples/)'

- id: pylint-warnings
name: pylint-warnings
entry: pylint
verbose: true
types: [python]
language: system
exclude: '^(docs/)|(examples/)'
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ formats:
- pdf

python:
version: 3.7
version: 3.8
install:
- method: pip
path: .
Expand Down
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions docs/source/module_guide/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ Calculation tools
.. automodule:: masci_tools.tools.cf_calculation
:members:

.. automodule:: masci_tools.tools.greensfunction
:members:

IO helper functions and file parsers
+++++++++++++++++++++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/fleurxmlmodifier.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ On the other hand, there are shortcut methods that already know some paths:
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_attrib_value()`: user-friendly method for setting attributes in the xml file by specifying their name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_first_attrib_value()`: user-friendly method for setting the first occurrence of an attribute in the xml file by specifying its name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.add_number_to_attrib()`: user-friendly method for adding to or multiplying values of attributes in the xml file by specifying their name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_first_attrib_value()`: user-friendly method for adding to or multiplying values of the first occurrence of an attribute in the xml file by specifying its name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.add_number_to_first_attrib()`: user-friendly method for adding to or multiplying values of the first occurrence of the attribute in the xml file by specifying their name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_text()`: user-friendly method for setting text on xml elements in the xml file by specifying their name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_first_text()`: user-friendly method for setting the text on the first occurrence of an xml element in the xml file by specifying its name
* :py:func:`~masci_tools.io.fleurxmlmodifier.FleurXMLModifier.set_simple_tag()`: user-friendly method for creating and setting attributes on simple xml elements (only attributes) in the xml file by specifying its name
Expand Down
2 changes: 1 addition & 1 deletion masci_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
'''
import logging

__version__ = '0.4.7'
__version__ = '0.4.8'

logging.getLogger(__name__).addHandler(logging.NullHandler())
11 changes: 5 additions & 6 deletions masci_tools/io/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,7 @@ def get_ef_from_potfile(potfile):
"""
extract fermi energy from potfile
"""
f = open_general(potfile)
with f:
with open_general(potfile) as f:
txt = f.readlines()
ef = float(txt[3].split()[1])
return ef
Expand Down Expand Up @@ -411,14 +410,14 @@ def convert_to_fortran(val, quote_strings=True):
else:
val_str = '.false.'
elif isinstance(val, numbers.Integral):
val_str = '{:d}'.format(val)
val_str = f'{val:d}'
elif isinstance(val, numbers.Real):
val_str = ('{:18.10e}'.format(val)).replace('e', 'd')
val_str = f'{val:18.10e}'.replace('e', 'd')
elif isinstance(val, str):
if quote_strings:
val_str = "'{!s}'".format(val)
val_str = f"'{val!s}'"
else:
val_str = '{!s}'.format(val)
val_str = f'{val!s}'
else:
raise ValueError(f"Invalid value '{val}' of type '{type(val)}' passed, accepts only booleans, ints, "
'floats and strings')
Expand Down
23 changes: 13 additions & 10 deletions masci_tools/io/fleurxmlmodifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"""
from collections import namedtuple
from lxml import etree
import copy

from masci_tools.util.xml.collect_xml_setters import XPATH_SETTERS, SCHEMA_DICT_SETTERS, NMMPMAT_SETTERS
#Enable warnings for missing docstrings
#pylint: enable=missing-function-docstring
Expand Down Expand Up @@ -83,7 +83,6 @@ def __init__(self, validate_signatures=True):
self._tasks = []
self.validate_signatures = validate_signatures


@classmethod
def fromList(cls, task_list, *args, **kwargs):
"""
Expand All @@ -98,17 +97,25 @@ def fromList(cls, task_list, *args, **kwargs):
"""

fm = cls(*args, **kwargs)
fm.add_task_list(task_list)
return fm

def add_task_list(self, task_list):
"""
Add a list of tasks to be added
:param task_list: list of tuples first index is the name of the method
second is defining the arguments by keyword in a dict
"""

facade_methods = fm.get_avail_actions()
facade_methods = self.get_avail_actions()

for name, kwargs in task_list:
try:
facade_methods[name](**kwargs)
except KeyError as exc:
raise ValueError(f"Unknown modification method '{name}'") from exc

return fm

def _validate_signature(self, name, *args, **kwargs):
"""
Validate that the given arguments to the registration
Expand Down Expand Up @@ -139,7 +146,7 @@ def _validate_signature(self, name, *args, **kwargs):
except TypeError as exc:
raise TypeError(
f"The given arguments for the registration method '{name}' are not valid for the XML modifying function"
) from exc
f'The following error was raised: {exc}') from exc

@classmethod
def apply_modifications(cls, xmltree, nmmp_lines, modification_tasks, validate_changes=True):
Expand Down Expand Up @@ -180,10 +187,6 @@ def apply_modifications(cls, xmltree, nmmp_lines, modification_tasks, validate_c
action = cls.nmmpmat_functions[task.name]
nmmp_lines = action(xmltree, nmmp_lines, schema_dict, *task.args, **task.kwargs)

elif task.name in cls.no_xmltree_functions:
action = cls.nmmpmat_functions[task.name]
nmmp_lines = action(xmltree, nmmp_lines, schema_dict, *task.args, **task.kwargs)

else:
raise ValueError(f'Unknown task {task.name}')

Expand Down
Loading

0 comments on commit bc6d7f6

Please sign in to comment.