diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ed8ebf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..021bba5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,14 @@ +fail_fast: true + +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.1 + hooks: + - id: ruff + args: [ --fix, --exit-non-zero-on-fix ] + - id: ruff-format + types_or: [ python, pyi ] + - repo: https://github.com/MarcoGorelli/madforhooks + rev: 0.4.1 + hooks: + - id: no-print-statements diff --git a/distributions/__init__.py b/distributions/__init__.py index 61daa51..64cee6a 100644 --- a/distributions/__init__.py +++ b/distributions/__init__.py @@ -1,5 +1,3 @@ -""" -PyTensor powered distributions. -""" +"""PyTensor powered distributions.""" __version__ = "0.1.0" diff --git a/distributions/asymmetriclaplace.py b/distributions/asymmetriclaplace.py index 04dadb4..4c10f8e 100644 --- a/distributions/asymmetriclaplace.py +++ b/distributions/asymmetriclaplace.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(mu, b, kappa): diff --git a/distributions/bernoulli.py b/distributions/bernoulli.py index 676ee9e..d64beb9 100644 --- a/distributions/bernoulli.py +++ b/distributions/bernoulli.py @@ -1,7 +1,7 @@ import pytensor.tensor as pt from pytensor.tensor.xlogx import xlogx -from .helper import ppf_bounds_disc, cdf_bounds +from distributions.helper import cdf_bounds, ppf_bounds_disc def mean(p): diff --git a/distributions/beta.py b/distributions/beta.py index 918e69d..aa0afaf 100644 --- a/distributions/beta.py +++ b/distributions/beta.py @@ -3,7 +3,7 @@ from pytensor.tensor.special import betaln from pytensor.tensor.xlogx import xlogy0 -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(alpha, beta): diff --git a/distributions/betabinomial.py b/distributions/betabinomial.py index e34193d..8689388 100644 --- a/distributions/betabinomial.py +++ b/distributions/betabinomial.py @@ -1,7 +1,7 @@ import pytensor.tensor as pt -from .helper import cdf_bounds, discrete_entropy, ppf_bounds_disc -from .optimization import find_ppf_discrete +from distributions.helper import cdf_bounds, discrete_entropy +from distributions.optimization import find_ppf_discrete def mean(n, alpha, beta): diff --git a/distributions/betascaled.py b/distributions/betascaled.py index 4ea861d..7864c99 100644 --- a/distributions/betascaled.py +++ b/distributions/betascaled.py @@ -1,9 +1,9 @@ import pytensor.tensor as pt +from pytensor.tensor.math import betaincinv from pytensor.tensor.special import betaln from pytensor.tensor.xlogx import xlogy0 -from pytensor.tensor.math import betaincinv -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(alpha, beta, lower, upper): diff --git a/distributions/binomial.py b/distributions/binomial.py index 0d09b49..1717d4a 100644 --- a/distributions/binomial.py +++ b/distributions/binomial.py @@ -1,9 +1,8 @@ import pytensor.tensor as pt from pytensor.tensor.xlogx import xlogy0 -from .helper import cdf_bounds, discrete_entropy, ppf_bounds_disc -from .normal import entropy as normal_entropy -from .optimization import find_ppf_discrete +from distributions.helper import cdf_bounds, discrete_entropy +from distributions.optimization import find_ppf_discrete def mean(n, p): diff --git a/distributions/cauchy.py b/distributions/cauchy.py index 9b8b7b9..b1c8eec 100644 --- a/distributions/cauchy.py +++ b/distributions/cauchy.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(alpha, beta): diff --git a/distributions/chisquared.py b/distributions/chisquared.py index 12cd3de..e73ead1 100644 --- a/distributions/chisquared.py +++ b/distributions/chisquared.py @@ -1,8 +1,8 @@ import pytensor.tensor as pt - -from .helper import ppf_bounds_cont, cdf_bounds from pytensor.tensor.xlogx import xlogy0 +from distributions.helper import cdf_bounds, ppf_bounds_cont + def mean(nu): return nu diff --git a/distributions/discreteuniform.py b/distributions/discreteuniform.py index 2a0817f..4f51a2c 100644 --- a/distributions/discreteuniform.py +++ b/distributions/discreteuniform.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import cdf_bounds, discrete_entropy, ppf_bounds_disc +from distributions.helper import cdf_bounds, discrete_entropy, ppf_bounds_disc def mean(lower, upper): diff --git a/distributions/exgaussian.py b/distributions/exgaussian.py index 6b91fd5..3de3447 100644 --- a/distributions/exgaussian.py +++ b/distributions/exgaussian.py @@ -1,9 +1,9 @@ import pytensor.tensor as pt -from .helper import logdiffexp, continuous_entropy -from .optimization import find_ppf -from .normal import logcdf as normal_logcdf -from .normal import logpdf as normal_logpdf +from distributions.helper import continuous_entropy, logdiffexp +from distributions.normal import logcdf as normal_logcdf +from distributions.normal import logpdf as normal_logpdf +from distributions.optimization import find_ppf def mean(mu, sigma, nu): diff --git a/distributions/exponential.py b/distributions/exponential.py index 413bc22..1cdf886 100644 --- a/distributions/exponential.py +++ b/distributions/exponential.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont, cdf_bounds +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(lam): diff --git a/distributions/gamma.py b/distributions/gamma.py index 9893a80..cdaa8f8 100644 --- a/distributions/gamma.py +++ b/distributions/gamma.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(alpha, beta): diff --git a/distributions/geometric.py b/distributions/geometric.py index 116170c..1116917 100644 --- a/distributions/geometric.py +++ b/distributions/geometric.py @@ -1,7 +1,6 @@ import pytensor.tensor as pt -from pytensor.tensor.xlogx import xlogy0 -from .helper import cdf_bounds, ppf_bounds_disc +from distributions.helper import cdf_bounds, ppf_bounds_disc def mean(p): diff --git a/distributions/gumbel.py b/distributions/gumbel.py index d4e6b3e..b324d09 100644 --- a/distributions/gumbel.py +++ b/distributions/gumbel.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import cdf_bounds, ppf_bounds_cont +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(mu, beta): diff --git a/distributions/halfcauchy.py b/distributions/halfcauchy.py index 1915b84..ff8fac1 100644 --- a/distributions/halfcauchy.py +++ b/distributions/halfcauchy.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont, cdf_bounds +from distributions.helper import ppf_bounds_cont def mean(beta): diff --git a/distributions/halfnormal.py b/distributions/halfnormal.py index fb82e0d..697ffe7 100644 --- a/distributions/halfnormal.py +++ b/distributions/halfnormal.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(sigma): diff --git a/distributions/halfstudentt.py b/distributions/halfstudentt.py index 3f0c190..074981b 100644 --- a/distributions/halfstudentt.py +++ b/distributions/halfstudentt.py @@ -1,11 +1,11 @@ import pytensor.tensor as pt -from pytensor.tensor.special import betaln from pytensor.tensor.math import betaincinv +from pytensor.tensor.special import betaln -from .helper import cdf_bounds, ppf_bounds_cont -from .halfnormal import entropy as halfnormal_entropy -from .halfnormal import cdf as halfnormal_cdf -from .halfnormal import logpdf as halfnormal_logpdf +from distributions.halfnormal import cdf as halfnormal_cdf +from distributions.halfnormal import entropy as halfnormal_entropy +from distributions.halfnormal import logpdf as halfnormal_logpdf +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(nu, sigma): diff --git a/distributions/helper.py b/distributions/helper.py index 3c99fb0..9055660 100644 --- a/distributions/helper.py +++ b/distributions/helper.py @@ -169,16 +169,12 @@ def discrete_entropy(min_x, max_x, logpdf, *params): def from_tau(tau): - """ - Convert precision (tau) to standard deviation (sigma). - """ + """Convert precision (tau) to standard deviation (sigma).""" sigma = 1 / pt.sqrt(tau) return sigma def to_tau(sigma): - """ - Convert standard deviation (sigma) to precision (tau). - """ + """Convert standard deviation (sigma) to precision (tau).""" tau = pt.power(sigma, -2) return tau diff --git a/distributions/inversegamma.py b/distributions/inversegamma.py index b41b52e..ecc0e51 100644 --- a/distributions/inversegamma.py +++ b/distributions/inversegamma.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import cdf_bounds, ppf_bounds_cont +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(alpha, beta): diff --git a/distributions/kumaraswamy.py b/distributions/kumaraswamy.py index 29dceef..dbb72a3 100644 --- a/distributions/kumaraswamy.py +++ b/distributions/kumaraswamy.py @@ -1,7 +1,7 @@ import pytensor.tensor as pt from pytensor.tensor.xlogx import xlogy0 -from .helper import cdf_bounds, ppf_bounds_cont, sf_bounds +from distributions.helper import cdf_bounds, ppf_bounds_cont, sf_bounds def mean(a, b): diff --git a/distributions/laplace.py b/distributions/laplace.py index ace2e41..7bf9209 100644 --- a/distributions/laplace.py +++ b/distributions/laplace.py @@ -1,5 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont, cdf_bounds + +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(mu, b): diff --git a/distributions/logistic.py b/distributions/logistic.py index 7a113ef..f071d6f 100644 --- a/distributions/logistic.py +++ b/distributions/logistic.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(mu, s): diff --git a/distributions/lognormal.py b/distributions/lognormal.py index d0ae6db..6c3fb08 100644 --- a/distributions/lognormal.py +++ b/distributions/lognormal.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import cdf_bounds, ppf_bounds_cont +from distributions.helper import cdf_bounds, ppf_bounds_cont def mean(mu, sigma): diff --git a/distributions/negativebinomial.py b/distributions/negativebinomial.py index e0c3e67..79a73f5 100644 --- a/distributions/negativebinomial.py +++ b/distributions/negativebinomial.py @@ -1,8 +1,8 @@ import pytensor.tensor as pt from pytensor.tensor.xlogx import xlogy0 -from .helper import cdf_bounds, discrete_entropy, sf_bounds -from .optimization import find_ppf_discrete +from distributions.helper import cdf_bounds, discrete_entropy, sf_bounds +from distributions.optimization import find_ppf_discrete def mean(n, p): diff --git a/distributions/normal.py b/distributions/normal.py index 1d04378..e1c3946 100644 --- a/distributions/normal.py +++ b/distributions/normal.py @@ -1,6 +1,6 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont +from distributions.helper import ppf_bounds_cont def mean(mu, sigma): diff --git a/distributions/optimization.py b/distributions/optimization.py index a689596..3fc70f7 100644 --- a/distributions/optimization.py +++ b/distributions/optimization.py @@ -1,12 +1,12 @@ import pytensor.tensor as pt -from .helper import ppf_bounds_cont, ppf_bounds_disc -from .normal import ppf as normal_ppf +from distributions.helper import ppf_bounds_cont, ppf_bounds_disc def find_ppf(q, lower, upper, cdf, *params): """ Compute the inverse CDF using the bisection method. + Uses iterative expansion for infinite bounds. Note: We need to improve this method!!! diff --git a/distributions/poisson.py b/distributions/poisson.py index 2f15497..ceec3e0 100644 --- a/distributions/poisson.py +++ b/distributions/poisson.py @@ -1,8 +1,8 @@ import pytensor.tensor as pt - from pytensor.tensor.xlogx import xlogy0 -from .helper import cdf_bounds, discrete_entropy, sf_bounds -from .optimization import find_ppf_discrete + +from distributions.helper import cdf_bounds, discrete_entropy, sf_bounds +from distributions.optimization import find_ppf_discrete def mean(mu): diff --git a/distributions/skewnormal.py b/distributions/skewnormal.py index 607c9d0..b9c854c 100644 --- a/distributions/skewnormal.py +++ b/distributions/skewnormal.py @@ -1,8 +1,8 @@ import pytensor.tensor as pt -from .optimization import find_ppf -from .halfnormal import entropy as halfnormal_entropy -from .normal import entropy as normal_entropy +from distributions.halfnormal import entropy as halfnormal_entropy +from distributions.normal import entropy as normal_entropy +from distributions.optimization import find_ppf def mean(mu, sigma, alpha): diff --git a/distributions/studentt.py b/distributions/studentt.py index 005e3d6..4a4df5f 100644 --- a/distributions/studentt.py +++ b/distributions/studentt.py @@ -1,11 +1,11 @@ import pytensor.tensor as pt -from pytensor.tensor.special import betaln from pytensor.tensor.math import betaincinv +from pytensor.tensor.special import betaln -from .helper import ppf_bounds_cont -from .normal import logcdf as normal_logpdf -from .normal import cdf as normal_logcdf -from .normal import entropy as normal_entropy +from distributions.helper import ppf_bounds_cont +from distributions.normal import cdf as normal_logcdf +from distributions.normal import entropy as normal_entropy +from distributions.normal import logcdf as normal_logpdf def mean(nu, mu, sigma): diff --git a/distributions/wald.py b/distributions/wald.py index b536b73..e89a806 100644 --- a/distributions/wald.py +++ b/distributions/wald.py @@ -1,7 +1,7 @@ import pytensor.tensor as pt -from .helper import cdf_bounds -from .optimization import find_ppf +from distributions.helper import cdf_bounds +from distributions.optimization import find_ppf def mean(mu, lam): diff --git a/tests/helper_empirical.py b/tests/helper_empirical.py index 351aae3..237547b 100644 --- a/tests/helper_empirical.py +++ b/tests/helper_empirical.py @@ -1,13 +1,10 @@ -""" -Common utilities for testing distributions against empirical samples. -For distributions not available in scipy. -""" +"""Common utilities for testing distributions not available in scipy.""" import numpy as np import pytensor.tensor as pt from numpy.testing import assert_allclose -from scipy.stats import skew, kurtosis from scipy.integrate import quad +from scipy.stats import kurtosis, skew def run_empirical_tests( @@ -24,9 +21,7 @@ def run_empirical_tests( quantiles_rtol=1e-4, cdf_rtol=1e-4, ): - """ - Test a distribution against empirical samples for distributions not in scipy. - """ + """Test a distribution against empirical samples for distributions not in scipy.""" rng_p = pt.random.default_rng(1) rvs = p_dist.rvs(*p_params, size=sample_size, random_state=rng_p).eval() sample_x = rvs[:20] @@ -178,9 +173,9 @@ def run_empirical_tests( mask = np.abs(pdf_vals) > 1e-4 if np.any(mask): rel_error = np.abs(numerical_pdf[mask] - pdf_vals[mask]) / (np.abs(pdf_vals[mask]) + 1e-10) - assert np.all( - rel_error < 1e-3 - ), f"PDF doesn't match CDF derivative. Max rel error: {np.max(rel_error)}" + assert np.all(rel_error < 1e-3), ( + f"PDF doesn't match CDF derivative. Max rel error: {np.max(rel_error)}" + ) # PPF-CDF inverse x_vals = p_dist.ppf(q, *p_params).eval() diff --git a/tests/helper_scipy.py b/tests/helper_scipy.py index 859fa52..ec23b25 100644 --- a/tests/helper_scipy.py +++ b/tests/helper_scipy.py @@ -1,10 +1,8 @@ -""" -Common utilities for testing distributions against scipy implementations. -""" +"""Common utilities for testing distributions against scipy implementations.""" import numpy as np import pytensor.tensor as pt -from numpy.testing import assert_almost_equal, assert_allclose +from numpy.testing import assert_allclose def run_distribution_tests( @@ -182,12 +180,13 @@ def run_distribution_tests( pdf_left = p_dist.pdf(mode_val - eps, *p_params).eval() pdf_right = p_dist.pdf(mode_val + eps, *p_params).eval() - assert ( - pdf_mode >= pdf_left - 1e-4 - ), f"Mode test (left) failed with {param_info}: pdf_mode={pdf_mode}, pdf_left={pdf_left}" - assert ( - pdf_mode >= pdf_right - 1e-4 - ), f"Mode test (right) failed with {param_info}: pdf_mode={pdf_mode}, pdf_right={pdf_right}" + assert pdf_mode >= pdf_left - 1e-4, ( + f"Mode test (left) failed with {param_info}: pdf_mode={pdf_mode}, pdf_left={pdf_left}" + ) + assert pdf_mode >= pdf_right - 1e-4, ( + f"Mode test (right) failed with {param_info}: " + f"pdf_mode={pdf_mode}, pdf_right={pdf_right}" + ) # Standard deviation std = p_dist.std(*p_params).eval() @@ -230,7 +229,7 @@ def run_distribution_tests( def make_params(*values, dtype=None): - """Helper to create PyTensor constant parameters.""" + """Create PyTensor constant parameters.""" if dtype: return tuple(pt.constant(v, dtype=dtype) for v in values) return tuple(pt.constant(v) for v in values) diff --git a/tests/test_asymmetriclaplace.py b/tests/test_asymmetriclaplace.py index 2f4c515..0a91951 100644 --- a/tests/test_asymmetriclaplace.py +++ b/tests/test_asymmetriclaplace.py @@ -1,11 +1,10 @@ -""" -Test AsymmetricLaplace distribution against scipy implementation. -""" +"""Test AsymmetricLaplace distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import asymmetriclaplace as AsymmetricLaplace -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( @@ -18,7 +17,7 @@ ], ) def test_asymmetriclaplace_vs_scipy(params, sp_params): - """Test AsymmetricLaplace distribution against scipy""" + """Test AsymmetricLaplace distribution against scipy.""" p_params = make_params(*params, dtype="float64") support = (-float("inf"), float("inf")) diff --git a/tests/test_bernoulli.py b/tests/test_bernoulli.py index 8f79212..b8d2c1c 100644 --- a/tests/test_bernoulli.py +++ b/tests/test_bernoulli.py @@ -1,11 +1,10 @@ -""" -Test Bernoulli distribution against scipy implementation. -""" +"""Test Bernoulli distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import bernoulli as Bernoulli -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_beta.py b/tests/test_beta.py index ecb42e0..cf687dc 100644 --- a/tests/test_beta.py +++ b/tests/test_beta.py @@ -1,12 +1,10 @@ -""" -Test Beta distribution against scipy implementation. -""" +"""Test Beta distribution against scipy implementation.""" import pytest -import numpy as np from scipy import stats + from distributions import beta as Beta -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_betabinomial.py b/tests/test_betabinomial.py index 0e49ded..abd9824 100644 --- a/tests/test_betabinomial.py +++ b/tests/test_betabinomial.py @@ -1,12 +1,11 @@ -""" -Test BetaBinomial distribution against scipy implementation. -""" +"""Test BetaBinomial distribution against scipy implementation.""" +import pytensor.tensor as pt import pytest from scipy import stats -import pytensor.tensor as pt + from distributions import betabinomial as BetaBinomial -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import run_distribution_tests @pytest.mark.parametrize( @@ -20,7 +19,7 @@ ], ) def test_betabinomial_vs_scipy(params, sp_params): - """Test BetaBinomial distribution against scipy""" + """Test BetaBinomial distribution against scipy.""" n_param = pt.constant(params[0], dtype="int64") alpha_param = pt.constant(params[1], dtype="float64") beta_param = pt.constant(params[2], dtype="float64") diff --git a/tests/test_betascaled.py b/tests/test_betascaled.py index aa7c75a..3a37b81 100644 --- a/tests/test_betascaled.py +++ b/tests/test_betascaled.py @@ -1,11 +1,10 @@ -""" -Test BetaScaled distribution against scipy implementation. -""" +"""Test BetaScaled distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import betascaled as BetaScaled -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_binomial.py b/tests/test_binomial.py index 7983e89..592888e 100644 --- a/tests/test_binomial.py +++ b/tests/test_binomial.py @@ -1,12 +1,11 @@ -""" -Test Binomial distribution against scipy implementation. -""" +"""Test Binomial distribution against scipy implementation.""" -import pytest import pytensor.tensor as pt +import pytest from scipy import stats + from distributions import binomial as Binomial -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_cauchy.py b/tests/test_cauchy.py index daed923..fb8fc9c 100644 --- a/tests/test_cauchy.py +++ b/tests/test_cauchy.py @@ -1,11 +1,10 @@ -""" -Test Cauchy distribution against scipy implementation. -""" +"""Test Cauchy distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import cauchy as Cauchy -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_chisquared.py b/tests/test_chisquared.py index 5dcce3e..a842672 100644 --- a/tests/test_chisquared.py +++ b/tests/test_chisquared.py @@ -1,11 +1,10 @@ -""" -Test Chi-squared distribution against scipy implementation. -""" +"""Test Chi-squared distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import chisquared as ChiSquared -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( @@ -18,7 +17,7 @@ ], ) def test_chisquared_vs_scipy(params, sp_params): - """Test Chi-squared distribution against scipy""" + """Test Chi-squared distribution against scipy.""" p_params = make_params(*params, dtype="float64") support = (0.0, float("inf")) diff --git a/tests/test_discreteuniform.py b/tests/test_discreteuniform.py index 3a5471b..a5be679 100644 --- a/tests/test_discreteuniform.py +++ b/tests/test_discreteuniform.py @@ -1,11 +1,10 @@ -""" -Test DiscreteUniform distribution against scipy implementation. -""" +"""Test DiscreteUniform distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import discreteuniform as DiscreteUniform -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_exgaussian.py b/tests/test_exgaussian.py index ff409db..7c48fb6 100644 --- a/tests/test_exgaussian.py +++ b/tests/test_exgaussian.py @@ -1,11 +1,10 @@ -""" -Test ExGaussian distribution against scipy implementation. -""" +"""Test ExGaussian distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import exgaussian as ExGaussian -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( @@ -18,7 +17,7 @@ ], ) def test_exgaussian_vs_scipy(params, sp_params): - """Test ExGaussian distribution against scipy""" + """Test ExGaussian distribution against scipy.""" p_params = make_params(*params, dtype="float64") support = (-float("inf"), float("inf")) diff --git a/tests/test_exponential.py b/tests/test_exponential.py index 8726573..a4f3c51 100644 --- a/tests/test_exponential.py +++ b/tests/test_exponential.py @@ -1,11 +1,10 @@ -""" -Test Exponential distribution against scipy implementation. -""" +"""Test Exponential distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import exponential as Exponential -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_gamma.py b/tests/test_gamma.py index ed921cf..3083003 100644 --- a/tests/test_gamma.py +++ b/tests/test_gamma.py @@ -1,11 +1,10 @@ -""" -Test Gamma distribution against scipy implementation. -""" +"""Test Gamma distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import gamma as Gamma -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_geometric.py b/tests/test_geometric.py index 180e438..7f3bf65 100644 --- a/tests/test_geometric.py +++ b/tests/test_geometric.py @@ -1,12 +1,11 @@ -""" -Test Geometric distribution against scipy implementation. -""" +"""Test Geometric distribution against scipy implementation.""" -import pytest import pytensor.tensor as pt +import pytest from scipy import stats + from distributions import geometric as Geometric -from .helper_scipy import run_distribution_tests +from tests.helper_scipy import run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_gumbel.py b/tests/test_gumbel.py index c0f2d08..1ce91e3 100644 --- a/tests/test_gumbel.py +++ b/tests/test_gumbel.py @@ -1,11 +1,10 @@ -""" -Test Gumbel distribution against scipy implementation. -""" +"""Test Gumbel distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import gumbel as Gumbel -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_halfcauchy.py b/tests/test_halfcauchy.py index dec1b8d..5bdbc2c 100644 --- a/tests/test_halfcauchy.py +++ b/tests/test_halfcauchy.py @@ -1,11 +1,10 @@ -""" -Test HalfCauchy distribution against scipy implementation. -""" +"""Test HalfCauchy distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import halfcauchy as HalfCauchy -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_halfnormal.py b/tests/test_halfnormal.py index 7b8d7e0..20656a8 100644 --- a/tests/test_halfnormal.py +++ b/tests/test_halfnormal.py @@ -1,11 +1,10 @@ -""" -Test HalfNormal distribution against scipy implementation. -""" +"""Test HalfNormal distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import halfnormal as HalfNormal -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_halfstudentt.py b/tests/test_halfstudentt.py index 090764e..e8c2a77 100644 --- a/tests/test_halfstudentt.py +++ b/tests/test_halfstudentt.py @@ -1,13 +1,10 @@ -""" -Tests for the HalfStudentT distribution. -""" +"""Tests for the HalfStudentT distribution.""" import pytest -import numpy as np from scipy import stats -from distributions import halfstudentt as HalfStudentT -from .helper_scipy import run_distribution_tests, make_params +from distributions import halfstudentt as HalfStudentT +from tests.helper_scipy import make_params, run_distribution_tests # HalfStudentT is not defined in scipy test_cases = [ diff --git a/tests/test_inversegamma.py b/tests/test_inversegamma.py index 7784b2b..5a4f5fc 100644 --- a/tests/test_inversegamma.py +++ b/tests/test_inversegamma.py @@ -1,11 +1,10 @@ -""" -Test InverseGamma distribution against scipy implementation. -""" +"""Test InverseGamma distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import inversegamma as InverseGamma -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_kumaraswamy.py b/tests/test_kumaraswamy.py index 3da7afd..60790f0 100644 --- a/tests/test_kumaraswamy.py +++ b/tests/test_kumaraswamy.py @@ -1,13 +1,11 @@ -""" -Test Kumaraswamy distribution against scipy implementation. -""" +"""Test Kumaraswamy distribution against scipy implementation.""" import pytest -import numpy as np from scipy import stats + from distributions import kumaraswamy as Kumaraswamy -from .helper_scipy import run_distribution_tests, make_params -from .helper_empirical import run_empirical_tests +from tests.helper_empirical import run_empirical_tests +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_laplace.py b/tests/test_laplace.py index a583303..6cae018 100644 --- a/tests/test_laplace.py +++ b/tests/test_laplace.py @@ -1,11 +1,10 @@ -""" -Test Laplace distribution against scipy implementation. -""" +"""Test Laplace distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import laplace as Laplace -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( @@ -18,7 +17,7 @@ ], ) def test_laplace_vs_scipy(params, sp_params): - """Test Laplace distribution against scipy""" + """Test Laplace distribution against scipy.""" p_params = make_params(*params) support = (-float("inf"), float("inf")) diff --git a/tests/test_logistic.py b/tests/test_logistic.py index 5309773..84567b1 100644 --- a/tests/test_logistic.py +++ b/tests/test_logistic.py @@ -1,11 +1,10 @@ -""" -Test Logistic distribution against scipy implementation. -""" +"""Test Logistic distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import logistic as Logistic -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_lognormal.py b/tests/test_lognormal.py index 9e45276..52926f4 100644 --- a/tests/test_lognormal.py +++ b/tests/test_lognormal.py @@ -1,12 +1,11 @@ -""" -Test LogNormal distribution against scipy implementation. -""" +"""Test LogNormal distribution against scipy implementation.""" -import pytest import numpy as np +import pytest from scipy import stats + from distributions import lognormal as LogNormal -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_negativebinomial.py b/tests/test_negativebinomial.py index 7cd68c7..58b7e05 100644 --- a/tests/test_negativebinomial.py +++ b/tests/test_negativebinomial.py @@ -1,11 +1,10 @@ -""" -Test NegativeBinomial distribution against scipy implementation. -""" +"""Test NegativeBinomial distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import negativebinomial as NegativeBinomial -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_normal.py b/tests/test_normal.py index 587d0de..82446bd 100644 --- a/tests/test_normal.py +++ b/tests/test_normal.py @@ -1,11 +1,10 @@ -""" -Test Normal distribution against scipy implementation. -""" +"""Test Normal distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import normal as Normal -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( @@ -19,7 +18,7 @@ ], ) def test_normal_vs_scipy(params, sp_params): - """Test Normal distribution against scipy""" + """Test Normal distribution against scipy.""" p_params = make_params(*params) support = (-float("inf"), float("inf")) diff --git a/tests/test_poisson.py b/tests/test_poisson.py index 37a606f..ffe661b 100644 --- a/tests/test_poisson.py +++ b/tests/test_poisson.py @@ -1,11 +1,10 @@ -""" -Test Poisson distribution against scipy implementation. -""" +"""Test Poisson distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import poisson as Poisson -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_skewnormal.py b/tests/test_skewnormal.py index 33a99c7..f16ebc2 100644 --- a/tests/test_skewnormal.py +++ b/tests/test_skewnormal.py @@ -1,11 +1,10 @@ -""" -Test SkewNormal distribution against scipy implementation. -""" +"""Test SkewNormal distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import skewnormal as SkewNormal -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_studentt.py b/tests/test_studentt.py index 126f04b..c1a4ae0 100644 --- a/tests/test_studentt.py +++ b/tests/test_studentt.py @@ -1,11 +1,10 @@ -""" -Test StudentT distribution against scipy implementation. -""" +"""Test StudentT distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import studentt as StudentT -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize( diff --git a/tests/test_wald.py b/tests/test_wald.py index e3afebf..9d3e2ed 100644 --- a/tests/test_wald.py +++ b/tests/test_wald.py @@ -1,11 +1,10 @@ -""" -Test Wald (Inverse Gaussian) distribution against scipy implementation. -""" +"""Test Wald (Inverse Gaussian) distribution against scipy implementation.""" import pytest from scipy import stats + from distributions import wald as Wald -from .helper_scipy import run_distribution_tests, make_params +from tests.helper_scipy import make_params, run_distribution_tests @pytest.mark.parametrize(