scipy 1.16.0__cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.whl → 1.16.2__cp313-cp313t-manylinux2014_aarch64.manylinux_2_17_aarch64.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 (127) hide show
  1. scipy/__config__.py +12 -12
  2. scipy/_cyutility.cpython-313t-aarch64-linux-gnu.so +0 -0
  3. scipy/_lib/_ccallback_c.cpython-313t-aarch64-linux-gnu.so +0 -0
  4. scipy/_lib/_test_deprecation_call.cpython-313t-aarch64-linux-gnu.so +0 -0
  5. scipy/_lib/_test_deprecation_def.cpython-313t-aarch64-linux-gnu.so +0 -0
  6. scipy/_lib/_util.py +7 -0
  7. scipy/_lib/messagestream.cpython-313t-aarch64-linux-gnu.so +0 -0
  8. scipy/cluster/_hierarchy.cpython-313t-aarch64-linux-gnu.so +0 -0
  9. scipy/cluster/_optimal_leaf_ordering.cpython-313t-aarch64-linux-gnu.so +0 -0
  10. scipy/cluster/_vq.cpython-313t-aarch64-linux-gnu.so +0 -0
  11. scipy/fft/_pocketfft/pypocketfft.cpython-313t-aarch64-linux-gnu.so +0 -0
  12. scipy/fftpack/convolve.cpython-313t-aarch64-linux-gnu.so +0 -0
  13. scipy/integrate/_dop.cpython-313t-aarch64-linux-gnu.so +0 -0
  14. scipy/integrate/_lsoda.cpython-313t-aarch64-linux-gnu.so +0 -0
  15. scipy/integrate/_odepack.cpython-313t-aarch64-linux-gnu.so +0 -0
  16. scipy/integrate/_test_odeint_banded.cpython-313t-aarch64-linux-gnu.so +0 -0
  17. scipy/integrate/_vode.cpython-313t-aarch64-linux-gnu.so +0 -0
  18. scipy/interpolate/_dfitpack.cpython-313t-aarch64-linux-gnu.so +0 -0
  19. scipy/interpolate/_dierckx.cpython-313t-aarch64-linux-gnu.so +0 -0
  20. scipy/interpolate/_interpnd.cpython-313t-aarch64-linux-gnu.so +0 -0
  21. scipy/interpolate/_ppoly.cpython-313t-aarch64-linux-gnu.so +0 -0
  22. scipy/interpolate/_rgi_cython.cpython-313t-aarch64-linux-gnu.so +0 -0
  23. scipy/io/_fast_matrix_market/_fmm_core.cpython-313t-aarch64-linux-gnu.so +0 -0
  24. scipy/io/_test_fortran.cpython-313t-aarch64-linux-gnu.so +0 -0
  25. scipy/io/matlab/_mio5_utils.cpython-313t-aarch64-linux-gnu.so +0 -0
  26. scipy/io/matlab/_mio_utils.cpython-313t-aarch64-linux-gnu.so +0 -0
  27. scipy/io/matlab/_streams.cpython-313t-aarch64-linux-gnu.so +0 -0
  28. scipy/io/matlab/tests/test_streams.py +9 -0
  29. scipy/linalg/_cythonized_array_utils.cpython-313t-aarch64-linux-gnu.so +0 -0
  30. scipy/linalg/_decomp_interpolative.cpython-313t-aarch64-linux-gnu.so +0 -0
  31. scipy/linalg/_decomp_lu_cython.cpython-313t-aarch64-linux-gnu.so +0 -0
  32. scipy/linalg/_decomp_update.cpython-313t-aarch64-linux-gnu.so +0 -0
  33. scipy/linalg/_fblas.cpython-313t-aarch64-linux-gnu.so +0 -0
  34. scipy/linalg/_flapack.cpython-313t-aarch64-linux-gnu.so +0 -0
  35. scipy/linalg/_matfuncs_expm.cpython-313t-aarch64-linux-gnu.so +0 -0
  36. scipy/linalg/_matfuncs_schur_sqrtm.cpython-313t-aarch64-linux-gnu.so +0 -0
  37. scipy/linalg/_matfuncs_sqrtm_triu.cpython-313t-aarch64-linux-gnu.so +0 -0
  38. scipy/linalg/_solve_toeplitz.cpython-313t-aarch64-linux-gnu.so +0 -0
  39. scipy/linalg/cython_blas.cpython-313t-aarch64-linux-gnu.so +0 -0
  40. scipy/linalg/cython_lapack.cpython-313t-aarch64-linux-gnu.so +0 -0
  41. scipy/linalg/tests/test_lapack.py +5 -1
  42. scipy/linalg/tests/test_matfuncs.py +7 -0
  43. scipy/ndimage/_cytest.cpython-313t-aarch64-linux-gnu.so +0 -0
  44. scipy/ndimage/_filters.py +11 -2
  45. scipy/ndimage/_ni_label.cpython-313t-aarch64-linux-gnu.so +0 -0
  46. scipy/ndimage/_rank_filter_1d.cpython-313t-aarch64-linux-gnu.so +0 -0
  47. scipy/ndimage/tests/test_filters.py +52 -0
  48. scipy/odr/__odrpack.cpython-313t-aarch64-linux-gnu.so +0 -0
  49. scipy/optimize/_bglu_dense.cpython-313t-aarch64-linux-gnu.so +0 -0
  50. scipy/optimize/_highspy/_core.cpython-313t-aarch64-linux-gnu.so +0 -0
  51. scipy/optimize/_highspy/_highs_options.cpython-313t-aarch64-linux-gnu.so +0 -0
  52. scipy/optimize/_lbfgsb.cpython-313t-aarch64-linux-gnu.so +0 -0
  53. scipy/optimize/_lbfgsb_py.py +2 -2
  54. scipy/optimize/_lsq/givens_elimination.cpython-313t-aarch64-linux-gnu.so +0 -0
  55. scipy/optimize/_lsq/least_squares.py +2 -2
  56. scipy/optimize/_minimize.py +0 -1
  57. scipy/optimize/_moduleTNC.cpython-313t-aarch64-linux-gnu.so +0 -0
  58. scipy/optimize/_pava_pybind.cpython-313t-aarch64-linux-gnu.so +0 -0
  59. scipy/optimize/_shgo_lib/_complex.py +2 -2
  60. scipy/optimize/_slsqp_py.py +5 -5
  61. scipy/optimize/_slsqplib.cpython-313t-aarch64-linux-gnu.so +0 -0
  62. scipy/optimize/_trlib/_trlib.cpython-313t-aarch64-linux-gnu.so +0 -0
  63. scipy/optimize/cython_optimize/_zeros.cpython-313t-aarch64-linux-gnu.so +0 -0
  64. scipy/optimize/tests/test_optimize.py +9 -0
  65. scipy/signal/_filter_design.py +13 -1
  66. scipy/signal/_fir_filter_design.py +1 -1
  67. scipy/signal/_peak_finding_utils.cpython-313t-aarch64-linux-gnu.so +0 -0
  68. scipy/signal/_polyutils.py +1 -1
  69. scipy/signal/_short_time_fft.py +74 -33
  70. scipy/signal/_sosfilt.cpython-313t-aarch64-linux-gnu.so +0 -0
  71. scipy/signal/_spectral_py.py +2 -2
  72. scipy/signal/_upfirdn_apply.cpython-313t-aarch64-linux-gnu.so +0 -0
  73. scipy/signal/tests/test_filter_design.py +19 -0
  74. scipy/signal/tests/test_fir_filter_design.py +5 -0
  75. scipy/signal/tests/test_short_time_fft.py +9 -0
  76. scipy/signal/tests/test_signaltools.py +8 -2
  77. scipy/signal/tests/test_spectral.py +39 -1
  78. scipy/sparse/_base.py +4 -1
  79. scipy/sparse/_csparsetools.cpython-313t-aarch64-linux-gnu.so +0 -0
  80. scipy/sparse/csgraph/_flow.cpython-313t-aarch64-linux-gnu.so +0 -0
  81. scipy/sparse/csgraph/_matching.cpython-313t-aarch64-linux-gnu.so +0 -0
  82. scipy/sparse/csgraph/_min_spanning_tree.cpython-313t-aarch64-linux-gnu.so +0 -0
  83. scipy/sparse/csgraph/_reordering.cpython-313t-aarch64-linux-gnu.so +0 -0
  84. scipy/sparse/csgraph/_shortest_path.cpython-313t-aarch64-linux-gnu.so +0 -0
  85. scipy/sparse/csgraph/_tools.cpython-313t-aarch64-linux-gnu.so +0 -0
  86. scipy/sparse/csgraph/_traversal.cpython-313t-aarch64-linux-gnu.so +0 -0
  87. scipy/sparse/linalg/_dsolve/_superlu.cpython-313t-aarch64-linux-gnu.so +0 -0
  88. scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-313t-aarch64-linux-gnu.so +0 -0
  89. scipy/sparse/linalg/_propack/_cpropack.cpython-313t-aarch64-linux-gnu.so +0 -0
  90. scipy/sparse/linalg/_propack/_dpropack.cpython-313t-aarch64-linux-gnu.so +0 -0
  91. scipy/sparse/linalg/_propack/_spropack.cpython-313t-aarch64-linux-gnu.so +0 -0
  92. scipy/sparse/linalg/_propack/_zpropack.cpython-313t-aarch64-linux-gnu.so +0 -0
  93. scipy/sparse/tests/test_base.py +3 -0
  94. scipy/spatial/_ckdtree.cpython-313t-aarch64-linux-gnu.so +0 -0
  95. scipy/spatial/_distance_pybind.cpython-313t-aarch64-linux-gnu.so +0 -0
  96. scipy/spatial/_hausdorff.cpython-313t-aarch64-linux-gnu.so +0 -0
  97. scipy/spatial/_qhull.cpython-313t-aarch64-linux-gnu.so +0 -0
  98. scipy/spatial/_voronoi.cpython-313t-aarch64-linux-gnu.so +0 -0
  99. scipy/spatial/qhull_src/COPYING_QHULL.txt +39 -0
  100. scipy/spatial/tests/test_distance.py +5 -4
  101. scipy/spatial/transform/_rigid_transform.cpython-313t-aarch64-linux-gnu.so +0 -0
  102. scipy/spatial/transform/_rotation.cpython-313t-aarch64-linux-gnu.so +0 -0
  103. scipy/special/_comb.cpython-313t-aarch64-linux-gnu.so +0 -0
  104. scipy/special/_ellip_harm_2.cpython-313t-aarch64-linux-gnu.so +0 -0
  105. scipy/special/_specfun.cpython-313t-aarch64-linux-gnu.so +0 -0
  106. scipy/special/_test_internal.cpython-313t-aarch64-linux-gnu.so +0 -0
  107. scipy/special/_ufuncs.cpython-313t-aarch64-linux-gnu.so +0 -0
  108. scipy/special/_ufuncs_cxx.cpython-313t-aarch64-linux-gnu.so +0 -0
  109. scipy/special/cython_special.cpython-313t-aarch64-linux-gnu.so +0 -0
  110. scipy/stats/_ansari_swilk_statistics.cpython-313t-aarch64-linux-gnu.so +0 -0
  111. scipy/stats/_biasedurn.cpython-313t-aarch64-linux-gnu.so +0 -0
  112. scipy/stats/_continuous_distns.py +19 -16
  113. scipy/stats/_levy_stable/levyst.cpython-313t-aarch64-linux-gnu.so +0 -0
  114. scipy/stats/_qmc_cy.cpython-313t-aarch64-linux-gnu.so +0 -0
  115. scipy/stats/_qmvnt_cy.cpython-313t-aarch64-linux-gnu.so +0 -0
  116. scipy/stats/_rcont/rcont.cpython-313t-aarch64-linux-gnu.so +0 -0
  117. scipy/stats/_sobol.cpython-313t-aarch64-linux-gnu.so +0 -0
  118. scipy/stats/_stats.cpython-313t-aarch64-linux-gnu.so +0 -0
  119. scipy/stats/_unuran/unuran_wrapper.cpython-313t-aarch64-linux-gnu.so +0 -0
  120. scipy/stats/tests/test_distributions.py +13 -0
  121. scipy/stats/tests/test_fast_gen_inversion.py +2 -0
  122. scipy/version.py +2 -2
  123. {scipy-1.16.0.dist-info → scipy-1.16.2.dist-info}/METADATA +3 -2
  124. {scipy-1.16.0.dist-info → scipy-1.16.2.dist-info}/RECORD +127 -126
  125. scipy.libs/{libscipy_openblas-9778f98e.so → libscipy_openblas-d651f195.so} +0 -0
  126. {scipy-1.16.0.dist-info → scipy-1.16.2.dist-info}/LICENSE.txt +0 -0
  127. {scipy-1.16.0.dist-info → scipy-1.16.2.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.2",
39
+ "version": r"3.1.3",
40
40
  "commands": r"cython",
41
41
  "args": r"",
42
42
  "linker args": r"",
@@ -59,7 +59,7 @@ CONFIG = _cleanup(
59
59
  },
60
60
  "pythran": {
61
61
  "version": r"0.18.0",
62
- "include directory": r"../../tmp/build-env-3obemx3q/lib/python3.13t/site-packages/pythran"
62
+ "include directory": r"../../tmp/build-env-_8md92k6/lib/python3.13t/site-packages/pythran"
63
63
  },
64
64
  },
65
65
  "Machine Information": {
@@ -81,32 +81,32 @@ CONFIG = _cleanup(
81
81
  "blas": {
82
82
  "name": "scipy-openblas",
83
83
  "found": bool("True".lower().replace('false', '')),
84
- "version": "0.3.28",
84
+ "version": "0.3.29.dev",
85
85
  "detection method": "pkgconfig",
86
- "include directory": r"/opt/_internal/cpython-3.13.4-nogil/lib/python3.13t/site-packages/scipy_openblas32/include",
87
- "lib directory": r"/opt/_internal/cpython-3.13.4-nogil/lib/python3.13t/site-packages/scipy_openblas32/lib",
88
- "openblas configuration": r"OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY neoversen2 MAX_THREADS=64",
86
+ "include directory": r"/opt/_internal/cpython-3.13.5-nogil/lib/python3.13t/site-packages/scipy_openblas32/include",
87
+ "lib directory": r"/opt/_internal/cpython-3.13.5-nogil/lib/python3.13t/site-packages/scipy_openblas32/lib",
88
+ "openblas configuration": r"OpenBLAS 0.3.29.dev DYNAMIC_ARCH NO_AFFINITY neoversev2 MAX_THREADS=64",
89
89
  "pc file directory": r"/project",
90
90
  },
91
91
  "lapack": {
92
92
  "name": "scipy-openblas",
93
93
  "found": bool("True".lower().replace('false', '')),
94
- "version": "0.3.28",
94
+ "version": "0.3.29.dev",
95
95
  "detection method": "pkgconfig",
96
- "include directory": r"/opt/_internal/cpython-3.13.4-nogil/lib/python3.13t/site-packages/scipy_openblas32/include",
97
- "lib directory": r"/opt/_internal/cpython-3.13.4-nogil/lib/python3.13t/site-packages/scipy_openblas32/lib",
98
- "openblas configuration": r"OpenBLAS 0.3.28 DYNAMIC_ARCH NO_AFFINITY neoversen2 MAX_THREADS=64",
96
+ "include directory": r"/opt/_internal/cpython-3.13.5-nogil/lib/python3.13t/site-packages/scipy_openblas32/include",
97
+ "lib directory": r"/opt/_internal/cpython-3.13.5-nogil/lib/python3.13t/site-packages/scipy_openblas32/lib",
98
+ "openblas configuration": r"OpenBLAS 0.3.29.dev DYNAMIC_ARCH NO_AFFINITY neoversev2 MAX_THREADS=64",
99
99
  "pc file directory": r"/project",
100
100
  },
101
101
  "pybind11": {
102
102
  "name": "pybind11",
103
- "version": "2.13.6",
103
+ "version": "3.0.1",
104
104
  "detection method": "config-tool",
105
105
  "include directory": r"unknown",
106
106
  },
107
107
  },
108
108
  "Python Information": {
109
- "path": r"/tmp/build-env-3obemx3q/bin/python",
109
+ "path": r"/tmp/build-env-_8md92k6/bin/python",
110
110
  "version": "3.13",
111
111
  },
112
112
  }
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']]
@@ -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
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  from functools import reduce
6
6
  import random
7
+ import sysconfig
7
8
 
8
9
  from numpy.testing import (assert_equal, assert_array_almost_equal, assert_,
9
10
  assert_allclose, assert_almost_equal,
@@ -503,7 +504,7 @@ class TestDlasd4:
503
504
  roots.append(res[1])
504
505
 
505
506
  assert_(
506
- (res[3] <= 0),
507
+ (res[3] <= 0),
507
508
  f"LAPACK root finding dlasd4 failed to find the singular value {i}"
508
509
  )
509
510
  roots = np.array(roots)[::-1]
@@ -3495,6 +3496,9 @@ def test_sy_hetrs(mtype, dtype, lower):
3495
3496
  def test_sy_he_tri(dtype, lower, mtype):
3496
3497
  if mtype == 'he' and dtype in REAL_DTYPES:
3497
3498
  pytest.skip("hetri not for real dtypes.")
3499
+ if sysconfig.get_platform() == 'win-arm64' and dtype in COMPLEX_DTYPES:
3500
+ pytest.skip("Test segfaulting on win-arm64 in CI, see gh-23133")
3501
+
3498
3502
  rng = np.random.default_rng(1723059677121834)
3499
3503
  n = 20
3500
3504
  A = rng.random((n, n)) + rng.random((n, n))*1j
@@ -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
scipy/ndimage/_filters.py CHANGED
@@ -232,7 +232,9 @@ def vectorized_filter(input, function, *, size=None, footprint=None, output=None
232
232
  We adjust `size` to the number of dimensions indicated by `axes`.
233
233
  For instance, if `axes` is ``(0, 2, 1)`` and ``n`` is passed for ``size``,
234
234
  then the effective `size` is ``(n, n, n)``.
235
- %(output)s
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.
236
238
  mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
237
239
  The `mode` parameter determines how the input array is extended
238
240
  beyond its boundaries. Default is 'reflect'. Behavior for each valid
@@ -1987,7 +1989,14 @@ def _rank_filter(input, rank, size=None, footprint=None, output=None,
1987
1989
  "A sequence of modes is not supported by non-separable rank "
1988
1990
  "filters")
1989
1991
  mode = _ni_support._extend_mode_to_code(mode, is_filter=True)
1990
- 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)):
1991
2000
  if input.dtype in (np.int64, np.float64, np.float32):
1992
2001
  x = input
1993
2002
  x_out = output
@@ -3029,3 +3029,55 @@ class TestVectorizedFilter:
3029
3029
  def test_gh_22586_crash_property(x, size, mode):
3030
3030
  # property-based test for median_filter resilience to hard crashing
3031
3031
  ndimage.median_filter(x, size=size, mode=mode)
3032
+
3033
+
3034
+ @pytest.mark.parametrize('samples, mode, size, expected', [
3035
+ ([1, 2], "reflect", 5, [2, 1]),
3036
+ ([2], "reflect", 5, [2]), # original failure from gh-23075
3037
+ ([2], "nearest", 5, [2]),
3038
+ ([2], "wrap", 5, [2]),
3039
+ ([2], "mirror", 5, [2]),
3040
+ ([2], "constant", 5, [0]),
3041
+ ([2], "reflect", 1, [2]),
3042
+ ([2], "nearest", 1, [2]),
3043
+ ([2], "wrap", 1, [2]),
3044
+ ([2], "mirror", 1, [2]),
3045
+ ([2], "constant", 1, [2]),
3046
+ ([2], "reflect", 100, [2]),
3047
+ ([2], "nearest", 100, [2]),
3048
+ ([2], "wrap", 100, [2]),
3049
+ ([2], "mirror", 100, [2]),
3050
+ ([2], "constant", 100, [0]),
3051
+ ])
3052
+ def test_gh_23075(samples, mode, size, expected):
3053
+ # results verified against SciPy 1.14.1, before the median_filter
3054
+ # overhaul
3055
+ sample_array = np.asarray(samples, dtype=np.float32)
3056
+ expected = np.asarray(expected, dtype=np.float32)
3057
+ filtered_samples = ndimage.median_filter(sample_array, size=size, mode=mode)
3058
+ xp_assert_close(filtered_samples, expected, check_shape=True, check_dtype=True)
3059
+
3060
+
3061
+ @pytest.mark.parametrize('samples, size, cval, expected', [
3062
+ ([2], 5, 17.7, [17.7]),
3063
+ ([2], 1, 0, [2]),
3064
+ ([2], 100, 1.4, [1.4]),
3065
+ ([9], 137, -7807.7, [-7807.7]),
3066
+ ])
3067
+ def test_gh_23075_constant(samples, size, cval, expected):
3068
+ # results verified against SciPy 1.14.1, before the median_filter
3069
+ # overhaul
3070
+ sample_array = np.asarray(samples, dtype=np.single)
3071
+ expected = np.asarray(expected, dtype=np.single)
3072
+ filtered_samples = ndimage.median_filter(sample_array,
3073
+ size=size,
3074
+ mode="constant",
3075
+ cval=cval)
3076
+ xp_assert_close(filtered_samples, expected, check_shape=True, check_dtype=True)
3077
+
3078
+
3079
+ def test_median_filter_lim2():
3080
+ sample_array = np.ones(8)
3081
+ expected = np.ones(8)
3082
+ filtered_samples = ndimage.median_filter(sample_array, size=19, mode="reflect")
3083
+ xp_assert_close(filtered_samples, expected, check_shape=True, check_dtype=True)
@@ -440,8 +440,8 @@ def _minimize_lbfgsb(fun, x0, args=(), jac=None, bounds=None,
440
440
  raise ValueError('maxls must be positive.')
441
441
 
442
442
  x = array(x0, dtype=np.float64)
443
- f = array(0.0, dtype=np.int32)
444
- g = zeros((n,), dtype=np.int32)
443
+ f = array(0.0, dtype=np.float64)
444
+ g = zeros((n,), dtype=np.float64)
445
445
  wa = zeros(2*m*n + 5*n + 11*m*m + 8*m, float64)
446
446
  iwa = zeros(3*n, dtype=np.int32)
447
447
  task = zeros(2, dtype=np.int32)
@@ -17,7 +17,7 @@ from .trf import trf
17
17
  from .dogbox import dogbox
18
18
  from .common import EPS, in_bounds, make_strictly_feasible
19
19
 
20
-
20
+
21
21
  from scipy.optimize._optimize import _wrap_callback
22
22
 
23
23
  TERMINATION_MESSAGES = {
@@ -392,7 +392,7 @@ def least_squares(
392
392
 
393
393
  * For 'trf' : ``x_scale == 1``
394
394
  * For 'dogbox' : ``x_scale == 1``
395
- * For 'jac' : ``x_scale == 'jac'``
395
+ * For 'lm' : ``x_scale == 'jac'``
396
396
 
397
397
  .. versionchanged:: 1.16.0
398
398
  The default keyword value is changed from 1 to None to indicate that
@@ -188,7 +188,6 @@ def minimize(fun, x0, args=(), method=None, jac=None, hess=None,
188
188
 
189
189
  Equality constraint means that the constraint function result is to
190
190
  be zero whereas inequality means that it is to be non-negative.
191
- Note that COBYLA only supports inequality constraints.
192
191
 
193
192
  tol : float, optional
194
193
  Tolerance for termination. When `tol` is specified, the selected
@@ -183,6 +183,7 @@ class Complex:
183
183
  self.V = VertexCacheIndex()
184
184
 
185
185
  self.V_non_symm = [] # List of non-symmetric vertices
186
+ self.split_edge = cache(self._split_edge)
186
187
 
187
188
  def __call__(self):
188
189
  return self.H
@@ -995,8 +996,7 @@ class Complex:
995
996
  d_v0v1.connect(d_v1v2)
996
997
  return
997
998
 
998
- @cache
999
- def split_edge(self, v1, v2):
999
+ def _split_edge(self, v1, v2):
1000
1000
  v1 = self.V[v1]
1001
1001
  v2 = self.V[v2]
1002
1002
  # Destroy original edge, if it exists:
@@ -234,8 +234,8 @@ def _minimize_slsqp(func, x0, args=(), jac=None, bounds=None,
234
234
  disp : bool
235
235
  Set to True to print convergence messages. If False,
236
236
  `verbosity` is ignored and set to 0.
237
- maxiter : int
238
- Maximum number of iterations.
237
+ maxiter : int, optional
238
+ Maximum number of iterations. Default value is 100.
239
239
  finite_diff_rel_step : None or array_like, optional
240
240
  If ``jac in ['2-point', '3-point', 'cs']`` the relative step size to
241
241
  use for numerical approximation of `jac`. The absolute step
@@ -268,8 +268,8 @@ def _minimize_slsqp(func, x0, args=(), jac=None, bounds=None,
268
268
  attribute as a NumPy array. Denoting the dimension of the equality constraints
269
269
  with ``meq``, and of inequality constraints with ``mineq``, then the returned
270
270
  array slice ``m[:meq]`` contains the multipliers for the equality constraints,
271
- and the remaining ``m[meq:meq + mineq]`` contains the multipliers for the
272
- inequality constraints. The multipliers corresponding to bound inequalities
271
+ and the remaining ``m[meq:meq + mineq]`` contains the multipliers for the
272
+ inequality constraints. The multipliers corresponding to bound inequalities
273
273
  are not returned. See [1]_ pp. 321 or [2]_ for an explanation of how to interpret
274
274
  these multipliers. The internal QP problem is solved using the methods given
275
275
  in [3]_ Chapter 25.
@@ -461,7 +461,7 @@ def _minimize_slsqp(func, x0, args=(), jac=None, bounds=None,
461
461
  "inconsistent": 0,
462
462
  "reset": 0,
463
463
  "iter": 0,
464
- "itermax": maxiter,
464
+ "itermax": int(maxiter),
465
465
  "line": 0,
466
466
  "m": m,
467
467
  "meq": meq,
@@ -3167,6 +3167,15 @@ def test_bounds_with_list():
3167
3167
  )
3168
3168
 
3169
3169
 
3170
+ @pytest.mark.parametrize('method', (
3171
+ 'slsqp', 'cg', 'cobyqa', 'powell','nelder-mead', 'bfgs', 'l-bfgs-b',
3172
+ 'trust-constr'))
3173
+ def test_minimize_maxiter_noninteger(method):
3174
+ # Regression test for gh-23430
3175
+ x0 = np.array([1.3, 0.7, 0.8, 1.9, 1.2])
3176
+ optimize.minimize(rosen, x0, method=method, options={'maxiter': 100.1})
3177
+
3178
+
3170
3179
  def test_x_overwritten_user_function():
3171
3180
  # if the user overwrites the x-array in the user function it's likely
3172
3181
  # that the minimizer stops working properly.
@@ -60,6 +60,17 @@ def _is_int_type(x):
60
60
  return True
61
61
 
62
62
 
63
+ def _real_dtype_for_complex(dtyp, *, xp):
64
+ if xp.isdtype(dtyp, 'real floating'):
65
+ return dtyp
66
+ if dtyp == xp.complex64:
67
+ return xp.float32
68
+ elif dtyp == xp.complex128:
69
+ return xp.float64
70
+ else:
71
+ raise ValueError(f"Unknown dtype {dtyp}.")
72
+
73
+
63
74
  # https://github.com/numpy/numpy/blob/v2.2.0/numpy/_core/function_base.py#L195-L302
64
75
  def _logspace(start, stop, num=50, endpoint=True, base=10.0, dtype=None, *, xp):
65
76
  if not isinstance(base, float | int) and xp.asarray(base).ndim > 0:
@@ -488,6 +499,7 @@ def freqz(b, a=1, worN=512, whole=False, plot=None, fs=2*pi,
488
499
  if xp.isdtype(a.dtype, 'integral'):
489
500
  a = xp.astype(a, xp_default_dtype(xp))
490
501
  res_dtype = xp.result_type(b, a)
502
+ real_dtype = _real_dtype_for_complex(res_dtype, xp=xp)
491
503
 
492
504
  b = xpx.atleast_nd(b, ndim=1, xp=xp)
493
505
  a = xpx.atleast_nd(a, ndim=1, xp=xp)
@@ -509,7 +521,7 @@ def freqz(b, a=1, worN=512, whole=False, plot=None, fs=2*pi,
509
521
  # if include_nyquist is true and whole is false, w should
510
522
  # include end point
511
523
  w = xp.linspace(0, lastpoint, N,
512
- endpoint=include_nyquist and not whole, dtype=res_dtype)
524
+ endpoint=include_nyquist and not whole, dtype=real_dtype)
513
525
  n_fft = N if whole else 2 * (N - 1) if include_nyquist else 2 * N
514
526
  if (xp_size(a) == 1 and (b.ndim == 1 or (b.shape[-1] == 1))
515
527
  and n_fft >= b.shape[0]
@@ -834,7 +834,7 @@ def remez(numtaps, bands, desired, *, weight=None, type='bandpass',
834
834
  xp = array_namespace(bands, desired, weight)
835
835
  bands = np.asarray(bands)
836
836
  desired = np.asarray(desired)
837
- if weight:
837
+ if weight is not None:
838
838
  weight = np.asarray(weight)
839
839
 
840
840
  fs = _validate_fs(fs, allow_none=True)
@@ -117,7 +117,7 @@ def poly(seq_of_zeros, *, xp):
117
117
  if xp.isdtype(a.dtype, 'complex floating'):
118
118
  # if complex roots are all complex conjugates, the roots are real.
119
119
  roots = xp.asarray(seq_of_zeros, dtype=xp.complex128)
120
- if xp.all(_sort_cmplx(roots, xp) == _sort_cmplx(xp.conj(roots), xp)):
120
+ if xp.all(xp.sort(xp.imag(roots)) == xp.sort(xp.imag(xp.conj(roots)))):
121
121
  a = xp.asarray(xp.real(a), copy=True)
122
122
 
123
123
  return a