diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b3e7763..14c7aa1f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks -default_stages: [commit, manual] +default_stages: [pre-commit, manual] repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.2.3 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -16,7 +16,7 @@ repos: - id: check-merge-conflict # Check for files that contain merge conflict strings. - id: debug-statements # Check for debugger imports and py37+ `breakpoint()` calls in python source. - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 24.10.0 hooks: - id: black - repo: local diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index fbdd5057..e35645a5 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,6 +1,11 @@ # RELEASE NOTES -## Version 0.5.5 +## Version 0.5.7 + +* Support for Python 3.13 +* Update to dev dependencies + +## Version 0.5.6 * Add support for Weibull and HalfNormal Distributions diff --git a/examples/simulations/regression_sim.py b/examples/simulations/regression_sim.py index a4126ce9..6a9cde3b 100644 --- a/examples/simulations/regression_sim.py +++ b/examples/simulations/regression_sim.py @@ -31,9 +31,7 @@ X_train, X_test = ( X[:1000, :], - X[ - 1000:, - ], + X[1000:,], ) Y_train, Y_test = Y[:1000], Y[1000:] diff --git a/examples/user-guide/scripts/clean.py b/examples/user-guide/scripts/clean.py index 949f4bad..981e1dd0 100644 --- a/examples/user-guide/scripts/clean.py +++ b/examples/user-guide/scripts/clean.py @@ -1,4 +1,5 @@ """A helper script to "clean up" all of your generated markdown and HTML files.""" + import shutil as sh from pathlib import Path diff --git a/figures/vis_crps.py b/figures/vis_crps.py index 38d08e88..2edde0a2 100644 --- a/figures/vis_crps.py +++ b/figures/vis_crps.py @@ -40,7 +40,7 @@ grads_y = np.zeros((20, 20)) crps = np.zeros((20, 20)) - for (i, j) in tqdm(itertools.product(np.arange(20), np.arange(20)), total=400): + for i, j in tqdm(itertools.product(np.arange(20), np.arange(20)), total=400): H = np.linalg.inv(metric_fn([loc[i, j], scale[i, j]])) g = np.array(grad_fn([loc[i, j], scale[i, j]])) gf = (H @ g).squeeze() diff --git a/figures/vis_mle.py b/figures/vis_mle.py index 0c083325..22c062c2 100644 --- a/figures/vis_mle.py +++ b/figures/vis_mle.py @@ -37,7 +37,7 @@ grads_y = np.zeros((20, 20)) nlls = np.zeros((20, 20)) - for (i, j) in tqdm(itertools.product(np.arange(20), np.arange(20)), total=400): + for i, j in tqdm(itertools.product(np.arange(20), np.arange(20)), total=400): H = np.linalg.inv(fisher_fn([loc[i, j], scale[i, j]])) g = np.array(grad_fn([loc[i, j], scale[i, j]])) gf = (H @ g).squeeze() diff --git a/ngboost/distns/__init__.py b/ngboost/distns/__init__.py index 2a574c8a..db3f8b78 100644 --- a/ngboost/distns/__init__.py +++ b/ngboost/distns/__init__.py @@ -1,4 +1,5 @@ """NGBoost distributions""" + from .categorical import Bernoulli, k_categorical from .cauchy import Cauchy from .distn import ClassificationDistn, Distn, RegressionDistn diff --git a/ngboost/distns/categorical.py b/ngboost/distns/categorical.py index 7de50b20..6bce2c93 100644 --- a/ngboost/distns/categorical.py +++ b/ngboost/distns/categorical.py @@ -1,4 +1,5 @@ """The NGBoost categorial distribution and scores""" + # pylint: disable=invalid-unary-operand-type, unused-argument import numpy as np import scipy as sp diff --git a/ngboost/distns/cauchy.py b/ngboost/distns/cauchy.py index 534df5ef..e2ba1c09 100644 --- a/ngboost/distns/cauchy.py +++ b/ngboost/distns/cauchy.py @@ -1,4 +1,5 @@ """The NGBoost Cauchy distribution and scores""" + from ngboost.distns.t import ( TFixedDf, TFixedDfFixedVar, diff --git a/ngboost/distns/distn.py b/ngboost/distns/distn.py index e738eb2a..184232f1 100644 --- a/ngboost/distns/distn.py +++ b/ngboost/distns/distn.py @@ -1,4 +1,5 @@ """The NGBoost base distribution""" + from warnings import warn import numpy as np diff --git a/ngboost/distns/exponential.py b/ngboost/distns/exponential.py index c057761e..d3dafb12 100644 --- a/ngboost/distns/exponential.py +++ b/ngboost/distns/exponential.py @@ -1,4 +1,5 @@ """The NGBoost Exponential distribution and scores""" + import numpy as np import scipy as sp from scipy.stats import expon as dist diff --git a/ngboost/distns/gamma.py b/ngboost/distns/gamma.py index 770b071e..c2ea71a3 100644 --- a/ngboost/distns/gamma.py +++ b/ngboost/distns/gamma.py @@ -1,4 +1,5 @@ """The NGBoost Gamma distribution and scores""" + import numpy as np import scipy as sp from scipy.stats import gamma as dist diff --git a/ngboost/distns/halfnormal.py b/ngboost/distns/halfnormal.py index bcd4eaba..d8a24e37 100644 --- a/ngboost/distns/halfnormal.py +++ b/ngboost/distns/halfnormal.py @@ -1,4 +1,5 @@ """The NGBoost Half-Normal distribution and scores""" + import numpy as np from scipy.stats import halfnorm as dist diff --git a/ngboost/distns/laplace.py b/ngboost/distns/laplace.py index d8eec925..17d8d654 100644 --- a/ngboost/distns/laplace.py +++ b/ngboost/distns/laplace.py @@ -1,4 +1,5 @@ """The NGBoost Laplace distribution and scores""" + import numpy as np from scipy.stats import laplace as dist diff --git a/ngboost/distns/lognormal.py b/ngboost/distns/lognormal.py index 6a95c4fe..3ff820f6 100644 --- a/ngboost/distns/lognormal.py +++ b/ngboost/distns/lognormal.py @@ -1,4 +1,5 @@ """The NGBoost LogNormal distribution and scores""" + import numpy as np import scipy as sp from scipy.stats import lognorm as dist @@ -89,7 +90,6 @@ def metric(self): class LogNormal(RegressionDistn): - """ Implements the log-normal distribution for NGBoost. diff --git a/ngboost/distns/multivariate_normal.py b/ngboost/distns/multivariate_normal.py index d65ca1d5..47fbe650 100644 --- a/ngboost/distns/multivariate_normal.py +++ b/ngboost/distns/multivariate_normal.py @@ -66,7 +66,6 @@ def d_score(self, Y): return gradient def metric(self): - """ Formulas for this part are not in the the paper mentioned. Obtained by taking the expectation of the Hessian. diff --git a/ngboost/distns/normal.py b/ngboost/distns/normal.py index 35bbdfd4..a2cae845 100644 --- a/ngboost/distns/normal.py +++ b/ngboost/distns/normal.py @@ -1,4 +1,5 @@ """The NGBoost Normal distribution and scores""" + import numpy as np import scipy as sp from scipy.stats import norm as dist diff --git a/ngboost/distns/poisson.py b/ngboost/distns/poisson.py index 56751462..9ce76944 100644 --- a/ngboost/distns/poisson.py +++ b/ngboost/distns/poisson.py @@ -1,4 +1,5 @@ """The NGBoost Poisson distribution and scores""" + import numpy as np from scipy.optimize import Bounds, minimize from scipy.stats import poisson as dist diff --git a/ngboost/distns/t.py b/ngboost/distns/t.py index cf29128e..78077903 100644 --- a/ngboost/distns/t.py +++ b/ngboost/distns/t.py @@ -1,4 +1,5 @@ """The NGBoost Student T distribution and scores""" + import numpy as np from scipy.special import digamma from scipy.stats import t as dist diff --git a/ngboost/distns/utils.py b/ngboost/distns/utils.py index e07f3928..8a4e6061 100644 --- a/ngboost/distns/utils.py +++ b/ngboost/distns/utils.py @@ -1,6 +1,7 @@ """ Extra functions useful for Distns """ + from ngboost.distns import RegressionDistn # pylint: disable=too-few-public-methods diff --git a/ngboost/distns/weibull.py b/ngboost/distns/weibull.py index 582811a9..64808b09 100644 --- a/ngboost/distns/weibull.py +++ b/ngboost/distns/weibull.py @@ -1,4 +1,5 @@ """The NGBoost Weibull distribution and scores""" + import numpy as np from scipy.stats import weibull_min as dist diff --git a/pyproject.toml b/pyproject.toml index 81c900ae..2378a62c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ngboost" -version = "0.5.6dev" +version = "0.5.7dev" description = "Library for probabilistic predictions via gradient boosting." authors = ["Stanford ML Group "] readme = "README.md" @@ -16,29 +16,47 @@ license = "Apache License 2.0" python = ">=3.9, <3.14" scikit-learn = "^1.6" numpy = [ - {version = ">=1.21.2", python = ">=3.9,<3.13"}, - {version = ">=2.1.0", python = ">=3.13"} + {version = ">=1.21.2", markers = "python_version < '3.13'"}, + {version = ">=2.1.0", markers = "python_version >= '3.13'"} ] scipy = [ - {version = ">=1.7.2", python = ">=3.9,<3.13"}, - {version = ">=1.14.1", python = ">=3.13"} + {version = ">=1.7.2", markers = "python_version < '3.13'"}, + {version = ">=1.14.1", markers = "python_version >= '3.13'"} ] tqdm = ">=4.3" lifelines = ">=0.25" -[tool.poetry.dev-dependencies] -pytest = "^6.1.2" -black = "^22.8.0" -pre-commit = "^2.0" -isort = "^5.6.4" -pylint = "^3.0.3" -flake8 = "^7.0.0" +[tool.poetry.group.dev.dependencies] +pytest = "^8.0.0" +black = "^24.0.0" +pre-commit = "^4.0.0" +isort = "^5.13.0" +pylint = "^3.2.0" +flake8 = "^7.1.0" [build-system] requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +[tool.black] +line-length = 88 +target-version = ['py39', 'py310', 'py311'] +include = '\.pyi?$' +extend-exclude = ''' +/( + # directories + \.eggs + | \.git + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | build + | dist +)/ +''' + [tool.isort] multi_line_output = 3 include_trailing_comma = true diff --git a/tests/test_distns.py b/tests/test_distns.py index 4b75d00e..d4a2695c 100644 --- a/tests/test_distns.py +++ b/tests/test_distns.py @@ -35,6 +35,7 @@ Tuple4Array = Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray] Tuple5Array = Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray] + # pylint: disable=redefined-outer-name @pytest.fixture(scope="module") def regression_data():