Skip to content

Commit

Permalink
Fix typing errors detected by newer mypy version (#36)
Browse files Browse the repository at this point in the history
* Fix typing errors detected by newer mypy version

Also pin mypy to avoid problems in the future.

* Fix mypy version in pre-commit hook

Co-authored-by: rbusche <[email protected]>
  • Loading branch information
JarnoRFB and rbusche authored Jun 30, 2021
1 parent d031511 commit 772cb0b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 20 deletions.
30 changes: 15 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
fail_fast: true
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: 'v4.3.21'
hooks:
- id: isort
additional_dependencies: ['isort[pyproject]']
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.730'
- repo: https://github.com/pre-commit/mirrors-isort
rev: "v4.3.21"
hooks:
- id: mypy
- repo: https://gitlab.com/pycqa/flake8
- id: isort
additional_dependencies: ["isort[pyproject]"]
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v0.910"
hooks:
- id: mypy
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.8
hooks:
- id: flake8
- id: flake8
exclude: ^(tests|examples|docs)/*
additional_dependencies: [pep8-naming, flake8-docstrings]
additional_dependencies: [pep8-naming, flake8-docstrings]
2 changes: 1 addition & 1 deletion epysurv/models/timepoint/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def _prepare_r_instance(self, data: pd.DataFrame):
"""Transform dataframe into R data structure on which the R algorithm can work."""
raise NotImplementedError

def _extract_alarms(self, surveillance_result) -> np.array:
def _extract_alarms(self, surveillance_result) -> np.ndarray:
"""Extract the binary alarm array from the surveillance result R data structure."""
raise NotImplementedError

Expand Down
7 changes: 4 additions & 3 deletions epysurv/simulation/seasonal_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import numpy as np
import pandas as pd
import rpy2.robjects.packages as rpackages
from epysurv.simulation.base import BaseSimulation
from epysurv.simulation.utils import add_date_time_index_to_frame, r_list_to_frame
from rpy2 import robjects
from scipy.stats import nbinom, poisson

from epysurv.simulation.base import BaseSimulation
from epysurv.simulation.utils import add_date_time_index_to_frame, r_list_to_frame

surveillance = rpackages.importr("surveillance")


Expand Down Expand Up @@ -187,7 +188,7 @@ def simulate(self, length: int) -> pd.DataFrame:
else:
cases = []
for mu in mu_s:
r = np.float(mu / (self.dispersion - 1))
r = mu / (self.dispersion - 1)
p = r / (r + mu)
cases.append(nbinom.rvs(r, p, size=1)[0])
return (
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pytest-datadir
pytest-cov
codecov
black==19.10b0
mypy
mypy==0.910
flake8
pep8-naming
flake8-docstrings
Expand Down

0 comments on commit 772cb0b

Please sign in to comment.