scipy 1.16.0rc1__cp311-cp311-macosx_10_14_x86_64.whl → 1.16.1__cp311-cp311-macosx_10_14_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. scipy/__config__.py +9 -9
  2. scipy/_cyutility.cpython-311-darwin.so +0 -0
  3. scipy/_lib/_ccallback_c.cpython-311-darwin.so +0 -0
  4. scipy/_lib/_test_deprecation_call.cpython-311-darwin.so +0 -0
  5. scipy/_lib/_util.py +7 -0
  6. scipy/_lib/messagestream.cpython-311-darwin.so +0 -0
  7. scipy/cluster/_hierarchy.cpython-311-darwin.so +0 -0
  8. scipy/cluster/_optimal_leaf_ordering.cpython-311-darwin.so +0 -0
  9. scipy/cluster/_vq.cpython-311-darwin.so +0 -0
  10. scipy/conftest.py +25 -0
  11. scipy/fft/_pocketfft/pypocketfft.cpython-311-darwin.so +0 -0
  12. scipy/fftpack/convolve.cpython-311-darwin.so +0 -0
  13. scipy/integrate/_dop.cpython-311-darwin.so +0 -0
  14. scipy/integrate/_lsoda.cpython-311-darwin.so +0 -0
  15. scipy/integrate/_odepack.cpython-311-darwin.so +0 -0
  16. scipy/integrate/_quadpack.cpython-311-darwin.so +0 -0
  17. scipy/integrate/_test_odeint_banded.cpython-311-darwin.so +0 -0
  18. scipy/integrate/_vode.cpython-311-darwin.so +0 -0
  19. scipy/interpolate/_dfitpack.cpython-311-darwin.so +0 -0
  20. scipy/interpolate/_dierckx.cpython-311-darwin.so +0 -0
  21. scipy/interpolate/_fitpack.cpython-311-darwin.so +0 -0
  22. scipy/interpolate/_interpnd.cpython-311-darwin.so +0 -0
  23. scipy/interpolate/_ppoly.cpython-311-darwin.so +0 -0
  24. scipy/interpolate/_rbfinterp_pythran.cpython-311-darwin.so +0 -0
  25. scipy/interpolate/_rgi_cython.cpython-311-darwin.so +0 -0
  26. scipy/io/_fast_matrix_market/_fmm_core.cpython-311-darwin.so +0 -0
  27. scipy/io/_test_fortran.cpython-311-darwin.so +0 -0
  28. scipy/io/matlab/_mio5_utils.cpython-311-darwin.so +0 -0
  29. scipy/io/matlab/_mio_utils.cpython-311-darwin.so +0 -0
  30. scipy/io/matlab/_streams.cpython-311-darwin.so +0 -0
  31. scipy/io/matlab/tests/test_streams.py +9 -0
  32. scipy/linalg/_cythonized_array_utils.cpython-311-darwin.so +0 -0
  33. scipy/linalg/_decomp_interpolative.cpython-311-darwin.so +0 -0
  34. scipy/linalg/_decomp_lu_cython.cpython-311-darwin.so +0 -0
  35. scipy/linalg/_decomp_update.cpython-311-darwin.so +0 -0
  36. scipy/linalg/_fblas.cpython-311-darwin.so +0 -0
  37. scipy/linalg/_flapack.cpython-311-darwin.so +0 -0
  38. scipy/linalg/_linalg_pythran.cpython-311-darwin.so +0 -0
  39. scipy/linalg/_matfuncs_expm.cpython-311-darwin.so +0 -0
  40. scipy/linalg/_matfuncs_schur_sqrtm.cpython-311-darwin.so +0 -0
  41. scipy/linalg/_matfuncs_sqrtm_triu.cpython-311-darwin.so +0 -0
  42. scipy/linalg/_solve_toeplitz.cpython-311-darwin.so +0 -0
  43. scipy/linalg/blas.py +35 -24
  44. scipy/linalg/cython_blas.cpython-311-darwin.so +0 -0
  45. scipy/linalg/cython_lapack.cpython-311-darwin.so +0 -0
  46. scipy/linalg/tests/test_matfuncs.py +7 -0
  47. scipy/ndimage/_cytest.cpython-311-darwin.so +0 -0
  48. scipy/ndimage/_filters.py +52 -23
  49. scipy/ndimage/_nd_image.cpython-311-darwin.so +0 -0
  50. scipy/ndimage/_ni_label.cpython-311-darwin.so +0 -0
  51. scipy/ndimage/_rank_filter_1d.cpython-311-darwin.so +0 -0
  52. scipy/ndimage/tests/test_filters.py +94 -9
  53. scipy/odr/__odrpack.cpython-311-darwin.so +0 -0
  54. scipy/optimize/_bglu_dense.cpython-311-darwin.so +0 -0
  55. scipy/optimize/_direct.cpython-311-darwin.so +0 -0
  56. scipy/optimize/_group_columns.cpython-311-darwin.so +0 -0
  57. scipy/optimize/_highspy/_core.cpython-311-darwin.so +0 -0
  58. scipy/optimize/_highspy/_highs_options.cpython-311-darwin.so +0 -0
  59. scipy/optimize/_lbfgsb.cpython-311-darwin.so +0 -0
  60. scipy/optimize/_lbfgsb_py.py +23 -8
  61. scipy/optimize/_lsap.cpython-311-darwin.so +0 -0
  62. scipy/optimize/_lsq/givens_elimination.cpython-311-darwin.so +0 -0
  63. scipy/optimize/_lsq/least_squares.py +2 -2
  64. scipy/optimize/_minimize.py +0 -1
  65. scipy/optimize/_minpack.cpython-311-darwin.so +0 -0
  66. scipy/optimize/_moduleTNC.cpython-311-darwin.so +0 -0
  67. scipy/optimize/_pava_pybind.cpython-311-darwin.so +0 -0
  68. scipy/optimize/_shgo_lib/_complex.py +2 -2
  69. scipy/optimize/_slsqplib.cpython-311-darwin.so +0 -0
  70. scipy/optimize/_trlib/_trlib.cpython-311-darwin.so +0 -0
  71. scipy/optimize/cython_optimize/_zeros.cpython-311-darwin.so +0 -0
  72. scipy/optimize/tests/test_lsq_linear.py +1 -1
  73. scipy/optimize/tests/test_optimize.py +3 -3
  74. scipy/signal/_filter_design.py +13 -1
  75. scipy/signal/_fir_filter_design.py +1 -1
  76. scipy/signal/_max_len_seq_inner.cpython-311-darwin.so +0 -0
  77. scipy/signal/_peak_finding_utils.cpython-311-darwin.so +0 -0
  78. scipy/signal/_polyutils.py +1 -1
  79. scipy/signal/_sigtools.cpython-311-darwin.so +0 -0
  80. scipy/signal/_sosfilt.cpython-311-darwin.so +0 -0
  81. scipy/signal/_spectral_py.py +9 -0
  82. scipy/signal/_spline.cpython-311-darwin.so +0 -0
  83. scipy/signal/_upfirdn_apply.cpython-311-darwin.so +0 -0
  84. scipy/signal/tests/test_filter_design.py +19 -0
  85. scipy/signal/tests/test_fir_filter_design.py +5 -0
  86. scipy/signal/tests/test_signaltools.py +1 -1
  87. scipy/signal/tests/test_spectral.py +31 -0
  88. scipy/sparse/_base.py +5 -2
  89. scipy/sparse/_csparsetools.cpython-311-darwin.so +0 -0
  90. scipy/sparse/_sparsetools.cpython-311-darwin.so +0 -0
  91. scipy/sparse/csgraph/_flow.cpython-311-darwin.so +0 -0
  92. scipy/sparse/csgraph/_matching.cpython-311-darwin.so +0 -0
  93. scipy/sparse/csgraph/_min_spanning_tree.cpython-311-darwin.so +0 -0
  94. scipy/sparse/csgraph/_reordering.cpython-311-darwin.so +0 -0
  95. scipy/sparse/csgraph/_shortest_path.cpython-311-darwin.so +0 -0
  96. scipy/sparse/csgraph/_tools.cpython-311-darwin.so +0 -0
  97. scipy/sparse/csgraph/_traversal.cpython-311-darwin.so +0 -0
  98. scipy/sparse/linalg/_dsolve/_superlu.cpython-311-darwin.so +0 -0
  99. scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-311-darwin.so +0 -0
  100. scipy/sparse/linalg/_propack/_cpropack.cpython-311-darwin.so +0 -0
  101. scipy/sparse/linalg/_propack/_dpropack.cpython-311-darwin.so +0 -0
  102. scipy/sparse/linalg/_propack/_spropack.cpython-311-darwin.so +0 -0
  103. scipy/sparse/linalg/_propack/_zpropack.cpython-311-darwin.so +0 -0
  104. scipy/sparse/tests/test_base.py +10 -0
  105. scipy/spatial/_ckdtree.cpython-311-darwin.so +0 -0
  106. scipy/spatial/_distance_pybind.cpython-311-darwin.so +0 -0
  107. scipy/spatial/_distance_wrap.cpython-311-darwin.so +0 -0
  108. scipy/spatial/_hausdorff.cpython-311-darwin.so +0 -0
  109. scipy/spatial/_qhull.cpython-311-darwin.so +0 -0
  110. scipy/spatial/_voronoi.cpython-311-darwin.so +0 -0
  111. scipy/spatial/tests/test_distance.py +12 -0
  112. scipy/spatial/transform/_rigid_transform.cpython-311-darwin.so +0 -0
  113. scipy/spatial/transform/_rotation.cpython-311-darwin.so +0 -0
  114. scipy/special/_comb.cpython-311-darwin.so +0 -0
  115. scipy/special/_ellip_harm_2.cpython-311-darwin.so +0 -0
  116. scipy/special/_gufuncs.cpython-311-darwin.so +0 -0
  117. scipy/special/_specfun.cpython-311-darwin.so +0 -0
  118. scipy/special/_special_ufuncs.cpython-311-darwin.so +0 -0
  119. scipy/special/_test_internal.cpython-311-darwin.so +0 -0
  120. scipy/special/_ufuncs.cpython-311-darwin.so +0 -0
  121. scipy/special/_ufuncs_cxx.cpython-311-darwin.so +0 -0
  122. scipy/special/cython_special.cpython-311-darwin.so +0 -0
  123. scipy/stats/_ansari_swilk_statistics.cpython-311-darwin.so +0 -0
  124. scipy/stats/_axis_nan_policy.py +1 -9
  125. scipy/stats/_biasedurn.cpython-311-darwin.so +0 -0
  126. scipy/stats/_continuous_distns.py +19 -16
  127. scipy/stats/_correlation.py +1 -1
  128. scipy/stats/_distribution_infrastructure.py +20 -0
  129. scipy/stats/_entropy.py +2 -2
  130. scipy/stats/_hypotests.py +1 -1
  131. scipy/stats/_levy_stable/levyst.cpython-311-darwin.so +0 -0
  132. scipy/stats/_morestats.py +7 -7
  133. scipy/stats/_qmc_cy.cpython-311-darwin.so +0 -0
  134. scipy/stats/_qmvnt_cy.cpython-311-darwin.so +0 -0
  135. scipy/stats/_rcont/rcont.cpython-311-darwin.so +0 -0
  136. scipy/stats/_resampling.py +1 -1
  137. scipy/stats/_sobol.cpython-311-darwin.so +0 -0
  138. scipy/stats/_stats.cpython-311-darwin.so +0 -0
  139. scipy/stats/_stats_mstats_common.py +4 -2
  140. scipy/stats/_stats_py.py +19 -19
  141. scipy/stats/_stats_pythran.cpython-311-darwin.so +0 -0
  142. scipy/stats/_unuran/unuran_wrapper.cpython-311-darwin.so +0 -0
  143. scipy/stats/_variation.py +1 -1
  144. scipy/stats/tests/test_distributions.py +13 -0
  145. scipy/stats/tests/test_fast_gen_inversion.py +2 -0
  146. scipy/stats/tests/test_morestats.py +4 -4
  147. scipy/version.py +2 -2
  148. {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/LICENSE.txt +3 -3
  149. {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/METADATA +5 -4
  150. {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/RECORD +151 -151
  151. {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/WHEEL +0 -0
scipy/__config__.py CHANGED
@@ -36,7 +36,7 @@ CONFIG = _cleanup(
36
36
  "cython": {
37
37
  "name": r"cython",
38
38
  "linker": r"cython",
39
- "version": r"3.1.1",
39
+ "version": r"3.1.2",
40
40
  "commands": r"cython",
41
41
  "args": r"",
42
42
  "linker args": r"",
@@ -58,8 +58,8 @@ CONFIG = _cleanup(
58
58
  "linker args": r"",
59
59
  },
60
60
  "pythran": {
61
- "version": r"0.17.0",
62
- "include directory": r"../../../../../../private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/pip-build-env-dkevsi_1/overlay/lib/python3.11/site-packages/pythran"
61
+ "version": r"0.18.0",
62
+ "include directory": r"../../../../../../private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/build-env-qqcu9av3/lib/python3.11/site-packages/pythran"
63
63
  },
64
64
  },
65
65
  "Machine Information": {
@@ -83,8 +83,8 @@ CONFIG = _cleanup(
83
83
  "found": bool("True".lower().replace('false', '')),
84
84
  "version": "0.3.28",
85
85
  "detection method": "pkgconfig",
86
- "include directory": r"/private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/cibw-run-3mbt8pl1/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/include",
87
- "lib directory": r"/private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/cibw-run-3mbt8pl1/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/lib",
86
+ "include directory": r"/private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/cibw-run-5aghaxqt/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/include",
87
+ "lib directory": r"/private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/cibw-run-5aghaxqt/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/lib",
88
88
  "openblas configuration": r"OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Sandybridge MAX_THREADS=64",
89
89
  "pc file directory": r"/Users/runner/work/scipy/scipy",
90
90
  },
@@ -93,20 +93,20 @@ CONFIG = _cleanup(
93
93
  "found": bool("True".lower().replace('false', '')),
94
94
  "version": "0.3.28",
95
95
  "detection method": "pkgconfig",
96
- "include directory": r"/private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/cibw-run-3mbt8pl1/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/include",
97
- "lib directory": r"/private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/cibw-run-3mbt8pl1/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/lib",
96
+ "include directory": r"/private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/cibw-run-5aghaxqt/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/include",
97
+ "lib directory": r"/private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/cibw-run-5aghaxqt/cp311-macosx_x86_64/build/venv/lib/python3.11/site-packages/scipy_openblas32/lib",
98
98
  "openblas configuration": r"OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY Sandybridge MAX_THREADS=64",
99
99
  "pc file directory": r"/Users/runner/work/scipy/scipy",
100
100
  },
101
101
  "pybind11": {
102
102
  "name": "pybind11",
103
- "version": "2.13.6",
103
+ "version": "3.0.0",
104
104
  "detection method": "config-tool",
105
105
  "include directory": r"unknown",
106
106
  },
107
107
  },
108
108
  "Python Information": {
109
- "path": r"/private/var/folders/q7/x09_16xd767gr8lwc56pjb_m0000gn/T/cibw-run-3mbt8pl1/cp311-macosx_x86_64/build/venv/bin/python",
109
+ "path": r"/private/var/folders/vk/nx37ffx50hv5djclhltc26vw0000gn/T/build-env-qqcu9av3/bin/python",
110
110
  "version": "3.11",
111
111
  },
112
112
  }
Binary file
scipy/_lib/_util.py CHANGED
@@ -351,6 +351,13 @@ def _transition_to_rng(old_name, *, position_num=None, end_version=None,
351
351
 
352
352
  return fun(*args, **kwargs)
353
353
 
354
+ # Add the old parameter name to the function signature
355
+ wrapped_signature = inspect.signature(fun)
356
+ wrapper.__signature__ = wrapped_signature.replace(parameters=[
357
+ *wrapped_signature.parameters.values(),
358
+ inspect.Parameter(old_name, inspect.Parameter.KEYWORD_ONLY, default=None),
359
+ ])
360
+
354
361
  if replace_doc:
355
362
  doc = FunctionDoc(wrapper)
356
363
  parameter_names = [param.name for param in doc['Parameters']]
Binary file
scipy/conftest.py CHANGED
@@ -34,6 +34,31 @@ except Exception:
34
34
 
35
35
 
36
36
  def pytest_configure(config):
37
+ """
38
+ Add pytest markers to avoid PytestUnknownMarkWarning
39
+
40
+ This needs to contain all markers that are SciPy-specific, as well as
41
+ dummy fallbacks for markers defined in optional test packages.
42
+
43
+ Note that we need both the registration here *and* in `pytest.ini`.
44
+ """
45
+ config.addinivalue_line("markers",
46
+ "slow: Tests that are very slow.")
47
+ config.addinivalue_line("markers",
48
+ "xslow: mark test as extremely slow (not run unless explicitly requested)")
49
+ config.addinivalue_line("markers",
50
+ "xfail_on_32bit: mark test as failing on 32-bit platforms")
51
+ config.addinivalue_line("markers",
52
+ "array_api_backends: test iterates on all array API backends")
53
+ config.addinivalue_line("markers",
54
+ ("skip_xp_backends(backends, reason=None, np_only=False, cpu_only=False, " +
55
+ "eager_only=False, exceptions=None): mark the desired skip configuration " +
56
+ "for the `skip_xp_backends` fixture"))
57
+ config.addinivalue_line("markers",
58
+ ("xfail_xp_backends(backends, reason=None, np_only=False, cpu_only=False, " +
59
+ "eager_only=False, exceptions=None): mark the desired xfail configuration " +
60
+ "for the `xfail_xp_backends` fixture"))
61
+
37
62
  try:
38
63
  import pytest_timeout # noqa:F401
39
64
  except Exception:
Binary file
Binary file
@@ -2,7 +2,9 @@
2
2
 
3
3
  """
4
4
 
5
+ import platform
5
6
  import os
7
+ import sys
6
8
  import zlib
7
9
 
8
10
  from io import BytesIO
@@ -15,6 +17,7 @@ import numpy as np
15
17
 
16
18
  from numpy.testing import assert_, assert_equal
17
19
  from pytest import raises as assert_raises
20
+ import pytest
18
21
 
19
22
  from scipy.io.matlab._streams import (make_stream,
20
23
  GenericStream, ZlibInputStream,
@@ -194,6 +197,9 @@ class TestZlibInputStream:
194
197
  stream.seek(1024)
195
198
  assert_(stream.all_data_read())
196
199
 
200
+ @pytest.mark.skipif(
201
+ (platform.system() == 'Windows' and sys.version_info >= (3, 14)),
202
+ reason='gh-23185')
197
203
  def test_all_data_read_overlap(self):
198
204
  COMPRESSION_LEVEL = 6
199
205
 
@@ -210,6 +216,9 @@ class TestZlibInputStream:
210
216
  stream.seek(len(data))
211
217
  assert_(stream.all_data_read())
212
218
 
219
+ @pytest.mark.skipif(
220
+ (platform.system() == 'Windows' and sys.version_info >= (3, 14)),
221
+ reason='gh-23185')
213
222
  def test_all_data_read_bad_checksum(self):
214
223
  COMPRESSION_LEVEL = 6
215
224
 
Binary file
Binary file
scipy/linalg/blas.py CHANGED
@@ -45,15 +45,19 @@ BLAS Level 1 functions
45
45
  .. autosummary::
46
46
  :toctree: generated/
47
47
 
48
- caxpy
49
- ccopy
50
- cdotc
51
- cdotu
52
- crotg
53
- cscal
54
- csrot
55
- csscal
56
- cswap
48
+ sasum
49
+ saxpy
50
+ scasum
51
+ scnrm2
52
+ scopy
53
+ sdot
54
+ snrm2
55
+ srot
56
+ srotg
57
+ srotm
58
+ srotmg
59
+ sscal
60
+ sswap
57
61
  dasum
58
62
  daxpy
59
63
  dcopy
@@ -71,19 +75,15 @@ BLAS Level 1 functions
71
75
  idamax
72
76
  isamax
73
77
  izamax
74
- sasum
75
- saxpy
76
- scasum
77
- scnrm2
78
- scopy
79
- sdot
80
- snrm2
81
- srot
82
- srotg
83
- srotm
84
- srotmg
85
- sscal
86
- sswap
78
+ caxpy
79
+ ccopy
80
+ cdotc
81
+ cdotu
82
+ crotg
83
+ cscal
84
+ csrot
85
+ csscal
86
+ cswap
87
87
  zaxpy
88
88
  zcopy
89
89
  zdotc
@@ -104,12 +104,15 @@ BLAS Level 2 functions
104
104
  sgemv
105
105
  sger
106
106
  ssbmv
107
+ sspmv
107
108
  sspr
108
109
  sspr2
109
110
  ssymv
110
111
  ssyr
111
112
  ssyr2
112
113
  stbmv
114
+ stbsv
115
+ stpmv
113
116
  stpsv
114
117
  strmv
115
118
  strsv
@@ -117,12 +120,15 @@ BLAS Level 2 functions
117
120
  dgemv
118
121
  dger
119
122
  dsbmv
123
+ dspmv
120
124
  dspr
121
125
  dspr2
122
126
  dsymv
123
127
  dsyr
124
128
  dsyr2
125
129
  dtbmv
130
+ dtbsv
131
+ dtpmv
126
132
  dtpsv
127
133
  dtrmv
128
134
  dtrsv
@@ -137,13 +143,15 @@ BLAS Level 2 functions
137
143
  chpmv
138
144
  chpr
139
145
  chpr2
146
+ cspmv
147
+ cspr
148
+ csyr
140
149
  ctbmv
141
150
  ctbsv
142
151
  ctpmv
143
152
  ctpsv
144
153
  ctrmv
145
154
  ctrsv
146
- csyr
147
155
  zgbmv
148
156
  zgemv
149
157
  zgerc
@@ -155,12 +163,15 @@ BLAS Level 2 functions
155
163
  zhpmv
156
164
  zhpr
157
165
  zhpr2
166
+ zspmv
167
+ zspr
168
+ zsyr
158
169
  ztbmv
159
170
  ztbsv
160
171
  ztpmv
172
+ ztpsv
161
173
  ztrmv
162
174
  ztrsv
163
- zsyr
164
175
 
165
176
  BLAS Level 3 functions
166
177
  ----------------------
@@ -460,6 +460,13 @@ class TestSqrtM:
460
460
  np.fill_diagonal(M, 1)
461
461
  assert np.isrealobj(sqrtm(M))
462
462
 
463
+ def test_gh23278(self):
464
+ M = np.array([[1., 0., 0.], [0, 1, -1j], [0, 1j, 2]])
465
+ sq = sqrtm(M)
466
+ assert_allclose(sq @ sq, M, atol=1e-14)
467
+ sq = sqrtm(M.astype(np.complex64))
468
+ assert_allclose(sq @ sq, M, atol=1e-6)
469
+
463
470
  def test_data_size_preservation_uint_in_float_out(self):
464
471
  M = np.eye(10, dtype=np.uint8)
465
472
  assert sqrtm(M).dtype == np.float64
Binary file
scipy/ndimage/_filters.py CHANGED
@@ -68,12 +68,23 @@ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
68
68
  if size is not None and footprint is not None:
69
69
  raise ValueError("Either `size` or `footprint` may be provided, not both.")
70
70
 
71
- # Either footprint or size must be provided, and these determine the core
72
- # dimensionality...
71
+ if axes is None:
72
+ axes = tuple(range(-input.ndim, 0))
73
+ elif np.isscalar(axes):
74
+ axes = (axes,)
75
+ n_axes = len(axes)
76
+ n_batch = input.ndim - n_axes
77
+
78
+ if n_axes > input.ndim:
79
+ message = ("The length of `axes` may not exceed the dimensionality of `input`"
80
+ "(`input.ndim`).")
81
+ raise ValueError(message)
82
+
83
+ # Either footprint or size must be provided
73
84
  footprinted_function = function
74
85
  if size is not None:
75
86
  # If provided, size must be an integer or tuple of integers.
76
- size = (size,)*input.ndim if np.isscalar(size) else tuple(size)
87
+ size = (size,)*n_axes if np.isscalar(size) else tuple(size)
77
88
  valid = [xp.isdtype(xp.asarray(i).dtype, 'integral') and i > 0 for i in size]
78
89
  if not all(valid):
79
90
  raise ValueError("All elements of `size` must be positive integers.")
@@ -84,13 +95,10 @@ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
84
95
  def footprinted_function(input, *args, axis=-1, **kwargs):
85
96
  return function(input[..., footprint], *args, axis=-1, **kwargs)
86
97
 
87
- n_axes = len(size)
88
- n_batch = input.ndim - n_axes
89
-
90
- # ...which can't exceed the dimensionality of `input`.
91
- if n_axes > input.ndim:
92
- message = ("The dimensionality of the window (`len(size)` or `footprint.ndim`) "
93
- "may not exceed the number of axes of `input` (`input.ndim`).")
98
+ # And by now, the dimensionality of the footprint must equal the number of axes
99
+ if n_axes != len(size):
100
+ message = ("`axes` must be compatible with the dimensionality "
101
+ "of the window specified by `size` or `footprint`.")
94
102
  raise ValueError(message)
95
103
 
96
104
  # If this is not *equal* to the dimensionality of `input`, then `axes`
@@ -101,9 +109,10 @@ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
101
109
  "(`len(size)` or `footprint.ndim`) does not equal the number "
102
110
  "of axes of `input` (`input.ndim`).")
103
111
  raise ValueError(message)
104
- axes = (axes,) if np.isscalar(axes) else axes
105
112
  else:
106
- axes = tuple(range(-n_axes, 0))
113
+ axes = tuple(range(-n_axes, 0)) if axes is None else axes
114
+
115
+ axes = (axes,) if np.isscalar(axes) else axes
107
116
 
108
117
  # If `origin` is provided, then it must be "broadcastable" to a tuple with length
109
118
  # equal to the core dimensionality.
@@ -150,10 +159,9 @@ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
150
159
 
151
160
  # For simplicity, work with `axes` at the end.
152
161
  working_axes = tuple(range(-n_axes, 0))
153
- if axes is not None:
154
- input = xp.moveaxis(input, axes, working_axes)
155
- output = (xp.moveaxis(output, axes, working_axes)
156
- if output is not None else output)
162
+ input = xp.moveaxis(input, axes, working_axes)
163
+ output = (xp.moveaxis(output, axes, working_axes)
164
+ if output is not None else output)
157
165
 
158
166
  # Wrap the function to limit maximum memory usage, deal with `footprint`,
159
167
  # and populate `output`. The latter requires some verbosity because we
@@ -190,8 +198,8 @@ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
190
198
  **kwargs)
191
199
  return output
192
200
 
193
- return (input, wrapped_function, size, mode, cval,
194
- origin, working_axes, n_axes, n_batch, xp)
201
+ return (input, wrapped_function, size, mode, cval, origin,
202
+ working_axes, axes, n_axes, n_batch, xp)
195
203
 
196
204
 
197
205
  @_ni_docstrings.docfiller
@@ -211,8 +219,22 @@ def vectorized_filter(input, function, *, size=None, footprint=None, output=None
211
219
 
212
220
  where ``axis`` specifies the axis (or axes) of ``window`` along which
213
221
  the filter function is evaluated.
214
- %(size_foot)s
215
- %(output)s
222
+ size : scalar or tuple, optional
223
+ See `footprint` below. Ignored if `footprint` is given.
224
+ footprint : array, optional
225
+ Either `size` or `footprint` must be defined. `size` gives
226
+ the shape that is taken from the input array, at every element
227
+ position, to define the input to the filter function.
228
+ `footprint` is a boolean array that specifies (implicitly) a
229
+ shape, but also which of the elements within this shape will get
230
+ passed to the filter function. Thus ``size=(n, m)`` is equivalent
231
+ to ``footprint=np.ones((n, m))``.
232
+ We adjust `size` to the number of dimensions indicated by `axes`.
233
+ For instance, if `axes` is ``(0, 2, 1)`` and ``n`` is passed for ``size``,
234
+ then the effective `size` is ``(n, n, n)``.
235
+ output : array, optional
236
+ The array in which to place the output. By default, an array of the dtype
237
+ returned by `function` will be created.
216
238
  mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
217
239
  The `mode` parameter determines how the input array is extended
218
240
  beyond its boundaries. Default is 'reflect'. Behavior for each valid
@@ -409,7 +431,7 @@ def vectorized_filter(input, function, *, size=None, footprint=None, output=None
409
431
 
410
432
  """ # noqa: E501
411
433
 
412
- (input, function, size, mode, cval, origin, working_axes, n_axes, n_batch, xp
434
+ (input, function, size, mode, cval, origin, working_axes, axes, n_axes, n_batch, xp
413
435
  ) = _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
414
436
  origin, axes, batch_memory)
415
437
 
@@ -455,7 +477,7 @@ def vectorized_filter(input, function, *, size=None, footprint=None, output=None
455
477
  res = function(view)
456
478
 
457
479
  # move working_axes back to original positions
458
- return xp.moveaxis(res, working_axes, axes) if axes is not None else res
480
+ return xp.moveaxis(res, working_axes, axes)
459
481
 
460
482
 
461
483
  def _invalid_origin(origin, lenw):
@@ -1967,7 +1989,14 @@ def _rank_filter(input, rank, size=None, footprint=None, output=None,
1967
1989
  "A sequence of modes is not supported by non-separable rank "
1968
1990
  "filters")
1969
1991
  mode = _ni_support._extend_mode_to_code(mode, is_filter=True)
1970
- if input.ndim == 1:
1992
+ # Some corner cases are currently not allowed to use the
1993
+ # "new"/fast 1D rank filter code, including when the
1994
+ # footprint is large compared to the array size.
1995
+ # See discussion in gh-23293; longer-term it may be possible
1996
+ # to allow the fast path for these corner cases as well,
1997
+ # if algorithmic fixes are found.
1998
+ lim2 = input.size - ((footprint.size - 1) // 2 - origin)
1999
+ if input.ndim == 1 and ((lim2 >= 0) or (input.size == 1)):
1971
2000
  if input.dtype in (np.int64, np.float64, np.float32):
1972
2001
  x = input
1973
2002
  x_out = output