1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
Index: scipy/scipy/stats/tests/test_axis_nan_policy.py
===================================================================
--- scipy.orig/scipy/stats/tests/test_axis_nan_policy.py 2025-01-21 12:40:26.637357722 +0100
+++ scipy/scipy/stats/tests/test_axis_nan_policy.py 2025-01-21 12:48:43.012564773 +0100
@@ -466,6 +466,144 @@
assert_allclose(res_nd, res_1d, rtol=1e-14)
+ """
+ test_axis_nan_policy_axis_is_None fails with [mixed-*-xp*] on mips64el
+ see https://github.com/scipy/scipy/issues/22360
+
+ The following set of tests tries various permutations of the array
+ aiming to help diagnose the problem.
+ """
+def test_nan_array_asany():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=None)
+
+def test_nan_array_asarray():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=None)
+
+def test_nan_array_asany_numpy():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=None)
+
+def test_nan_array_asarray_numpy():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=None)
+
+def test_nan_array_asany_axis0():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=0)
+
+def test_nan_array_asarray_axis0():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=0)
+
+def test_nan_array_asany_numpy_axis0():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=0)
+
+def test_nan_array_asarray_numpy_axis0():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr, axis=0)
+
+def test_nan_array_asany_axis_default():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr)
+
+def test_nan_array_asarray_axis_default():
+ import warnings
+ from scipy._lib.array_api_compat import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr)
+
+def test_nan_array_asany_numpy_axis_default():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asanyarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr)
+
+def test_nan_array_asarray_numpy_axis_default():
+ import warnings
+ import numpy as np
+ nan = np.nan
+ arr = np.asarray([0.63696169, 0.26978671, 0.04097352, 0.01652764, 0.81327024,
+ 0.91275558, 0.60663578, 0.72949656, 0.543624, nan, 0.13509651,
+ nan, 0.52535432, 0.31024188, 0.48583536, nan, nan, 0.3577952 ])
+ with warnings.catch_warnings():
+ warnings.simplefilter('error')
+ np.mean(arr)
@pytest.mark.parametrize(("hypotest", "args", "kwds", "n_samples", "n_outputs",
"paired", "unpacker"), axis_nan_policy_cases)
|