diff --git a/.gitignore b/.gitignore index 068ebde..e9bebc7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # dev .vim env +*.sqlite3 *.py[cod] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c2de02..e0a6ad4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,22 +20,24 @@ repos: - id: check-added-large-files args: ['--maxkb=3000'] + - repo: https://github.com/myint/autoflake rev: v2.3.1 hooks: - id: autoflake - name: Removes unused variables + name: removes unused variables args: - --in-place - --remove-all-unused-imports - --expand-star-imports - --ignore-init-module-imports + - repo: https://github.com/pre-commit/mirrors-isort rev: v5.10.1 hooks: - id: isort - name: Sorts imports + name: sorts imports args: [ # Align isort with black formatting "--multi-line=3", @@ -45,11 +47,12 @@ repos: "--line-width=99", ] + - repo: https://github.com/psf/black rev: 24.10.0 hooks: - id: black - name: Fixes formatting + name: fixes formatting language_version: python3 args: ["--line-length=99"] @@ -58,7 +61,7 @@ repos: rev: 7.1.1 hooks: - id: flake8 - name: Checks pep8 style + name: checks pep8 style args: [ "--max-line-length=99", # Ignore imports in init files @@ -69,16 +72,11 @@ repos: "--ignore=E501,E203,W503", ] - # - repo: https://github.com/pre-commit/mirrors-mypy - # rev: v0.782 - # hooks: - # - id: mypy - # args: [--ignore-missing-imports] - repo: local hooks: - id: mypy - name: Checking types + name: checking types entry: mypy language: system types: [ python ] @@ -87,12 +85,6 @@ repos: - repo: local hooks: - # - id: mypy - # name: Static type checking - # entry: mypy - # files: \.py$ - # language: python - - id: jupyisort name: Sorts ipynb imports entry: jupytext --pipe-fmt ".py" --pipe "isort - --multi-line=3 --trailing-comma --force-grid-wrap=0 --use-parentheses --line-width=99" --sync diff --git a/Makefile b/Makefile index a1aee77..56676c5 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ python=./env/bin/python +pytest=./env/bin/pytest +package=rmsd ## Setup env: - conda env create -f ./environment.yaml -p ./env --quiet + conda env create -f ./environment.yml -p ./env --quiet ${python} -m pre_commit install ${python} -m pip install -e . @@ -23,10 +25,10 @@ test-dist: types: ${python} -m monkeytype run $$(which ${pytest}) ./tests - ${python} -m monkeytype list-modules | grep ${pkg} | parallel -j${j} "${python} -m monkeytype apply {} > /dev/null && echo {}" + ${python} -m monkeytype list-modules | grep ${package} | parallel -j1 "${python} -m monkeytype apply {} > /dev/null && echo {}" cov: - ${python} -m pytest --cov=${pkg} --cov-config .coveragerc --cov-report html tests + ${python} -m pytest --cov=${package} --cov-config .coveragerc --cov-report html tests compile: ${python} _compile.py diff --git a/requirements.txt b/requirements.txt index 3984821..55da765 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ -numpy -scipy +build matplotlib -qmllib +monkeytype mypy numpy +numpy pre-commit pylint pytest pytest-cov +qmllib +scipy scipy -build twine -monkeytype diff --git a/rmsd/calculate_rmsd.py b/rmsd/calculate_rmsd.py index eda88b8..108f9d4 100644 --- a/rmsd/calculate_rmsd.py +++ b/rmsd/calculate_rmsd.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 __doc__ = """ Calculate Root-mean-square deviation (RMSD) between structure A and B, in XYZ or PDB format, using transformation and rotation. @@ -27,8 +27,8 @@ import qmllib # type: ignore from qmllib.kernels import laplacian_kernel # type: ignore from qmllib.representations import generate_fchl19 # type: ignore -except ImportError: # pragma: no cover - qmllib = None # pragma: no cover +except ImportError: + qmllib = None METHOD_KABSCH = "kabsch" @@ -1939,8 +1939,8 @@ def main(args: Optional[List[str]] = None) -> str: use_view: bool = True if settings.ignore_hydrogen: - p_view = np.where(p_atoms != 1) # type: ignore - q_view = np.where(q_atoms != 1) # type: ignore + (p_view,) = np.where(p_atoms != 1) + (q_view,) = np.where(q_atoms != 1) elif settings.remove_idx: index = np.array(list(set(range(p_size)) - set(settings.remove_idx))) @@ -2088,5 +2088,5 @@ def main(args: Optional[List[str]] = None) -> str: if __name__ == "__main__": - result = main() # pragma: no cover + result = main() print(result)