Skip to content

Commit

Permalink
BUG: stats: Random parameters in pytest.mark.parametrize() break py…
Browse files Browse the repository at this point in the history
…test-xdist.

Don't use random parameters in `pytest.mark.parametrize()`, as it can confuse
the pytest-xdist extension; see pytest-dev/pytest-xdist#432

Closes scipygh-17468.
  • Loading branch information
WarrenWeckesser committed Nov 24, 2022
1 parent 3a4b42d commit bb32a8d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scipy/stats/tests/test_distributions.py
Expand Up @@ -1385,7 +1385,8 @@ def test_logpdf_extreme_values(self):
# with 64 bit floating point.
assert_equal(logp, [-800, -800])

@pytest.mark.parametrize("loc_rvs,scale_rvs", [np.random.rand(2)])
@pytest.mark.parametrize("loc_rvs,scale_rvs", [(0.4484955, 0.10216821),
(0.62918191, 0.74367064)])
def test_fit(self, loc_rvs, scale_rvs):
data = stats.logistic.rvs(size=100, loc=loc_rvs, scale=scale_rvs)

Expand Down Expand Up @@ -2183,7 +2184,7 @@ def setup_method(self):
np.random.seed(1234)

@pytest.mark.parametrize("rvs_mu,rvs_loc,rvs_scale",
[(2, 0, 1), (np.random.rand(3)*10)])
[(2, 0, 1), (4.635, 4.362, 6.303)])
def test_fit(self, rvs_mu, rvs_loc, rvs_scale):
data = stats.invgauss.rvs(size=100, mu=rvs_mu,
loc=rvs_loc, scale=rvs_scale)
Expand Down Expand Up @@ -2214,7 +2215,7 @@ def test_fit(self, rvs_mu, rvs_loc, rvs_scale):
assert shape_mle1 == shape_mle2 == shape_mle3 == 1.04

@pytest.mark.parametrize("rvs_mu,rvs_loc,rvs_scale",
[(2, 0, 1), (np.random.rand(3)*10)])
[(2, 0, 1), (6.311, 3.225, 4.520)])
def test_fit_MLE_comp_optimizer(self, rvs_mu, rvs_loc, rvs_scale):
data = stats.invgauss.rvs(size=100, mu=rvs_mu,
loc=rvs_loc, scale=rvs_scale)
Expand Down Expand Up @@ -5120,7 +5121,8 @@ def test_logsf(self):
y = stats.rayleigh.logsf(50)
assert_allclose(y, -1250)

@pytest.mark.parametrize("rvs_loc,rvs_scale", [np.random.rand(2)])
@pytest.mark.parametrize("rvs_loc,rvs_scale", [(0.85373171, 0.86932204),
(0.20558821, 0.61621008)])
def test_fit(self, rvs_loc, rvs_scale):
data = stats.rayleigh.rvs(size=250, loc=rvs_loc, scale=rvs_scale)

Expand All @@ -5145,7 +5147,7 @@ def scale_mle(data, floc):
assert_equal(scale, scale_mle(data, loc))

@pytest.mark.parametrize("rvs_loc,rvs_scale", [[0.74, 0.01],
np.random.rand(2)])
[0.08464463, 0.12069025]])
def test_fit_comparison_super_method(self, rvs_loc, rvs_scale):
# test that the objective function result of the analytical MLEs is
# less than or equal to that of the numerically optimized estimate
Expand Down

0 comments on commit bb32a8d

Please sign in to comment.