scipy 1.16.0rc1__cp312-cp312-macosx_14_0_arm64.whl → 1.16.1__cp312-cp312-macosx_14_0_arm64.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.
- scipy/.dylibs/libgcc_s.1.1.dylib +0 -0
- scipy/.dylibs/libgfortran.5.dylib +0 -0
- scipy/.dylibs/libquadmath.0.dylib +0 -0
- scipy/__config__.py +6 -6
- scipy/_cyutility.cpython-312-darwin.so +0 -0
- scipy/_lib/_ccallback_c.cpython-312-darwin.so +0 -0
- scipy/_lib/_test_deprecation_call.cpython-312-darwin.so +0 -0
- scipy/_lib/_util.py +7 -0
- scipy/_lib/messagestream.cpython-312-darwin.so +0 -0
- scipy/cluster/_hierarchy.cpython-312-darwin.so +0 -0
- scipy/cluster/_optimal_leaf_ordering.cpython-312-darwin.so +0 -0
- scipy/cluster/_vq.cpython-312-darwin.so +0 -0
- scipy/conftest.py +25 -0
- scipy/fft/_pocketfft/pypocketfft.cpython-312-darwin.so +0 -0
- scipy/fftpack/convolve.cpython-312-darwin.so +0 -0
- scipy/integrate/_dop.cpython-312-darwin.so +0 -0
- scipy/integrate/_lsoda.cpython-312-darwin.so +0 -0
- scipy/integrate/_odepack.cpython-312-darwin.so +0 -0
- scipy/integrate/_quadpack.cpython-312-darwin.so +0 -0
- scipy/integrate/_test_odeint_banded.cpython-312-darwin.so +0 -0
- scipy/integrate/_vode.cpython-312-darwin.so +0 -0
- scipy/interpolate/_dfitpack.cpython-312-darwin.so +0 -0
- scipy/interpolate/_dierckx.cpython-312-darwin.so +0 -0
- scipy/interpolate/_fitpack.cpython-312-darwin.so +0 -0
- scipy/interpolate/_interpnd.cpython-312-darwin.so +0 -0
- scipy/interpolate/_ppoly.cpython-312-darwin.so +0 -0
- scipy/interpolate/_rbfinterp_pythran.cpython-312-darwin.so +0 -0
- scipy/interpolate/_rgi_cython.cpython-312-darwin.so +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cpython-312-darwin.so +0 -0
- scipy/io/_test_fortran.cpython-312-darwin.so +0 -0
- scipy/io/matlab/_mio5_utils.cpython-312-darwin.so +0 -0
- scipy/io/matlab/_mio_utils.cpython-312-darwin.so +0 -0
- scipy/io/matlab/_streams.cpython-312-darwin.so +0 -0
- scipy/io/matlab/tests/test_streams.py +9 -0
- scipy/linalg/_cythonized_array_utils.cpython-312-darwin.so +0 -0
- scipy/linalg/_decomp_interpolative.cpython-312-darwin.so +0 -0
- scipy/linalg/_decomp_lu_cython.cpython-312-darwin.so +0 -0
- scipy/linalg/_decomp_update.cpython-312-darwin.so +0 -0
- scipy/linalg/_fblas.cpython-312-darwin.so +0 -0
- scipy/linalg/_flapack.cpython-312-darwin.so +0 -0
- scipy/linalg/_linalg_pythran.cpython-312-darwin.so +0 -0
- scipy/linalg/_matfuncs_expm.cpython-312-darwin.so +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cpython-312-darwin.so +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cpython-312-darwin.so +0 -0
- scipy/linalg/_solve_toeplitz.cpython-312-darwin.so +0 -0
- scipy/linalg/blas.py +35 -24
- scipy/linalg/cython_blas.cpython-312-darwin.so +0 -0
- scipy/linalg/cython_lapack.cpython-312-darwin.so +0 -0
- scipy/linalg/tests/test_matfuncs.py +7 -0
- scipy/ndimage/_cytest.cpython-312-darwin.so +0 -0
- scipy/ndimage/_filters.py +52 -23
- scipy/ndimage/_nd_image.cpython-312-darwin.so +0 -0
- scipy/ndimage/_ni_label.cpython-312-darwin.so +0 -0
- scipy/ndimage/_rank_filter_1d.cpython-312-darwin.so +0 -0
- scipy/ndimage/tests/test_filters.py +94 -9
- scipy/odr/__odrpack.cpython-312-darwin.so +0 -0
- scipy/optimize/_bglu_dense.cpython-312-darwin.so +0 -0
- scipy/optimize/_direct.cpython-312-darwin.so +0 -0
- scipy/optimize/_group_columns.cpython-312-darwin.so +0 -0
- scipy/optimize/_highspy/_core.cpython-312-darwin.so +0 -0
- scipy/optimize/_highspy/_highs_options.cpython-312-darwin.so +0 -0
- scipy/optimize/_lbfgsb.cpython-312-darwin.so +0 -0
- scipy/optimize/_lbfgsb_py.py +23 -8
- scipy/optimize/_lsap.cpython-312-darwin.so +0 -0
- scipy/optimize/_lsq/givens_elimination.cpython-312-darwin.so +0 -0
- scipy/optimize/_lsq/least_squares.py +2 -2
- scipy/optimize/_minimize.py +0 -1
- scipy/optimize/_minpack.cpython-312-darwin.so +0 -0
- scipy/optimize/_moduleTNC.cpython-312-darwin.so +0 -0
- scipy/optimize/_pava_pybind.cpython-312-darwin.so +0 -0
- scipy/optimize/_shgo_lib/_complex.py +2 -2
- scipy/optimize/_slsqplib.cpython-312-darwin.so +0 -0
- scipy/optimize/_trlib/_trlib.cpython-312-darwin.so +0 -0
- scipy/optimize/cython_optimize/_zeros.cpython-312-darwin.so +0 -0
- scipy/optimize/tests/test_lsq_linear.py +1 -1
- scipy/optimize/tests/test_optimize.py +3 -3
- scipy/signal/_filter_design.py +13 -1
- scipy/signal/_fir_filter_design.py +1 -1
- scipy/signal/_max_len_seq_inner.cpython-312-darwin.so +0 -0
- scipy/signal/_peak_finding_utils.cpython-312-darwin.so +0 -0
- scipy/signal/_polyutils.py +1 -1
- scipy/signal/_sigtools.cpython-312-darwin.so +0 -0
- scipy/signal/_sosfilt.cpython-312-darwin.so +0 -0
- scipy/signal/_spectral_py.py +9 -0
- scipy/signal/_spline.cpython-312-darwin.so +0 -0
- scipy/signal/_upfirdn_apply.cpython-312-darwin.so +0 -0
- scipy/signal/tests/test_filter_design.py +19 -0
- scipy/signal/tests/test_fir_filter_design.py +5 -0
- scipy/signal/tests/test_signaltools.py +1 -1
- scipy/signal/tests/test_spectral.py +31 -0
- scipy/sparse/_base.py +5 -2
- scipy/sparse/_csparsetools.cpython-312-darwin.so +0 -0
- scipy/sparse/_sparsetools.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_flow.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_matching.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_reordering.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_shortest_path.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_tools.cpython-312-darwin.so +0 -0
- scipy/sparse/csgraph/_traversal.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_spropack.cpython-312-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cpython-312-darwin.so +0 -0
- scipy/sparse/tests/test_base.py +10 -0
- scipy/spatial/_ckdtree.cpython-312-darwin.so +0 -0
- scipy/spatial/_distance_pybind.cpython-312-darwin.so +0 -0
- scipy/spatial/_distance_wrap.cpython-312-darwin.so +0 -0
- scipy/spatial/_hausdorff.cpython-312-darwin.so +0 -0
- scipy/spatial/_qhull.cpython-312-darwin.so +0 -0
- scipy/spatial/_voronoi.cpython-312-darwin.so +0 -0
- scipy/spatial/tests/test_distance.py +12 -0
- scipy/spatial/transform/_rigid_transform.cpython-312-darwin.so +0 -0
- scipy/spatial/transform/_rotation.cpython-312-darwin.so +0 -0
- scipy/special/_comb.cpython-312-darwin.so +0 -0
- scipy/special/_ellip_harm_2.cpython-312-darwin.so +0 -0
- scipy/special/_gufuncs.cpython-312-darwin.so +0 -0
- scipy/special/_specfun.cpython-312-darwin.so +0 -0
- scipy/special/_special_ufuncs.cpython-312-darwin.so +0 -0
- scipy/special/_test_internal.cpython-312-darwin.so +0 -0
- scipy/special/_ufuncs.cpython-312-darwin.so +0 -0
- scipy/special/_ufuncs_cxx.cpython-312-darwin.so +0 -0
- scipy/special/cython_special.cpython-312-darwin.so +0 -0
- scipy/stats/_ansari_swilk_statistics.cpython-312-darwin.so +0 -0
- scipy/stats/_axis_nan_policy.py +1 -9
- scipy/stats/_biasedurn.cpython-312-darwin.so +0 -0
- scipy/stats/_continuous_distns.py +19 -16
- scipy/stats/_correlation.py +1 -1
- scipy/stats/_distribution_infrastructure.py +20 -0
- scipy/stats/_entropy.py +2 -2
- scipy/stats/_hypotests.py +1 -1
- scipy/stats/_levy_stable/levyst.cpython-312-darwin.so +0 -0
- scipy/stats/_morestats.py +7 -7
- scipy/stats/_qmc_cy.cpython-312-darwin.so +0 -0
- scipy/stats/_qmvnt_cy.cpython-312-darwin.so +0 -0
- scipy/stats/_rcont/rcont.cpython-312-darwin.so +0 -0
- scipy/stats/_resampling.py +1 -1
- scipy/stats/_sobol.cpython-312-darwin.so +0 -0
- scipy/stats/_stats.cpython-312-darwin.so +0 -0
- scipy/stats/_stats_mstats_common.py +4 -2
- scipy/stats/_stats_py.py +19 -19
- scipy/stats/_stats_pythran.cpython-312-darwin.so +0 -0
- scipy/stats/_unuran/unuran_wrapper.cpython-312-darwin.so +0 -0
- scipy/stats/_variation.py +1 -1
- scipy/stats/tests/test_distributions.py +13 -0
- scipy/stats/tests/test_fast_gen_inversion.py +2 -0
- scipy/stats/tests/test_morestats.py +4 -4
- scipy/version.py +2 -2
- {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/LICENSE.txt +3 -3
- {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/METADATA +5 -4
- {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/RECORD +154 -154
- {scipy-1.16.0rc1.dist-info → scipy-1.16.1.dist-info}/WHEEL +0 -0
@@ -2571,7 +2571,7 @@ class TestThreading:
|
|
2571
2571
|
for i in range(n):
|
2572
2572
|
fun(*args, output=out[i, ...])
|
2573
2573
|
|
2574
|
-
@xfail_xp_backends("cupy",
|
2574
|
+
@xfail_xp_backends("cupy",
|
2575
2575
|
reason="XXX thread exception; cannot repro outside of pytest")
|
2576
2576
|
def test_correlate1d(self, xp):
|
2577
2577
|
d = np.random.randn(5000)
|
@@ -2585,7 +2585,7 @@ class TestThreading:
|
|
2585
2585
|
self.check_func_thread(4, ndimage.correlate1d, (d, k), ot)
|
2586
2586
|
xp_assert_equal(os, ot)
|
2587
2587
|
|
2588
|
-
@xfail_xp_backends("cupy",
|
2588
|
+
@xfail_xp_backends("cupy",
|
2589
2589
|
reason="XXX thread exception; cannot repro outside of pytest")
|
2590
2590
|
def test_correlate(self, xp):
|
2591
2591
|
d = xp.asarray(np.random.randn(500, 500))
|
@@ -2596,7 +2596,7 @@ class TestThreading:
|
|
2596
2596
|
self.check_func_thread(4, ndimage.correlate, (d, k), ot)
|
2597
2597
|
xp_assert_equal(os, ot)
|
2598
2598
|
|
2599
|
-
@xfail_xp_backends("cupy",
|
2599
|
+
@xfail_xp_backends("cupy",
|
2600
2600
|
reason="XXX thread exception; cannot repro outside of pytest")
|
2601
2601
|
def test_median_filter(self, xp):
|
2602
2602
|
d = xp.asarray(np.random.randn(500, 500))
|
@@ -2606,7 +2606,7 @@ class TestThreading:
|
|
2606
2606
|
self.check_func_thread(4, ndimage.median_filter, (d, 3), ot)
|
2607
2607
|
xp_assert_equal(os, ot)
|
2608
2608
|
|
2609
|
-
@xfail_xp_backends("cupy",
|
2609
|
+
@xfail_xp_backends("cupy",
|
2610
2610
|
reason="XXX thread exception; cannot repro outside of pytest")
|
2611
2611
|
def test_uniform_filter1d(self, xp):
|
2612
2612
|
d = np.random.randn(5000)
|
@@ -2619,7 +2619,7 @@ class TestThreading:
|
|
2619
2619
|
self.check_func_thread(4, ndimage.uniform_filter1d, (d, 5), ot)
|
2620
2620
|
xp_assert_equal(os, ot)
|
2621
2621
|
|
2622
|
-
@xfail_xp_backends("cupy",
|
2622
|
+
@xfail_xp_backends("cupy",
|
2623
2623
|
reason="XXX thread exception; cannot repro outside of pytest")
|
2624
2624
|
def test_minmax_filter(self, xp):
|
2625
2625
|
d = xp.asarray(np.random.randn(500, 500))
|
@@ -2908,15 +2908,19 @@ class TestVectorizedFilter:
|
|
2908
2908
|
with pytest.raises(ValueError, match=message):
|
2909
2909
|
ndimage.vectorized_filter(input, function, size=0)
|
2910
2910
|
|
2911
|
-
message = "The
|
2911
|
+
message = "The length of `axes` may not exceed "
|
2912
|
+
axes = (0, 1, 2)
|
2912
2913
|
with pytest.raises(ValueError, match=message):
|
2913
|
-
ndimage.vectorized_filter(input, function, size=(1, 2,
|
2914
|
+
ndimage.vectorized_filter(input, function, size=(1, 2), axes=axes)
|
2914
2915
|
with pytest.raises(ValueError, match=message):
|
2915
|
-
ndimage.vectorized_filter(input, function, footprint=xp.ones((2, 2
|
2916
|
+
ndimage.vectorized_filter(input, function, footprint=xp.ones((2, 2)),
|
2917
|
+
axes=axes)
|
2916
2918
|
|
2917
|
-
message = "`axes` must be
|
2919
|
+
message = "`axes` must be compatible with the dimensionality..."
|
2918
2920
|
with pytest.raises(ValueError, match=message):
|
2919
2921
|
ndimage.vectorized_filter(input, function, size=(1,))
|
2922
|
+
with pytest.raises(ValueError, match=message):
|
2923
|
+
ndimage.vectorized_filter(input, function, size=(2,), axes=(0,1))
|
2920
2924
|
|
2921
2925
|
message = "All elements of `origin` must be integers"
|
2922
2926
|
with pytest.raises(ValueError, match=message):
|
@@ -2986,6 +2990,35 @@ class TestVectorizedFilter:
|
|
2986
2990
|
ref = ndimage.vectorized_filter(input, function, size=21)
|
2987
2991
|
xp_assert_close(res, ref)
|
2988
2992
|
|
2993
|
+
def test_gh23046_feature(self, xp):
|
2994
|
+
# The intent of gh-23046 was to always allow `size` to be a scalar.
|
2995
|
+
rng = np.random.default_rng(45982734597824)
|
2996
|
+
img = xp.asarray(rng.random((5, 5)))
|
2997
|
+
|
2998
|
+
ref = ndimage.vectorized_filter(img, xp.mean, size=2)
|
2999
|
+
res = ndimage.vectorized_filter(img, xp.mean, size=2, axes=(0, 1))
|
3000
|
+
xp_assert_close(res, ref)
|
3001
|
+
|
3002
|
+
ref = ndimage.vectorized_filter(img, xp.mean, size=(2,), axes=(0,))
|
3003
|
+
res = ndimage.vectorized_filter(img, xp.mean, size=2, axes=0)
|
3004
|
+
xp_assert_close(res, ref)
|
3005
|
+
|
3006
|
+
def test_gh23046_fix(self, xp):
|
3007
|
+
# While investigating the feasibility of gh-23046, I noticed a bug when the
|
3008
|
+
# length of an `axes` tuple equals the dimensionality of the image.
|
3009
|
+
rng = np.random.default_rng(45982734597824)
|
3010
|
+
img = xp.asarray(rng.random((5, 5)))
|
3011
|
+
size = (2, 3)
|
3012
|
+
ref = ndimage.vectorized_filter(img.T, xp.mean, size=size).T
|
3013
|
+
res = ndimage.vectorized_filter(img, xp.mean, size=size, axes=(1, 0))
|
3014
|
+
xp_assert_close(res, ref)
|
3015
|
+
|
3016
|
+
ref = ndimage.vectorized_filter(img, xp.mean, size=size, mode='constant')
|
3017
|
+
res = ndimage.vectorized_filter(img, xp.mean, size=size[::-1], axes=(1, 0),
|
3018
|
+
mode='constant')
|
3019
|
+
xp_assert_close(res, ref)
|
3020
|
+
|
3021
|
+
|
2989
3022
|
|
2990
3023
|
@given(x=npst.arrays(dtype=np.float64,
|
2991
3024
|
shape=st.integers(min_value=1, max_value=1000)),
|
@@ -2996,3 +3029,55 @@ class TestVectorizedFilter:
|
|
2996
3029
|
def test_gh_22586_crash_property(x, size, mode):
|
2997
3030
|
# property-based test for median_filter resilience to hard crashing
|
2998
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)
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
scipy/optimize/_lbfgsb_py.py
CHANGED
@@ -42,6 +42,8 @@ from ._optimize import (MemoizeJac, OptimizeResult, _call_callback_maybe_halt,
|
|
42
42
|
from ._constraints import old_bound_to_new
|
43
43
|
|
44
44
|
from scipy.sparse.linalg import LinearOperator
|
45
|
+
from scipy._lib.deprecation import _NoValue
|
46
|
+
import warnings
|
45
47
|
|
46
48
|
__all__ = ['fmin_l_bfgs_b', 'LbfgsInvHessProduct']
|
47
49
|
|
@@ -93,7 +95,7 @@ def fmin_l_bfgs_b(func, x0, fprime=None, args=(),
|
|
93
95
|
approx_grad=0,
|
94
96
|
bounds=None, m=10, factr=1e7, pgtol=1e-5,
|
95
97
|
epsilon=1e-8,
|
96
|
-
iprint
|
98
|
+
iprint=_NoValue, maxfun=15000, maxiter=15000, disp=_NoValue,
|
97
99
|
callback=None, maxls=20):
|
98
100
|
"""
|
99
101
|
Minimize a function func using the L-BFGS-B algorithm.
|
@@ -144,7 +146,7 @@ def fmin_l_bfgs_b(func, x0, fprime=None, args=(),
|
|
144
146
|
output and this keyword has no function.
|
145
147
|
|
146
148
|
.. deprecated:: 1.15.0
|
147
|
-
This keyword is deprecated and will be removed from SciPy 1.
|
149
|
+
This keyword is deprecated and will be removed from SciPy 1.18.0.
|
148
150
|
|
149
151
|
disp : int, optional
|
150
152
|
Deprecated option that previously controlled the text printed on the
|
@@ -152,7 +154,7 @@ def fmin_l_bfgs_b(func, x0, fprime=None, args=(),
|
|
152
154
|
output and this keyword has no function.
|
153
155
|
|
154
156
|
.. deprecated:: 1.15.0
|
155
|
-
This keyword is deprecated and will be removed from SciPy 1.
|
157
|
+
This keyword is deprecated and will be removed from SciPy 1.18.0.
|
156
158
|
|
157
159
|
maxfun : int, optional
|
158
160
|
Maximum number of function evaluations. Note that this function
|
@@ -265,7 +267,9 @@ def fmin_l_bfgs_b(func, x0, fprime=None, args=(),
|
|
265
267
|
|
266
268
|
# build options
|
267
269
|
callback = _wrap_callback(callback)
|
268
|
-
opts = {'
|
270
|
+
opts = {'disp': disp,
|
271
|
+
'iprint': iprint,
|
272
|
+
'maxcor': m,
|
269
273
|
'ftol': factr * np.finfo(float).eps,
|
270
274
|
'gtol': pgtol,
|
271
275
|
'eps': epsilon,
|
@@ -288,9 +292,9 @@ def fmin_l_bfgs_b(func, x0, fprime=None, args=(),
|
|
288
292
|
|
289
293
|
|
290
294
|
def _minimize_lbfgsb(fun, x0, args=(), jac=None, bounds=None,
|
291
|
-
disp=
|
295
|
+
disp=_NoValue, maxcor=10, ftol=2.2204460492503131e-09,
|
292
296
|
gtol=1e-5, eps=1e-8, maxfun=15000, maxiter=15000,
|
293
|
-
iprint
|
297
|
+
iprint=_NoValue, callback=None, maxls=20,
|
294
298
|
finite_diff_rel_step=None, workers=None,
|
295
299
|
**unknown_options):
|
296
300
|
"""
|
@@ -305,7 +309,7 @@ def _minimize_lbfgsb(fun, x0, args=(), jac=None, bounds=None,
|
|
305
309
|
output and this keyword has no function.
|
306
310
|
|
307
311
|
.. deprecated:: 1.15.0
|
308
|
-
This keyword is deprecated and will be removed from SciPy 1.
|
312
|
+
This keyword is deprecated and will be removed from SciPy 1.18.0.
|
309
313
|
|
310
314
|
maxcor : int
|
311
315
|
The maximum number of variable metric corrections used to
|
@@ -334,7 +338,7 @@ def _minimize_lbfgsb(fun, x0, args=(), jac=None, bounds=None,
|
|
334
338
|
output and this keyword has no function.
|
335
339
|
|
336
340
|
.. deprecated:: 1.15.0
|
337
|
-
This keyword is deprecated and will be removed from SciPy 1.
|
341
|
+
This keyword is deprecated and will be removed from SciPy 1.18.0.
|
338
342
|
|
339
343
|
maxls : int, optional
|
340
344
|
Maximum number of line search steps (per iteration). Default is 20.
|
@@ -373,6 +377,17 @@ def _minimize_lbfgsb(fun, x0, args=(), jac=None, bounds=None,
|
|
373
377
|
|
374
378
|
x0 = asarray(x0).ravel()
|
375
379
|
n, = x0.shape
|
380
|
+
if disp is not _NoValue:
|
381
|
+
warnings.warn("scipy.optimize: The `disp` and `iprint` options of the "
|
382
|
+
"L-BFGS-B solver are deprecated and will be removed in "
|
383
|
+
"SciPy 1.18.0.",
|
384
|
+
DeprecationWarning, stacklevel=3)
|
385
|
+
|
386
|
+
if iprint is not _NoValue:
|
387
|
+
warnings.warn("scipy.optimize: The `disp` and `iprint` options of the "
|
388
|
+
"L-BFGS-B solver are deprecated and will be removed in "
|
389
|
+
"SciPy 1.18.0.",
|
390
|
+
DeprecationWarning, stacklevel=3)
|
376
391
|
|
377
392
|
# historically old-style bounds were/are expected by lbfgsb.
|
378
393
|
# That's still the case but we'll deal with new-style from here on,
|
Binary file
|
Binary file
|
@@ -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 '
|
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
|
scipy/optimize/_minimize.py
CHANGED
@@ -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
|
Binary file
|
Binary file
|
Binary file
|
@@ -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
|
-
|
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:
|
Binary file
|
Binary file
|
Binary file
|
@@ -239,7 +239,7 @@ class SparseMixin:
|
|
239
239
|
|
240
240
|
# Default lsmr arguments should not fully converge the solution
|
241
241
|
default_lsmr_sol = lsq_linear(A, b, lsq_solver='lsmr')
|
242
|
-
with pytest.raises(AssertionError
|
242
|
+
with pytest.raises(AssertionError):
|
243
243
|
assert_allclose(exact_sol.x, default_lsmr_sol.x)
|
244
244
|
|
245
245
|
# By increasing the maximum lsmr iters, it will converge
|
@@ -1126,7 +1126,7 @@ class TestOptimizeSimple(CheckOptimize):
|
|
1126
1126
|
|
1127
1127
|
def test_minimize_l_bfgs_b(self):
|
1128
1128
|
# Minimize with L-BFGS-B method
|
1129
|
-
opts = {'
|
1129
|
+
opts = {'maxiter': self.maxiter}
|
1130
1130
|
r = optimize.minimize(self.func, self.startparams,
|
1131
1131
|
method='L-BFGS-B', jac=self.grad,
|
1132
1132
|
options=opts)
|
@@ -1156,7 +1156,7 @@ class TestOptimizeSimple(CheckOptimize):
|
|
1156
1156
|
# Check that the `ftol` parameter in l_bfgs_b works as expected
|
1157
1157
|
v0 = None
|
1158
1158
|
for tol in [1e-1, 1e-4, 1e-7, 1e-10]:
|
1159
|
-
opts = {'
|
1159
|
+
opts = {'maxiter': self.maxiter, 'ftol': tol}
|
1160
1160
|
sol = optimize.minimize(self.func, self.startparams,
|
1161
1161
|
method='L-BFGS-B', jac=self.grad,
|
1162
1162
|
options=opts)
|
@@ -1173,7 +1173,7 @@ class TestOptimizeSimple(CheckOptimize):
|
|
1173
1173
|
# check that the maxls is passed down to the Fortran routine
|
1174
1174
|
sol = optimize.minimize(optimize.rosen, np.array([-1.2, 1.0]),
|
1175
1175
|
method='L-BFGS-B', jac=optimize.rosen_der,
|
1176
|
-
options={'
|
1176
|
+
options={'maxls': 1})
|
1177
1177
|
assert not sol.success
|
1178
1178
|
|
1179
1179
|
def test_minimize_l_bfgs_b_maxfun_interruption(self):
|
scipy/signal/_filter_design.py
CHANGED
@@ -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=
|
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)
|
Binary file
|
Binary file
|
scipy/signal/_polyutils.py
CHANGED
@@ -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(
|
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
|
Binary file
|
Binary file
|
scipy/signal/_spectral_py.py
CHANGED
@@ -897,6 +897,15 @@ def csd(x, y, fs=1.0, window='hann', nperseg=None, noverlap=None, nfft=None,
|
|
897
897
|
if np.iscomplexobj(x) and return_onesided:
|
898
898
|
return_onesided = False
|
899
899
|
|
900
|
+
if x.shape[axis] < y.shape[axis]: # zero-pad x to shape of y:
|
901
|
+
z_shape = list(y.shape)
|
902
|
+
z_shape[axis] = y.shape[axis] - x.shape[axis]
|
903
|
+
x = np.concatenate((x, np.zeros(z_shape)), axis=axis)
|
904
|
+
elif y.shape[axis] < x.shape[axis]: # zero-pad y to shape of x:
|
905
|
+
z_shape = list(x.shape)
|
906
|
+
z_shape[axis] = x.shape[axis] - y.shape[axis]
|
907
|
+
y = np.concatenate((y, np.zeros(z_shape)), axis=axis)
|
908
|
+
|
900
909
|
# using cast() to make mypy happy:
|
901
910
|
fft_mode = cast(FFT_MODE_TYPE, 'onesided' if return_onesided else 'twosided')
|
902
911
|
if scaling not in (scales := {'spectrum': 'magnitude', 'density': 'psd'}):
|
Binary file
|
Binary file
|
@@ -382,6 +382,19 @@ class TestTf2Sos:
|
|
382
382
|
sos2 = tf2sos(b, a, analog=analog)
|
383
383
|
assert_array_almost_equal(sos, sos2, decimal=4)
|
384
384
|
|
385
|
+
def test_gh_23221(self):
|
386
|
+
# Tests that this tf2sos call below does not produce ComplexWarnings
|
387
|
+
# This test is specific for scipy==1.16.0: later scipy versions do not produce
|
388
|
+
# the warning.
|
389
|
+
with suppress_warnings():
|
390
|
+
warnings.simplefilter("error")
|
391
|
+
tf2sos([0.21860986786301265, -0.4372197357260253, -0.2186098678630126,
|
392
|
+
0.8744394714520509, -0.21860986786301248, -0.4372197357260253,
|
393
|
+
0.21860986786301265],
|
394
|
+
[1., -4.18323041786553, 6.829924151626914, -5.407777865686045,
|
395
|
+
2.0773105450802336, -0.33482732571537893, 0.0186009178695853 ]
|
396
|
+
)
|
397
|
+
|
385
398
|
|
386
399
|
@skip_xp_backends(
|
387
400
|
cpu_only=True, reason="XXX zpk2sos is numpy-only", exceptions=['cupy']
|
@@ -754,6 +767,12 @@ class TestFreqz:
|
|
754
767
|
xp_assert_equal(w, xp.asarray([0. , 0.1]))
|
755
768
|
xp_assert_equal(h, xp.asarray([1.+0.j, 1.+0.j]))
|
756
769
|
|
770
|
+
def test_gh_23277(self):
|
771
|
+
# backwards compatibility: `w` array must be real, not complex
|
772
|
+
filt = [0.5 + 0.0j, 0.5 + 0.0j]
|
773
|
+
w, _ = freqz(filt, worN=8)
|
774
|
+
assert w.dtype == np.float64
|
775
|
+
|
757
776
|
def test_basic(self, xp):
|
758
777
|
w, h = freqz(xp.asarray([1.0]), worN=8)
|
759
778
|
assert_array_almost_equal(w, xp.pi * xp.arange(8, dtype=w.dtype) / 8.)
|
@@ -546,6 +546,11 @@ class TestRemez:
|
|
546
546
|
with pytest.raises(ValueError, match="Sampling.*single scalar"):
|
547
547
|
remez(11, .1, 1, fs=np.array([10, 20]))
|
548
548
|
|
549
|
+
def test_gh_23266(self, xp):
|
550
|
+
bands = xp.asarray([0.0, 0.2, 0.3, 0.5])
|
551
|
+
desired = xp.asarray([1.0, 0.0])
|
552
|
+
weight = xp.asarray([1.0, 2.0])
|
553
|
+
remez(21, bands, desired, weight=weight)
|
549
554
|
|
550
555
|
|
551
556
|
@skip_xp_backends(cpu_only=True, reason="lstsq")
|
@@ -1295,7 +1295,7 @@ class TestMedFilt:
|
|
1295
1295
|
# us into wrong memory if used (but it does not need to be used)
|
1296
1296
|
dummy = xp.arange(10, dtype=xp.float64)
|
1297
1297
|
a = dummy[5:6]
|
1298
|
-
a.strides
|
1298
|
+
a = np.lib.stride_tricks.as_strided(a, strides=(16,))
|
1299
1299
|
xp_assert_close(signal.medfilt(a, 1), xp.asarray([5.]))
|
1300
1300
|
|
1301
1301
|
@skip_xp_backends(
|
@@ -8,6 +8,7 @@ import pytest
|
|
8
8
|
from pytest import raises as assert_raises
|
9
9
|
|
10
10
|
from scipy import signal
|
11
|
+
from scipy._lib._array_api import xp_assert_close
|
11
12
|
from scipy.fft import fftfreq, rfftfreq, fft, irfft
|
12
13
|
from scipy.integrate import trapezoid
|
13
14
|
from scipy.signal import (periodogram, welch, lombscargle, coherence, csd,
|
@@ -591,6 +592,36 @@ class TestCSD:
|
|
591
592
|
assert_allclose(f, f1)
|
592
593
|
assert_allclose(c, c1)
|
593
594
|
|
595
|
+
def test_unequal_length_input_1D(self):
|
596
|
+
"""Test zero-padding for input `x.shape[axis] != y.shape[axis]` for 1d arrays.
|
597
|
+
|
598
|
+
This test ensures that issue 23036 is fixed.
|
599
|
+
"""
|
600
|
+
x = np.tile([4, 0, -4, 0], 4)
|
601
|
+
|
602
|
+
kw = dict(fs=len(x), window='boxcar', nperseg=4)
|
603
|
+
X0 = signal.csd(x, np.copy(x), **kw)[1] # `x is x` must be False
|
604
|
+
X1 = signal.csd(x, x[:8], **kw)[1]
|
605
|
+
X2 = signal.csd(x[:8], x, **kw)[1]
|
606
|
+
xp_assert_close(X1, X0 / 2)
|
607
|
+
xp_assert_close(X2, X0 / 2)
|
608
|
+
|
609
|
+
def test_unequal_length_input_3D(self):
|
610
|
+
"""Test zero-padding for input `x.shape[axis] != y.shape[axis]` for 3d arrays.
|
611
|
+
|
612
|
+
This test ensures that issue 23036 is fixed.
|
613
|
+
"""
|
614
|
+
n = 8
|
615
|
+
x = np.zeros(2 * 3 * n).reshape(2, n, 3)
|
616
|
+
x[:, 0, :] = n
|
617
|
+
|
618
|
+
kw = dict(fs=n, window='boxcar', nperseg=n, detrend=None, axis=1)
|
619
|
+
X0 = signal.csd(x, x.copy(), **kw)[1] # `x is x` must be False
|
620
|
+
X1 = signal.csd(x, x[:, :2, :], **kw)[1]
|
621
|
+
X2 = signal.csd(x[:, :2, :], x, **kw)[1]
|
622
|
+
xp_assert_close(X1, X0)
|
623
|
+
xp_assert_close(X2, X0)
|
624
|
+
|
594
625
|
def test_real_onesided_even(self):
|
595
626
|
x = np.zeros(16)
|
596
627
|
x[0] = 1
|
scipy/sparse/_base.py
CHANGED
@@ -494,7 +494,10 @@ class _spbase(SparseABC):
|
|
494
494
|
return self._mul_scalar(other)
|
495
495
|
|
496
496
|
if self.ndim < 3:
|
497
|
-
|
497
|
+
try:
|
498
|
+
return self._multiply_2d_with_broadcasting(other)
|
499
|
+
except AttributeError:
|
500
|
+
return self.tocsr()._multiply_2d_with_broadcasting(other)
|
498
501
|
|
499
502
|
if not (issparse(other) or isdense(other)):
|
500
503
|
# If it's a list or whatever, treat it like an array
|
@@ -658,7 +661,7 @@ class _spbase(SparseABC):
|
|
658
661
|
# eq and ne return True or False instead of an array when the shapes
|
659
662
|
# don't match. Numpy doesn't do this. Is this what we want?
|
660
663
|
if op in (operator.eq, operator.ne):
|
661
|
-
return op
|
664
|
+
return op is operator.ne
|
662
665
|
raise ValueError("inconsistent shape")
|
663
666
|
|
664
667
|
csr_self = (self if self.ndim < 3 else self.reshape(1, -1)).tocsr()
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
scipy/sparse/tests/test_base.py
CHANGED
@@ -433,6 +433,13 @@ class _TestCommon:
|
|
433
433
|
for dtype in self.checked_dtypes:
|
434
434
|
check(dtype)
|
435
435
|
|
436
|
+
def test_eq_ne_different_shapes(self):
|
437
|
+
if self.datsp.format not in ['bsr', 'csc', 'csr']:
|
438
|
+
pytest.skip("Bool comparisons only implemented for BSR, CSC, and CSR.")
|
439
|
+
# Is this what we want? numpy raises when shape differs. we return False.
|
440
|
+
assert (self.datsp == self.datsp.T) is False
|
441
|
+
assert (self.datsp != self.datsp.T) is True
|
442
|
+
|
436
443
|
def test_lt(self):
|
437
444
|
sup = suppress_warnings()
|
438
445
|
sup.filter(SparseEfficiencyWarning)
|
@@ -1617,6 +1624,9 @@ class _TestCommon:
|
|
1617
1624
|
B = array([[0,7,0],[0,-4,0]])
|
1618
1625
|
Asp = self.spcreator(A)
|
1619
1626
|
Bsp = self.spcreator(B)
|
1627
|
+
# check output format
|
1628
|
+
out_fmt = Asp.format if Asp.format in ('csc', 'dia', 'bsr') else 'csr'
|
1629
|
+
assert (Asp.multiply(Bsp)).format == out_fmt
|
1620
1630
|
assert_almost_equal(Asp.multiply(Bsp).toarray(), A*B) # sparse/sparse
|
1621
1631
|
assert_almost_equal(Asp.multiply(B).toarray(), A*B) # sparse/dense
|
1622
1632
|
|
Binary file
|