Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated python types #113

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# dev
.vim
env
*.sqlite3

*.py[cod]

Expand Down
24 changes: 8 additions & 16 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"]

Expand All @@ -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
Expand All @@ -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 ]
Expand All @@ -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
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 .

Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions rmsd/calculate_rmsd.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -2088,5 +2088,5 @@ def main(args: Optional[List[str]] = None) -> str:


if __name__ == "__main__":
result = main() # pragma: no cover
result = main()
print(result)
Loading