|
48 | 48 | from scipy._lib.array_api_extra.testing import lazy_xp_function
|
49 | 49 |
|
50 | 50 | skip_xp_backends = pytest.mark.skip_xp_backends
|
51 |
| -boolean_index_skip_reason = 'JAX/Dask arrays do not support boolean assignment.' |
52 | 51 |
|
53 | 52 |
|
54 | 53 | """ Numbers in docstrings beginning with 'W' refer to the section numbers
|
@@ -554,7 +553,7 @@ def test_length_two_constant_input(self, xp):
|
554 | 553 | # cor.test(x, y, method = "pearson", alternative = "g")
|
555 | 554 | # correlation coefficient and p-value for alternative='two-sided'
|
556 | 555 | # calculated with mpmath agree to 16 digits.
|
557 |
| - @pytest.mark.skip_xp_backends(np_only=True) |
| 556 | + @skip_xp_backends(np_only=True) |
558 | 557 | @pytest.mark.parametrize('alternative, pval, rlow, rhigh, sign',
|
559 | 558 | [('two-sided', 0.325800137536, -0.814938968841, 0.99230697523, 1),
|
560 | 559 | ('less', 0.8370999312316, -1, 0.985600937290653, 1),
|
@@ -4016,7 +4015,7 @@ def test_1samp_alternative(self, xp):
|
4016 | 4015 | xp_assert_close(p, xp.asarray(self.P1_1_g))
|
4017 | 4016 | xp_assert_close(t, xp.asarray(self.T1_1))
|
4018 | 4017 |
|
4019 |
| - @pytest.mark.skip_xp_backends('jax.numpy', reason='Generic stdtrit mutates array.') |
| 4018 | + @skip_xp_backends('jax.numpy', reason='Generic stdtrit mutates array.') |
4020 | 4019 | @pytest.mark.parametrize("alternative", ['two-sided', 'less', 'greater'])
|
4021 | 4020 | def test_1samp_ci_1d(self, xp, alternative):
|
4022 | 4021 | # test confidence interval method against reference values
|
@@ -4049,7 +4048,7 @@ def test_1samp_ci_iv(self, xp):
|
4049 | 4048 | with pytest.raises(ValueError, match=message):
|
4050 | 4049 | res.confidence_interval(confidence_level=10)
|
4051 | 4050 |
|
4052 |
| - @pytest.mark.skip_xp_backends(np_only=True, reason='Too slow.') |
| 4051 | + @skip_xp_backends(np_only=True, reason='Too slow.') |
4053 | 4052 | @pytest.mark.xslow
|
4054 | 4053 | @hypothesis.given(alpha=hypothesis.strategies.floats(1e-15, 1-1e-15),
|
4055 | 4054 | data_axis=ttest_data_axis_strategy())
|
@@ -5676,8 +5675,7 @@ def test_resampling_input_validation(self):
|
5676 | 5675 | with pytest.raises(ValueError, match=message):
|
5677 | 5676 | stats.ttest_ind([1, 2, 3], [4, 5, 6], method='migratory')
|
5678 | 5677 |
|
5679 |
| - @pytest.mark.skip_xp_backends(cpu_only=True, |
5680 |
| - reason='Uses NumPy for pvalue, CI') |
| 5678 | + @skip_xp_backends(cpu_only=True, reason='Uses NumPy for pvalue, CI') |
5681 | 5679 | def test_permutation_not_implement_for_xp(self, xp):
|
5682 | 5680 | a2, b2 = xp.asarray(self.a2), xp.asarray(self.b2)
|
5683 | 5681 |
|
@@ -5904,8 +5902,7 @@ def test_errors_unsupported(self):
|
5904 | 5902 | stats.ttest_ind([1, 2], [2, 3], trim=.2, permutations=2,
|
5905 | 5903 | random_state=2)
|
5906 | 5904 |
|
5907 |
| - @pytest.mark.skip_xp_backends(cpu_only=True, |
5908 |
| - reason='Uses NumPy for pvalue, CI') |
| 5905 | + @skip_xp_backends(cpu_only=True, reason='Uses NumPy for pvalue, CI') |
5909 | 5906 | def test_permutation_not_implement_for_xp(self, xp):
|
5910 | 5907 | message = "Use of `trim` is compatible only with NumPy arrays."
|
5911 | 5908 | a, b = xp.arange(10), xp.arange(10)+1
|
@@ -5969,7 +5966,7 @@ class Test_ttest_CI:
|
5969 | 5966 | @pytest.mark.parametrize('alternative', ['two-sided', 'less', 'greater'])
|
5970 | 5967 | @pytest.mark.parametrize('equal_var', [False, True])
|
5971 | 5968 | @pytest.mark.parametrize('trim', [0, 0.2])
|
5972 |
| - @pytest.mark.skip_xp_backends('jax.numpy', reason='Generic stdtrit mutates array.') |
| 5969 | + @skip_xp_backends('jax.numpy', reason='Generic stdtrit mutates array.') |
5973 | 5970 | def test_confidence_interval(self, alternative, equal_var, trim, xp):
|
5974 | 5971 | if equal_var and trim:
|
5975 | 5972 | pytest.xfail('Discrepancy in `main`; needs further investigation.')
|
@@ -6282,6 +6279,7 @@ def _convert_pvalue_alternative(t, p, alt, xp):
|
6282 | 6279 | @pytest.mark.slow
|
6283 | 6280 | @pytest.mark.filterwarnings("ignore:divide by zero encountered:RuntimeWarning:dask")
|
6284 | 6281 | @pytest.mark.filterwarnings("ignore:invalid value encountered:RuntimeWarning:dask")
|
| 6282 | +@make_skip_xp_backends(stats.ttest_1samp) |
6285 | 6283 | def test_ttest_1samp_new(xp):
|
6286 | 6284 | n1, n2, n3 = (10, 15, 20)
|
6287 | 6285 | rvn1 = stats.norm.rvs(loc=5, scale=10, size=(n1, n2, n3))
|
@@ -6342,8 +6340,7 @@ def test_ttest_1samp_new(xp):
|
6342 | 6340 | xp_assert_equal(res.pvalue, xp.asarray([1., xp.nan]))
|
6343 | 6341 |
|
6344 | 6342 |
|
6345 |
| -@pytest.mark.skip_xp_backends(np_only=True, |
6346 |
| - reason="Only NumPy has nan_policy='omit' for now") |
| 6343 | +@skip_xp_backends(np_only=True, reason="Only NumPy has nan_policy='omit' for now") |
6347 | 6344 | def test_ttest_1samp_new_omit(xp):
|
6348 | 6345 | n1, n2, n3 = (5, 10, 15)
|
6349 | 6346 | rvn1 = stats.norm.rvs(loc=5, scale=10, size=(n1, n2, n3))
|
@@ -7027,7 +7024,7 @@ def test_2d_axis1_with_zero(self, xp):
|
7027 | 7024 | desired = np.array([0.0, 63.03939962, 103.80078637])
|
7028 | 7025 | check_equal_hmean(a, desired, axis=1, xp=xp)
|
7029 | 7026 |
|
7030 |
| - @pytest.mark.skip_xp_backends( |
| 7027 | + @skip_xp_backends( |
7031 | 7028 | np_only=True,
|
7032 | 7029 | reason='array-likes only supported for NumPy backend',
|
7033 | 7030 | )
|
@@ -7156,7 +7153,7 @@ def test_1d_neg(self, xp):
|
7156 | 7153 | with np.errstate(invalid='ignore'):
|
7157 | 7154 | check_equal_gmean(a, desired, xp=xp)
|
7158 | 7155 |
|
7159 |
| - @pytest.mark.skip_xp_backends( |
| 7156 | + @skip_xp_backends( |
7160 | 7157 | np_only=True,
|
7161 | 7158 | reason='array-likes only supported for NumPy backend',
|
7162 | 7159 | )
|
@@ -7272,7 +7269,7 @@ def test_weights_1d(self, xp):
|
7272 | 7269 | desired = TestPMean.wpmean_reference(np.array(a), p, weights)
|
7273 | 7270 | check_equal_pmean(a, p, desired, weights=weights, rtol=1e-5, xp=xp)
|
7274 | 7271 |
|
7275 |
| - @pytest.mark.skip_xp_backends( |
| 7272 | + @skip_xp_backends( |
7276 | 7273 | np_only=True,
|
7277 | 7274 | reason='array-likes only supported for NumPy backend',
|
7278 | 7275 | )
|
@@ -9744,8 +9741,7 @@ def test_chk_asarray(xp):
|
9744 | 9741 | assert_equal(axis_out, axis)
|
9745 | 9742 |
|
9746 | 9743 |
|
9747 |
| -@pytest.mark.skip_xp_backends('numpy', |
9748 |
| - reason='These parameters *are* compatible with NumPy') |
| 9744 | +@skip_xp_backends('numpy', reason='These parameters *are* compatible with NumPy') |
9749 | 9745 | def test_axis_nan_policy_keepdims_nanpolicy(xp):
|
9750 | 9746 | # this test does not need to be repeated for every function
|
9751 | 9747 | # using the _axis_nan_policy decorator. The test is here
|
|
0 commit comments