From 2df17f1c3de9695bb78cc6280ece5be98697a1e6 Mon Sep 17 00:00:00 2001 From: Max Halford Date: Mon, 2 Oct 2023 20:13:51 +0200 Subject: [PATCH] remove pytest from gaussian.py --- .gitignore | 3 +++ river/proba/gaussian.py | 27 --------------------------- river/proba/test_gaussian.py | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 river/proba/test_gaussian.py diff --git a/.gitignore b/.gitignore index 312295e81d..28ddefaa7f 100644 --- a/.gitignore +++ b/.gitignore @@ -130,3 +130,6 @@ benchmarks/.asv # Cargo file Cargo.lock + +# WASM +/*.html diff --git a/river/proba/gaussian.py b/river/proba/gaussian.py index 2c8f51ae28..6022775361 100644 --- a/river/proba/gaussian.py +++ b/river/proba/gaussian.py @@ -4,7 +4,6 @@ import numpy as np import pandas as pd -import pytest from scipy.stats import multivariate_normal from river import covariance, stats @@ -313,29 +312,3 @@ def sample(self) -> dict[str, float]: @property def mode(self) -> dict: return self.mu - - -@pytest.mark.parametrize( - "p", - [ - pytest.param( - p, - id=f"{p=}", - ) - for p in [1, 3, 5] - ], -) -def test_univariate_multivariate_consistency(p): - X = pd.DataFrame(np.random.random((30, p)), columns=range(p)) - - multi = MultivariateGaussian() - single = {c: Gaussian() for c in X.columns} - - for x in X.to_dict(orient="records"): - multi = multi.update(x) - for c, s in single.items(): - s.update(x[c]) - - for c in X.columns: - assert math.isclose(multi.mu[c], single[c].mu) - assert math.isclose(multi.sigma[c][c], single[c].sigma) diff --git a/river/proba/test_gaussian.py b/river/proba/test_gaussian.py new file mode 100644 index 0000000000..f38fd4ff19 --- /dev/null +++ b/river/proba/test_gaussian.py @@ -0,0 +1,31 @@ +import pytest +import pandas as pd +import numpy as np +import math +from river import proba + + +@pytest.mark.parametrize( + "p", + [ + pytest.param( + p, + id=f"{p=}", + ) + for p in [1, 3, 5] + ], +) +def test_univariate_multivariate_consistency(p): + X = pd.DataFrame(np.random.random((30, p)), columns=range(p)) + + multi = proba.MultivariateGaussian() + single = {c: proba.Gaussian() for c in X.columns} + + for x in X.to_dict(orient="records"): + multi = multi.update(x) + for c, s in single.items(): + s.update(x[c]) + + for c in X.columns: + assert math.isclose(multi.mu[c], single[c].mu) + assert math.isclose(multi.sigma[c][c], single[c].sigma)