diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62a0eff1..4862b7ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v5.0.0 hooks: - id: check-added-large-files args: ['--maxkb=500'] @@ -18,7 +18,7 @@ repos: args: [--branch, main] - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 # Use the ref you want to point at + rev: v1.10.0 # Use the ref you want to point at hooks: - id: python-check-blanket-noqa - id: python-check-mock-methods @@ -32,31 +32,31 @@ repos: - id: text-unicode-replacement-char exclude_types: [jupyter] - repo: https://github.com/asottile/pyupgrade - rev: v2.29.0 + rev: v3.19.0 hooks: - id: pyupgrade args: [--py36-plus] -- repo: https://github.com/asottile/reorder_python_imports - rev: v2.6.0 +- repo: https://github.com/asottile/reorder-python-imports + rev: v3.14.0 hooks: - id: reorder-python-imports types: [python] - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.17.0 + rev: v2.7.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/psf/black - rev: 21.9b0 + rev: 24.10.0 hooks: - id: black types: [python] - repo: https://github.com/asottile/blacken-docs - rev: v1.11.0 + rev: 1.19.1 hooks: - id: blacken-docs additional_dependencies: [black] - repo: https://github.com/PyCQA/flake8 - rev: 3.9.2 + rev: 7.1.1 hooks: - id: flake8 types: [python] @@ -76,29 +76,29 @@ repos: Pygments, ] - repo: https://github.com/nbQA-dev/nbQA - rev: 1.1.1 + rev: 1.9.1 hooks: - id: nbqa-black - id: nbqa-pyupgrade - id: nbqa-isort - repo: https://github.com/PyCQA/doc8 - rev: 0.9.1 + rev: v1.1.2 hooks: - id: doc8 - repo: https://github.com/econchick/interrogate - rev: 1.5.0 + rev: 1.7.0 hooks: - id: interrogate args: [-v, --fail-under=78, src] pass_filenames: false - repo: https://github.com/codespell-project/codespell - rev: v2.1.0 + rev: v2.3.0 hooks: - id: codespell exclude: \.ipynb args: [-L effekt, -L unparseable] - repo: https://github.com/mgedmin/check-manifest - rev: "0.47" + rev: "0.50" hooks: - id: check-manifest - repo: meta diff --git a/docs/source/_static/images/make_infectiousness_period.ipynb b/docs/source/_static/images/make_infectiousness_period.ipynb index 98714fd3..55f9a33f 100644 --- a/docs/source/_static/images/make_infectiousness_period.ipynb +++ b/docs/source/_static/images/make_infectiousness_period.ipynb @@ -125,9 +125,7 @@ ], "source": [ "dist_mean = 2 * 0.12 + 4 * 0.29 + 6 * 0.47 + 10 * 0.12\n", - "dist_var = (\n", - " 2 ** 2 * 0.12 + 4 ** 2 * 0.29 + 6 ** 2 * 0.47 + 10 ** 2 * 0.12 - dist_mean ** 2\n", - ")\n", + "dist_var = 2**2 * 0.12 + 4**2 * 0.29 + 6**2 * 0.47 + 10**2 * 0.12 - dist_mean**2\n", "dist_std = np.sqrt(dist_var)\n", "dist_mean, dist_std" ] diff --git a/docs/source/_static/images/make_time_until_death.ipynb b/docs/source/_static/images/make_time_until_death.ipynb index 2b256418..c156451e 100644 --- a/docs/source/_static/images/make_time_until_death.ipynb +++ b/docs/source/_static/images/make_time_until_death.ipynb @@ -41,7 +41,7 @@ "source": [ "mean = 11.74\n", "std = 8.79\n", - "var = 8.79 ** 2\n", + "var = 8.79**2\n", "\n", "print(mean, std)" ] diff --git a/docs/source/_static/images/make_time_until_icu_recovery.ipynb b/docs/source/_static/images/make_time_until_icu_recovery.ipynb index acbe7ad4..59159f00 100644 --- a/docs/source/_static/images/make_time_until_icu_recovery.ipynb +++ b/docs/source/_static/images/make_time_until_icu_recovery.ipynb @@ -41,7 +41,7 @@ "source": [ "mean = 18.8\n", "std = 12.21\n", - "var = std ** 2\n", + "var = std**2\n", "\n", "print(mean, std)" ] diff --git a/setup.cfg b/setup.cfg index 85391e77..80e63ec0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,7 +7,7 @@ url = https://github.com/covid-19-impact-lab/sid author = Janos Gabler, Tobias Raabe, Klara Roehrl author_email = janos.gabler@gmail.com license = MIT -license_file = LICENSE +license_files = LICENSE platforms = any classifiers = Development Status :: 3 - Alpha @@ -16,10 +16,6 @@ classifiers = Operating System :: OS Independent Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 Topic :: Scientific/Engineering project_urls = Changelog = https://sid-dev.readthedocs.io/en/latest/changes.html @@ -41,7 +37,7 @@ install_requires = python-snappy seaborn tqdm -python_requires = >=3.6 +python_requires = >=3.9 include_package_data = True package_dir = =src diff --git a/src/sid/colors.py b/src/sid/colors.py index 78f5d5f3..c861d2de 100644 --- a/src/sid/colors.py +++ b/src/sid/colors.py @@ -3,6 +3,7 @@ https://github.com/covid-19-impact-lab/utilities/blob/master/utilities/colors.py."" """ + import numpy as np import seaborn as sns from matplotlib.colors import LinearSegmentedColormap diff --git a/src/sid/config.py b/src/sid/config.py index 2ae3d2ef..75f04039 100644 --- a/src/sid/config.py +++ b/src/sid/config.py @@ -1,4 +1,5 @@ """This module contains configuration values for sid.""" + from pathlib import Path import numpy as np diff --git a/src/sid/contacts.py b/src/sid/contacts.py index c3399e88..f78f3f7b 100644 --- a/src/sid/contacts.py +++ b/src/sid/contacts.py @@ -1,4 +1,5 @@ """This module contains everything related to contacts and matching.""" + import itertools from typing import Any from typing import Dict diff --git a/src/sid/events.py b/src/sid/events.py index f5ca5163..02aacf44 100644 --- a/src/sid/events.py +++ b/src/sid/events.py @@ -1,4 +1,5 @@ """This module contains the code to calculate infections by events.""" + import pandas as pd from sid.config import DTYPE_VIRUS_STRAIN from sid.virus_strains import combine_first_factorized_infections diff --git a/src/sid/initial_conditions.py b/src/sid/initial_conditions.py index c7fb79c3..f51191e4 100644 --- a/src/sid/initial_conditions.py +++ b/src/sid/initial_conditions.py @@ -4,6 +4,7 @@ beginning of a simulation and can used to create patterns which match the real data. """ + import itertools import math from typing import Any @@ -456,9 +457,9 @@ def _sample_factorized_virus_strains_for_infections( sampled_virus_strains = np.random.choice( virus_strain_factors, p=probabilities, size=n_infected ) - spread_out_virus_strains.loc[ - spread_out_infections[column], column - ] = sampled_virus_strains + spread_out_virus_strains.loc[spread_out_infections[column], column] = ( + sampled_virus_strains + ) return spread_out_virus_strains diff --git a/src/sid/matching_probabilities.py b/src/sid/matching_probabilities.py index 9b8062dd..eae091e1 100644 --- a/src/sid/matching_probabilities.py +++ b/src/sid/matching_probabilities.py @@ -1,4 +1,5 @@ """Functions to work with transition matrices for assortative matching.""" + import string import warnings from typing import List diff --git a/src/sid/msm.py b/src/sid/msm.py index 175e5b92..d270aaf9 100644 --- a/src/sid/msm.py +++ b/src/sid/msm.py @@ -15,6 +15,7 @@ of Asset Prices. Econometrica, 61(4), 929-952. """ + import functools import numpy as np @@ -156,7 +157,7 @@ def _msm( moment_errors = flat_simulated_moments - flat_empirical_moments root_contribs = np.sqrt(np.diagonal(weighting_matrix)) * moment_errors - value = np.sum(root_contribs ** 2) + value = np.sum(root_contribs**2) out = { "value": value, diff --git a/src/sid/parse_model.py b/src/sid/parse_model.py index 441b3e12..a6be07f5 100644 --- a/src/sid/parse_model.py +++ b/src/sid/parse_model.py @@ -1,4 +1,5 @@ """This module contains the code the parse input data.""" + import copy import pprint import warnings diff --git a/src/sid/pathogenesis.py b/src/sid/pathogenesis.py index 43ddeec2..5a658d23 100644 --- a/src/sid/pathogenesis.py +++ b/src/sid/pathogenesis.py @@ -4,6 +4,7 @@ countdown lengths. Currently, most of it is deterministic. """ + import numpy as np import pandas as pd from sid.config import DTYPE_DRAW_COURSE_OF_DISEASE diff --git a/src/sid/policies.py b/src/sid/policies.py index e6ff4074..ecb4dc82 100644 --- a/src/sid/policies.py +++ b/src/sid/policies.py @@ -1,4 +1,5 @@ """This module contains the code to for applying contact policies.""" + import itertools from typing import Any from typing import Dict diff --git a/src/sid/seasonality.py b/src/sid/seasonality.py index 6978055a..b9b84d9d 100644 --- a/src/sid/seasonality.py +++ b/src/sid/seasonality.py @@ -1,4 +1,5 @@ """This module contains the code related to seasonality.""" + import itertools from typing import Any from typing import Callable diff --git a/src/sid/testing.py b/src/sid/testing.py index 5580bf45..54afe66d 100644 --- a/src/sid/testing.py +++ b/src/sid/testing.py @@ -1,4 +1,5 @@ """This module holds the interface for the testing models.""" + import itertools from typing import Any from typing import Dict diff --git a/src/sid/testing_demand.py b/src/sid/testing_demand.py index f05dcaf4..98d5512c 100644 --- a/src/sid/testing_demand.py +++ b/src/sid/testing_demand.py @@ -1,4 +1,5 @@ """Contains the code for calculating the demand for tests.""" + import itertools from typing import Any from typing import Dict diff --git a/src/sid/time.py b/src/sid/time.py index 1a720b86..08873d96 100644 --- a/src/sid/time.py +++ b/src/sid/time.py @@ -13,6 +13,7 @@ estimation to reduce memory consumption. """ + from functools import partial import pandas as pd diff --git a/src/sid/update_states.py b/src/sid/update_states.py index 36ac3819..468f8873 100644 --- a/src/sid/update_states.py +++ b/src/sid/update_states.py @@ -289,7 +289,7 @@ def _get_waning_immunity_coefficients( ("immunity", "immunity_waning", f"slope_after_maximum_{event}"), "value" ] - slope_before_maximum = maximum_immunity / (time_to_reach_maximum ** 3) + slope_before_maximum = maximum_immunity / (time_to_reach_maximum**3) intercept_after_maximum = ( maximum_immunity - slope_after_maximum * time_to_reach_maximum ) diff --git a/src/sid/vaccination.py b/src/sid/vaccination.py index df255d73..96f9a7c6 100644 --- a/src/sid/vaccination.py +++ b/src/sid/vaccination.py @@ -1,4 +1,5 @@ """This module contains the code for vaccinating individuals.""" + import itertools from typing import Any from typing import Dict diff --git a/src/sid/validation.py b/src/sid/validation.py index 7b12311a..70ee6cb3 100644 --- a/src/sid/validation.py +++ b/src/sid/validation.py @@ -1,4 +1,5 @@ """This module contains routines to validate inputs to functions.""" + import inspect import warnings from typing import Callable