scipy 1.15.3__cp313-cp313t-macosx_14_0_arm64.whl → 1.16.0rc2__cp313-cp313t-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/__config__.py +3 -3
- scipy/__init__.py +3 -6
- scipy/_cyutility.cpython-313t-darwin.so +0 -0
- scipy/_lib/_array_api.py +486 -161
- scipy/_lib/_array_api_compat_vendor.py +9 -0
- scipy/_lib/_bunch.py +4 -0
- scipy/_lib/_ccallback_c.cpython-313t-darwin.so +0 -0
- scipy/_lib/_docscrape.py +1 -1
- scipy/_lib/_elementwise_iterative_method.py +15 -26
- scipy/_lib/_sparse.py +41 -0
- scipy/_lib/_test_deprecation_call.cpython-313t-darwin.so +0 -0
- scipy/_lib/_testutils.py +6 -2
- scipy/_lib/_util.py +222 -125
- scipy/_lib/array_api_compat/__init__.py +4 -4
- scipy/_lib/array_api_compat/_internal.py +19 -6
- scipy/_lib/array_api_compat/common/__init__.py +1 -1
- scipy/_lib/array_api_compat/common/_aliases.py +365 -193
- scipy/_lib/array_api_compat/common/_fft.py +94 -64
- scipy/_lib/array_api_compat/common/_helpers.py +413 -180
- scipy/_lib/array_api_compat/common/_linalg.py +116 -40
- scipy/_lib/array_api_compat/common/_typing.py +179 -10
- scipy/_lib/array_api_compat/cupy/__init__.py +1 -4
- scipy/_lib/array_api_compat/cupy/_aliases.py +61 -41
- scipy/_lib/array_api_compat/cupy/_info.py +16 -6
- scipy/_lib/array_api_compat/cupy/_typing.py +24 -39
- scipy/_lib/array_api_compat/dask/array/__init__.py +6 -3
- scipy/_lib/array_api_compat/dask/array/_aliases.py +267 -108
- scipy/_lib/array_api_compat/dask/array/_info.py +105 -34
- scipy/_lib/array_api_compat/dask/array/fft.py +5 -8
- scipy/_lib/array_api_compat/dask/array/linalg.py +21 -22
- scipy/_lib/array_api_compat/numpy/__init__.py +13 -15
- scipy/_lib/array_api_compat/numpy/_aliases.py +98 -49
- scipy/_lib/array_api_compat/numpy/_info.py +36 -16
- scipy/_lib/array_api_compat/numpy/_typing.py +27 -43
- scipy/_lib/array_api_compat/numpy/fft.py +11 -5
- scipy/_lib/array_api_compat/numpy/linalg.py +75 -22
- scipy/_lib/array_api_compat/torch/__init__.py +3 -5
- scipy/_lib/array_api_compat/torch/_aliases.py +262 -159
- scipy/_lib/array_api_compat/torch/_info.py +27 -16
- scipy/_lib/array_api_compat/torch/_typing.py +3 -0
- scipy/_lib/array_api_compat/torch/fft.py +17 -18
- scipy/_lib/array_api_compat/torch/linalg.py +16 -16
- scipy/_lib/array_api_extra/__init__.py +26 -3
- scipy/_lib/array_api_extra/_delegation.py +171 -0
- scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_at.py +463 -0
- scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
- scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
- scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
- scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
- scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
- scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
- scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
- scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
- scipy/_lib/array_api_extra/testing.py +359 -0
- scipy/_lib/decorator.py +2 -2
- scipy/_lib/doccer.py +1 -7
- scipy/_lib/messagestream.cpython-313t-darwin.so +0 -0
- scipy/_lib/pyprima/__init__.py +212 -0
- scipy/_lib/pyprima/cobyla/__init__.py +0 -0
- scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
- scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
- scipy/_lib/pyprima/cobyla/geometry.py +226 -0
- scipy/_lib/pyprima/cobyla/initialize.py +215 -0
- scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
- scipy/_lib/pyprima/cobyla/update.py +289 -0
- scipy/_lib/pyprima/common/__init__.py +0 -0
- scipy/_lib/pyprima/common/_bounds.py +34 -0
- scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
- scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
- scipy/_lib/pyprima/common/_project.py +173 -0
- scipy/_lib/pyprima/common/checkbreak.py +93 -0
- scipy/_lib/pyprima/common/consts.py +47 -0
- scipy/_lib/pyprima/common/evaluate.py +99 -0
- scipy/_lib/pyprima/common/history.py +38 -0
- scipy/_lib/pyprima/common/infos.py +30 -0
- scipy/_lib/pyprima/common/linalg.py +435 -0
- scipy/_lib/pyprima/common/message.py +290 -0
- scipy/_lib/pyprima/common/powalg.py +131 -0
- scipy/_lib/pyprima/common/preproc.py +277 -0
- scipy/_lib/pyprima/common/present.py +5 -0
- scipy/_lib/pyprima/common/ratio.py +54 -0
- scipy/_lib/pyprima/common/redrho.py +47 -0
- scipy/_lib/pyprima/common/selectx.py +296 -0
- scipy/_lib/tests/test__util.py +105 -121
- scipy/_lib/tests/test_array_api.py +166 -35
- scipy/_lib/tests/test_bunch.py +7 -0
- scipy/_lib/tests/test_ccallback.py +2 -10
- scipy/_lib/tests/test_public_api.py +13 -0
- scipy/cluster/_hierarchy.cpython-313t-darwin.so +0 -0
- scipy/cluster/_optimal_leaf_ordering.cpython-313t-darwin.so +0 -0
- scipy/cluster/_vq.cpython-313t-darwin.so +0 -0
- scipy/cluster/hierarchy.py +393 -223
- scipy/cluster/tests/test_hierarchy.py +273 -335
- scipy/cluster/tests/test_vq.py +45 -61
- scipy/cluster/vq.py +39 -35
- scipy/conftest.py +263 -157
- scipy/constants/_constants.py +4 -1
- scipy/constants/tests/test_codata.py +2 -2
- scipy/constants/tests/test_constants.py +11 -18
- scipy/datasets/_download_all.py +15 -1
- scipy/datasets/_fetchers.py +7 -1
- scipy/datasets/_utils.py +1 -1
- scipy/differentiate/_differentiate.py +25 -25
- scipy/differentiate/tests/test_differentiate.py +24 -25
- scipy/fft/_basic.py +20 -0
- scipy/fft/_helper.py +3 -34
- scipy/fft/_pocketfft/helper.py +29 -1
- scipy/fft/_pocketfft/tests/test_basic.py +2 -4
- scipy/fft/_pocketfft/tests/test_real_transforms.py +4 -4
- scipy/fft/_realtransforms.py +13 -0
- scipy/fft/tests/test_basic.py +27 -25
- scipy/fft/tests/test_fftlog.py +16 -7
- scipy/fft/tests/test_helper.py +18 -34
- scipy/fft/tests/test_real_transforms.py +8 -10
- scipy/fftpack/convolve.cpython-313t-darwin.so +0 -0
- scipy/fftpack/tests/test_basic.py +2 -4
- scipy/fftpack/tests/test_real_transforms.py +8 -9
- scipy/integrate/_bvp.py +9 -3
- scipy/integrate/_cubature.py +3 -2
- scipy/integrate/_dop.cpython-313t-darwin.so +0 -0
- scipy/integrate/_lsoda.cpython-313t-darwin.so +0 -0
- scipy/integrate/_ode.py +9 -2
- scipy/integrate/_odepack.cpython-313t-darwin.so +0 -0
- scipy/integrate/_quad_vec.py +21 -29
- scipy/integrate/_quadpack.cpython-313t-darwin.so +0 -0
- scipy/integrate/_quadpack_py.py +11 -7
- scipy/integrate/_quadrature.py +3 -3
- scipy/integrate/_rules/_base.py +2 -2
- scipy/integrate/_tanhsinh.py +48 -47
- scipy/integrate/_test_odeint_banded.cpython-313t-darwin.so +0 -0
- scipy/integrate/_vode.cpython-313t-darwin.so +0 -0
- scipy/integrate/tests/test__quad_vec.py +0 -6
- scipy/integrate/tests/test_banded_ode_solvers.py +85 -0
- scipy/integrate/tests/test_cubature.py +21 -35
- scipy/integrate/tests/test_quadrature.py +6 -8
- scipy/integrate/tests/test_tanhsinh.py +56 -48
- scipy/interpolate/__init__.py +70 -58
- scipy/interpolate/_bary_rational.py +22 -22
- scipy/interpolate/_bsplines.py +119 -66
- scipy/interpolate/_cubic.py +65 -50
- scipy/interpolate/_dfitpack.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_dierckx.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_fitpack.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_fitpack2.py +9 -6
- scipy/interpolate/_fitpack_impl.py +32 -26
- scipy/interpolate/_fitpack_repro.py +23 -19
- scipy/interpolate/_interpnd.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_interpolate.py +30 -12
- scipy/interpolate/_ndbspline.py +13 -18
- scipy/interpolate/_ndgriddata.py +5 -8
- scipy/interpolate/_polyint.py +95 -31
- scipy/interpolate/_ppoly.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_rbf.py +2 -2
- scipy/interpolate/_rbfinterp.py +1 -1
- scipy/interpolate/_rbfinterp_pythran.cpython-313t-darwin.so +0 -0
- scipy/interpolate/_rgi.py +31 -26
- scipy/interpolate/_rgi_cython.cpython-313t-darwin.so +0 -0
- scipy/interpolate/dfitpack.py +0 -20
- scipy/interpolate/interpnd.py +1 -2
- scipy/interpolate/tests/test_bary_rational.py +2 -2
- scipy/interpolate/tests/test_bsplines.py +97 -1
- scipy/interpolate/tests/test_fitpack2.py +39 -1
- scipy/interpolate/tests/test_interpnd.py +32 -20
- scipy/interpolate/tests/test_interpolate.py +48 -4
- scipy/interpolate/tests/test_rgi.py +2 -1
- scipy/io/_fast_matrix_market/__init__.py +2 -0
- scipy/io/_harwell_boeing/_fortran_format_parser.py +19 -16
- scipy/io/_harwell_boeing/hb.py +7 -11
- scipy/io/_idl.py +5 -7
- scipy/io/_netcdf.py +15 -5
- scipy/io/_test_fortran.cpython-313t-darwin.so +0 -0
- scipy/io/arff/tests/test_arffread.py +3 -3
- scipy/io/matlab/__init__.py +5 -3
- scipy/io/matlab/_mio.py +4 -1
- scipy/io/matlab/_mio5.py +19 -13
- scipy/io/matlab/_mio5_utils.cpython-313t-darwin.so +0 -0
- scipy/io/matlab/_mio_utils.cpython-313t-darwin.so +0 -0
- scipy/io/matlab/_miobase.py +4 -1
- scipy/io/matlab/_streams.cpython-313t-darwin.so +0 -0
- scipy/io/matlab/tests/test_mio.py +46 -18
- scipy/io/matlab/tests/test_mio_funcs.py +1 -1
- scipy/io/tests/test_mmio.py +7 -1
- scipy/io/tests/test_wavfile.py +41 -0
- scipy/io/wavfile.py +57 -10
- scipy/linalg/_basic.py +113 -86
- scipy/linalg/_cythonized_array_utils.cpython-313t-darwin.so +0 -0
- scipy/linalg/_decomp.py +22 -9
- scipy/linalg/_decomp_cholesky.py +28 -13
- scipy/linalg/_decomp_cossin.py +45 -30
- scipy/linalg/_decomp_interpolative.cpython-313t-darwin.so +0 -0
- scipy/linalg/_decomp_ldl.py +4 -1
- scipy/linalg/_decomp_lu.py +18 -6
- scipy/linalg/_decomp_lu_cython.cpython-313t-darwin.so +0 -0
- scipy/linalg/_decomp_polar.py +2 -0
- scipy/linalg/_decomp_qr.py +6 -2
- scipy/linalg/_decomp_qz.py +3 -0
- scipy/linalg/_decomp_schur.py +3 -1
- scipy/linalg/_decomp_svd.py +13 -2
- scipy/linalg/_decomp_update.cpython-313t-darwin.so +0 -0
- scipy/linalg/_expm_frechet.py +4 -0
- scipy/linalg/_fblas.cpython-313t-darwin.so +0 -0
- scipy/linalg/_flapack.cpython-313t-darwin.so +0 -0
- scipy/linalg/_linalg_pythran.cpython-313t-darwin.so +0 -0
- scipy/linalg/_matfuncs.py +187 -4
- scipy/linalg/_matfuncs_expm.cpython-313t-darwin.so +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cpython-313t-darwin.so +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +1 -99
- scipy/linalg/_matfuncs_sqrtm_triu.cpython-313t-darwin.so +0 -0
- scipy/linalg/_procrustes.py +2 -0
- scipy/linalg/_sketches.py +17 -6
- scipy/linalg/_solve_toeplitz.cpython-313t-darwin.so +0 -0
- scipy/linalg/_solvers.py +7 -2
- scipy/linalg/_special_matrices.py +26 -36
- scipy/linalg/cython_blas.cpython-313t-darwin.so +0 -0
- scipy/linalg/cython_lapack.cpython-313t-darwin.so +0 -0
- scipy/linalg/lapack.py +22 -2
- scipy/linalg/tests/_cython_examples/meson.build +7 -0
- scipy/linalg/tests/test_basic.py +31 -16
- scipy/linalg/tests/test_batch.py +588 -0
- scipy/linalg/tests/test_cythonized_array_utils.py +0 -2
- scipy/linalg/tests/test_decomp.py +40 -3
- scipy/linalg/tests/test_decomp_cossin.py +14 -0
- scipy/linalg/tests/test_decomp_ldl.py +1 -1
- scipy/linalg/tests/test_lapack.py +115 -7
- scipy/linalg/tests/test_matfuncs.py +157 -102
- scipy/linalg/tests/test_procrustes.py +0 -7
- scipy/linalg/tests/test_solve_toeplitz.py +1 -1
- scipy/linalg/tests/test_special_matrices.py +1 -5
- scipy/ndimage/__init__.py +1 -0
- scipy/ndimage/_cytest.cpython-313t-darwin.so +0 -0
- scipy/ndimage/_delegators.py +8 -2
- scipy/ndimage/_filters.py +453 -5
- scipy/ndimage/_interpolation.py +36 -6
- scipy/ndimage/_measurements.py +4 -2
- scipy/ndimage/_morphology.py +5 -0
- scipy/ndimage/_nd_image.cpython-313t-darwin.so +0 -0
- scipy/ndimage/_ni_docstrings.py +5 -1
- scipy/ndimage/_ni_label.cpython-313t-darwin.so +0 -0
- scipy/ndimage/_ni_support.py +1 -5
- scipy/ndimage/_rank_filter_1d.cpython-313t-darwin.so +0 -0
- scipy/ndimage/_support_alternative_backends.py +18 -6
- scipy/ndimage/tests/test_filters.py +370 -259
- scipy/ndimage/tests/test_fourier.py +7 -9
- scipy/ndimage/tests/test_interpolation.py +68 -61
- scipy/ndimage/tests/test_measurements.py +18 -35
- scipy/ndimage/tests/test_morphology.py +143 -131
- scipy/ndimage/tests/test_splines.py +1 -3
- scipy/odr/__odrpack.cpython-313t-darwin.so +0 -0
- scipy/optimize/_basinhopping.py +13 -7
- scipy/optimize/_bglu_dense.cpython-313t-darwin.so +0 -0
- scipy/optimize/_bracket.py +17 -24
- scipy/optimize/_chandrupatla.py +9 -10
- scipy/optimize/_cobyla_py.py +104 -123
- scipy/optimize/_constraints.py +14 -10
- scipy/optimize/_differentiable_functions.py +371 -230
- scipy/optimize/_differentialevolution.py +4 -3
- scipy/optimize/_direct.cpython-313t-darwin.so +0 -0
- scipy/optimize/_dual_annealing.py +1 -1
- scipy/optimize/_elementwise.py +1 -4
- scipy/optimize/_group_columns.cpython-313t-darwin.so +0 -0
- scipy/optimize/_lbfgsb.cpython-313t-darwin.so +0 -0
- scipy/optimize/_lbfgsb_py.py +57 -16
- scipy/optimize/_linprog_doc.py +2 -2
- scipy/optimize/_linprog_highs.py +2 -2
- scipy/optimize/_linprog_ip.py +25 -10
- scipy/optimize/_linprog_util.py +14 -16
- scipy/optimize/_lsap.cpython-313t-darwin.so +0 -0
- scipy/optimize/_lsq/common.py +3 -3
- scipy/optimize/_lsq/dogbox.py +16 -2
- scipy/optimize/_lsq/givens_elimination.cpython-313t-darwin.so +0 -0
- scipy/optimize/_lsq/least_squares.py +198 -126
- scipy/optimize/_lsq/lsq_linear.py +6 -6
- scipy/optimize/_lsq/trf.py +35 -8
- scipy/optimize/_milp.py +3 -1
- scipy/optimize/_minimize.py +105 -36
- scipy/optimize/_minpack.cpython-313t-darwin.so +0 -0
- scipy/optimize/_minpack_py.py +21 -14
- scipy/optimize/_moduleTNC.cpython-313t-darwin.so +0 -0
- scipy/optimize/_nnls.py +20 -21
- scipy/optimize/_nonlin.py +34 -3
- scipy/optimize/_numdiff.py +288 -110
- scipy/optimize/_optimize.py +86 -48
- scipy/optimize/_pava_pybind.cpython-313t-darwin.so +0 -0
- scipy/optimize/_remove_redundancy.py +5 -5
- scipy/optimize/_root_scalar.py +1 -1
- scipy/optimize/_shgo.py +6 -0
- scipy/optimize/_shgo_lib/_complex.py +1 -1
- scipy/optimize/_slsqp_py.py +216 -124
- scipy/optimize/_slsqplib.cpython-313t-darwin.so +0 -0
- scipy/optimize/_spectral.py +1 -1
- scipy/optimize/_tnc.py +8 -1
- scipy/optimize/_trlib/_trlib.cpython-313t-darwin.so +0 -0
- scipy/optimize/_trustregion.py +20 -6
- scipy/optimize/_trustregion_constr/canonical_constraint.py +7 -7
- scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +1 -1
- scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +11 -3
- scipy/optimize/_trustregion_constr/projections.py +12 -8
- scipy/optimize/_trustregion_constr/qp_subproblem.py +9 -9
- scipy/optimize/_trustregion_constr/tests/test_projections.py +7 -7
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +77 -77
- scipy/optimize/_trustregion_constr/tr_interior_point.py +5 -5
- scipy/optimize/_trustregion_exact.py +0 -1
- scipy/optimize/_zeros.cpython-313t-darwin.so +0 -0
- scipy/optimize/_zeros_py.py +97 -17
- scipy/optimize/cython_optimize/_zeros.cpython-313t-darwin.so +0 -0
- scipy/optimize/slsqp.py +0 -1
- scipy/optimize/tests/test__basinhopping.py +1 -1
- scipy/optimize/tests/test__differential_evolution.py +4 -4
- scipy/optimize/tests/test__linprog_clean_inputs.py +5 -3
- scipy/optimize/tests/test__numdiff.py +66 -22
- scipy/optimize/tests/test__remove_redundancy.py +2 -2
- scipy/optimize/tests/test__shgo.py +9 -1
- scipy/optimize/tests/test_bracket.py +36 -46
- scipy/optimize/tests/test_chandrupatla.py +133 -135
- scipy/optimize/tests/test_cobyla.py +74 -45
- scipy/optimize/tests/test_constraints.py +1 -1
- scipy/optimize/tests/test_differentiable_functions.py +226 -6
- scipy/optimize/tests/test_lbfgsb_hessinv.py +22 -0
- scipy/optimize/tests/test_least_squares.py +125 -13
- scipy/optimize/tests/test_linear_assignment.py +3 -3
- scipy/optimize/tests/test_linprog.py +3 -3
- scipy/optimize/tests/test_lsq_linear.py +6 -6
- scipy/optimize/tests/test_minimize_constrained.py +2 -2
- scipy/optimize/tests/test_minpack.py +4 -4
- scipy/optimize/tests/test_nnls.py +43 -3
- scipy/optimize/tests/test_nonlin.py +36 -0
- scipy/optimize/tests/test_optimize.py +95 -17
- scipy/optimize/tests/test_slsqp.py +36 -4
- scipy/optimize/tests/test_zeros.py +34 -1
- scipy/signal/__init__.py +12 -23
- scipy/signal/_delegators.py +568 -0
- scipy/signal/_filter_design.py +459 -241
- scipy/signal/_fir_filter_design.py +262 -90
- scipy/signal/_lti_conversion.py +3 -2
- scipy/signal/_ltisys.py +118 -91
- scipy/signal/_max_len_seq_inner.cpython-313t-darwin.so +0 -0
- scipy/signal/_peak_finding_utils.cpython-313t-darwin.so +0 -0
- scipy/signal/_polyutils.py +172 -0
- scipy/signal/_short_time_fft.py +519 -70
- scipy/signal/_signal_api.py +30 -0
- scipy/signal/_signaltools.py +719 -399
- scipy/signal/_sigtools.cpython-313t-darwin.so +0 -0
- scipy/signal/_sosfilt.cpython-313t-darwin.so +0 -0
- scipy/signal/_spectral_py.py +230 -50
- scipy/signal/_spline.cpython-313t-darwin.so +0 -0
- scipy/signal/_spline_filters.py +108 -68
- scipy/signal/_support_alternative_backends.py +73 -0
- scipy/signal/_upfirdn.py +4 -1
- scipy/signal/_upfirdn_apply.cpython-313t-darwin.so +0 -0
- scipy/signal/_waveforms.py +2 -11
- scipy/signal/_wavelets.py +1 -1
- scipy/signal/fir_filter_design.py +1 -0
- scipy/signal/spline.py +4 -11
- scipy/signal/tests/_scipy_spectral_test_shim.py +2 -171
- scipy/signal/tests/test_bsplines.py +114 -79
- scipy/signal/tests/test_cont2discrete.py +9 -2
- scipy/signal/tests/test_filter_design.py +721 -481
- scipy/signal/tests/test_fir_filter_design.py +332 -140
- scipy/signal/tests/test_savitzky_golay.py +4 -3
- scipy/signal/tests/test_short_time_fft.py +221 -3
- scipy/signal/tests/test_signaltools.py +2144 -1348
- scipy/signal/tests/test_spectral.py +50 -6
- scipy/signal/tests/test_splines.py +161 -96
- scipy/signal/tests/test_upfirdn.py +84 -50
- scipy/signal/tests/test_waveforms.py +20 -0
- scipy/signal/tests/test_windows.py +607 -466
- scipy/signal/windows/_windows.py +287 -148
- scipy/sparse/__init__.py +23 -4
- scipy/sparse/_base.py +270 -108
- scipy/sparse/_bsr.py +7 -4
- scipy/sparse/_compressed.py +59 -231
- scipy/sparse/_construct.py +90 -38
- scipy/sparse/_coo.py +115 -181
- scipy/sparse/_csc.py +4 -4
- scipy/sparse/_csparsetools.cpython-313t-darwin.so +0 -0
- scipy/sparse/_csr.py +2 -2
- scipy/sparse/_data.py +48 -48
- scipy/sparse/_dia.py +105 -18
- scipy/sparse/_dok.py +0 -23
- scipy/sparse/_index.py +4 -4
- scipy/sparse/_matrix.py +23 -0
- scipy/sparse/_sparsetools.cpython-313t-darwin.so +0 -0
- scipy/sparse/_sputils.py +37 -22
- scipy/sparse/base.py +0 -9
- scipy/sparse/bsr.py +0 -14
- scipy/sparse/compressed.py +0 -23
- scipy/sparse/construct.py +0 -6
- scipy/sparse/coo.py +0 -14
- scipy/sparse/csc.py +0 -3
- scipy/sparse/csgraph/_flow.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_matching.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_reordering.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_shortest_path.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_tools.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/_traversal.cpython-313t-darwin.so +0 -0
- scipy/sparse/csgraph/tests/test_matching.py +14 -2
- scipy/sparse/csgraph/tests/test_pydata_sparse.py +4 -1
- scipy/sparse/csgraph/tests/test_shortest_path.py +83 -27
- scipy/sparse/csr.py +0 -5
- scipy/sparse/data.py +1 -6
- scipy/sparse/dia.py +0 -7
- scipy/sparse/dok.py +0 -10
- scipy/sparse/linalg/_dsolve/_superlu.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_dsolve/linsolve.py +9 -0
- scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +35 -28
- scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_eigen/arpack/arpack.py +23 -17
- scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +6 -6
- scipy/sparse/linalg/_interface.py +17 -18
- scipy/sparse/linalg/_isolve/_gcrotmk.py +4 -4
- scipy/sparse/linalg/_isolve/iterative.py +51 -45
- scipy/sparse/linalg/_isolve/lgmres.py +6 -6
- scipy/sparse/linalg/_isolve/minres.py +5 -5
- scipy/sparse/linalg/_isolve/tfqmr.py +7 -7
- scipy/sparse/linalg/_isolve/utils.py +2 -8
- scipy/sparse/linalg/_matfuncs.py +1 -1
- scipy/sparse/linalg/_norm.py +1 -1
- scipy/sparse/linalg/_propack/_cpropack.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_spropack.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cpython-313t-darwin.so +0 -0
- scipy/sparse/linalg/_special_sparse_arrays.py +39 -38
- scipy/sparse/linalg/tests/test_pydata_sparse.py +14 -0
- scipy/sparse/tests/test_arithmetic1d.py +5 -2
- scipy/sparse/tests/test_base.py +214 -42
- scipy/sparse/tests/test_common1d.py +7 -7
- scipy/sparse/tests/test_construct.py +1 -1
- scipy/sparse/tests/test_coo.py +272 -4
- scipy/sparse/tests/test_sparsetools.py +5 -0
- scipy/sparse/tests/test_sputils.py +36 -7
- scipy/spatial/_ckdtree.cpython-313t-darwin.so +0 -0
- scipy/spatial/_distance_pybind.cpython-313t-darwin.so +0 -0
- scipy/spatial/_distance_wrap.cpython-313t-darwin.so +0 -0
- scipy/spatial/_hausdorff.cpython-313t-darwin.so +0 -0
- scipy/spatial/_qhull.cpython-313t-darwin.so +0 -0
- scipy/spatial/_voronoi.cpython-313t-darwin.so +0 -0
- scipy/spatial/distance.py +49 -42
- scipy/spatial/tests/test_distance.py +15 -1
- scipy/spatial/tests/test_kdtree.py +1 -0
- scipy/spatial/tests/test_qhull.py +7 -2
- scipy/spatial/transform/__init__.py +5 -3
- scipy/spatial/transform/_rigid_transform.cpython-313t-darwin.so +0 -0
- scipy/spatial/transform/_rotation.cpython-313t-darwin.so +0 -0
- scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
- scipy/spatial/transform/tests/test_rotation.py +1213 -832
- scipy/spatial/transform/tests/test_rotation_groups.py +3 -3
- scipy/spatial/transform/tests/test_rotation_spline.py +29 -8
- scipy/special/__init__.py +1 -47
- scipy/special/_add_newdocs.py +34 -772
- scipy/special/_basic.py +22 -25
- scipy/special/_comb.cpython-313t-darwin.so +0 -0
- scipy/special/_ellip_harm_2.cpython-313t-darwin.so +0 -0
- scipy/special/_gufuncs.cpython-313t-darwin.so +0 -0
- scipy/special/_logsumexp.py +67 -58
- scipy/special/_orthogonal.pyi +1 -1
- scipy/special/_specfun.cpython-313t-darwin.so +0 -0
- scipy/special/_special_ufuncs.cpython-313t-darwin.so +0 -0
- scipy/special/_spherical_bessel.py +4 -4
- scipy/special/_support_alternative_backends.py +212 -119
- scipy/special/_test_internal.cpython-313t-darwin.so +0 -0
- scipy/special/_testutils.py +4 -4
- scipy/special/_ufuncs.cpython-313t-darwin.so +0 -0
- scipy/special/_ufuncs.pyi +1 -0
- scipy/special/_ufuncs.pyx +215 -1400
- scipy/special/_ufuncs_cxx.cpython-313t-darwin.so +0 -0
- scipy/special/_ufuncs_cxx.pxd +2 -15
- scipy/special/_ufuncs_cxx.pyx +5 -44
- scipy/special/_ufuncs_cxx_defs.h +2 -16
- scipy/special/_ufuncs_defs.h +0 -8
- scipy/special/cython_special.cpython-313t-darwin.so +0 -0
- scipy/special/cython_special.pxd +1 -1
- scipy/special/tests/_cython_examples/meson.build +10 -1
- scipy/special/tests/test_basic.py +153 -20
- scipy/special/tests/test_boost_ufuncs.py +3 -0
- scipy/special/tests/test_cdflib.py +35 -11
- scipy/special/tests/test_gammainc.py +16 -0
- scipy/special/tests/test_hyp2f1.py +2 -2
- scipy/special/tests/test_log1mexp.py +85 -0
- scipy/special/tests/test_logsumexp.py +206 -64
- scipy/special/tests/test_mpmath.py +1 -0
- scipy/special/tests/test_nan_inputs.py +1 -1
- scipy/special/tests/test_orthogonal.py +17 -18
- scipy/special/tests/test_sf_error.py +3 -2
- scipy/special/tests/test_sph_harm.py +6 -7
- scipy/special/tests/test_support_alternative_backends.py +211 -76
- scipy/stats/__init__.py +4 -1
- scipy/stats/_ansari_swilk_statistics.cpython-313t-darwin.so +0 -0
- scipy/stats/_axis_nan_policy.py +5 -12
- scipy/stats/_biasedurn.cpython-313t-darwin.so +0 -0
- scipy/stats/_continued_fraction.py +387 -0
- scipy/stats/_continuous_distns.py +277 -310
- scipy/stats/_correlation.py +1 -1
- scipy/stats/_covariance.py +6 -3
- scipy/stats/_discrete_distns.py +39 -32
- scipy/stats/_distn_infrastructure.py +39 -12
- scipy/stats/_distribution_infrastructure.py +900 -238
- scipy/stats/_entropy.py +9 -10
- scipy/{_lib → stats}/_finite_differences.py +1 -1
- scipy/stats/_hypotests.py +83 -50
- scipy/stats/_kde.py +53 -49
- scipy/stats/_ksstats.py +1 -1
- scipy/stats/_levy_stable/__init__.py +7 -15
- scipy/stats/_levy_stable/levyst.cpython-313t-darwin.so +0 -0
- scipy/stats/_morestats.py +118 -73
- scipy/stats/_mstats_basic.py +13 -17
- scipy/stats/_mstats_extras.py +8 -8
- scipy/stats/_multivariate.py +89 -113
- scipy/stats/_new_distributions.py +97 -20
- scipy/stats/_page_trend_test.py +12 -5
- scipy/stats/_probability_distribution.py +265 -43
- scipy/stats/_qmc.py +14 -9
- scipy/stats/_qmc_cy.cpython-313t-darwin.so +0 -0
- scipy/stats/_qmvnt.py +16 -95
- scipy/stats/_qmvnt_cy.cpython-313t-darwin.so +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/rcont.cpython-313t-darwin.so +0 -0
- scipy/stats/_resampling.py +4 -29
- scipy/stats/_sampling.py +1 -1
- scipy/stats/_sobol.cpython-313t-darwin.so +0 -0
- scipy/stats/_stats.cpython-313t-darwin.so +0 -0
- scipy/stats/_stats_mstats_common.py +21 -2
- scipy/stats/_stats_py.py +550 -476
- scipy/stats/_stats_pythran.cpython-313t-darwin.so +0 -0
- scipy/stats/_unuran/unuran_wrapper.cpython-313t-darwin.so +0 -0
- scipy/stats/_unuran/unuran_wrapper.pyi +2 -1
- scipy/stats/_variation.py +6 -8
- scipy/stats/_wilcoxon.py +13 -7
- scipy/stats/tests/common_tests.py +6 -4
- scipy/stats/tests/test_axis_nan_policy.py +62 -24
- scipy/stats/tests/test_continued_fraction.py +173 -0
- scipy/stats/tests/test_continuous.py +379 -60
- scipy/stats/tests/test_continuous_basic.py +18 -12
- scipy/stats/tests/test_discrete_basic.py +14 -8
- scipy/stats/tests/test_discrete_distns.py +16 -16
- scipy/stats/tests/test_distributions.py +95 -75
- scipy/stats/tests/test_entropy.py +40 -48
- scipy/stats/tests/test_fit.py +4 -3
- scipy/stats/tests/test_hypotests.py +153 -24
- scipy/stats/tests/test_kdeoth.py +109 -41
- scipy/stats/tests/test_marray.py +289 -0
- scipy/stats/tests/test_morestats.py +79 -47
- scipy/stats/tests/test_mstats_basic.py +3 -3
- scipy/stats/tests/test_multivariate.py +434 -83
- scipy/stats/tests/test_qmc.py +13 -10
- scipy/stats/tests/test_quantile.py +199 -0
- scipy/stats/tests/test_rank.py +119 -112
- scipy/stats/tests/test_resampling.py +47 -56
- scipy/stats/tests/test_sampling.py +9 -4
- scipy/stats/tests/test_stats.py +799 -939
- scipy/stats/tests/test_variation.py +8 -6
- scipy/version.py +2 -2
- {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/LICENSE.txt +4 -4
- {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/METADATA +11 -11
- {scipy-1.15.3.dist-info → scipy-1.16.0rc2.dist-info}/RECORD +559 -566
- scipy-1.16.0rc2.dist-info/WHEEL +6 -0
- scipy/_lib/array_api_extra/_funcs.py +0 -484
- scipy/_lib/array_api_extra/_typing.py +0 -8
- scipy/interpolate/_bspl.cpython-313t-darwin.so +0 -0
- scipy/optimize/_cobyla.cpython-313t-darwin.so +0 -0
- scipy/optimize/_cython_nnls.cpython-313t-darwin.so +0 -0
- scipy/optimize/_slsqp.cpython-313t-darwin.so +0 -0
- scipy/spatial/qhull_src/COPYING.txt +0 -38
- scipy/special/libsf_error_state.dylib +0 -0
- scipy/special/tests/test_log_softmax.py +0 -109
- scipy/special/tests/test_xsf_cuda.py +0 -114
- scipy/special/xsf/binom.h +0 -89
- scipy/special/xsf/cdflib.h +0 -100
- scipy/special/xsf/cephes/airy.h +0 -307
- scipy/special/xsf/cephes/besselpoly.h +0 -51
- scipy/special/xsf/cephes/beta.h +0 -257
- scipy/special/xsf/cephes/cbrt.h +0 -131
- scipy/special/xsf/cephes/chbevl.h +0 -85
- scipy/special/xsf/cephes/chdtr.h +0 -193
- scipy/special/xsf/cephes/const.h +0 -87
- scipy/special/xsf/cephes/ellie.h +0 -293
- scipy/special/xsf/cephes/ellik.h +0 -251
- scipy/special/xsf/cephes/ellpe.h +0 -107
- scipy/special/xsf/cephes/ellpk.h +0 -117
- scipy/special/xsf/cephes/expn.h +0 -260
- scipy/special/xsf/cephes/gamma.h +0 -398
- scipy/special/xsf/cephes/hyp2f1.h +0 -596
- scipy/special/xsf/cephes/hyperg.h +0 -361
- scipy/special/xsf/cephes/i0.h +0 -149
- scipy/special/xsf/cephes/i1.h +0 -158
- scipy/special/xsf/cephes/igam.h +0 -421
- scipy/special/xsf/cephes/igam_asymp_coeff.h +0 -195
- scipy/special/xsf/cephes/igami.h +0 -313
- scipy/special/xsf/cephes/j0.h +0 -225
- scipy/special/xsf/cephes/j1.h +0 -198
- scipy/special/xsf/cephes/jv.h +0 -715
- scipy/special/xsf/cephes/k0.h +0 -164
- scipy/special/xsf/cephes/k1.h +0 -163
- scipy/special/xsf/cephes/kn.h +0 -243
- scipy/special/xsf/cephes/lanczos.h +0 -112
- scipy/special/xsf/cephes/ndtr.h +0 -275
- scipy/special/xsf/cephes/poch.h +0 -85
- scipy/special/xsf/cephes/polevl.h +0 -167
- scipy/special/xsf/cephes/psi.h +0 -194
- scipy/special/xsf/cephes/rgamma.h +0 -111
- scipy/special/xsf/cephes/scipy_iv.h +0 -811
- scipy/special/xsf/cephes/shichi.h +0 -248
- scipy/special/xsf/cephes/sici.h +0 -224
- scipy/special/xsf/cephes/sindg.h +0 -221
- scipy/special/xsf/cephes/tandg.h +0 -139
- scipy/special/xsf/cephes/trig.h +0 -58
- scipy/special/xsf/cephes/unity.h +0 -186
- scipy/special/xsf/cephes/zeta.h +0 -172
- scipy/special/xsf/config.h +0 -304
- scipy/special/xsf/digamma.h +0 -205
- scipy/special/xsf/error.h +0 -57
- scipy/special/xsf/evalpoly.h +0 -47
- scipy/special/xsf/expint.h +0 -266
- scipy/special/xsf/hyp2f1.h +0 -694
- scipy/special/xsf/iv_ratio.h +0 -173
- scipy/special/xsf/lambertw.h +0 -150
- scipy/special/xsf/loggamma.h +0 -163
- scipy/special/xsf/sici.h +0 -200
- scipy/special/xsf/tools.h +0 -427
- scipy/special/xsf/trig.h +0 -164
- scipy/special/xsf/wright_bessel.h +0 -843
- scipy/special/xsf/zlog1.h +0 -35
- scipy/stats/_mvn.cpython-313t-darwin.so +0 -0
- scipy-1.15.3.dist-info/WHEEL +0 -4
scipy/sparse/tests/test_coo.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
import math
|
1
2
|
import numpy as np
|
2
|
-
from numpy.testing import assert_equal
|
3
|
+
from numpy.testing import assert_equal, assert_allclose, suppress_warnings
|
3
4
|
import pytest
|
4
5
|
from scipy.linalg import block_diag
|
5
|
-
from scipy.sparse import coo_array, random_array
|
6
|
+
from scipy.sparse import coo_array, random_array, SparseEfficiencyWarning
|
6
7
|
from .._coo import _block_diag, _extract_block_diag
|
7
8
|
|
8
9
|
|
@@ -563,8 +564,7 @@ def test_nd_add_sparse_with_inconsistent_shapes(a_shape, b_shape):
|
|
563
564
|
|
564
565
|
arr_a = random_array((a_shape), density=0.6, rng=rng, dtype=int)
|
565
566
|
arr_b = random_array((b_shape), density=0.6, rng=rng, dtype=int)
|
566
|
-
with pytest.raises(ValueError,
|
567
|
-
match="(Incompatible|inconsistent) shapes|cannot be broadcast"):
|
567
|
+
with pytest.raises(ValueError, match="inconsistent shapes"):
|
568
568
|
arr_a + arr_b
|
569
569
|
|
570
570
|
|
@@ -849,3 +849,271 @@ def test_extract_block_diag(shape):
|
|
849
849
|
res = _extract_block_diag(_block_diag(sp_x), shape)
|
850
850
|
|
851
851
|
assert_equal(res.toarray(), sp_x.toarray())
|
852
|
+
|
853
|
+
|
854
|
+
add_sub_shapes = [
|
855
|
+
((3,4), (3,4)), ((3,4,6), (3,4,6)), ((3,7,5), (3,7,5))
|
856
|
+
]
|
857
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), add_sub_shapes)
|
858
|
+
def test_add_no_broadcasting(a_shape, b_shape):
|
859
|
+
rng = np.random.default_rng(23409823)
|
860
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
861
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
862
|
+
|
863
|
+
res = a + b
|
864
|
+
exp = np.add(a.toarray(), b.toarray())
|
865
|
+
assert_equal(res.toarray(), exp)
|
866
|
+
res = a + b.toarray()
|
867
|
+
assert_equal(res, exp)
|
868
|
+
|
869
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), add_sub_shapes)
|
870
|
+
def test_sub_no_broadcasting(a_shape, b_shape):
|
871
|
+
rng = np.random.default_rng(23409823)
|
872
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
873
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
874
|
+
|
875
|
+
res = a - b
|
876
|
+
exp = np.subtract(a.toarray(), b.toarray())
|
877
|
+
assert_equal(res.toarray(), exp)
|
878
|
+
|
879
|
+
res = a - b.toarray()
|
880
|
+
assert_equal(res, exp)
|
881
|
+
|
882
|
+
argmax_argmin_shapes_axis = [
|
883
|
+
((3,), None), ((3,), 0),
|
884
|
+
((4,6), 1), ((7,3), 0), ((3,5), None),
|
885
|
+
((2,8,7), 2), ((2,8,7), 0),
|
886
|
+
((2,0), 0), ((3,0,0,2), 0),
|
887
|
+
((3,2,4,7), None), ((3,2,4,7), 1), ((3,2,4,7), 0), ((3,2,4,7), 2),
|
888
|
+
((3,2,4,7), -2), ((4,5,7,8,2), 4), ((4,5,7,8,2), -3),
|
889
|
+
]
|
890
|
+
@pytest.mark.parametrize(('shape', 'axis'), argmax_argmin_shapes_axis)
|
891
|
+
def test_argmax_argmin(shape, axis):
|
892
|
+
rng = np.random.default_rng(23409823)
|
893
|
+
a = random_array(shape, density=0.6, random_state=rng, dtype=int)
|
894
|
+
|
895
|
+
res = a.argmax(axis=axis)
|
896
|
+
exp = np.argmax(a.toarray(), axis=axis)
|
897
|
+
assert_equal(res, exp)
|
898
|
+
|
899
|
+
res = a.argmin(axis=axis)
|
900
|
+
exp = np.argmin(a.toarray(), axis=axis)
|
901
|
+
assert_equal(res, exp)
|
902
|
+
|
903
|
+
|
904
|
+
max_min_shapes_axis = [
|
905
|
+
((3,), None), ((3,), 0),
|
906
|
+
((4,6), 1), ((7,3), 0), ((3,5), None),
|
907
|
+
((2,8,7), 2), ((2,8,7), 0),
|
908
|
+
((3,2,4,7), None), ((3,2,4,7), 1), ((3,2,4,7), 0), ((3,2,4,7), 2),
|
909
|
+
((4,5,7,8,2), 4), ((4,5,8,1), 3), ((4,6), (0,)), ((4,6), (0,1)),
|
910
|
+
((3,0,2), 2), ((3,0,2), (0,2)), ((3,0), 0),
|
911
|
+
((3,7,8,5), (0,1)), ((3,7,8,5), (2,1)), ((3,7,8,5), (2,0)),
|
912
|
+
((3,7,8,5), (0,-2)), ((3,7,8,5), (-1,2)), ((3,7,8,5), (3)),
|
913
|
+
((3,7,8,5), (0,1,2)), ((3,7,8,5), (0,1,2,3)),
|
914
|
+
]
|
915
|
+
@pytest.mark.parametrize(('shape', 'axis'), max_min_shapes_axis)
|
916
|
+
def test_min_max(shape, axis):
|
917
|
+
rng = np.random.default_rng(23409823)
|
918
|
+
a = random_array(shape, density=0.6, random_state=rng, dtype=int)
|
919
|
+
|
920
|
+
res_min = a.min(axis=axis)
|
921
|
+
exp_min = np.min(a.toarray(), axis=axis)
|
922
|
+
res_max = a.max(axis=axis)
|
923
|
+
exp_max = np.max(a.toarray(), axis=axis)
|
924
|
+
res_nanmin = a.nanmin(axis=axis)
|
925
|
+
exp_nanmin = np.nanmin(a.toarray(), axis=axis)
|
926
|
+
res_nanmax = a.nanmax(axis=axis)
|
927
|
+
exp_nanmax = np.nanmax(a.toarray(), axis=axis)
|
928
|
+
|
929
|
+
for res, exp in [(res_min, exp_min), (res_max, exp_max),
|
930
|
+
(res_nanmin, exp_nanmin), (res_nanmax, exp_nanmax)]:
|
931
|
+
if np.issubdtype(type(res), np.number):
|
932
|
+
assert_equal(res, exp)
|
933
|
+
else:
|
934
|
+
assert_equal(res.toarray(), exp)
|
935
|
+
|
936
|
+
|
937
|
+
def test_min_max_full():
|
938
|
+
for a in (coo_array([[[1, 2, 3, 4]]]), coo_array([[1, 2, 3, 4]])):
|
939
|
+
assert a.min() == 1
|
940
|
+
assert (-a).max() == -1
|
941
|
+
|
942
|
+
|
943
|
+
sum_mean_params = [
|
944
|
+
((3,), None, None), ((3,), 0, None),
|
945
|
+
((4,6), 1, None), ((7,3), 0, None), ((3,5), None, None),
|
946
|
+
((2,8,7), 2, None), ((2,8,7), 0, np.zeros((8,7))),
|
947
|
+
((3,2,4,7), None, None), ((3,2,4,7), 1, np.zeros((3,4,7))),
|
948
|
+
((3,2,4,7), 0, None), ((4,5,7,8,2), 4, None),
|
949
|
+
((4,5,8,1), 3, None), ((4,6), (0,), None), ((4,6), (0,1), None),
|
950
|
+
((3,0,2), 2, None), ((3,0,2), (0,2), None), ((3,0), 0, None),
|
951
|
+
((3,7,8,5), (0,1), np.zeros((8,5))), ((3,7,8,5), (2,1), None),
|
952
|
+
((3,7,8,5), (0,-2), None), ((3,7,8,5), (-1,2), np.zeros((3,7))),
|
953
|
+
((3,7,8,5), (3), None), ((3,7,8,5), (0,1,2), np.zeros((5,))),
|
954
|
+
((3,7,8,5), (0,1,2,3), None),
|
955
|
+
]
|
956
|
+
@pytest.mark.parametrize(('shape', 'axis', 'out'), sum_mean_params)
|
957
|
+
def test_sum(shape, axis, out):
|
958
|
+
rng = np.random.default_rng(23409823)
|
959
|
+
a = random_array(shape, density=0.6, random_state=rng, dtype=int)
|
960
|
+
|
961
|
+
res = a.sum(axis=axis, out=out)
|
962
|
+
exp = np.sum(a.toarray(), axis=axis)
|
963
|
+
assert_equal(res, exp)
|
964
|
+
if out is not None:
|
965
|
+
assert_equal(out, exp)
|
966
|
+
assert id(res) == id(out)
|
967
|
+
|
968
|
+
|
969
|
+
@pytest.mark.parametrize(('shape', 'axis', 'out'), sum_mean_params)
|
970
|
+
def test_mean(shape, axis, out):
|
971
|
+
rng = np.random.default_rng(23409823)
|
972
|
+
a = random_array(shape, density=0.6, random_state=rng, dtype=int)
|
973
|
+
|
974
|
+
res = a.mean(axis=axis, out=out)
|
975
|
+
exp = np.mean(a.toarray(), axis=axis)
|
976
|
+
assert_allclose(res, exp)
|
977
|
+
if out is not None:
|
978
|
+
assert id(res) == id(out)
|
979
|
+
assert_allclose(out, exp)
|
980
|
+
|
981
|
+
|
982
|
+
def test_pow_abs_round():
|
983
|
+
rng = np.random.default_rng(23409823)
|
984
|
+
a = random_array((3,6,5,2,4), density=0.6, random_state=rng, dtype=int)
|
985
|
+
assert_allclose((a**3).toarray(), np.power(a.toarray(), 3))
|
986
|
+
assert_allclose((a**7).toarray(), np.power(a.toarray(), 7))
|
987
|
+
assert_allclose(round(a).toarray(), np.round(a.toarray()))
|
988
|
+
assert_allclose(abs(a).toarray(), np.abs(a.toarray()))
|
989
|
+
|
990
|
+
|
991
|
+
#bitwise_op_and_compare_broadcast_shapes = [
|
992
|
+
# ((3,4), (3,4)), ((1,4), (2,1)), ((3,5), (1,)), ((1,), (7,8)),
|
993
|
+
# ((3,4,6), (3,4,6)), ((4,3), (2,1,3)), ((2,1,3), (4,3)),
|
994
|
+
# ((3,5,4), (1,)), ((1,), (7,8,4)), ((16,1,6), (2,6)), ((3,7,5), (3,7,5)),
|
995
|
+
# ((16,2,6), (1,2,6)), ((7,8), (5,7,8)), ((4,5,1), (5,1)),
|
996
|
+
# ((6,8,3), (4,1,1,3)), ((1,1,1), (3,4,2)), ((3,4,2), (1,1,1,1,1)),
|
997
|
+
bitwise_op_and_compare_shapes = [
|
998
|
+
((3,4), (3,4)), ((3,4,6), (3,4,6)), ((3,7,5), (3,7,5)),
|
999
|
+
]
|
1000
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), bitwise_op_and_compare_shapes)
|
1001
|
+
def test_boolean_comparisons(a_shape, b_shape):
|
1002
|
+
rng = np.random.default_rng(23409823)
|
1003
|
+
sup = suppress_warnings()
|
1004
|
+
sup.filter(SparseEfficiencyWarning)
|
1005
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
1006
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
1007
|
+
with sup:
|
1008
|
+
assert_equal((a==b).toarray(), a.toarray()==b.toarray())
|
1009
|
+
assert_equal((a!=b).toarray(), a.toarray()!=b.toarray())
|
1010
|
+
assert_equal((a>=b).toarray(), a.toarray()>=b.toarray())
|
1011
|
+
assert_equal((a<=b).toarray(), a.toarray()<=b.toarray())
|
1012
|
+
assert_equal((a>b).toarray(), a.toarray()>b.toarray())
|
1013
|
+
assert_equal((a<b).toarray(), a.toarray()<b.toarray())
|
1014
|
+
assert_equal((a==b).toarray(), np.bitwise_not((a!=b).toarray()))
|
1015
|
+
assert_equal((a>=b).toarray(), np.bitwise_not((a<b).toarray()))
|
1016
|
+
assert_equal((a<=b).toarray(), np.bitwise_not((a>b).toarray()))
|
1017
|
+
|
1018
|
+
|
1019
|
+
def test_boolean_comparisons_with_scalar():
|
1020
|
+
rng = np.random.default_rng(23409823)
|
1021
|
+
sup = suppress_warnings()
|
1022
|
+
sup.filter(SparseEfficiencyWarning)
|
1023
|
+
a = random_array((5,4,8,7), density=0.6, random_state=rng, dtype=int)
|
1024
|
+
with sup:
|
1025
|
+
assert_equal((a==0).toarray(), a.toarray()==0)
|
1026
|
+
assert_equal((a!=0).toarray(), a.toarray()!=0)
|
1027
|
+
assert_equal((a>=1).toarray(), a.toarray()>=1)
|
1028
|
+
assert_equal((a<=1).toarray(), a.toarray()<=1)
|
1029
|
+
assert_equal((a>0).toarray(), a.toarray()>0)
|
1030
|
+
assert_equal((a<0).toarray(), a.toarray()<0)
|
1031
|
+
|
1032
|
+
|
1033
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), bitwise_op_and_compare_shapes)
|
1034
|
+
def test_multiply(a_shape, b_shape):
|
1035
|
+
rng = np.random.default_rng(23409823)
|
1036
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
1037
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
1038
|
+
res = a * b
|
1039
|
+
exp = np.multiply(a.toarray(), b.toarray())
|
1040
|
+
assert_equal(res.toarray(), exp)
|
1041
|
+
|
1042
|
+
|
1043
|
+
def test_multiply_with_scalar():
|
1044
|
+
rng = np.random.default_rng(23409823)
|
1045
|
+
a = random_array((3,5,4), density=0.6, random_state=rng, dtype=int)
|
1046
|
+
res = a * 7
|
1047
|
+
exp = np.multiply(a.toarray(), 7)
|
1048
|
+
assert_equal(res.toarray(), exp)
|
1049
|
+
|
1050
|
+
|
1051
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), bitwise_op_and_compare_shapes)
|
1052
|
+
def test_divide(a_shape, b_shape):
|
1053
|
+
rng = np.random.default_rng(23409823)
|
1054
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
1055
|
+
b = np.arange(1, 1 + math.prod(b_shape)).reshape(b_shape)
|
1056
|
+
res = a / b
|
1057
|
+
exp = a.toarray() / b
|
1058
|
+
assert_allclose(res.toarray(), exp)
|
1059
|
+
|
1060
|
+
res = a / b
|
1061
|
+
assert_allclose(res.toarray(), exp)
|
1062
|
+
|
1063
|
+
|
1064
|
+
def test_divide_with_scalar():
|
1065
|
+
rng = np.random.default_rng(23409823)
|
1066
|
+
a = random_array((3,5,4), density=0.6, random_state=rng, dtype=int)
|
1067
|
+
res = a / 7
|
1068
|
+
exp = a.toarray() / 7
|
1069
|
+
assert_allclose(res.toarray(), exp)
|
1070
|
+
|
1071
|
+
|
1072
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), bitwise_op_and_compare_shapes)
|
1073
|
+
def test_maximum(a_shape, b_shape):
|
1074
|
+
rng = np.random.default_rng(23409823)
|
1075
|
+
sup = suppress_warnings()
|
1076
|
+
sup.filter(SparseEfficiencyWarning)
|
1077
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
1078
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
1079
|
+
with sup:
|
1080
|
+
res = a.maximum(b)
|
1081
|
+
exp = np.maximum(a.toarray(), b.toarray())
|
1082
|
+
assert_equal(res.toarray(), exp)
|
1083
|
+
|
1084
|
+
@pytest.mark.parametrize(('a_shape', 'b_shape'), bitwise_op_and_compare_shapes)
|
1085
|
+
def test_minimum(a_shape, b_shape):
|
1086
|
+
rng = np.random.default_rng(23409823)
|
1087
|
+
sup = suppress_warnings()
|
1088
|
+
sup.filter(SparseEfficiencyWarning)
|
1089
|
+
a = random_array(a_shape, density=0.6, random_state=rng, dtype=int)
|
1090
|
+
b = random_array(b_shape, density=0.6, random_state=rng, dtype=int)
|
1091
|
+
with sup:
|
1092
|
+
res = a.minimum(b)
|
1093
|
+
exp = np.minimum(a.toarray(), b.toarray())
|
1094
|
+
assert_equal(res.toarray(), exp)
|
1095
|
+
|
1096
|
+
|
1097
|
+
def test_maximum_with_scalar():
|
1098
|
+
sup = suppress_warnings()
|
1099
|
+
sup.filter(SparseEfficiencyWarning)
|
1100
|
+
a = coo_array([0,1,6])
|
1101
|
+
b = coo_array([[15, 0], [14, 5], [0, -12]])
|
1102
|
+
c = coo_array([[[[3,0], [2,4]], [[8,9], [-3,12]]],
|
1103
|
+
[[[5,2], [3,0]], [[0,7], [0,-6]]]])
|
1104
|
+
with sup:
|
1105
|
+
assert_equal(a.maximum(5).toarray(), np.maximum(a.toarray(), 5))
|
1106
|
+
assert_equal(b.maximum(9).toarray(), np.maximum(b.toarray(), 9))
|
1107
|
+
assert_equal(c.maximum(5).toarray(), np.maximum(c.toarray(), 5))
|
1108
|
+
|
1109
|
+
def test_minimum_with_scalar():
|
1110
|
+
sup = suppress_warnings()
|
1111
|
+
sup.filter(SparseEfficiencyWarning)
|
1112
|
+
a = coo_array([0,1,6])
|
1113
|
+
b = coo_array([[15, 0], [14, 5], [0, -12]])
|
1114
|
+
c = coo_array([[[[3,0], [2,4]], [[8,9], [-3,12]]],
|
1115
|
+
[[[5,2], [3,0]], [[0,7], [0,-6]]]])
|
1116
|
+
with sup:
|
1117
|
+
assert_equal(a.minimum(5).toarray(), np.minimum(a.toarray(), 5))
|
1118
|
+
assert_equal(b.minimum(9).toarray(), np.minimum(b.toarray(), 9))
|
1119
|
+
assert_equal(c.minimum(5).toarray(), np.minimum(c.toarray(), 5))
|
@@ -21,6 +21,7 @@ def int_to_int8(n):
|
|
21
21
|
return (n + 128) % 256 - 128
|
22
22
|
|
23
23
|
|
24
|
+
@pytest.mark.thread_unsafe # Exception handling in CPython 3.13 has races
|
24
25
|
def test_exception():
|
25
26
|
assert_raises(MemoryError, _sparsetools.test_throw_error)
|
26
27
|
|
@@ -68,6 +69,7 @@ def test_regression_std_vector_dtypes():
|
|
68
69
|
|
69
70
|
|
70
71
|
@pytest.mark.slow
|
72
|
+
@pytest.mark.thread_unsafe
|
71
73
|
@pytest.mark.xfail_on_32bit("Can't create large array for test")
|
72
74
|
def test_nnz_overflow():
|
73
75
|
# Regression test for gh-7230 / gh-7871, checking that coo_toarray
|
@@ -88,6 +90,7 @@ def test_nnz_overflow():
|
|
88
90
|
assert_allclose(d, [[4]])
|
89
91
|
|
90
92
|
|
93
|
+
@pytest.mark.thread_unsafe
|
91
94
|
@pytest.mark.skipif(
|
92
95
|
not (sys.platform.startswith('linux') and np.dtype(np.intp).itemsize >= 8),
|
93
96
|
reason="test requires 64-bit Linux"
|
@@ -117,6 +120,7 @@ class TestInt32Overflow:
|
|
117
120
|
def teardown_method(self):
|
118
121
|
gc.collect()
|
119
122
|
|
123
|
+
@pytest.mark.fail_slow(2) # keep in fast set, only non-slow test
|
120
124
|
def test_coo_todense(self):
|
121
125
|
# Check *_todense routines (cf. gh-2179)
|
122
126
|
#
|
@@ -270,6 +274,7 @@ class TestInt32Overflow:
|
|
270
274
|
m2.dot(m) # shouldn't SIGSEGV
|
271
275
|
|
272
276
|
|
277
|
+
@pytest.mark.thread_unsafe
|
273
278
|
@pytest.mark.skip(reason="64-bit indices in sparse matrices not available")
|
274
279
|
def test_csr_matmat_int64_overflow():
|
275
280
|
n = 3037000500
|
@@ -107,13 +107,42 @@ class TestSparseUtils:
|
|
107
107
|
assert_equal(sputils.isdense(matrix([1])), True)
|
108
108
|
|
109
109
|
def test_validateaxis(self):
|
110
|
-
assert_raises(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
with assert_raises(ValueError, match="does not accept 0D axis"):
|
111
|
+
sputils.validateaxis(())
|
112
|
+
|
113
|
+
for ax in [1.5, (0, 1.5), (1.5, 0)]:
|
114
|
+
with assert_raises(TypeError, match="must be an integer"):
|
115
|
+
sputils.validateaxis(ax)
|
116
|
+
for ax in [(1, 1), (1, -1), (0, -2)]:
|
117
|
+
with assert_raises(ValueError, match="duplicate value in axis"):
|
118
|
+
sputils.validateaxis(ax)
|
119
|
+
|
120
|
+
# ndim 1
|
121
|
+
for ax in [1, -2, (0, 1), (1, -1)]:
|
122
|
+
with assert_raises(ValueError, match="out of range"):
|
123
|
+
sputils.validateaxis(ax, ndim=1)
|
124
|
+
with assert_raises(ValueError, match="duplicate value in axis"):
|
125
|
+
sputils.validateaxis((0, -1), ndim=1)
|
126
|
+
# all valid axis values lead to None when canonical
|
127
|
+
for axis in (0, -1, None, (0,), (-1,)):
|
128
|
+
assert sputils.validateaxis(axis, ndim=1) is None
|
129
|
+
|
130
|
+
# ndim 2
|
131
|
+
for ax in [5, -5, (0, 5), (-5, 0)]:
|
132
|
+
with assert_raises(ValueError, match="out of range"):
|
133
|
+
sputils.validateaxis(ax, ndim=2)
|
134
|
+
for axis in ((0,), (1,), None):
|
135
|
+
assert sputils.validateaxis(axis, ndim=2) == axis
|
136
|
+
axis_2d = {-2: (0,), -1: (1,), 0: (0,), 1: (1,), (0, 1): None, (0, -1): None}
|
137
|
+
for axis, canonical_axis in axis_2d.items():
|
138
|
+
assert sputils.validateaxis(axis, ndim=2) == canonical_axis
|
139
|
+
|
140
|
+
# ndim 4
|
141
|
+
for axis in ((2,), (3,), (2, 3), (2, 1), (0, 3)):
|
142
|
+
assert sputils.validateaxis(axis, ndim=4) == axis
|
143
|
+
axis_4d = {-4: (0,), -3: (1,), 2: (2,), 3: (3,), (3, -4): (3, 0)}
|
144
|
+
for axis, canonical_axis in axis_4d.items():
|
145
|
+
sputils.validateaxis(axis, ndim=4) == canonical_axis
|
117
146
|
|
118
147
|
@pytest.mark.parametrize("container", [csr_array, bsr_array])
|
119
148
|
def test_safely_cast_index_compressed(self, container):
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
scipy/spatial/distance.py
CHANGED
@@ -107,20 +107,19 @@ __all__ = [
|
|
107
107
|
|
108
108
|
import math
|
109
109
|
import warnings
|
110
|
-
import numpy as np
|
111
110
|
import dataclasses
|
112
|
-
|
113
111
|
from collections.abc import Callable
|
114
112
|
from functools import partial
|
115
|
-
from scipy._lib._util import _asarray_validated, _transition_to_rng
|
116
|
-
from scipy._lib.deprecation import _deprecated
|
117
113
|
|
118
|
-
|
119
|
-
from . import _hausdorff
|
120
|
-
from ..linalg import norm
|
121
|
-
from ..special import rel_entr
|
114
|
+
import numpy as np
|
122
115
|
|
123
|
-
from . import
|
116
|
+
from scipy._lib._array_api import _asarray
|
117
|
+
from scipy._lib._util import _asarray_validated, _transition_to_rng
|
118
|
+
from scipy._lib import array_api_extra as xpx
|
119
|
+
from scipy._lib.deprecation import _deprecated
|
120
|
+
from scipy.linalg import norm
|
121
|
+
from scipy.special import rel_entr
|
122
|
+
from . import _hausdorff, _distance_pybind, _distance_wrap
|
124
123
|
|
125
124
|
|
126
125
|
def _copy_array_if_base_present(a):
|
@@ -222,9 +221,8 @@ def _validate_hamming_kwargs(X, m, n, **kwargs):
|
|
222
221
|
w = kwargs.get('w', np.ones((n,), dtype='double'))
|
223
222
|
|
224
223
|
if w.ndim != 1 or w.shape[0] != n:
|
225
|
-
raise ValueError(
|
226
|
-
|
227
|
-
)
|
224
|
+
raise ValueError(f"Weights must have same size as input vector. "
|
225
|
+
f"{w.shape[0]} vs. {n}")
|
228
226
|
|
229
227
|
kwargs['w'] = _validate_weights(w)
|
230
228
|
return kwargs
|
@@ -236,11 +234,10 @@ def _validate_mahalanobis_kwargs(X, m, n, **kwargs):
|
|
236
234
|
if m <= n:
|
237
235
|
# There are fewer observations than the dimension of
|
238
236
|
# the observations.
|
239
|
-
raise ValueError(
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
"are required." % (m, n, n + 1))
|
237
|
+
raise ValueError(
|
238
|
+
f"The number of observations ({m}) is too small; "
|
239
|
+
f"the covariance matrix is singular. For observations "
|
240
|
+
f"with {n} dimensions, at least {n + 1} observations are required.")
|
244
241
|
if isinstance(X, tuple):
|
245
242
|
X = np.vstack(X)
|
246
243
|
CV = np.atleast_2d(np.cov(X.astype(np.float64, copy=False).T))
|
@@ -2295,14 +2292,33 @@ def pdist(X, metric='euclidean', *, out=None, **kwargs):
|
|
2295
2292
|
# between all pairs of vectors in X using the distance metric 'abc' but
|
2296
2293
|
# with a more succinct, verifiable, but less efficient implementation.
|
2297
2294
|
|
2295
|
+
X = _asarray(X)
|
2296
|
+
if X.ndim != 2:
|
2297
|
+
raise ValueError(f'A 2-dimensional array must be passed. (Shape was {X.shape}).')
|
2298
|
+
|
2299
|
+
n = X.shape[0]
|
2300
|
+
return xpx.lazy_apply(_np_pdist, X, out,
|
2301
|
+
# lazy_apply doesn't support Array kwargs
|
2302
|
+
kwargs.pop('w', None),
|
2303
|
+
kwargs.pop('V', None),
|
2304
|
+
kwargs.pop('VI', None),
|
2305
|
+
# See src/distance_pybind.cpp::pdist
|
2306
|
+
shape=((n * (n - 1)) // 2, ), dtype=X.dtype,
|
2307
|
+
as_numpy=True, metric=metric, **kwargs)
|
2308
|
+
|
2309
|
+
|
2310
|
+
def _np_pdist(X, out, w, V, VI, metric='euclidean', **kwargs):
|
2311
|
+
|
2298
2312
|
X = _asarray_validated(X, sparse_ok=False, objects_ok=True, mask_ok=True,
|
2299
2313
|
check_finite=False)
|
2314
|
+
m, n = X.shape
|
2300
2315
|
|
2301
|
-
|
2302
|
-
|
2303
|
-
|
2304
|
-
|
2305
|
-
|
2316
|
+
if w is not None:
|
2317
|
+
kwargs["w"] = w
|
2318
|
+
if V is not None:
|
2319
|
+
kwargs["V"] = V
|
2320
|
+
if VI is not None:
|
2321
|
+
kwargs["VI"] = VI
|
2306
2322
|
|
2307
2323
|
if callable(metric):
|
2308
2324
|
mstr = getattr(metric, '__name__', 'UnknownCustomMetric')
|
@@ -2622,7 +2638,7 @@ def is_valid_y(y, warning=False, throw=False, name=None):
|
|
2622
2638
|
throw : bool, optional
|
2623
2639
|
Throws an exception if the variable passed is not a valid
|
2624
2640
|
condensed distance matrix.
|
2625
|
-
name :
|
2641
|
+
name : str, optional
|
2626
2642
|
Used when referencing the offending variable in the
|
2627
2643
|
warning or exception message.
|
2628
2644
|
|
@@ -2650,34 +2666,25 @@ def is_valid_y(y, warning=False, throw=False, name=None):
|
|
2650
2666
|
False
|
2651
2667
|
|
2652
2668
|
"""
|
2653
|
-
y =
|
2654
|
-
|
2669
|
+
y = _asarray(y)
|
2670
|
+
name_str = f"'{name}' " if name else ""
|
2655
2671
|
try:
|
2656
2672
|
if len(y.shape) != 1:
|
2657
|
-
|
2658
|
-
|
2659
|
-
"have shape=1 (i.e. be one-dimensional).")
|
2660
|
-
else:
|
2661
|
-
raise ValueError('Condensed distance matrix must have shape=1 '
|
2662
|
-
'(i.e. be one-dimensional).')
|
2673
|
+
raise ValueError(f"Condensed distance matrix {name_str}must "
|
2674
|
+
"have shape=1 (i.e. be one-dimensional).")
|
2663
2675
|
n = y.shape[0]
|
2664
2676
|
d = int(np.ceil(np.sqrt(n * 2)))
|
2665
2677
|
if (d * (d - 1) / 2) != n:
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
"there must be a k such that (k \\choose 2)=n)!")
|
2670
|
-
else:
|
2671
|
-
raise ValueError('Length n of condensed distance matrix must '
|
2672
|
-
'be a binomial coefficient, i.e. there must '
|
2673
|
-
'be a k such that (k \\choose 2)=n)!')
|
2678
|
+
raise ValueError(f"Length n of condensed distance matrix {name_str}"
|
2679
|
+
"must be a binomial coefficient, i.e. "
|
2680
|
+
"there must be a k such that (k \\choose 2)=n)!")
|
2674
2681
|
except Exception as e:
|
2675
2682
|
if throw:
|
2676
2683
|
raise
|
2677
2684
|
if warning:
|
2678
2685
|
warnings.warn(str(e), stacklevel=2)
|
2679
|
-
|
2680
|
-
return
|
2686
|
+
return False
|
2687
|
+
return True
|
2681
2688
|
|
2682
2689
|
|
2683
2690
|
def num_obs_dm(d):
|
@@ -2735,7 +2742,7 @@ def num_obs_y(Y):
|
|
2735
2742
|
>>> num_obs_y(Y)
|
2736
2743
|
4
|
2737
2744
|
"""
|
2738
|
-
Y =
|
2745
|
+
Y = _asarray(Y)
|
2739
2746
|
is_valid_y(Y, throw=True, name='Y')
|
2740
2747
|
k = Y.shape[0]
|
2741
2748
|
if k == 0:
|
@@ -63,6 +63,7 @@ from scipy.spatial.distance import (braycurtis, canberra, chebyshev, cityblock,
|
|
63
63
|
russellrao, seuclidean, sokalmichener, # noqa: F401
|
64
64
|
sokalsneath, sqeuclidean, yule)
|
65
65
|
from scipy._lib._util import np_long, np_ulong
|
66
|
+
from scipy.conftest import skip_xp_invalid_arg
|
66
67
|
|
67
68
|
|
68
69
|
@pytest.fixture(params=_METRICS_NAMES, scope="session")
|
@@ -1370,6 +1371,7 @@ class TestPdist:
|
|
1370
1371
|
right_y = 0.01492537
|
1371
1372
|
assert_allclose(pdist_y, right_y, atol=eps, verbose=verbose > 2)
|
1372
1373
|
|
1374
|
+
@skip_xp_invalid_arg
|
1373
1375
|
def test_pdist_custom_notdouble(self):
|
1374
1376
|
# tests that when using a custom metric the data type is not altered
|
1375
1377
|
class myclass:
|
@@ -2106,7 +2108,7 @@ def test_Xdist_deprecated_args(metric):
|
|
2106
2108
|
pdist(X1, metric, 2.)
|
2107
2109
|
|
2108
2110
|
for arg in ["p", "V", "VI"]:
|
2109
|
-
kwargs = {arg:
|
2111
|
+
kwargs = {arg: np.asarray(1.)}
|
2110
2112
|
|
2111
2113
|
if ((arg == "V" and metric == "seuclidean")
|
2112
2114
|
or (arg == "VI" and metric == "mahalanobis")
|
@@ -2229,6 +2231,18 @@ def test_immutable_input(metric):
|
|
2229
2231
|
getattr(scipy.spatial.distance, metric)(x, x, w=x)
|
2230
2232
|
|
2231
2233
|
|
2234
|
+
def test_gh_23109():
|
2235
|
+
a = np.array([0, 0, 1, 1])
|
2236
|
+
b = np.array([0, 1, 1, 0])
|
2237
|
+
w = np.asarray([1.5, 1.2, 0.7, 1.3])
|
2238
|
+
expected = yule(a, b, w=w)
|
2239
|
+
assert_allclose(expected, 1.1954022988505748)
|
2240
|
+
actual = cdist(np.atleast_2d(a),
|
2241
|
+
np.atleast_2d(b),
|
2242
|
+
metric='yule', w=w)
|
2243
|
+
assert_allclose(actual, expected)
|
2244
|
+
|
2245
|
+
|
2232
2246
|
class TestJaccard:
|
2233
2247
|
|
2234
2248
|
def test_pdist_jaccard_random(self):
|
@@ -111,7 +111,7 @@ def _add_inc_data(name, chunksize):
|
|
111
111
|
for j in range(nmin, len(points), chunksize):
|
112
112
|
chunks.append(points[j:j+chunksize])
|
113
113
|
|
114
|
-
new_name = "
|
114
|
+
new_name = f"{name}-chunk-{chunksize}"
|
115
115
|
assert new_name not in INCREMENTAL_DATASETS
|
116
116
|
INCREMENTAL_DATASETS[new_name] = (chunks, opts)
|
117
117
|
|
@@ -362,7 +362,7 @@ class TestUtilities:
|
|
362
362
|
list(map(np.ravel, np.broadcast_arrays(*np.ix_(*([x]*ndim)))))
|
363
363
|
].T
|
364
364
|
|
365
|
-
err_msg = "ndim
|
365
|
+
err_msg = f"ndim={ndim}"
|
366
366
|
|
367
367
|
# Check using regular grid
|
368
368
|
tri = qhull.Delaunay(grid)
|
@@ -428,6 +428,10 @@ class TestDelaunay:
|
|
428
428
|
masked_array = np.ma.masked_all(1)
|
429
429
|
assert_raises(ValueError, qhull.Delaunay, masked_array)
|
430
430
|
|
431
|
+
# Shouldn't be inherently unsafe; retry with cpython 3.14 once traceback
|
432
|
+
# thread safety issues are fixed (also goes for other test with same name
|
433
|
+
# further down)
|
434
|
+
@pytest.mark.thread_unsafe
|
431
435
|
def test_array_with_nans_fails(self):
|
432
436
|
points_with_nan = np.array([(0,0), (0,1), (1,1), (1,np.nan)], dtype=np.float64)
|
433
437
|
assert_raises(ValueError, qhull.Delaunay, points_with_nan)
|
@@ -607,6 +611,7 @@ class TestConvexHull:
|
|
607
611
|
masked_array = np.ma.masked_all(1)
|
608
612
|
assert_raises(ValueError, qhull.ConvexHull, masked_array)
|
609
613
|
|
614
|
+
@pytest.mark.thread_unsafe
|
610
615
|
def test_array_with_nans_fails(self):
|
611
616
|
points_with_nan = np.array([(0,0), (1,1), (2,np.nan)], dtype=np.float64)
|
612
617
|
assert_raises(ValueError, qhull.ConvexHull, points_with_nan)
|
@@ -4,25 +4,27 @@ Spatial Transformations (:mod:`scipy.spatial.transform`)
|
|
4
4
|
|
5
5
|
.. currentmodule:: scipy.spatial.transform
|
6
6
|
|
7
|
-
This package implements various spatial transformations. For now,
|
8
|
-
|
7
|
+
This package implements various spatial transformations. For now, rotations
|
8
|
+
and rigid transforms (rotations and translations) are supported.
|
9
9
|
|
10
10
|
Rotations in 3 dimensions
|
11
11
|
-------------------------
|
12
12
|
.. autosummary::
|
13
13
|
:toctree: generated/
|
14
14
|
|
15
|
+
RigidTransform
|
15
16
|
Rotation
|
16
17
|
Slerp
|
17
18
|
RotationSpline
|
18
19
|
"""
|
20
|
+
from ._rigid_transform import RigidTransform
|
19
21
|
from ._rotation import Rotation, Slerp
|
20
22
|
from ._rotation_spline import RotationSpline
|
21
23
|
|
22
24
|
# Deprecated namespaces, to be removed in v2.0.0
|
23
25
|
from . import rotation
|
24
26
|
|
25
|
-
__all__ = ['Rotation', 'Slerp', 'RotationSpline']
|
27
|
+
__all__ = ['Rotation', 'Slerp', 'RotationSpline', 'RigidTransform']
|
26
28
|
|
27
29
|
from scipy._lib._testutils import PytestTester
|
28
30
|
test = PytestTester(__name__)
|
Binary file
|
Binary file
|