scipy 1.16.2__cp313-cp313t-win_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 +161 -0
- scipy/__init__.py +150 -0
- scipy/_cyutility.cp313t-win_arm64.lib +0 -0
- scipy/_cyutility.cp313t-win_arm64.pyd +0 -0
- scipy/_distributor_init.py +18 -0
- scipy/_lib/__init__.py +14 -0
- scipy/_lib/_array_api.py +931 -0
- scipy/_lib/_array_api_compat_vendor.py +9 -0
- scipy/_lib/_array_api_no_0d.py +103 -0
- scipy/_lib/_bunch.py +229 -0
- scipy/_lib/_ccallback.py +251 -0
- scipy/_lib/_ccallback_c.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_disjoint_set.py +254 -0
- scipy/_lib/_docscrape.py +761 -0
- scipy/_lib/_elementwise_iterative_method.py +346 -0
- scipy/_lib/_fpumode.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_gcutils.py +105 -0
- scipy/_lib/_pep440.py +487 -0
- scipy/_lib/_sparse.py +41 -0
- scipy/_lib/_test_ccallback.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_testutils.py +373 -0
- scipy/_lib/_threadsafety.py +58 -0
- scipy/_lib/_tmpdirs.py +86 -0
- scipy/_lib/_uarray/LICENSE +29 -0
- scipy/_lib/_uarray/__init__.py +116 -0
- scipy/_lib/_uarray/_backend.py +707 -0
- scipy/_lib/_uarray/_uarray.cp313t-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp313t-win_arm64.pyd +0 -0
- scipy/_lib/_util.py +1283 -0
- scipy/_lib/array_api_compat/__init__.py +22 -0
- scipy/_lib/array_api_compat/_internal.py +59 -0
- scipy/_lib/array_api_compat/common/__init__.py +1 -0
- scipy/_lib/array_api_compat/common/_aliases.py +727 -0
- scipy/_lib/array_api_compat/common/_fft.py +213 -0
- scipy/_lib/array_api_compat/common/_helpers.py +1058 -0
- scipy/_lib/array_api_compat/common/_linalg.py +232 -0
- scipy/_lib/array_api_compat/common/_typing.py +192 -0
- scipy/_lib/array_api_compat/cupy/__init__.py +13 -0
- scipy/_lib/array_api_compat/cupy/_aliases.py +156 -0
- scipy/_lib/array_api_compat/cupy/_info.py +336 -0
- scipy/_lib/array_api_compat/cupy/_typing.py +31 -0
- scipy/_lib/array_api_compat/cupy/fft.py +36 -0
- scipy/_lib/array_api_compat/cupy/linalg.py +49 -0
- scipy/_lib/array_api_compat/dask/__init__.py +0 -0
- scipy/_lib/array_api_compat/dask/array/__init__.py +12 -0
- scipy/_lib/array_api_compat/dask/array/_aliases.py +376 -0
- scipy/_lib/array_api_compat/dask/array/_info.py +416 -0
- scipy/_lib/array_api_compat/dask/array/fft.py +21 -0
- scipy/_lib/array_api_compat/dask/array/linalg.py +72 -0
- scipy/_lib/array_api_compat/numpy/__init__.py +28 -0
- scipy/_lib/array_api_compat/numpy/_aliases.py +190 -0
- scipy/_lib/array_api_compat/numpy/_info.py +366 -0
- scipy/_lib/array_api_compat/numpy/_typing.py +30 -0
- scipy/_lib/array_api_compat/numpy/fft.py +35 -0
- scipy/_lib/array_api_compat/numpy/linalg.py +143 -0
- scipy/_lib/array_api_compat/torch/__init__.py +22 -0
- scipy/_lib/array_api_compat/torch/_aliases.py +855 -0
- scipy/_lib/array_api_compat/torch/_info.py +369 -0
- scipy/_lib/array_api_compat/torch/_typing.py +3 -0
- scipy/_lib/array_api_compat/torch/fft.py +85 -0
- scipy/_lib/array_api_compat/torch/linalg.py +121 -0
- scipy/_lib/array_api_extra/__init__.py +38 -0
- 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/cobyqa/__init__.py +20 -0
- scipy/_lib/cobyqa/framework.py +1240 -0
- scipy/_lib/cobyqa/main.py +1506 -0
- scipy/_lib/cobyqa/models.py +1529 -0
- scipy/_lib/cobyqa/problem.py +1296 -0
- scipy/_lib/cobyqa/settings.py +132 -0
- scipy/_lib/cobyqa/subsolvers/__init__.py +14 -0
- scipy/_lib/cobyqa/subsolvers/geometry.py +387 -0
- scipy/_lib/cobyqa/subsolvers/optim.py +1203 -0
- scipy/_lib/cobyqa/utils/__init__.py +18 -0
- scipy/_lib/cobyqa/utils/exceptions.py +22 -0
- scipy/_lib/cobyqa/utils/math.py +77 -0
- scipy/_lib/cobyqa/utils/versions.py +67 -0
- scipy/_lib/decorator.py +399 -0
- scipy/_lib/deprecation.py +274 -0
- scipy/_lib/doccer.py +366 -0
- scipy/_lib/messagestream.cp313t-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp313t-win_arm64.pyd +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/__init__.py +0 -0
- scipy/_lib/tests/test__gcutils.py +110 -0
- scipy/_lib/tests/test__pep440.py +67 -0
- scipy/_lib/tests/test__testutils.py +32 -0
- scipy/_lib/tests/test__threadsafety.py +51 -0
- scipy/_lib/tests/test__util.py +641 -0
- scipy/_lib/tests/test_array_api.py +322 -0
- scipy/_lib/tests/test_bunch.py +169 -0
- scipy/_lib/tests/test_ccallback.py +196 -0
- scipy/_lib/tests/test_config.py +45 -0
- scipy/_lib/tests/test_deprecation.py +10 -0
- scipy/_lib/tests/test_doccer.py +143 -0
- scipy/_lib/tests/test_import_cycles.py +18 -0
- scipy/_lib/tests/test_public_api.py +482 -0
- scipy/_lib/tests/test_scipy_version.py +28 -0
- scipy/_lib/tests/test_tmpdirs.py +48 -0
- scipy/_lib/tests/test_warnings.py +137 -0
- scipy/_lib/uarray.py +31 -0
- scipy/cluster/__init__.py +31 -0
- scipy/cluster/_hierarchy.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp313t-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp313t-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp313t-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp313t-win_arm64.pyd +0 -0
- scipy/cluster/hierarchy.py +4348 -0
- scipy/cluster/tests/__init__.py +0 -0
- scipy/cluster/tests/hierarchy_test_data.py +145 -0
- scipy/cluster/tests/test_disjoint_set.py +202 -0
- scipy/cluster/tests/test_hierarchy.py +1238 -0
- scipy/cluster/tests/test_vq.py +434 -0
- scipy/cluster/vq.py +832 -0
- scipy/conftest.py +683 -0
- scipy/constants/__init__.py +358 -0
- scipy/constants/_codata.py +2266 -0
- scipy/constants/_constants.py +369 -0
- scipy/constants/codata.py +21 -0
- scipy/constants/constants.py +53 -0
- scipy/constants/tests/__init__.py +0 -0
- scipy/constants/tests/test_codata.py +78 -0
- scipy/constants/tests/test_constants.py +83 -0
- scipy/datasets/__init__.py +90 -0
- scipy/datasets/_download_all.py +71 -0
- scipy/datasets/_fetchers.py +225 -0
- scipy/datasets/_registry.py +26 -0
- scipy/datasets/_utils.py +81 -0
- scipy/datasets/tests/__init__.py +0 -0
- scipy/datasets/tests/test_data.py +128 -0
- scipy/differentiate/__init__.py +27 -0
- scipy/differentiate/_differentiate.py +1129 -0
- scipy/differentiate/tests/__init__.py +0 -0
- scipy/differentiate/tests/test_differentiate.py +694 -0
- scipy/fft/__init__.py +114 -0
- scipy/fft/_backend.py +196 -0
- scipy/fft/_basic.py +1650 -0
- scipy/fft/_basic_backend.py +197 -0
- scipy/fft/_debug_backends.py +22 -0
- scipy/fft/_fftlog.py +223 -0
- scipy/fft/_fftlog_backend.py +200 -0
- scipy/fft/_helper.py +348 -0
- scipy/fft/_pocketfft/LICENSE.md +25 -0
- scipy/fft/_pocketfft/__init__.py +9 -0
- scipy/fft/_pocketfft/basic.py +251 -0
- scipy/fft/_pocketfft/helper.py +249 -0
- scipy/fft/_pocketfft/pypocketfft.cp313t-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp313t-win_arm64.pyd +0 -0
- scipy/fft/_pocketfft/realtransforms.py +109 -0
- scipy/fft/_pocketfft/tests/__init__.py +0 -0
- scipy/fft/_pocketfft/tests/test_basic.py +1011 -0
- scipy/fft/_pocketfft/tests/test_real_transforms.py +505 -0
- scipy/fft/_realtransforms.py +706 -0
- scipy/fft/_realtransforms_backend.py +63 -0
- scipy/fft/tests/__init__.py +0 -0
- scipy/fft/tests/mock_backend.py +96 -0
- scipy/fft/tests/test_backend.py +98 -0
- scipy/fft/tests/test_basic.py +504 -0
- scipy/fft/tests/test_fftlog.py +215 -0
- scipy/fft/tests/test_helper.py +558 -0
- scipy/fft/tests/test_multithreading.py +84 -0
- scipy/fft/tests/test_real_transforms.py +247 -0
- scipy/fftpack/__init__.py +103 -0
- scipy/fftpack/_basic.py +428 -0
- scipy/fftpack/_helper.py +115 -0
- scipy/fftpack/_pseudo_diffs.py +554 -0
- scipy/fftpack/_realtransforms.py +598 -0
- scipy/fftpack/basic.py +20 -0
- scipy/fftpack/convolve.cp313t-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp313t-win_arm64.pyd +0 -0
- scipy/fftpack/helper.py +19 -0
- scipy/fftpack/pseudo_diffs.py +22 -0
- scipy/fftpack/realtransforms.py +19 -0
- scipy/fftpack/tests/__init__.py +0 -0
- scipy/fftpack/tests/fftw_double_ref.npz +0 -0
- scipy/fftpack/tests/fftw_longdouble_ref.npz +0 -0
- scipy/fftpack/tests/fftw_single_ref.npz +0 -0
- scipy/fftpack/tests/test.npz +0 -0
- scipy/fftpack/tests/test_basic.py +877 -0
- scipy/fftpack/tests/test_helper.py +54 -0
- scipy/fftpack/tests/test_import.py +33 -0
- scipy/fftpack/tests/test_pseudo_diffs.py +388 -0
- scipy/fftpack/tests/test_real_transforms.py +836 -0
- scipy/integrate/__init__.py +122 -0
- scipy/integrate/_bvp.py +1160 -0
- scipy/integrate/_cubature.py +729 -0
- scipy/integrate/_dop.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_ivp/__init__.py +8 -0
- scipy/integrate/_ivp/base.py +290 -0
- scipy/integrate/_ivp/bdf.py +478 -0
- scipy/integrate/_ivp/common.py +451 -0
- scipy/integrate/_ivp/dop853_coefficients.py +193 -0
- scipy/integrate/_ivp/ivp.py +755 -0
- scipy/integrate/_ivp/lsoda.py +224 -0
- scipy/integrate/_ivp/radau.py +572 -0
- scipy/integrate/_ivp/rk.py +601 -0
- scipy/integrate/_ivp/tests/__init__.py +0 -0
- scipy/integrate/_ivp/tests/test_ivp.py +1287 -0
- scipy/integrate/_ivp/tests/test_rk.py +37 -0
- scipy/integrate/_lebedev.py +5450 -0
- scipy/integrate/_lsoda.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_quadpack_py.py +1283 -0
- scipy/integrate/_quadrature.py +1336 -0
- scipy/integrate/_rules/__init__.py +12 -0
- scipy/integrate/_rules/_base.py +518 -0
- scipy/integrate/_rules/_gauss_kronrod.py +202 -0
- scipy/integrate/_rules/_gauss_legendre.py +62 -0
- scipy/integrate/_rules/_genz_malik.py +210 -0
- scipy/integrate/_tanhsinh.py +1385 -0
- scipy/integrate/_test_multivariate.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp313t-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp313t-win_arm64.pyd +0 -0
- scipy/integrate/dop.py +15 -0
- scipy/integrate/lsoda.py +15 -0
- scipy/integrate/odepack.py +17 -0
- scipy/integrate/quadpack.py +23 -0
- scipy/integrate/tests/__init__.py +0 -0
- scipy/integrate/tests/test__quad_vec.py +211 -0
- scipy/integrate/tests/test_banded_ode_solvers.py +305 -0
- scipy/integrate/tests/test_bvp.py +714 -0
- scipy/integrate/tests/test_cubature.py +1375 -0
- scipy/integrate/tests/test_integrate.py +840 -0
- scipy/integrate/tests/test_odeint_jac.py +74 -0
- scipy/integrate/tests/test_quadpack.py +680 -0
- scipy/integrate/tests/test_quadrature.py +730 -0
- scipy/integrate/tests/test_tanhsinh.py +1171 -0
- scipy/integrate/vode.py +15 -0
- scipy/interpolate/__init__.py +228 -0
- scipy/interpolate/_bary_rational.py +715 -0
- scipy/interpolate/_bsplines.py +2469 -0
- scipy/interpolate/_cubic.py +973 -0
- scipy/interpolate/_dfitpack.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack2.py +2397 -0
- scipy/interpolate/_fitpack_impl.py +811 -0
- scipy/interpolate/_fitpack_py.py +898 -0
- scipy/interpolate/_fitpack_repro.py +996 -0
- scipy/interpolate/_interpnd.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_interpolate.py +2266 -0
- scipy/interpolate/_ndbspline.py +415 -0
- scipy/interpolate/_ndgriddata.py +329 -0
- scipy/interpolate/_pade.py +67 -0
- scipy/interpolate/_polyint.py +1025 -0
- scipy/interpolate/_ppoly.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp313t-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp313t-win_arm64.pyd +0 -0
- scipy/interpolate/dfitpack.py +24 -0
- scipy/interpolate/fitpack.py +31 -0
- scipy/interpolate/fitpack2.py +29 -0
- scipy/interpolate/interpnd.py +24 -0
- scipy/interpolate/interpolate.py +30 -0
- scipy/interpolate/ndgriddata.py +23 -0
- scipy/interpolate/polyint.py +24 -0
- scipy/interpolate/rbf.py +18 -0
- scipy/interpolate/tests/__init__.py +0 -0
- scipy/interpolate/tests/data/bug-1310.npz +0 -0
- scipy/interpolate/tests/data/estimate_gradients_hang.npy +0 -0
- scipy/interpolate/tests/data/gcvspl.npz +0 -0
- scipy/interpolate/tests/test_bary_rational.py +368 -0
- scipy/interpolate/tests/test_bsplines.py +3754 -0
- scipy/interpolate/tests/test_fitpack.py +519 -0
- scipy/interpolate/tests/test_fitpack2.py +1431 -0
- scipy/interpolate/tests/test_gil.py +64 -0
- scipy/interpolate/tests/test_interpnd.py +452 -0
- scipy/interpolate/tests/test_interpolate.py +2630 -0
- scipy/interpolate/tests/test_ndgriddata.py +308 -0
- scipy/interpolate/tests/test_pade.py +107 -0
- scipy/interpolate/tests/test_polyint.py +972 -0
- scipy/interpolate/tests/test_rbf.py +246 -0
- scipy/interpolate/tests/test_rbfinterp.py +534 -0
- scipy/interpolate/tests/test_rgi.py +1151 -0
- scipy/io/__init__.py +116 -0
- scipy/io/_fast_matrix_market/__init__.py +600 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp313t-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp313t-win_arm64.pyd +0 -0
- scipy/io/_fortran.py +354 -0
- scipy/io/_harwell_boeing/__init__.py +7 -0
- scipy/io/_harwell_boeing/_fortran_format_parser.py +316 -0
- scipy/io/_harwell_boeing/hb.py +571 -0
- scipy/io/_harwell_boeing/tests/__init__.py +0 -0
- scipy/io/_harwell_boeing/tests/test_fortran_format.py +74 -0
- scipy/io/_harwell_boeing/tests/test_hb.py +70 -0
- scipy/io/_idl.py +917 -0
- scipy/io/_mmio.py +968 -0
- scipy/io/_netcdf.py +1104 -0
- scipy/io/_test_fortran.cp313t-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp313t-win_arm64.pyd +0 -0
- scipy/io/arff/__init__.py +28 -0
- scipy/io/arff/_arffread.py +873 -0
- scipy/io/arff/arffread.py +19 -0
- scipy/io/arff/tests/__init__.py +0 -0
- scipy/io/arff/tests/data/iris.arff +225 -0
- scipy/io/arff/tests/data/missing.arff +8 -0
- scipy/io/arff/tests/data/nodata.arff +11 -0
- scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
- scipy/io/arff/tests/data/quoted_nominal_spaces.arff +13 -0
- scipy/io/arff/tests/data/test1.arff +10 -0
- scipy/io/arff/tests/data/test10.arff +8 -0
- scipy/io/arff/tests/data/test11.arff +11 -0
- scipy/io/arff/tests/data/test2.arff +15 -0
- scipy/io/arff/tests/data/test3.arff +6 -0
- scipy/io/arff/tests/data/test4.arff +11 -0
- scipy/io/arff/tests/data/test5.arff +26 -0
- scipy/io/arff/tests/data/test6.arff +12 -0
- scipy/io/arff/tests/data/test7.arff +15 -0
- scipy/io/arff/tests/data/test8.arff +12 -0
- scipy/io/arff/tests/data/test9.arff +14 -0
- scipy/io/arff/tests/test_arffread.py +421 -0
- scipy/io/harwell_boeing.py +17 -0
- scipy/io/idl.py +17 -0
- scipy/io/matlab/__init__.py +66 -0
- scipy/io/matlab/_byteordercodes.py +75 -0
- scipy/io/matlab/_mio.py +375 -0
- scipy/io/matlab/_mio4.py +632 -0
- scipy/io/matlab/_mio5.py +901 -0
- scipy/io/matlab/_mio5_params.py +281 -0
- scipy/io/matlab/_mio5_utils.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp313t-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp313t-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp313t-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp313t-win_arm64.pyd +0 -0
- scipy/io/matlab/byteordercodes.py +17 -0
- scipy/io/matlab/mio.py +16 -0
- scipy/io/matlab/mio4.py +17 -0
- scipy/io/matlab/mio5.py +19 -0
- scipy/io/matlab/mio5_params.py +18 -0
- scipy/io/matlab/mio5_utils.py +17 -0
- scipy/io/matlab/mio_utils.py +17 -0
- scipy/io/matlab/miobase.py +16 -0
- scipy/io/matlab/streams.py +16 -0
- scipy/io/matlab/tests/__init__.py +0 -0
- scipy/io/matlab/tests/data/bad_miuint32.mat +0 -0
- scipy/io/matlab/tests/data/bad_miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/big_endian.mat +0 -0
- scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_checksum.mat +0 -0
- scipy/io/matlab/tests/data/corrupted_zlib_data.mat +0 -0
- scipy/io/matlab/tests/data/debigged_m4.mat +0 -0
- scipy/io/matlab/tests/data/japanese_utf8.txt +5 -0
- scipy/io/matlab/tests/data/little_endian.mat +0 -0
- scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
- scipy/io/matlab/tests/data/malformed1.mat +0 -0
- scipy/io/matlab/tests/data/miuint32_for_miint32.mat +0 -0
- scipy/io/matlab/tests/data/miutf8_array_name.mat +0 -0
- scipy/io/matlab/tests/data/nasty_duplicate_fieldnames.mat +0 -0
- scipy/io/matlab/tests/data/one_by_zero_char.mat +0 -0
- scipy/io/matlab/tests/data/parabola.mat +0 -0
- scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
- scipy/io/matlab/tests/data/some_functions.mat +0 -0
- scipy/io/matlab/tests/data/sqr.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/test_empty_struct.mat +0 -0
- scipy/io/matlab/tests/data/test_mat4_le_floats.mat +0 -0
- scipy/io/matlab/tests/data/test_skip_variable.mat +0 -0
- scipy/io/matlab/tests/data/testbool_8_WIN64.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_5.3_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testhdf5_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testminus_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testobject_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsimplecell.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststring_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_4.2c_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.1_SOL2.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_6.5.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.1_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/data/testvec_4_GLNX86.mat +0 -0
- scipy/io/matlab/tests/test_byteordercodes.py +29 -0
- scipy/io/matlab/tests/test_mio.py +1399 -0
- scipy/io/matlab/tests/test_mio5_utils.py +179 -0
- scipy/io/matlab/tests/test_mio_funcs.py +51 -0
- scipy/io/matlab/tests/test_mio_utils.py +45 -0
- scipy/io/matlab/tests/test_miobase.py +32 -0
- scipy/io/matlab/tests/test_pathological.py +33 -0
- scipy/io/matlab/tests/test_streams.py +241 -0
- scipy/io/mmio.py +17 -0
- scipy/io/netcdf.py +17 -0
- scipy/io/tests/__init__.py +0 -0
- scipy/io/tests/data/Transparent Busy.ani +0 -0
- scipy/io/tests/data/array_float32_1d.sav +0 -0
- scipy/io/tests/data/array_float32_2d.sav +0 -0
- scipy/io/tests/data/array_float32_3d.sav +0 -0
- scipy/io/tests/data/array_float32_4d.sav +0 -0
- scipy/io/tests/data/array_float32_5d.sav +0 -0
- scipy/io/tests/data/array_float32_6d.sav +0 -0
- scipy/io/tests/data/array_float32_7d.sav +0 -0
- scipy/io/tests/data/array_float32_8d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_1d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_2d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_3d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_4d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_5d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_6d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_7d.sav +0 -0
- scipy/io/tests/data/array_float32_pointer_8d.sav +0 -0
- scipy/io/tests/data/example_1.nc +0 -0
- scipy/io/tests/data/example_2.nc +0 -0
- scipy/io/tests/data/example_3_maskedvals.nc +0 -0
- scipy/io/tests/data/fortran-3x3d-2i.dat +0 -0
- scipy/io/tests/data/fortran-mixed.dat +0 -0
- scipy/io/tests/data/fortran-sf8-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-sf8-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-sf8-1x3x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-11x1x10.dat +0 -0
- scipy/io/tests/data/fortran-si4-15x10x22.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x1.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x5.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x1x7.dat +0 -0
- scipy/io/tests/data/fortran-si4-1x3x5.dat +0 -0
- scipy/io/tests/data/invalid_pointer.sav +0 -0
- scipy/io/tests/data/null_pointer.sav +0 -0
- scipy/io/tests/data/scalar_byte.sav +0 -0
- scipy/io/tests/data/scalar_byte_descr.sav +0 -0
- scipy/io/tests/data/scalar_complex32.sav +0 -0
- scipy/io/tests/data/scalar_complex64.sav +0 -0
- scipy/io/tests/data/scalar_float32.sav +0 -0
- scipy/io/tests/data/scalar_float64.sav +0 -0
- scipy/io/tests/data/scalar_heap_pointer.sav +0 -0
- scipy/io/tests/data/scalar_int16.sav +0 -0
- scipy/io/tests/data/scalar_int32.sav +0 -0
- scipy/io/tests/data/scalar_int64.sav +0 -0
- scipy/io/tests/data/scalar_string.sav +0 -0
- scipy/io/tests/data/scalar_uint16.sav +0 -0
- scipy/io/tests/data/scalar_uint32.sav +0 -0
- scipy/io/tests/data/scalar_uint64.sav +0 -0
- scipy/io/tests/data/struct_arrays.sav +0 -0
- scipy/io/tests/data/struct_arrays_byte_idl80.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_inherit.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointer_arrays_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_pointers.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated.sav +0 -0
- scipy/io/tests/data/struct_pointers_replicated_3d.sav +0 -0
- scipy/io/tests/data/struct_scalars.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated.sav +0 -0
- scipy/io/tests/data/struct_scalars_replicated_3d.sav +0 -0
- scipy/io/tests/data/test-1234Hz-le-1ch-10S-20bit-extra.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-be.wav +0 -0
- scipy/io/tests/data/test-44100Hz-2ch-32bit-float-le.wav +0 -0
- scipy/io/tests/data/test-44100Hz-be-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof-no-data.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-rf64.wav +0 -0
- scipy/io/tests/data/test-44100Hz-le-1ch-4bytes.wav +0 -0
- scipy/io/tests/data/test-48000Hz-2ch-64bit-float-le-wavex.wav +0 -0
- scipy/io/tests/data/test-8000Hz-be-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-1ch-1byte-ulaw.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-2ch-1byteu.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-inconsistent.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-rf64.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-36bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-45bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-53bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-3ch-5S-64bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-4ch-9S-12bit.wav +0 -0
- scipy/io/tests/data/test-8000Hz-le-5ch-9S-5bit.wav +0 -0
- scipy/io/tests/data/various_compressed.sav +0 -0
- scipy/io/tests/test_fortran.py +264 -0
- scipy/io/tests/test_idl.py +483 -0
- scipy/io/tests/test_mmio.py +831 -0
- scipy/io/tests/test_netcdf.py +550 -0
- scipy/io/tests/test_paths.py +93 -0
- scipy/io/tests/test_wavfile.py +501 -0
- scipy/io/wavfile.py +938 -0
- scipy/linalg/__init__.pxd +1 -0
- scipy/linalg/__init__.py +236 -0
- scipy/linalg/_basic.py +2146 -0
- scipy/linalg/_blas_subroutines.h +164 -0
- scipy/linalg/_cythonized_array_utils.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_cythonized_array_utils.pxd +40 -0
- scipy/linalg/_cythonized_array_utils.pyi +16 -0
- scipy/linalg/_decomp.py +1645 -0
- scipy/linalg/_decomp_cholesky.py +413 -0
- scipy/linalg/_decomp_cossin.py +236 -0
- scipy/linalg/_decomp_interpolative.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_lu_cython.pyi +6 -0
- scipy/linalg/_decomp_polar.py +113 -0
- scipy/linalg/_decomp_qr.py +494 -0
- scipy/linalg/_decomp_qz.py +452 -0
- scipy/linalg/_decomp_schur.py +336 -0
- scipy/linalg/_decomp_svd.py +545 -0
- scipy/linalg/_decomp_update.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_expm.pyi +6 -0
- scipy/linalg/_matfuncs_inv_ssq.py +886 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_misc.py +191 -0
- scipy/linalg/_procrustes.py +113 -0
- scipy/linalg/_sketches.py +189 -0
- scipy/linalg/_solve_toeplitz.cp313t-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/_solvers.py +862 -0
- scipy/linalg/_special_matrices.py +1322 -0
- scipy/linalg/_testutils.py +65 -0
- scipy/linalg/basic.py +23 -0
- scipy/linalg/blas.py +495 -0
- scipy/linalg/cython_blas.cp313t-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp313t-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp313t-win_arm64.pyd +0 -0
- scipy/linalg/cython_lapack.pxd +1528 -0
- scipy/linalg/cython_lapack.pyx +12045 -0
- scipy/linalg/decomp.py +23 -0
- scipy/linalg/decomp_cholesky.py +21 -0
- scipy/linalg/decomp_lu.py +21 -0
- scipy/linalg/decomp_qr.py +20 -0
- scipy/linalg/decomp_schur.py +21 -0
- scipy/linalg/decomp_svd.py +21 -0
- scipy/linalg/interpolative.py +989 -0
- scipy/linalg/lapack.py +1081 -0
- scipy/linalg/matfuncs.py +23 -0
- scipy/linalg/misc.py +21 -0
- scipy/linalg/special_matrices.py +22 -0
- scipy/linalg/tests/__init__.py +0 -0
- scipy/linalg/tests/_cython_examples/extending.pyx +23 -0
- scipy/linalg/tests/_cython_examples/meson.build +34 -0
- scipy/linalg/tests/data/carex_15_data.npz +0 -0
- scipy/linalg/tests/data/carex_18_data.npz +0 -0
- scipy/linalg/tests/data/carex_19_data.npz +0 -0
- scipy/linalg/tests/data/carex_20_data.npz +0 -0
- scipy/linalg/tests/data/carex_6_data.npz +0 -0
- scipy/linalg/tests/data/gendare_20170120_data.npz +0 -0
- scipy/linalg/tests/test_basic.py +2074 -0
- scipy/linalg/tests/test_batch.py +588 -0
- scipy/linalg/tests/test_blas.py +1127 -0
- scipy/linalg/tests/test_cython_blas.py +118 -0
- scipy/linalg/tests/test_cython_lapack.py +22 -0
- scipy/linalg/tests/test_cythonized_array_utils.py +130 -0
- scipy/linalg/tests/test_decomp.py +3189 -0
- scipy/linalg/tests/test_decomp_cholesky.py +268 -0
- scipy/linalg/tests/test_decomp_cossin.py +314 -0
- scipy/linalg/tests/test_decomp_ldl.py +137 -0
- scipy/linalg/tests/test_decomp_lu.py +308 -0
- scipy/linalg/tests/test_decomp_polar.py +110 -0
- scipy/linalg/tests/test_decomp_update.py +1701 -0
- scipy/linalg/tests/test_extending.py +46 -0
- scipy/linalg/tests/test_fblas.py +607 -0
- scipy/linalg/tests/test_interpolative.py +232 -0
- scipy/linalg/tests/test_lapack.py +3620 -0
- scipy/linalg/tests/test_matfuncs.py +1125 -0
- scipy/linalg/tests/test_matmul_toeplitz.py +136 -0
- scipy/linalg/tests/test_procrustes.py +214 -0
- scipy/linalg/tests/test_sketches.py +118 -0
- scipy/linalg/tests/test_solve_toeplitz.py +150 -0
- scipy/linalg/tests/test_solvers.py +844 -0
- scipy/linalg/tests/test_special_matrices.py +636 -0
- scipy/misc/__init__.py +6 -0
- scipy/misc/common.py +6 -0
- scipy/misc/doccer.py +6 -0
- scipy/ndimage/__init__.py +174 -0
- scipy/ndimage/_ctest.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_delegators.py +303 -0
- scipy/ndimage/_filters.py +2422 -0
- scipy/ndimage/_fourier.py +306 -0
- scipy/ndimage/_interpolation.py +1033 -0
- scipy/ndimage/_measurements.py +1689 -0
- scipy/ndimage/_morphology.py +2634 -0
- scipy/ndimage/_nd_image.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp313t-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp313t-win_arm64.pyd +0 -0
- scipy/ndimage/_support_alternative_backends.py +84 -0
- scipy/ndimage/filters.py +27 -0
- scipy/ndimage/fourier.py +21 -0
- scipy/ndimage/interpolation.py +22 -0
- scipy/ndimage/measurements.py +24 -0
- scipy/ndimage/morphology.py +27 -0
- scipy/ndimage/tests/__init__.py +12 -0
- scipy/ndimage/tests/data/label_inputs.txt +21 -0
- scipy/ndimage/tests/data/label_results.txt +294 -0
- scipy/ndimage/tests/data/label_strels.txt +42 -0
- scipy/ndimage/tests/dots.png +0 -0
- scipy/ndimage/tests/test_c_api.py +102 -0
- scipy/ndimage/tests/test_datatypes.py +67 -0
- scipy/ndimage/tests/test_filters.py +3083 -0
- scipy/ndimage/tests/test_fourier.py +187 -0
- scipy/ndimage/tests/test_interpolation.py +1491 -0
- scipy/ndimage/tests/test_measurements.py +1592 -0
- scipy/ndimage/tests/test_morphology.py +2950 -0
- scipy/ndimage/tests/test_ni_support.py +78 -0
- scipy/ndimage/tests/test_splines.py +70 -0
- scipy/odr/__init__.py +131 -0
- scipy/odr/__odrpack.cp313t-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp313t-win_arm64.pyd +0 -0
- scipy/odr/_add_newdocs.py +34 -0
- scipy/odr/_models.py +315 -0
- scipy/odr/_odrpack.py +1154 -0
- scipy/odr/models.py +20 -0
- scipy/odr/odrpack.py +21 -0
- scipy/odr/tests/__init__.py +0 -0
- scipy/odr/tests/test_odr.py +607 -0
- scipy/optimize/__init__.pxd +1 -0
- scipy/optimize/__init__.py +460 -0
- scipy/optimize/_basinhopping.py +741 -0
- scipy/optimize/_bglu_dense.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_bracket.py +706 -0
- scipy/optimize/_chandrupatla.py +551 -0
- scipy/optimize/_cobyla_py.py +297 -0
- scipy/optimize/_cobyqa_py.py +72 -0
- scipy/optimize/_constraints.py +598 -0
- scipy/optimize/_dcsrch.py +728 -0
- scipy/optimize/_differentiable_functions.py +835 -0
- scipy/optimize/_differentialevolution.py +1970 -0
- scipy/optimize/_direct.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_direct_py.py +280 -0
- scipy/optimize/_dual_annealing.py +732 -0
- scipy/optimize/_elementwise.py +798 -0
- scipy/optimize/_group_columns.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_lbfgsb_py.py +634 -0
- scipy/optimize/_linesearch.py +896 -0
- scipy/optimize/_linprog.py +733 -0
- scipy/optimize/_linprog_doc.py +1434 -0
- scipy/optimize/_linprog_highs.py +422 -0
- scipy/optimize/_linprog_ip.py +1141 -0
- scipy/optimize/_linprog_rs.py +572 -0
- scipy/optimize/_linprog_simplex.py +663 -0
- scipy/optimize/_linprog_util.py +1521 -0
- scipy/optimize/_lsap.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/__init__.py +5 -0
- scipy/optimize/_lsq/bvls.py +183 -0
- scipy/optimize/_lsq/common.py +731 -0
- scipy/optimize/_lsq/dogbox.py +345 -0
- scipy/optimize/_lsq/givens_elimination.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_lsq/least_squares.py +1044 -0
- scipy/optimize/_lsq/lsq_linear.py +361 -0
- scipy/optimize/_lsq/trf.py +587 -0
- scipy/optimize/_lsq/trf_linear.py +249 -0
- scipy/optimize/_milp.py +394 -0
- scipy/optimize/_minimize.py +1199 -0
- scipy/optimize/_minpack.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_nnls.py +96 -0
- scipy/optimize/_nonlin.py +1634 -0
- scipy/optimize/_numdiff.py +963 -0
- scipy/optimize/_optimize.py +4169 -0
- scipy/optimize/_pava_pybind.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_qap.py +760 -0
- scipy/optimize/_remove_redundancy.py +522 -0
- scipy/optimize/_root.py +732 -0
- scipy/optimize/_root_scalar.py +538 -0
- scipy/optimize/_shgo.py +1606 -0
- scipy/optimize/_shgo_lib/__init__.py +0 -0
- scipy/optimize/_shgo_lib/_complex.py +1225 -0
- scipy/optimize/_shgo_lib/_vertex.py +460 -0
- scipy/optimize/_slsqp_py.py +603 -0
- scipy/optimize/_slsqplib.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_spectral.py +260 -0
- scipy/optimize/_tnc.py +438 -0
- scipy/optimize/_trlib/__init__.py +12 -0
- scipy/optimize/_trlib/_trlib.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_trustregion.py +318 -0
- scipy/optimize/_trustregion_constr/__init__.py +6 -0
- scipy/optimize/_trustregion_constr/canonical_constraint.py +390 -0
- scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +231 -0
- scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +584 -0
- scipy/optimize/_trustregion_constr/projections.py +411 -0
- scipy/optimize/_trustregion_constr/qp_subproblem.py +637 -0
- scipy/optimize/_trustregion_constr/report.py +49 -0
- scipy/optimize/_trustregion_constr/tests/__init__.py +0 -0
- scipy/optimize/_trustregion_constr/tests/test_canonical_constraint.py +296 -0
- scipy/optimize/_trustregion_constr/tests/test_nested_minimize.py +39 -0
- scipy/optimize/_trustregion_constr/tests/test_projections.py +214 -0
- scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +645 -0
- scipy/optimize/_trustregion_constr/tests/test_report.py +34 -0
- scipy/optimize/_trustregion_constr/tr_interior_point.py +361 -0
- scipy/optimize/_trustregion_dogleg.py +122 -0
- scipy/optimize/_trustregion_exact.py +437 -0
- scipy/optimize/_trustregion_krylov.py +65 -0
- scipy/optimize/_trustregion_ncg.py +126 -0
- scipy/optimize/_tstutils.py +972 -0
- scipy/optimize/_zeros.cp313t-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/_zeros_py.py +1475 -0
- scipy/optimize/cobyla.py +19 -0
- scipy/optimize/cython_optimize/__init__.py +133 -0
- scipy/optimize/cython_optimize/_zeros.cp313t-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp313t-win_arm64.pyd +0 -0
- scipy/optimize/cython_optimize/_zeros.pxd +33 -0
- scipy/optimize/cython_optimize/c_zeros.pxd +26 -0
- scipy/optimize/cython_optimize.pxd +11 -0
- scipy/optimize/elementwise.py +38 -0
- scipy/optimize/lbfgsb.py +23 -0
- scipy/optimize/linesearch.py +18 -0
- scipy/optimize/minpack.py +27 -0
- scipy/optimize/minpack2.py +17 -0
- scipy/optimize/moduleTNC.py +19 -0
- scipy/optimize/nonlin.py +29 -0
- scipy/optimize/optimize.py +40 -0
- scipy/optimize/slsqp.py +22 -0
- scipy/optimize/tests/__init__.py +0 -0
- scipy/optimize/tests/_cython_examples/extending.pyx +43 -0
- scipy/optimize/tests/_cython_examples/meson.build +32 -0
- scipy/optimize/tests/test__basinhopping.py +535 -0
- scipy/optimize/tests/test__differential_evolution.py +1703 -0
- scipy/optimize/tests/test__dual_annealing.py +416 -0
- scipy/optimize/tests/test__linprog_clean_inputs.py +312 -0
- scipy/optimize/tests/test__numdiff.py +885 -0
- scipy/optimize/tests/test__remove_redundancy.py +228 -0
- scipy/optimize/tests/test__root.py +124 -0
- scipy/optimize/tests/test__shgo.py +1164 -0
- scipy/optimize/tests/test__spectral.py +226 -0
- scipy/optimize/tests/test_bracket.py +896 -0
- scipy/optimize/tests/test_chandrupatla.py +982 -0
- scipy/optimize/tests/test_cobyla.py +195 -0
- scipy/optimize/tests/test_cobyqa.py +252 -0
- scipy/optimize/tests/test_constraint_conversion.py +286 -0
- scipy/optimize/tests/test_constraints.py +255 -0
- scipy/optimize/tests/test_cython_optimize.py +92 -0
- scipy/optimize/tests/test_differentiable_functions.py +1025 -0
- scipy/optimize/tests/test_direct.py +321 -0
- scipy/optimize/tests/test_extending.py +28 -0
- scipy/optimize/tests/test_hessian_update_strategy.py +300 -0
- scipy/optimize/tests/test_isotonic_regression.py +167 -0
- scipy/optimize/tests/test_lbfgsb_hessinv.py +65 -0
- scipy/optimize/tests/test_lbfgsb_setulb.py +122 -0
- scipy/optimize/tests/test_least_squares.py +986 -0
- scipy/optimize/tests/test_linear_assignment.py +116 -0
- scipy/optimize/tests/test_linesearch.py +328 -0
- scipy/optimize/tests/test_linprog.py +2577 -0
- scipy/optimize/tests/test_lsq_common.py +297 -0
- scipy/optimize/tests/test_lsq_linear.py +287 -0
- scipy/optimize/tests/test_milp.py +459 -0
- scipy/optimize/tests/test_minimize_constrained.py +845 -0
- scipy/optimize/tests/test_minpack.py +1194 -0
- scipy/optimize/tests/test_nnls.py +469 -0
- scipy/optimize/tests/test_nonlin.py +572 -0
- scipy/optimize/tests/test_optimize.py +3344 -0
- scipy/optimize/tests/test_quadratic_assignment.py +455 -0
- scipy/optimize/tests/test_regression.py +40 -0
- scipy/optimize/tests/test_slsqp.py +645 -0
- scipy/optimize/tests/test_tnc.py +345 -0
- scipy/optimize/tests/test_trustregion.py +110 -0
- scipy/optimize/tests/test_trustregion_exact.py +351 -0
- scipy/optimize/tests/test_trustregion_krylov.py +170 -0
- scipy/optimize/tests/test_zeros.py +998 -0
- scipy/optimize/tnc.py +22 -0
- scipy/optimize/zeros.py +26 -0
- scipy/signal/__init__.py +316 -0
- scipy/signal/_arraytools.py +264 -0
- scipy/signal/_czt.py +575 -0
- scipy/signal/_delegators.py +568 -0
- scipy/signal/_filter_design.py +5893 -0
- scipy/signal/_fir_filter_design.py +1458 -0
- scipy/signal/_lti_conversion.py +534 -0
- scipy/signal/_ltisys.py +3546 -0
- scipy/signal/_max_len_seq.py +139 -0
- scipy/signal/_max_len_seq_inner.cp313t-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp313t-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_polyutils.py +172 -0
- scipy/signal/_savitzky_golay.py +357 -0
- scipy/signal/_short_time_fft.py +2228 -0
- scipy/signal/_signal_api.py +30 -0
- scipy/signal/_signaltools.py +5309 -0
- scipy/signal/_sigtools.cp313t-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp313t-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp313t-win_arm64.lib +0 -0
- scipy/signal/_spline.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_spline.pyi +34 -0
- scipy/signal/_spline_filters.py +848 -0
- scipy/signal/_support_alternative_backends.py +73 -0
- scipy/signal/_upfirdn.py +219 -0
- scipy/signal/_upfirdn_apply.cp313t-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp313t-win_arm64.pyd +0 -0
- scipy/signal/_waveforms.py +687 -0
- scipy/signal/_wavelets.py +29 -0
- scipy/signal/bsplines.py +21 -0
- scipy/signal/filter_design.py +28 -0
- scipy/signal/fir_filter_design.py +21 -0
- scipy/signal/lti_conversion.py +20 -0
- scipy/signal/ltisys.py +25 -0
- scipy/signal/signaltools.py +27 -0
- scipy/signal/spectral.py +21 -0
- scipy/signal/spline.py +18 -0
- scipy/signal/tests/__init__.py +0 -0
- scipy/signal/tests/_scipy_spectral_test_shim.py +311 -0
- scipy/signal/tests/mpsig.py +122 -0
- scipy/signal/tests/test_array_tools.py +111 -0
- scipy/signal/tests/test_bsplines.py +365 -0
- scipy/signal/tests/test_cont2discrete.py +424 -0
- scipy/signal/tests/test_czt.py +221 -0
- scipy/signal/tests/test_dltisys.py +599 -0
- scipy/signal/tests/test_filter_design.py +4744 -0
- scipy/signal/tests/test_fir_filter_design.py +851 -0
- scipy/signal/tests/test_ltisys.py +1225 -0
- scipy/signal/tests/test_max_len_seq.py +71 -0
- scipy/signal/tests/test_peak_finding.py +915 -0
- scipy/signal/tests/test_result_type.py +51 -0
- scipy/signal/tests/test_savitzky_golay.py +363 -0
- scipy/signal/tests/test_short_time_fft.py +1107 -0
- scipy/signal/tests/test_signaltools.py +4735 -0
- scipy/signal/tests/test_spectral.py +2141 -0
- scipy/signal/tests/test_splines.py +427 -0
- scipy/signal/tests/test_upfirdn.py +322 -0
- scipy/signal/tests/test_waveforms.py +400 -0
- scipy/signal/tests/test_wavelets.py +59 -0
- scipy/signal/tests/test_windows.py +987 -0
- scipy/signal/waveforms.py +20 -0
- scipy/signal/wavelets.py +17 -0
- scipy/signal/windows/__init__.py +52 -0
- scipy/signal/windows/_windows.py +2513 -0
- scipy/signal/windows/windows.py +23 -0
- scipy/sparse/__init__.py +350 -0
- scipy/sparse/_base.py +1613 -0
- scipy/sparse/_bsr.py +880 -0
- scipy/sparse/_compressed.py +1328 -0
- scipy/sparse/_construct.py +1454 -0
- scipy/sparse/_coo.py +1581 -0
- scipy/sparse/_csc.py +367 -0
- scipy/sparse/_csparsetools.cp313t-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/_csr.py +558 -0
- scipy/sparse/_data.py +569 -0
- scipy/sparse/_dia.py +677 -0
- scipy/sparse/_dok.py +669 -0
- scipy/sparse/_extract.py +178 -0
- scipy/sparse/_index.py +444 -0
- scipy/sparse/_lil.py +632 -0
- scipy/sparse/_matrix.py +169 -0
- scipy/sparse/_matrix_io.py +167 -0
- scipy/sparse/_sparsetools.cp313t-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/_spfuncs.py +76 -0
- scipy/sparse/_sputils.py +632 -0
- scipy/sparse/base.py +24 -0
- scipy/sparse/bsr.py +22 -0
- scipy/sparse/compressed.py +20 -0
- scipy/sparse/construct.py +38 -0
- scipy/sparse/coo.py +23 -0
- scipy/sparse/csc.py +22 -0
- scipy/sparse/csgraph/__init__.py +210 -0
- scipy/sparse/csgraph/_flow.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp313t-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_validation.py +66 -0
- scipy/sparse/csgraph/tests/__init__.py +0 -0
- scipy/sparse/csgraph/tests/test_connected_components.py +119 -0
- scipy/sparse/csgraph/tests/test_conversions.py +61 -0
- scipy/sparse/csgraph/tests/test_flow.py +209 -0
- scipy/sparse/csgraph/tests/test_graph_laplacian.py +368 -0
- scipy/sparse/csgraph/tests/test_matching.py +307 -0
- scipy/sparse/csgraph/tests/test_pydata_sparse.py +197 -0
- scipy/sparse/csgraph/tests/test_reordering.py +70 -0
- scipy/sparse/csgraph/tests/test_shortest_path.py +540 -0
- scipy/sparse/csgraph/tests/test_spanning_tree.py +66 -0
- scipy/sparse/csgraph/tests/test_traversal.py +148 -0
- scipy/sparse/csr.py +22 -0
- scipy/sparse/data.py +18 -0
- scipy/sparse/dia.py +22 -0
- scipy/sparse/dok.py +22 -0
- scipy/sparse/extract.py +23 -0
- scipy/sparse/lil.py +22 -0
- scipy/sparse/linalg/__init__.py +148 -0
- scipy/sparse/linalg/_dsolve/__init__.py +71 -0
- scipy/sparse/linalg/_dsolve/_add_newdocs.py +147 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_dsolve/linsolve.py +882 -0
- scipy/sparse/linalg/_dsolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +928 -0
- scipy/sparse/linalg/_eigen/__init__.py +22 -0
- scipy/sparse/linalg/_eigen/_svds.py +540 -0
- scipy/sparse/linalg/_eigen/_svds_doc.py +382 -0
- scipy/sparse/linalg/_eigen/arpack/COPYING +45 -0
- scipy/sparse/linalg/_eigen/arpack/__init__.py +20 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_eigen/arpack/arpack.py +1706 -0
- scipy/sparse/linalg/_eigen/arpack/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/arpack/tests/test_arpack.py +717 -0
- scipy/sparse/linalg/_eigen/lobpcg/__init__.py +16 -0
- scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +1110 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py +725 -0
- scipy/sparse/linalg/_eigen/tests/__init__.py +0 -0
- scipy/sparse/linalg/_eigen/tests/test_svds.py +886 -0
- scipy/sparse/linalg/_expm_multiply.py +816 -0
- scipy/sparse/linalg/_interface.py +920 -0
- scipy/sparse/linalg/_isolve/__init__.py +20 -0
- scipy/sparse/linalg/_isolve/_gcrotmk.py +503 -0
- scipy/sparse/linalg/_isolve/iterative.py +1051 -0
- scipy/sparse/linalg/_isolve/lgmres.py +230 -0
- scipy/sparse/linalg/_isolve/lsmr.py +486 -0
- scipy/sparse/linalg/_isolve/lsqr.py +589 -0
- scipy/sparse/linalg/_isolve/minres.py +372 -0
- scipy/sparse/linalg/_isolve/tests/__init__.py +0 -0
- scipy/sparse/linalg/_isolve/tests/test_gcrotmk.py +183 -0
- scipy/sparse/linalg/_isolve/tests/test_iterative.py +809 -0
- scipy/sparse/linalg/_isolve/tests/test_lgmres.py +225 -0
- scipy/sparse/linalg/_isolve/tests/test_lsmr.py +185 -0
- scipy/sparse/linalg/_isolve/tests/test_lsqr.py +120 -0
- scipy/sparse/linalg/_isolve/tests/test_minres.py +97 -0
- scipy/sparse/linalg/_isolve/tests/test_utils.py +9 -0
- scipy/sparse/linalg/_isolve/tfqmr.py +179 -0
- scipy/sparse/linalg/_isolve/utils.py +121 -0
- scipy/sparse/linalg/_matfuncs.py +940 -0
- scipy/sparse/linalg/_norm.py +195 -0
- scipy/sparse/linalg/_onenormest.py +467 -0
- scipy/sparse/linalg/_propack/_cpropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp313t-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp313t-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_special_sparse_arrays.py +949 -0
- scipy/sparse/linalg/_svdp.py +309 -0
- scipy/sparse/linalg/dsolve.py +22 -0
- scipy/sparse/linalg/eigen.py +21 -0
- scipy/sparse/linalg/interface.py +20 -0
- scipy/sparse/linalg/isolve.py +22 -0
- scipy/sparse/linalg/matfuncs.py +18 -0
- scipy/sparse/linalg/tests/__init__.py +0 -0
- scipy/sparse/linalg/tests/propack_test_data.npz +0 -0
- scipy/sparse/linalg/tests/test_expm_multiply.py +367 -0
- scipy/sparse/linalg/tests/test_interface.py +561 -0
- scipy/sparse/linalg/tests/test_matfuncs.py +592 -0
- scipy/sparse/linalg/tests/test_norm.py +154 -0
- scipy/sparse/linalg/tests/test_onenormest.py +252 -0
- scipy/sparse/linalg/tests/test_propack.py +165 -0
- scipy/sparse/linalg/tests/test_pydata_sparse.py +272 -0
- scipy/sparse/linalg/tests/test_special_sparse_arrays.py +337 -0
- scipy/sparse/sparsetools.py +17 -0
- scipy/sparse/spfuncs.py +17 -0
- scipy/sparse/sputils.py +17 -0
- scipy/sparse/tests/__init__.py +0 -0
- scipy/sparse/tests/data/csc_py2.npz +0 -0
- scipy/sparse/tests/data/csc_py3.npz +0 -0
- scipy/sparse/tests/test_arithmetic1d.py +341 -0
- scipy/sparse/tests/test_array_api.py +561 -0
- scipy/sparse/tests/test_base.py +5870 -0
- scipy/sparse/tests/test_common1d.py +447 -0
- scipy/sparse/tests/test_construct.py +872 -0
- scipy/sparse/tests/test_coo.py +1119 -0
- scipy/sparse/tests/test_csc.py +98 -0
- scipy/sparse/tests/test_csr.py +214 -0
- scipy/sparse/tests/test_dok.py +209 -0
- scipy/sparse/tests/test_extract.py +51 -0
- scipy/sparse/tests/test_indexing1d.py +603 -0
- scipy/sparse/tests/test_matrix_io.py +109 -0
- scipy/sparse/tests/test_minmax1d.py +128 -0
- scipy/sparse/tests/test_sparsetools.py +344 -0
- scipy/sparse/tests/test_spfuncs.py +97 -0
- scipy/sparse/tests/test_sputils.py +424 -0
- scipy/spatial/__init__.py +129 -0
- scipy/spatial/_ckdtree.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_kdtree.py +920 -0
- scipy/spatial/_plotutils.py +274 -0
- scipy/spatial/_procrustes.py +132 -0
- scipy/spatial/_qhull.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp313t-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/_voronoi.pyi +4 -0
- scipy/spatial/ckdtree.py +18 -0
- scipy/spatial/distance.py +3147 -0
- scipy/spatial/distance.pyi +210 -0
- scipy/spatial/kdtree.py +25 -0
- scipy/spatial/qhull.py +25 -0
- scipy/spatial/qhull_src/COPYING_QHULL.txt +39 -0
- scipy/spatial/tests/__init__.py +0 -0
- scipy/spatial/tests/data/cdist-X1.txt +10 -0
- scipy/spatial/tests/data/cdist-X2.txt +20 -0
- scipy/spatial/tests/data/degenerate_pointset.npz +0 -0
- scipy/spatial/tests/data/iris.txt +150 -0
- scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
- scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +1 -0
- scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
- scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
- scipy/spatial/tests/data/random-bool-data.txt +100 -0
- scipy/spatial/tests/data/random-double-data.txt +100 -0
- scipy/spatial/tests/data/random-int-data.txt +100 -0
- scipy/spatial/tests/data/random-uint-data.txt +100 -0
- scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
- scipy/spatial/tests/test__plotutils.py +91 -0
- scipy/spatial/tests/test__procrustes.py +116 -0
- scipy/spatial/tests/test_distance.py +2389 -0
- scipy/spatial/tests/test_hausdorff.py +199 -0
- scipy/spatial/tests/test_kdtree.py +1536 -0
- scipy/spatial/tests/test_qhull.py +1313 -0
- scipy/spatial/tests/test_slerp.py +417 -0
- scipy/spatial/tests/test_spherical_voronoi.py +358 -0
- scipy/spatial/transform/__init__.py +31 -0
- scipy/spatial/transform/_rigid_transform.cp313t-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp313t-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp313t-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation_groups.py +140 -0
- scipy/spatial/transform/_rotation_spline.py +460 -0
- scipy/spatial/transform/rotation.py +21 -0
- scipy/spatial/transform/tests/__init__.py +0 -0
- scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
- scipy/spatial/transform/tests/test_rotation.py +2569 -0
- scipy/spatial/transform/tests/test_rotation_groups.py +169 -0
- scipy/spatial/transform/tests/test_rotation_spline.py +183 -0
- scipy/special/__init__.pxd +1 -0
- scipy/special/__init__.py +841 -0
- scipy/special/_add_newdocs.py +9961 -0
- scipy/special/_basic.py +3576 -0
- scipy/special/_comb.cp313t-win_arm64.lib +0 -0
- scipy/special/_comb.cp313t-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp313t-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp313t-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp313t-win_arm64.pyd +0 -0
- scipy/special/_input_validation.py +17 -0
- scipy/special/_lambertw.py +149 -0
- scipy/special/_logsumexp.py +426 -0
- scipy/special/_mptestutils.py +453 -0
- scipy/special/_multiufuncs.py +610 -0
- scipy/special/_orthogonal.py +2592 -0
- scipy/special/_orthogonal.pyi +330 -0
- scipy/special/_precompute/__init__.py +0 -0
- scipy/special/_precompute/cosine_cdf.py +17 -0
- scipy/special/_precompute/expn_asy.py +54 -0
- scipy/special/_precompute/gammainc_asy.py +116 -0
- scipy/special/_precompute/gammainc_data.py +124 -0
- scipy/special/_precompute/hyp2f1_data.py +484 -0
- scipy/special/_precompute/lambertw.py +68 -0
- scipy/special/_precompute/loggamma.py +43 -0
- scipy/special/_precompute/struve_convergence.py +131 -0
- scipy/special/_precompute/utils.py +38 -0
- scipy/special/_precompute/wright_bessel.py +342 -0
- scipy/special/_precompute/wright_bessel_data.py +152 -0
- scipy/special/_precompute/wrightomega.py +41 -0
- scipy/special/_precompute/zetac.py +27 -0
- scipy/special/_sf_error.py +15 -0
- scipy/special/_specfun.cp313t-win_arm64.lib +0 -0
- scipy/special/_specfun.cp313t-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp313t-win_arm64.pyd +0 -0
- scipy/special/_spfun_stats.py +106 -0
- scipy/special/_spherical_bessel.py +397 -0
- scipy/special/_support_alternative_backends.py +295 -0
- scipy/special/_test_internal.cp313t-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp313t-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp313t-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp313t-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp313t-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp313t-win_arm64.pyd +0 -0
- scipy/special/_ufuncs_cxx.pxd +142 -0
- scipy/special/_ufuncs_cxx.pyx +427 -0
- scipy/special/_ufuncs_cxx_defs.h +147 -0
- scipy/special/_ufuncs_defs.h +57 -0
- scipy/special/add_newdocs.py +15 -0
- scipy/special/basic.py +87 -0
- scipy/special/cython_special.cp313t-win_arm64.lib +0 -0
- scipy/special/cython_special.cp313t-win_arm64.pyd +0 -0
- scipy/special/cython_special.pxd +259 -0
- scipy/special/cython_special.pyi +3 -0
- scipy/special/orthogonal.py +45 -0
- scipy/special/sf_error.py +20 -0
- scipy/special/specfun.py +24 -0
- scipy/special/spfun_stats.py +17 -0
- scipy/special/tests/__init__.py +0 -0
- scipy/special/tests/_cython_examples/extending.pyx +12 -0
- scipy/special/tests/_cython_examples/meson.build +34 -0
- scipy/special/tests/data/__init__.py +0 -0
- scipy/special/tests/data/boost.npz +0 -0
- scipy/special/tests/data/gsl.npz +0 -0
- scipy/special/tests/data/local.npz +0 -0
- scipy/special/tests/test_basic.py +4815 -0
- scipy/special/tests/test_bdtr.py +112 -0
- scipy/special/tests/test_boost_ufuncs.py +64 -0
- scipy/special/tests/test_boxcox.py +125 -0
- scipy/special/tests/test_cdflib.py +712 -0
- scipy/special/tests/test_cdft_asymptotic.py +49 -0
- scipy/special/tests/test_cephes_intp_cast.py +29 -0
- scipy/special/tests/test_cosine_distr.py +83 -0
- scipy/special/tests/test_cython_special.py +363 -0
- scipy/special/tests/test_data.py +719 -0
- scipy/special/tests/test_dd.py +42 -0
- scipy/special/tests/test_digamma.py +45 -0
- scipy/special/tests/test_ellip_harm.py +278 -0
- scipy/special/tests/test_erfinv.py +89 -0
- scipy/special/tests/test_exponential_integrals.py +118 -0
- scipy/special/tests/test_extending.py +28 -0
- scipy/special/tests/test_faddeeva.py +85 -0
- scipy/special/tests/test_gamma.py +12 -0
- scipy/special/tests/test_gammainc.py +152 -0
- scipy/special/tests/test_hyp2f1.py +2566 -0
- scipy/special/tests/test_hypergeometric.py +234 -0
- scipy/special/tests/test_iv_ratio.py +249 -0
- scipy/special/tests/test_kolmogorov.py +491 -0
- scipy/special/tests/test_lambertw.py +109 -0
- scipy/special/tests/test_legendre.py +1518 -0
- scipy/special/tests/test_log1mexp.py +85 -0
- scipy/special/tests/test_loggamma.py +70 -0
- scipy/special/tests/test_logit.py +162 -0
- scipy/special/tests/test_logsumexp.py +469 -0
- scipy/special/tests/test_mpmath.py +2293 -0
- scipy/special/tests/test_nan_inputs.py +65 -0
- scipy/special/tests/test_ndtr.py +77 -0
- scipy/special/tests/test_ndtri_exp.py +94 -0
- scipy/special/tests/test_orthogonal.py +821 -0
- scipy/special/tests/test_orthogonal_eval.py +275 -0
- scipy/special/tests/test_owens_t.py +53 -0
- scipy/special/tests/test_pcf.py +24 -0
- scipy/special/tests/test_pdtr.py +48 -0
- scipy/special/tests/test_powm1.py +65 -0
- scipy/special/tests/test_precompute_expn_asy.py +24 -0
- scipy/special/tests/test_precompute_gammainc.py +108 -0
- scipy/special/tests/test_precompute_utils.py +36 -0
- scipy/special/tests/test_round.py +18 -0
- scipy/special/tests/test_sf_error.py +146 -0
- scipy/special/tests/test_sici.py +36 -0
- scipy/special/tests/test_specfun.py +48 -0
- scipy/special/tests/test_spence.py +32 -0
- scipy/special/tests/test_spfun_stats.py +61 -0
- scipy/special/tests/test_sph_harm.py +85 -0
- scipy/special/tests/test_spherical_bessel.py +400 -0
- scipy/special/tests/test_support_alternative_backends.py +248 -0
- scipy/special/tests/test_trig.py +72 -0
- scipy/special/tests/test_ufunc_signatures.py +46 -0
- scipy/special/tests/test_wright_bessel.py +205 -0
- scipy/special/tests/test_wrightomega.py +117 -0
- scipy/special/tests/test_zeta.py +301 -0
- scipy/stats/__init__.py +670 -0
- scipy/stats/_ansari_swilk_statistics.cp313t-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp313t-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_biasedurn.pxd +27 -0
- scipy/stats/_binned_statistic.py +795 -0
- scipy/stats/_binomtest.py +375 -0
- scipy/stats/_bws_test.py +177 -0
- scipy/stats/_censored_data.py +459 -0
- scipy/stats/_common.py +5 -0
- scipy/stats/_constants.py +42 -0
- scipy/stats/_continued_fraction.py +387 -0
- scipy/stats/_continuous_distns.py +12486 -0
- scipy/stats/_correlation.py +210 -0
- scipy/stats/_covariance.py +636 -0
- scipy/stats/_crosstab.py +204 -0
- scipy/stats/_discrete_distns.py +2098 -0
- scipy/stats/_distn_infrastructure.py +4201 -0
- scipy/stats/_distr_params.py +299 -0
- scipy/stats/_distribution_infrastructure.py +5750 -0
- scipy/stats/_entropy.py +428 -0
- scipy/stats/_finite_differences.py +145 -0
- scipy/stats/_fit.py +1351 -0
- scipy/stats/_hypotests.py +2060 -0
- scipy/stats/_kde.py +732 -0
- scipy/stats/_ksstats.py +600 -0
- scipy/stats/_levy_stable/__init__.py +1231 -0
- scipy/stats/_levy_stable/levyst.cp313t-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_mannwhitneyu.py +492 -0
- scipy/stats/_mgc.py +550 -0
- scipy/stats/_morestats.py +4626 -0
- scipy/stats/_mstats_basic.py +3658 -0
- scipy/stats/_mstats_extras.py +521 -0
- scipy/stats/_multicomp.py +449 -0
- scipy/stats/_multivariate.py +7281 -0
- scipy/stats/_new_distributions.py +452 -0
- scipy/stats/_odds_ratio.py +466 -0
- scipy/stats/_page_trend_test.py +486 -0
- scipy/stats/_probability_distribution.py +1964 -0
- scipy/stats/_qmc.py +2956 -0
- scipy/stats/_qmc_cy.cp313t-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp313t-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp313t-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_relative_risk.py +263 -0
- scipy/stats/_resampling.py +2352 -0
- scipy/stats/_result_classes.py +40 -0
- scipy/stats/_sampling.py +1314 -0
- scipy/stats/_sensitivity_analysis.py +713 -0
- scipy/stats/_sobol.cp313t-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp313t-win_arm64.lib +0 -0
- scipy/stats/_stats.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_stats.pxd +10 -0
- scipy/stats/_stats_mstats_common.py +322 -0
- scipy/stats/_stats_py.py +11089 -0
- scipy/stats/_stats_pythran.cp313t-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_survival.py +683 -0
- scipy/stats/_tukeylambda_stats.py +199 -0
- scipy/stats/_unuran/__init__.py +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp313t-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp313t-win_arm64.pyd +0 -0
- scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
- scipy/stats/_variation.py +126 -0
- scipy/stats/_warnings_errors.py +38 -0
- scipy/stats/_wilcoxon.py +265 -0
- scipy/stats/biasedurn.py +16 -0
- scipy/stats/contingency.py +521 -0
- scipy/stats/distributions.py +24 -0
- scipy/stats/kde.py +18 -0
- scipy/stats/morestats.py +27 -0
- scipy/stats/mstats.py +140 -0
- scipy/stats/mstats_basic.py +42 -0
- scipy/stats/mstats_extras.py +25 -0
- scipy/stats/mvn.py +17 -0
- scipy/stats/qmc.py +236 -0
- scipy/stats/sampling.py +73 -0
- scipy/stats/stats.py +41 -0
- scipy/stats/tests/__init__.py +0 -0
- scipy/stats/tests/common_tests.py +356 -0
- scipy/stats/tests/data/_mvt.py +171 -0
- scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
- scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
- scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
- scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
- scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
- scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
- scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
- scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
- scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
- scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
- scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
- scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
- scipy/stats/tests/test_axis_nan_policy.py +1388 -0
- scipy/stats/tests/test_binned_statistic.py +568 -0
- scipy/stats/tests/test_censored_data.py +152 -0
- scipy/stats/tests/test_contingency.py +294 -0
- scipy/stats/tests/test_continued_fraction.py +173 -0
- scipy/stats/tests/test_continuous.py +2198 -0
- scipy/stats/tests/test_continuous_basic.py +1053 -0
- scipy/stats/tests/test_continuous_fit_censored.py +683 -0
- scipy/stats/tests/test_correlation.py +80 -0
- scipy/stats/tests/test_crosstab.py +115 -0
- scipy/stats/tests/test_discrete_basic.py +580 -0
- scipy/stats/tests/test_discrete_distns.py +700 -0
- scipy/stats/tests/test_distributions.py +10413 -0
- scipy/stats/tests/test_entropy.py +322 -0
- scipy/stats/tests/test_fast_gen_inversion.py +435 -0
- scipy/stats/tests/test_fit.py +1090 -0
- scipy/stats/tests/test_hypotests.py +1991 -0
- scipy/stats/tests/test_kdeoth.py +676 -0
- scipy/stats/tests/test_marray.py +289 -0
- scipy/stats/tests/test_mgc.py +217 -0
- scipy/stats/tests/test_morestats.py +3259 -0
- scipy/stats/tests/test_mstats_basic.py +2071 -0
- scipy/stats/tests/test_mstats_extras.py +172 -0
- scipy/stats/tests/test_multicomp.py +405 -0
- scipy/stats/tests/test_multivariate.py +4381 -0
- scipy/stats/tests/test_odds_ratio.py +148 -0
- scipy/stats/tests/test_qmc.py +1492 -0
- scipy/stats/tests/test_quantile.py +199 -0
- scipy/stats/tests/test_rank.py +345 -0
- scipy/stats/tests/test_relative_risk.py +95 -0
- scipy/stats/tests/test_resampling.py +2000 -0
- scipy/stats/tests/test_sampling.py +1450 -0
- scipy/stats/tests/test_sensitivity_analysis.py +310 -0
- scipy/stats/tests/test_stats.py +9707 -0
- scipy/stats/tests/test_survival.py +466 -0
- scipy/stats/tests/test_tukeylambda_stats.py +85 -0
- scipy/stats/tests/test_variation.py +216 -0
- scipy/version.py +12 -0
- scipy-1.16.2.dist-info/DELVEWHEEL +2 -0
- scipy-1.16.2.dist-info/LICENSE.txt +912 -0
- scipy-1.16.2.dist-info/METADATA +1061 -0
- scipy-1.16.2.dist-info/RECORD +1530 -0
- scipy-1.16.2.dist-info/WHEEL +4 -0
- scipy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
- scipy.libs/scipy_openblas-f3ac85b1f412f7e86514c923dc4058d1.dll +0 -0
@@ -0,0 +1,2074 @@
|
|
1
|
+
import itertools
|
2
|
+
|
3
|
+
import numpy as np
|
4
|
+
from numpy import (arange, array, dot, zeros, identity, conjugate, transpose,
|
5
|
+
float32)
|
6
|
+
from numpy.random import random
|
7
|
+
|
8
|
+
from numpy.testing import (assert_equal, assert_almost_equal, assert_,
|
9
|
+
assert_array_almost_equal, assert_allclose,
|
10
|
+
assert_array_equal, suppress_warnings)
|
11
|
+
import pytest
|
12
|
+
from pytest import raises as assert_raises
|
13
|
+
|
14
|
+
from scipy.linalg import (solve, inv, det, lstsq, pinv, pinvh, norm,
|
15
|
+
solve_banded, solveh_banded, solve_triangular,
|
16
|
+
solve_circulant, circulant, LinAlgError, block_diag,
|
17
|
+
matrix_balance, qr, LinAlgWarning)
|
18
|
+
|
19
|
+
from scipy.linalg._testutils import assert_no_overwrite
|
20
|
+
from scipy._lib._testutils import check_free_memory, IS_MUSL
|
21
|
+
from scipy.linalg.blas import HAS_ILP64
|
22
|
+
|
23
|
+
REAL_DTYPES = (np.float32, np.float64, np.longdouble)
|
24
|
+
COMPLEX_DTYPES = (np.complex64, np.complex128, np.clongdouble)
|
25
|
+
DTYPES = REAL_DTYPES + COMPLEX_DTYPES
|
26
|
+
|
27
|
+
|
28
|
+
def _eps_cast(dtyp):
|
29
|
+
"""Get the epsilon for dtype, possibly downcast to BLAS types."""
|
30
|
+
dt = dtyp
|
31
|
+
if dt == np.longdouble:
|
32
|
+
dt = np.float64
|
33
|
+
elif dt == np.clongdouble:
|
34
|
+
dt = np.complex128
|
35
|
+
return np.finfo(dt).eps
|
36
|
+
|
37
|
+
|
38
|
+
class TestSolveBanded:
|
39
|
+
|
40
|
+
def test_real(self):
|
41
|
+
a = array([[1.0, 20, 0, 0],
|
42
|
+
[-30, 4, 6, 0],
|
43
|
+
[2, 1, 20, 2],
|
44
|
+
[0, -1, 7, 14]])
|
45
|
+
ab = array([[0.0, 20, 6, 2],
|
46
|
+
[1, 4, 20, 14],
|
47
|
+
[-30, 1, 7, 0],
|
48
|
+
[2, -1, 0, 0]])
|
49
|
+
l, u = 2, 1
|
50
|
+
b4 = array([10.0, 0.0, 2.0, 14.0])
|
51
|
+
b4by1 = b4.reshape(-1, 1)
|
52
|
+
b4by2 = array([[2, 1],
|
53
|
+
[-30, 4],
|
54
|
+
[2, 3],
|
55
|
+
[1, 3]])
|
56
|
+
b4by4 = array([[1, 0, 0, 0],
|
57
|
+
[0, 0, 0, 1],
|
58
|
+
[0, 1, 0, 0],
|
59
|
+
[0, 1, 0, 0]])
|
60
|
+
for b in [b4, b4by1, b4by2, b4by4]:
|
61
|
+
x = solve_banded((l, u), ab, b)
|
62
|
+
assert_array_almost_equal(dot(a, x), b)
|
63
|
+
|
64
|
+
def test_complex(self):
|
65
|
+
a = array([[1.0, 20, 0, 0],
|
66
|
+
[-30, 4, 6, 0],
|
67
|
+
[2j, 1, 20, 2j],
|
68
|
+
[0, -1, 7, 14]])
|
69
|
+
ab = array([[0.0, 20, 6, 2j],
|
70
|
+
[1, 4, 20, 14],
|
71
|
+
[-30, 1, 7, 0],
|
72
|
+
[2j, -1, 0, 0]])
|
73
|
+
l, u = 2, 1
|
74
|
+
b4 = array([10.0, 0.0, 2.0, 14.0j])
|
75
|
+
b4by1 = b4.reshape(-1, 1)
|
76
|
+
b4by2 = array([[2, 1],
|
77
|
+
[-30, 4],
|
78
|
+
[2, 3],
|
79
|
+
[1, 3]])
|
80
|
+
b4by4 = array([[1, 0, 0, 0],
|
81
|
+
[0, 0, 0, 1j],
|
82
|
+
[0, 1, 0, 0],
|
83
|
+
[0, 1, 0, 0]])
|
84
|
+
for b in [b4, b4by1, b4by2, b4by4]:
|
85
|
+
x = solve_banded((l, u), ab, b)
|
86
|
+
assert_array_almost_equal(dot(a, x), b)
|
87
|
+
|
88
|
+
def test_tridiag_real(self):
|
89
|
+
ab = array([[0.0, 20, 6, 2],
|
90
|
+
[1, 4, 20, 14],
|
91
|
+
[-30, 1, 7, 0]])
|
92
|
+
a = np.diag(ab[0, 1:], 1) + np.diag(ab[1, :], 0) + np.diag(
|
93
|
+
ab[2, :-1], -1)
|
94
|
+
b4 = array([10.0, 0.0, 2.0, 14.0])
|
95
|
+
b4by1 = b4.reshape(-1, 1)
|
96
|
+
b4by2 = array([[2, 1],
|
97
|
+
[-30, 4],
|
98
|
+
[2, 3],
|
99
|
+
[1, 3]])
|
100
|
+
b4by4 = array([[1, 0, 0, 0],
|
101
|
+
[0, 0, 0, 1],
|
102
|
+
[0, 1, 0, 0],
|
103
|
+
[0, 1, 0, 0]])
|
104
|
+
for b in [b4, b4by1, b4by2, b4by4]:
|
105
|
+
x = solve_banded((1, 1), ab, b)
|
106
|
+
assert_array_almost_equal(dot(a, x), b)
|
107
|
+
|
108
|
+
def test_tridiag_complex(self):
|
109
|
+
ab = array([[0.0, 20, 6, 2j],
|
110
|
+
[1, 4, 20, 14],
|
111
|
+
[-30, 1, 7, 0]])
|
112
|
+
a = np.diag(ab[0, 1:], 1) + np.diag(ab[1, :], 0) + np.diag(
|
113
|
+
ab[2, :-1], -1)
|
114
|
+
b4 = array([10.0, 0.0, 2.0, 14.0j])
|
115
|
+
b4by1 = b4.reshape(-1, 1)
|
116
|
+
b4by2 = array([[2, 1],
|
117
|
+
[-30, 4],
|
118
|
+
[2, 3],
|
119
|
+
[1, 3]])
|
120
|
+
b4by4 = array([[1, 0, 0, 0],
|
121
|
+
[0, 0, 0, 1],
|
122
|
+
[0, 1, 0, 0],
|
123
|
+
[0, 1, 0, 0]])
|
124
|
+
for b in [b4, b4by1, b4by2, b4by4]:
|
125
|
+
x = solve_banded((1, 1), ab, b)
|
126
|
+
assert_array_almost_equal(dot(a, x), b)
|
127
|
+
|
128
|
+
def test_check_finite(self):
|
129
|
+
a = array([[1.0, 20, 0, 0],
|
130
|
+
[-30, 4, 6, 0],
|
131
|
+
[2, 1, 20, 2],
|
132
|
+
[0, -1, 7, 14]])
|
133
|
+
ab = array([[0.0, 20, 6, 2],
|
134
|
+
[1, 4, 20, 14],
|
135
|
+
[-30, 1, 7, 0],
|
136
|
+
[2, -1, 0, 0]])
|
137
|
+
l, u = 2, 1
|
138
|
+
b4 = array([10.0, 0.0, 2.0, 14.0])
|
139
|
+
x = solve_banded((l, u), ab, b4, check_finite=False)
|
140
|
+
assert_array_almost_equal(dot(a, x), b4)
|
141
|
+
|
142
|
+
def test_bad_shape(self):
|
143
|
+
ab = array([[0.0, 20, 6, 2],
|
144
|
+
[1, 4, 20, 14],
|
145
|
+
[-30, 1, 7, 0],
|
146
|
+
[2, -1, 0, 0]])
|
147
|
+
l, u = 2, 1
|
148
|
+
bad = array([1.0, 2.0, 3.0, 4.0]).reshape(-1, 4)
|
149
|
+
assert_raises(ValueError, solve_banded, (l, u), ab, bad)
|
150
|
+
assert_raises(ValueError, solve_banded, (l, u), ab, [1.0, 2.0])
|
151
|
+
|
152
|
+
# Values of (l,u) are not compatible with ab.
|
153
|
+
assert_raises(ValueError, solve_banded, (1, 1), ab, [1.0, 2.0])
|
154
|
+
|
155
|
+
def test_1x1(self):
|
156
|
+
# gh-8906 noted that the case of A@x = b with 1x1 A was handled
|
157
|
+
# incorrectly; check that this is resolved. Typical case:
|
158
|
+
# nupper == nlower == 0
|
159
|
+
# A = [[2]]
|
160
|
+
b = array([[1., 2., 3.]])
|
161
|
+
ref = array([[0.5, 1.0, 1.5]])
|
162
|
+
x = solve_banded((0, 0), [[2]], b)
|
163
|
+
assert_allclose(x, ref, rtol=1e-15)
|
164
|
+
|
165
|
+
# However, the user *can* represent the same system with garbage rows
|
166
|
+
# in `ab`. Test the case with `nupper == 1, nlower == 1`.
|
167
|
+
x = solve_banded((1, 1), [[0], [2], [0]], b)
|
168
|
+
assert_allclose(x, ref, rtol=1e-15)
|
169
|
+
assert_equal(x.dtype, np.dtype('f8'))
|
170
|
+
assert_array_equal(b, [[1.0, 2.0, 3.0]])
|
171
|
+
|
172
|
+
def test_native_list_arguments(self):
|
173
|
+
a = [[1.0, 20, 0, 0],
|
174
|
+
[-30, 4, 6, 0],
|
175
|
+
[2, 1, 20, 2],
|
176
|
+
[0, -1, 7, 14]]
|
177
|
+
ab = [[0.0, 20, 6, 2],
|
178
|
+
[1, 4, 20, 14],
|
179
|
+
[-30, 1, 7, 0],
|
180
|
+
[2, -1, 0, 0]]
|
181
|
+
l, u = 2, 1
|
182
|
+
b = [10.0, 0.0, 2.0, 14.0]
|
183
|
+
x = solve_banded((l, u), ab, b)
|
184
|
+
assert_array_almost_equal(dot(a, x), b)
|
185
|
+
|
186
|
+
@pytest.mark.parametrize('dt_ab', [int, float, np.float32, complex, np.complex64])
|
187
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
188
|
+
def test_empty(self, dt_ab, dt_b):
|
189
|
+
# ab contains one empty row corresponding to the diagonal
|
190
|
+
ab = np.array([[]], dtype=dt_ab)
|
191
|
+
b = np.array([], dtype=dt_b)
|
192
|
+
x = solve_banded((0, 0), ab, b)
|
193
|
+
|
194
|
+
assert x.shape == (0,)
|
195
|
+
assert x.dtype == solve(np.eye(1, dtype=dt_ab), np.ones(1, dtype=dt_b)).dtype
|
196
|
+
|
197
|
+
b = np.empty((0, 0), dtype=dt_b)
|
198
|
+
x = solve_banded((0, 0), ab, b)
|
199
|
+
|
200
|
+
assert x.shape == (0, 0)
|
201
|
+
assert x.dtype == solve(np.eye(1, dtype=dt_ab), np.ones(1, dtype=dt_b)).dtype
|
202
|
+
|
203
|
+
|
204
|
+
class TestSolveHBanded:
|
205
|
+
|
206
|
+
def test_01_upper(self):
|
207
|
+
# Solve
|
208
|
+
# [ 4 1 2 0] [1]
|
209
|
+
# [ 1 4 1 2] X = [4]
|
210
|
+
# [ 2 1 4 1] [1]
|
211
|
+
# [ 0 2 1 4] [2]
|
212
|
+
# with the RHS as a 1D array.
|
213
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
214
|
+
[-99, 1.0, 1.0, 1.0],
|
215
|
+
[4.0, 4.0, 4.0, 4.0]])
|
216
|
+
b = array([1.0, 4.0, 1.0, 2.0])
|
217
|
+
x = solveh_banded(ab, b)
|
218
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0, 0.0])
|
219
|
+
|
220
|
+
def test_02_upper(self):
|
221
|
+
# Solve
|
222
|
+
# [ 4 1 2 0] [1 6]
|
223
|
+
# [ 1 4 1 2] X = [4 2]
|
224
|
+
# [ 2 1 4 1] [1 6]
|
225
|
+
# [ 0 2 1 4] [2 1]
|
226
|
+
#
|
227
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
228
|
+
[-99, 1.0, 1.0, 1.0],
|
229
|
+
[4.0, 4.0, 4.0, 4.0]])
|
230
|
+
b = array([[1.0, 6.0],
|
231
|
+
[4.0, 2.0],
|
232
|
+
[1.0, 6.0],
|
233
|
+
[2.0, 1.0]])
|
234
|
+
x = solveh_banded(ab, b)
|
235
|
+
expected = array([[0.0, 1.0],
|
236
|
+
[1.0, 0.0],
|
237
|
+
[0.0, 1.0],
|
238
|
+
[0.0, 0.0]])
|
239
|
+
assert_array_almost_equal(x, expected)
|
240
|
+
|
241
|
+
def test_03_upper(self):
|
242
|
+
# Solve
|
243
|
+
# [ 4 1 2 0] [1]
|
244
|
+
# [ 1 4 1 2] X = [4]
|
245
|
+
# [ 2 1 4 1] [1]
|
246
|
+
# [ 0 2 1 4] [2]
|
247
|
+
# with the RHS as a 2D array with shape (3,1).
|
248
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
249
|
+
[-99, 1.0, 1.0, 1.0],
|
250
|
+
[4.0, 4.0, 4.0, 4.0]])
|
251
|
+
b = array([1.0, 4.0, 1.0, 2.0]).reshape(-1, 1)
|
252
|
+
x = solveh_banded(ab, b)
|
253
|
+
assert_array_almost_equal(x, array([0., 1., 0., 0.]).reshape(-1, 1))
|
254
|
+
|
255
|
+
def test_01_lower(self):
|
256
|
+
# Solve
|
257
|
+
# [ 4 1 2 0] [1]
|
258
|
+
# [ 1 4 1 2] X = [4]
|
259
|
+
# [ 2 1 4 1] [1]
|
260
|
+
# [ 0 2 1 4] [2]
|
261
|
+
#
|
262
|
+
ab = array([[4.0, 4.0, 4.0, 4.0],
|
263
|
+
[1.0, 1.0, 1.0, -99],
|
264
|
+
[2.0, 2.0, 0.0, 0.0]])
|
265
|
+
b = array([1.0, 4.0, 1.0, 2.0])
|
266
|
+
x = solveh_banded(ab, b, lower=True)
|
267
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0, 0.0])
|
268
|
+
|
269
|
+
def test_02_lower(self):
|
270
|
+
# Solve
|
271
|
+
# [ 4 1 2 0] [1 6]
|
272
|
+
# [ 1 4 1 2] X = [4 2]
|
273
|
+
# [ 2 1 4 1] [1 6]
|
274
|
+
# [ 0 2 1 4] [2 1]
|
275
|
+
#
|
276
|
+
ab = array([[4.0, 4.0, 4.0, 4.0],
|
277
|
+
[1.0, 1.0, 1.0, -99],
|
278
|
+
[2.0, 2.0, 0.0, 0.0]])
|
279
|
+
b = array([[1.0, 6.0],
|
280
|
+
[4.0, 2.0],
|
281
|
+
[1.0, 6.0],
|
282
|
+
[2.0, 1.0]])
|
283
|
+
x = solveh_banded(ab, b, lower=True)
|
284
|
+
expected = array([[0.0, 1.0],
|
285
|
+
[1.0, 0.0],
|
286
|
+
[0.0, 1.0],
|
287
|
+
[0.0, 0.0]])
|
288
|
+
assert_array_almost_equal(x, expected)
|
289
|
+
|
290
|
+
def test_01_float32(self):
|
291
|
+
# Solve
|
292
|
+
# [ 4 1 2 0] [1]
|
293
|
+
# [ 1 4 1 2] X = [4]
|
294
|
+
# [ 2 1 4 1] [1]
|
295
|
+
# [ 0 2 1 4] [2]
|
296
|
+
#
|
297
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
298
|
+
[-99, 1.0, 1.0, 1.0],
|
299
|
+
[4.0, 4.0, 4.0, 4.0]], dtype=float32)
|
300
|
+
b = array([1.0, 4.0, 1.0, 2.0], dtype=float32)
|
301
|
+
x = solveh_banded(ab, b)
|
302
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0, 0.0])
|
303
|
+
|
304
|
+
def test_02_float32(self):
|
305
|
+
# Solve
|
306
|
+
# [ 4 1 2 0] [1 6]
|
307
|
+
# [ 1 4 1 2] X = [4 2]
|
308
|
+
# [ 2 1 4 1] [1 6]
|
309
|
+
# [ 0 2 1 4] [2 1]
|
310
|
+
#
|
311
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
312
|
+
[-99, 1.0, 1.0, 1.0],
|
313
|
+
[4.0, 4.0, 4.0, 4.0]], dtype=float32)
|
314
|
+
b = array([[1.0, 6.0],
|
315
|
+
[4.0, 2.0],
|
316
|
+
[1.0, 6.0],
|
317
|
+
[2.0, 1.0]], dtype=float32)
|
318
|
+
x = solveh_banded(ab, b)
|
319
|
+
expected = array([[0.0, 1.0],
|
320
|
+
[1.0, 0.0],
|
321
|
+
[0.0, 1.0],
|
322
|
+
[0.0, 0.0]])
|
323
|
+
assert_array_almost_equal(x, expected)
|
324
|
+
|
325
|
+
def test_01_complex(self):
|
326
|
+
# Solve
|
327
|
+
# [ 4 -j 2 0] [2-j]
|
328
|
+
# [ j 4 -j 2] X = [4-j]
|
329
|
+
# [ 2 j 4 -j] [4+j]
|
330
|
+
# [ 0 2 j 4] [2+j]
|
331
|
+
#
|
332
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
333
|
+
[-99, -1.0j, -1.0j, -1.0j],
|
334
|
+
[4.0, 4.0, 4.0, 4.0]])
|
335
|
+
b = array([2-1.0j, 4.0-1j, 4+1j, 2+1j])
|
336
|
+
x = solveh_banded(ab, b)
|
337
|
+
assert_array_almost_equal(x, [0.0, 1.0, 1.0, 0.0])
|
338
|
+
|
339
|
+
def test_02_complex(self):
|
340
|
+
# Solve
|
341
|
+
# [ 4 -j 2 0] [2-j 2+4j]
|
342
|
+
# [ j 4 -j 2] X = [4-j -1-j]
|
343
|
+
# [ 2 j 4 -j] [4+j 4+2j]
|
344
|
+
# [ 0 2 j 4] [2+j j]
|
345
|
+
#
|
346
|
+
ab = array([[0.0, 0.0, 2.0, 2.0],
|
347
|
+
[-99, -1.0j, -1.0j, -1.0j],
|
348
|
+
[4.0, 4.0, 4.0, 4.0]])
|
349
|
+
b = array([[2-1j, 2+4j],
|
350
|
+
[4.0-1j, -1-1j],
|
351
|
+
[4.0+1j, 4+2j],
|
352
|
+
[2+1j, 1j]])
|
353
|
+
x = solveh_banded(ab, b)
|
354
|
+
expected = array([[0.0, 1.0j],
|
355
|
+
[1.0, 0.0],
|
356
|
+
[1.0, 1.0],
|
357
|
+
[0.0, 0.0]])
|
358
|
+
assert_array_almost_equal(x, expected)
|
359
|
+
|
360
|
+
def test_tridiag_01_upper(self):
|
361
|
+
# Solve
|
362
|
+
# [ 4 1 0] [1]
|
363
|
+
# [ 1 4 1] X = [4]
|
364
|
+
# [ 0 1 4] [1]
|
365
|
+
# with the RHS as a 1D array.
|
366
|
+
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
|
367
|
+
b = array([1.0, 4.0, 1.0])
|
368
|
+
x = solveh_banded(ab, b)
|
369
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
|
370
|
+
|
371
|
+
def test_tridiag_02_upper(self):
|
372
|
+
# Solve
|
373
|
+
# [ 4 1 0] [1 4]
|
374
|
+
# [ 1 4 1] X = [4 2]
|
375
|
+
# [ 0 1 4] [1 4]
|
376
|
+
#
|
377
|
+
ab = array([[-99, 1.0, 1.0],
|
378
|
+
[4.0, 4.0, 4.0]])
|
379
|
+
b = array([[1.0, 4.0],
|
380
|
+
[4.0, 2.0],
|
381
|
+
[1.0, 4.0]])
|
382
|
+
x = solveh_banded(ab, b)
|
383
|
+
expected = array([[0.0, 1.0],
|
384
|
+
[1.0, 0.0],
|
385
|
+
[0.0, 1.0]])
|
386
|
+
assert_array_almost_equal(x, expected)
|
387
|
+
|
388
|
+
def test_tridiag_03_upper(self):
|
389
|
+
# Solve
|
390
|
+
# [ 4 1 0] [1]
|
391
|
+
# [ 1 4 1] X = [4]
|
392
|
+
# [ 0 1 4] [1]
|
393
|
+
# with the RHS as a 2D array with shape (3,1).
|
394
|
+
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
|
395
|
+
b = array([1.0, 4.0, 1.0]).reshape(-1, 1)
|
396
|
+
x = solveh_banded(ab, b)
|
397
|
+
assert_array_almost_equal(x, array([0.0, 1.0, 0.0]).reshape(-1, 1))
|
398
|
+
|
399
|
+
def test_tridiag_01_lower(self):
|
400
|
+
# Solve
|
401
|
+
# [ 4 1 0] [1]
|
402
|
+
# [ 1 4 1] X = [4]
|
403
|
+
# [ 0 1 4] [1]
|
404
|
+
#
|
405
|
+
ab = array([[4.0, 4.0, 4.0],
|
406
|
+
[1.0, 1.0, -99]])
|
407
|
+
b = array([1.0, 4.0, 1.0])
|
408
|
+
x = solveh_banded(ab, b, lower=True)
|
409
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
|
410
|
+
|
411
|
+
def test_tridiag_02_lower(self):
|
412
|
+
# Solve
|
413
|
+
# [ 4 1 0] [1 4]
|
414
|
+
# [ 1 4 1] X = [4 2]
|
415
|
+
# [ 0 1 4] [1 4]
|
416
|
+
#
|
417
|
+
ab = array([[4.0, 4.0, 4.0],
|
418
|
+
[1.0, 1.0, -99]])
|
419
|
+
b = array([[1.0, 4.0],
|
420
|
+
[4.0, 2.0],
|
421
|
+
[1.0, 4.0]])
|
422
|
+
x = solveh_banded(ab, b, lower=True)
|
423
|
+
expected = array([[0.0, 1.0],
|
424
|
+
[1.0, 0.0],
|
425
|
+
[0.0, 1.0]])
|
426
|
+
assert_array_almost_equal(x, expected)
|
427
|
+
|
428
|
+
def test_tridiag_01_float32(self):
|
429
|
+
# Solve
|
430
|
+
# [ 4 1 0] [1]
|
431
|
+
# [ 1 4 1] X = [4]
|
432
|
+
# [ 0 1 4] [1]
|
433
|
+
#
|
434
|
+
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]], dtype=float32)
|
435
|
+
b = array([1.0, 4.0, 1.0], dtype=float32)
|
436
|
+
x = solveh_banded(ab, b)
|
437
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
|
438
|
+
|
439
|
+
def test_tridiag_02_float32(self):
|
440
|
+
# Solve
|
441
|
+
# [ 4 1 0] [1 4]
|
442
|
+
# [ 1 4 1] X = [4 2]
|
443
|
+
# [ 0 1 4] [1 4]
|
444
|
+
#
|
445
|
+
ab = array([[-99, 1.0, 1.0],
|
446
|
+
[4.0, 4.0, 4.0]], dtype=float32)
|
447
|
+
b = array([[1.0, 4.0],
|
448
|
+
[4.0, 2.0],
|
449
|
+
[1.0, 4.0]], dtype=float32)
|
450
|
+
x = solveh_banded(ab, b)
|
451
|
+
expected = array([[0.0, 1.0],
|
452
|
+
[1.0, 0.0],
|
453
|
+
[0.0, 1.0]])
|
454
|
+
assert_array_almost_equal(x, expected)
|
455
|
+
|
456
|
+
def test_tridiag_01_complex(self):
|
457
|
+
# Solve
|
458
|
+
# [ 4 -j 0] [ -j]
|
459
|
+
# [ j 4 -j] X = [4-j]
|
460
|
+
# [ 0 j 4] [4+j]
|
461
|
+
#
|
462
|
+
ab = array([[-99, -1.0j, -1.0j], [4.0, 4.0, 4.0]])
|
463
|
+
b = array([-1.0j, 4.0-1j, 4+1j])
|
464
|
+
x = solveh_banded(ab, b)
|
465
|
+
assert_array_almost_equal(x, [0.0, 1.0, 1.0])
|
466
|
+
|
467
|
+
def test_tridiag_02_complex(self):
|
468
|
+
# Solve
|
469
|
+
# [ 4 -j 0] [ -j 4j]
|
470
|
+
# [ j 4 -j] X = [4-j -1-j]
|
471
|
+
# [ 0 j 4] [4+j 4 ]
|
472
|
+
#
|
473
|
+
ab = array([[-99, -1.0j, -1.0j],
|
474
|
+
[4.0, 4.0, 4.0]])
|
475
|
+
b = array([[-1j, 4.0j],
|
476
|
+
[4.0-1j, -1.0-1j],
|
477
|
+
[4.0+1j, 4.0]])
|
478
|
+
x = solveh_banded(ab, b)
|
479
|
+
expected = array([[0.0, 1.0j],
|
480
|
+
[1.0, 0.0],
|
481
|
+
[1.0, 1.0]])
|
482
|
+
assert_array_almost_equal(x, expected)
|
483
|
+
|
484
|
+
def test_check_finite(self):
|
485
|
+
# Solve
|
486
|
+
# [ 4 1 0] [1]
|
487
|
+
# [ 1 4 1] X = [4]
|
488
|
+
# [ 0 1 4] [1]
|
489
|
+
# with the RHS as a 1D array.
|
490
|
+
ab = array([[-99, 1.0, 1.0], [4.0, 4.0, 4.0]])
|
491
|
+
b = array([1.0, 4.0, 1.0])
|
492
|
+
x = solveh_banded(ab, b, check_finite=False)
|
493
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0])
|
494
|
+
|
495
|
+
def test_bad_shapes(self):
|
496
|
+
ab = array([[-99, 1.0, 1.0],
|
497
|
+
[4.0, 4.0, 4.0]])
|
498
|
+
b = array([[1.0, 4.0],
|
499
|
+
[4.0, 2.0]])
|
500
|
+
assert_raises(ValueError, solveh_banded, ab, b)
|
501
|
+
assert_raises(ValueError, solveh_banded, ab, [1.0, 2.0])
|
502
|
+
assert_raises(ValueError, solveh_banded, ab, [1.0])
|
503
|
+
|
504
|
+
def test_1x1(self):
|
505
|
+
x = solveh_banded([[1]], [[1, 2, 3]])
|
506
|
+
assert_array_equal(x, [[1.0, 2.0, 3.0]])
|
507
|
+
assert_equal(x.dtype, np.dtype('f8'))
|
508
|
+
|
509
|
+
def test_native_list_arguments(self):
|
510
|
+
# Same as test_01_upper, using python's native list.
|
511
|
+
ab = [[0.0, 0.0, 2.0, 2.0],
|
512
|
+
[-99, 1.0, 1.0, 1.0],
|
513
|
+
[4.0, 4.0, 4.0, 4.0]]
|
514
|
+
b = [1.0, 4.0, 1.0, 2.0]
|
515
|
+
x = solveh_banded(ab, b)
|
516
|
+
assert_array_almost_equal(x, [0.0, 1.0, 0.0, 0.0])
|
517
|
+
|
518
|
+
@pytest.mark.parametrize('dt_ab', [int, float, np.float32, complex, np.complex64])
|
519
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
520
|
+
def test_empty(self, dt_ab, dt_b):
|
521
|
+
# ab contains one empty row corresponding to the diagonal
|
522
|
+
ab = np.array([[]], dtype=dt_ab)
|
523
|
+
b = np.array([], dtype=dt_b)
|
524
|
+
x = solveh_banded(ab, b)
|
525
|
+
|
526
|
+
assert x.shape == (0,)
|
527
|
+
assert x.dtype == solve(np.eye(1, dtype=dt_ab), np.ones(1, dtype=dt_b)).dtype
|
528
|
+
|
529
|
+
b = np.empty((0, 0), dtype=dt_b)
|
530
|
+
x = solveh_banded(ab, b)
|
531
|
+
|
532
|
+
assert x.shape == (0, 0)
|
533
|
+
assert x.dtype == solve(np.eye(1, dtype=dt_ab), np.ones(1, dtype=dt_b)).dtype
|
534
|
+
|
535
|
+
|
536
|
+
class TestSolve:
|
537
|
+
def setup_method(self):
|
538
|
+
np.random.seed(1234)
|
539
|
+
|
540
|
+
@pytest.mark.thread_unsafe
|
541
|
+
def test_20Feb04_bug(self):
|
542
|
+
a = [[1, 1], [1.0, 0]] # ok
|
543
|
+
x0 = solve(a, [1, 0j])
|
544
|
+
assert_array_almost_equal(dot(a, x0), [1, 0])
|
545
|
+
|
546
|
+
# gives failure with clapack.zgesv(..,rowmajor=0)
|
547
|
+
a = [[1, 1], [1.2, 0]]
|
548
|
+
b = [1, 0j]
|
549
|
+
x0 = solve(a, b)
|
550
|
+
assert_array_almost_equal(dot(a, x0), [1, 0])
|
551
|
+
|
552
|
+
def test_simple(self):
|
553
|
+
a = [[1, 20], [-30, 4]]
|
554
|
+
for b in ([[1, 0], [0, 1]],
|
555
|
+
[1, 0],
|
556
|
+
[[2, 1], [-30, 4]]
|
557
|
+
):
|
558
|
+
x = solve(a, b)
|
559
|
+
assert_array_almost_equal(dot(a, x), b)
|
560
|
+
|
561
|
+
def test_simple_complex(self):
|
562
|
+
a = array([[5, 2], [2j, 4]], 'D')
|
563
|
+
for b in ([1j, 0],
|
564
|
+
[[1j, 1j], [0, 2]],
|
565
|
+
[1, 0j],
|
566
|
+
array([1, 0], 'D'),
|
567
|
+
):
|
568
|
+
x = solve(a, b)
|
569
|
+
assert_array_almost_equal(dot(a, x), b)
|
570
|
+
|
571
|
+
def test_simple_pos(self):
|
572
|
+
a = [[2, 3], [3, 5]]
|
573
|
+
for lower in [0, 1]:
|
574
|
+
for b in ([[1, 0], [0, 1]],
|
575
|
+
[1, 0]
|
576
|
+
):
|
577
|
+
x = solve(a, b, assume_a='pos', lower=lower)
|
578
|
+
assert_array_almost_equal(dot(a, x), b)
|
579
|
+
|
580
|
+
def test_simple_pos_complexb(self):
|
581
|
+
a = [[5, 2], [2, 4]]
|
582
|
+
for b in ([1j, 0],
|
583
|
+
[[1j, 1j], [0, 2]],
|
584
|
+
):
|
585
|
+
x = solve(a, b, assume_a='pos')
|
586
|
+
assert_array_almost_equal(dot(a, x), b)
|
587
|
+
|
588
|
+
def test_simple_sym(self):
|
589
|
+
a = [[2, 3], [3, -5]]
|
590
|
+
for lower in [0, 1]:
|
591
|
+
for b in ([[1, 0], [0, 1]],
|
592
|
+
[1, 0]
|
593
|
+
):
|
594
|
+
x = solve(a, b, assume_a='sym', lower=lower)
|
595
|
+
assert_array_almost_equal(dot(a, x), b)
|
596
|
+
|
597
|
+
def test_simple_sym_complexb(self):
|
598
|
+
a = [[5, 2], [2, -4]]
|
599
|
+
for b in ([1j, 0],
|
600
|
+
[[1j, 1j], [0, 2]]
|
601
|
+
):
|
602
|
+
x = solve(a, b, assume_a='sym')
|
603
|
+
assert_array_almost_equal(dot(a, x), b)
|
604
|
+
|
605
|
+
def test_simple_sym_complex(self):
|
606
|
+
a = [[5, 2+1j], [2+1j, -4]]
|
607
|
+
for b in ([1j, 0],
|
608
|
+
[1, 0],
|
609
|
+
[[1j, 1j], [0, 2]]
|
610
|
+
):
|
611
|
+
x = solve(a, b, assume_a='sym')
|
612
|
+
assert_array_almost_equal(dot(a, x), b)
|
613
|
+
|
614
|
+
def test_simple_her_actuallysym(self):
|
615
|
+
a = [[2, 3], [3, -5]]
|
616
|
+
for lower in [0, 1]:
|
617
|
+
for b in ([[1, 0], [0, 1]],
|
618
|
+
[1, 0],
|
619
|
+
[1j, 0],
|
620
|
+
):
|
621
|
+
x = solve(a, b, assume_a='her', lower=lower)
|
622
|
+
assert_array_almost_equal(dot(a, x), b)
|
623
|
+
|
624
|
+
def test_simple_her(self):
|
625
|
+
a = [[5, 2+1j], [2-1j, -4]]
|
626
|
+
for b in ([1j, 0],
|
627
|
+
[1, 0],
|
628
|
+
[[1j, 1j], [0, 2]]
|
629
|
+
):
|
630
|
+
x = solve(a, b, assume_a='her')
|
631
|
+
assert_array_almost_equal(dot(a, x), b)
|
632
|
+
|
633
|
+
def test_nils_20Feb04(self):
|
634
|
+
n = 2
|
635
|
+
A = random([n, n])+random([n, n])*1j
|
636
|
+
X = zeros((n, n), 'D')
|
637
|
+
Ainv = inv(A)
|
638
|
+
R = identity(n)+identity(n)*0j
|
639
|
+
for i in arange(0, n):
|
640
|
+
r = R[:, i]
|
641
|
+
X[:, i] = solve(A, r)
|
642
|
+
assert_array_almost_equal(X, Ainv)
|
643
|
+
|
644
|
+
def test_random(self):
|
645
|
+
|
646
|
+
n = 20
|
647
|
+
a = random([n, n])
|
648
|
+
for i in range(n):
|
649
|
+
a[i, i] = 20*(.1+a[i, i])
|
650
|
+
for i in range(4):
|
651
|
+
b = random([n, 3])
|
652
|
+
x = solve(a, b)
|
653
|
+
assert_array_almost_equal(dot(a, x), b)
|
654
|
+
|
655
|
+
def test_random_complex(self):
|
656
|
+
n = 20
|
657
|
+
a = random([n, n]) + 1j * random([n, n])
|
658
|
+
for i in range(n):
|
659
|
+
a[i, i] = 20*(.1+a[i, i])
|
660
|
+
for i in range(2):
|
661
|
+
b = random([n, 3])
|
662
|
+
x = solve(a, b)
|
663
|
+
assert_array_almost_equal(dot(a, x), b)
|
664
|
+
|
665
|
+
def test_random_sym(self):
|
666
|
+
n = 20
|
667
|
+
a = random([n, n])
|
668
|
+
for i in range(n):
|
669
|
+
a[i, i] = abs(20*(.1+a[i, i]))
|
670
|
+
for j in range(i):
|
671
|
+
a[i, j] = a[j, i]
|
672
|
+
for i in range(4):
|
673
|
+
b = random([n])
|
674
|
+
x = solve(a, b, assume_a="pos")
|
675
|
+
assert_array_almost_equal(dot(a, x), b)
|
676
|
+
|
677
|
+
def test_random_sym_complex(self):
|
678
|
+
n = 20
|
679
|
+
a = random([n, n])
|
680
|
+
a = a + 1j*random([n, n])
|
681
|
+
for i in range(n):
|
682
|
+
a[i, i] = abs(20*(.1+a[i, i]))
|
683
|
+
for j in range(i):
|
684
|
+
a[i, j] = conjugate(a[j, i])
|
685
|
+
b = random([n])+2j*random([n])
|
686
|
+
for i in range(2):
|
687
|
+
x = solve(a, b, assume_a="pos")
|
688
|
+
assert_array_almost_equal(dot(a, x), b)
|
689
|
+
|
690
|
+
def test_check_finite(self):
|
691
|
+
a = [[1, 20], [-30, 4]]
|
692
|
+
for b in ([[1, 0], [0, 1]], [1, 0],
|
693
|
+
[[2, 1], [-30, 4]]):
|
694
|
+
x = solve(a, b, check_finite=False)
|
695
|
+
assert_array_almost_equal(dot(a, x), b)
|
696
|
+
|
697
|
+
def test_scalar_a_and_1D_b(self):
|
698
|
+
a = 1
|
699
|
+
b = [1, 2, 3]
|
700
|
+
x = solve(a, b)
|
701
|
+
assert_array_almost_equal(x.ravel(), b)
|
702
|
+
assert_(x.shape == (3,), 'Scalar_a_1D_b test returned wrong shape')
|
703
|
+
|
704
|
+
def test_simple2(self):
|
705
|
+
a = np.array([[1.80, 2.88, 2.05, -0.89],
|
706
|
+
[525.00, -295.00, -95.00, -380.00],
|
707
|
+
[1.58, -2.69, -2.90, -1.04],
|
708
|
+
[-1.11, -0.66, -0.59, 0.80]])
|
709
|
+
|
710
|
+
b = np.array([[9.52, 18.47],
|
711
|
+
[2435.00, 225.00],
|
712
|
+
[0.77, -13.28],
|
713
|
+
[-6.22, -6.21]])
|
714
|
+
|
715
|
+
x = solve(a, b)
|
716
|
+
assert_array_almost_equal(x, np.array([[1., -1, 3, -5],
|
717
|
+
[3, 2, 4, 1]]).T)
|
718
|
+
|
719
|
+
def test_simple_complex2(self):
|
720
|
+
a = np.array([[-1.34+2.55j, 0.28+3.17j, -6.39-2.20j, 0.72-0.92j],
|
721
|
+
[-1.70-14.10j, 33.10-1.50j, -1.50+13.40j, 12.90+13.80j],
|
722
|
+
[-3.29-2.39j, -1.91+4.42j, -0.14-1.35j, 1.72+1.35j],
|
723
|
+
[2.41+0.39j, -0.56+1.47j, -0.83-0.69j, -1.96+0.67j]])
|
724
|
+
|
725
|
+
b = np.array([[26.26+51.78j, 31.32-6.70j],
|
726
|
+
[64.30-86.80j, 158.60-14.20j],
|
727
|
+
[-5.75+25.31j, -2.15+30.19j],
|
728
|
+
[1.16+2.57j, -2.56+7.55j]])
|
729
|
+
|
730
|
+
x = solve(a, b)
|
731
|
+
assert_array_almost_equal(x, np. array([[1+1.j, -1-2.j],
|
732
|
+
[2-3.j, 5+1.j],
|
733
|
+
[-4-5.j, -3+4.j],
|
734
|
+
[6.j, 2-3.j]]))
|
735
|
+
|
736
|
+
@pytest.mark.parametrize("assume_a", ['her', 'sym'])
|
737
|
+
def test_symmetric_hermitian(self, assume_a):
|
738
|
+
# An upper triangular matrix will be used for symmetric/hermitian matrix a
|
739
|
+
a = np.array([[-1.84, 0.11-0.11j, -1.78-1.18j, 3.91-1.50j],
|
740
|
+
[0, -4.63, -1.84+0.03j, 2.21+0.21j],
|
741
|
+
[0, 0, -8.87, 1.58-0.90j],
|
742
|
+
[0, 0, 0, -1.36]])
|
743
|
+
b = np.array([[2.98-10.18j, 28.68-39.89j],
|
744
|
+
[-9.58+3.88j, -24.79-8.40j],
|
745
|
+
[-0.77-16.05j, 4.23-70.02j],
|
746
|
+
[7.79+5.48j, -35.39+18.01j]])
|
747
|
+
|
748
|
+
a2 = a.T if assume_a == 'sym' else a.conj().T # for testing `lower`
|
749
|
+
a3 = a + a2 # for reference solution
|
750
|
+
a3[np.arange(4), np.arange(4)] = np.diag(a)
|
751
|
+
ref = solve(a3, b, assume_a='general')
|
752
|
+
|
753
|
+
x = solve(a, b, assume_a=assume_a)
|
754
|
+
assert_array_almost_equal(x, ref)
|
755
|
+
# Also transpose(/conjugate) `a` and test for lower triangular data
|
756
|
+
# This also tests gh-22265 resolution; otherwise, a warning would be emitted
|
757
|
+
x = solve(a2, b, assume_a=assume_a, lower=True)
|
758
|
+
assert_array_almost_equal(x, ref)
|
759
|
+
|
760
|
+
def test_pos_and_sym(self):
|
761
|
+
A = np.arange(1, 10).reshape(3, 3)
|
762
|
+
x = solve(np.tril(A)/9, np.ones(3), assume_a='pos')
|
763
|
+
assert_array_almost_equal(x, [9., 1.8, 1.])
|
764
|
+
x = solve(np.tril(A)/9, np.ones(3), assume_a='sym')
|
765
|
+
assert_array_almost_equal(x, [9., 1.8, 1.])
|
766
|
+
|
767
|
+
def test_singularity(self):
|
768
|
+
a = np.array([[1, 0, 0, 0, 0, 0, 1, 0, 1],
|
769
|
+
[1, 1, 1, 0, 0, 0, 1, 0, 1],
|
770
|
+
[0, 1, 1, 0, 0, 0, 1, 0, 1],
|
771
|
+
[1, 0, 1, 1, 1, 1, 0, 0, 0],
|
772
|
+
[1, 0, 1, 1, 1, 1, 0, 0, 0],
|
773
|
+
[1, 0, 1, 1, 1, 1, 0, 0, 0],
|
774
|
+
[1, 0, 1, 1, 1, 1, 0, 0, 0],
|
775
|
+
[1, 1, 1, 1, 1, 1, 1, 1, 1],
|
776
|
+
[1, 1, 1, 1, 1, 1, 1, 1, 1]])
|
777
|
+
b = np.arange(9)[:, None]
|
778
|
+
assert_raises(LinAlgError, solve, a, b)
|
779
|
+
|
780
|
+
@pytest.mark.thread_unsafe
|
781
|
+
@pytest.mark.parametrize('structure',
|
782
|
+
('diagonal', 'tridiagonal', 'lower triangular',
|
783
|
+
'upper triangular', 'symmetric', 'hermitian',
|
784
|
+
'positive definite', 'general', 'banded', None))
|
785
|
+
def test_ill_condition_warning(self, structure):
|
786
|
+
rng = np.random.default_rng(234859349452)
|
787
|
+
n = 10
|
788
|
+
d = np.logspace(0, 50, n)
|
789
|
+
A = np.diag(d)
|
790
|
+
b = rng.random(size=n)
|
791
|
+
message = "Ill-conditioned matrix..."
|
792
|
+
with pytest.warns(LinAlgWarning, match=message):
|
793
|
+
solve(A, b, assume_a=structure)
|
794
|
+
|
795
|
+
@pytest.mark.thread_unsafe
|
796
|
+
@pytest.mark.parametrize('structure',
|
797
|
+
('diagonal', 'tridiagonal', 'lower triangular',
|
798
|
+
'upper triangular', 'symmetric', 'hermitian',
|
799
|
+
'positive definite', 'general', None))
|
800
|
+
def test_exactly_singular_gh22263(self, structure):
|
801
|
+
n = 10
|
802
|
+
A = np.zeros((n, n))
|
803
|
+
b = np.ones(n)
|
804
|
+
with (pytest.raises(LinAlgError, match="singular"), np.errstate(all='ignore')):
|
805
|
+
solve(A, b, assume_a=structure)
|
806
|
+
|
807
|
+
def test_multiple_rhs(self):
|
808
|
+
a = np.eye(2)
|
809
|
+
b = np.random.rand(2, 12)
|
810
|
+
x = solve(a, b)
|
811
|
+
assert_array_almost_equal(x, b)
|
812
|
+
|
813
|
+
def test_transposed_keyword(self):
|
814
|
+
A = np.arange(9).reshape(3, 3) + 1
|
815
|
+
x = solve(np.tril(A)/9, np.ones(3), transposed=True)
|
816
|
+
assert_array_almost_equal(x, [1.2, 0.2, 1])
|
817
|
+
x = solve(np.tril(A)/9, np.ones(3), transposed=False)
|
818
|
+
assert_array_almost_equal(x, [9, -5.4, -1.2])
|
819
|
+
|
820
|
+
def test_transposed_notimplemented(self):
|
821
|
+
a = np.eye(3).astype(complex)
|
822
|
+
with assert_raises(NotImplementedError):
|
823
|
+
solve(a, a, transposed=True)
|
824
|
+
|
825
|
+
def test_nonsquare_a(self):
|
826
|
+
assert_raises(ValueError, solve, [1, 2], 1)
|
827
|
+
|
828
|
+
def test_size_mismatch_with_1D_b(self):
|
829
|
+
assert_array_almost_equal(solve(np.eye(3), np.ones(3)), np.ones(3))
|
830
|
+
assert_raises(ValueError, solve, np.eye(3), np.ones(4))
|
831
|
+
|
832
|
+
def test_assume_a_keyword(self):
|
833
|
+
assert_raises(ValueError, solve, 1, 1, assume_a='zxcv')
|
834
|
+
|
835
|
+
@pytest.mark.skip(reason="Failure on OS X (gh-7500), "
|
836
|
+
"crash on Windows (gh-8064)")
|
837
|
+
def test_all_type_size_routine_combinations(self):
|
838
|
+
sizes = [10, 100]
|
839
|
+
assume_as = ['gen', 'sym', 'pos', 'her']
|
840
|
+
dtypes = [np.float32, np.float64, np.complex64, np.complex128]
|
841
|
+
for size, assume_a, dtype in itertools.product(sizes, assume_as,
|
842
|
+
dtypes):
|
843
|
+
is_complex = dtype in (np.complex64, np.complex128)
|
844
|
+
if assume_a == 'her' and not is_complex:
|
845
|
+
continue
|
846
|
+
|
847
|
+
err_msg = (f"Failed for size: {size}, assume_a: {assume_a},"
|
848
|
+
f"dtype: {dtype}")
|
849
|
+
|
850
|
+
a = np.random.randn(size, size).astype(dtype)
|
851
|
+
b = np.random.randn(size).astype(dtype)
|
852
|
+
if is_complex:
|
853
|
+
a = a + (1j*np.random.randn(size, size)).astype(dtype)
|
854
|
+
|
855
|
+
if assume_a == 'sym': # Can still be complex but only symmetric
|
856
|
+
a = a + a.T
|
857
|
+
elif assume_a == 'her': # Handle hermitian matrices here instead
|
858
|
+
a = a + a.T.conj()
|
859
|
+
elif assume_a == 'pos':
|
860
|
+
a = a.conj().T.dot(a) + 0.1*np.eye(size)
|
861
|
+
|
862
|
+
tol = 1e-12 if dtype in (np.float64, np.complex128) else 1e-6
|
863
|
+
|
864
|
+
if assume_a in ['gen', 'sym', 'her']:
|
865
|
+
# We revert the tolerance from before
|
866
|
+
# 4b4a6e7c34fa4060533db38f9a819b98fa81476c
|
867
|
+
if dtype in (np.float32, np.complex64):
|
868
|
+
tol *= 10
|
869
|
+
|
870
|
+
x = solve(a, b, assume_a=assume_a)
|
871
|
+
assert_allclose(a.dot(x), b,
|
872
|
+
atol=tol * size,
|
873
|
+
rtol=tol * size,
|
874
|
+
err_msg=err_msg)
|
875
|
+
|
876
|
+
if assume_a == 'sym' and dtype not in (np.complex64,
|
877
|
+
np.complex128):
|
878
|
+
x = solve(a, b, assume_a=assume_a, transposed=True)
|
879
|
+
assert_allclose(a.dot(x), b,
|
880
|
+
atol=tol * size,
|
881
|
+
rtol=tol * size,
|
882
|
+
err_msg=err_msg)
|
883
|
+
|
884
|
+
@pytest.mark.thread_unsafe
|
885
|
+
@pytest.mark.parametrize('dt_a', [int, float, np.float32, complex, np.complex64])
|
886
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
887
|
+
def test_empty(self, dt_a, dt_b):
|
888
|
+
a = np.empty((0, 0), dtype=dt_a)
|
889
|
+
b = np.empty(0, dtype=dt_b)
|
890
|
+
x = solve(a, b)
|
891
|
+
|
892
|
+
assert x.size == 0
|
893
|
+
dt_nonempty = solve(np.eye(2, dtype=dt_a), np.ones(2, dtype=dt_b)).dtype
|
894
|
+
assert x.dtype == dt_nonempty
|
895
|
+
|
896
|
+
def test_empty_rhs(self):
|
897
|
+
a = np.eye(2)
|
898
|
+
b = [[], []]
|
899
|
+
x = solve(a, b)
|
900
|
+
assert_(x.size == 0, 'Returned array is not empty')
|
901
|
+
assert_(x.shape == (2, 0), 'Returned empty array shape is wrong')
|
902
|
+
|
903
|
+
@pytest.mark.parametrize('dtype', [np.float64, np.complex128])
|
904
|
+
# "pos" and "positive definite" need to be added
|
905
|
+
@pytest.mark.parametrize('assume_a', ['diagonal', 'tridiagonal', 'banded',
|
906
|
+
'lower triangular', 'upper triangular',
|
907
|
+
'symmetric', 'hermitian', 'banded',
|
908
|
+
'general', 'sym', 'her', 'gen'])
|
909
|
+
@pytest.mark.parametrize('nrhs', [(), (5,)])
|
910
|
+
@pytest.mark.parametrize('transposed', [True, False])
|
911
|
+
@pytest.mark.parametrize('overwrite', [True, False])
|
912
|
+
@pytest.mark.parametrize('fortran', [True, False])
|
913
|
+
def test_structure_detection(self, dtype, assume_a, nrhs, transposed,
|
914
|
+
overwrite, fortran):
|
915
|
+
rng = np.random.default_rng(982345982439826)
|
916
|
+
n = 5 if not assume_a == 'banded' else 20
|
917
|
+
b = rng.random(size=(n,) + nrhs)
|
918
|
+
A = rng.random(size=(n, n))
|
919
|
+
|
920
|
+
if np.issubdtype(dtype, np.complexfloating):
|
921
|
+
b = b + rng.random(size=(n,) + nrhs) * 1j
|
922
|
+
A = A + rng.random(size=(n, n)) * 1j
|
923
|
+
|
924
|
+
if assume_a == 'diagonal':
|
925
|
+
A = np.diag(np.diag(A))
|
926
|
+
elif assume_a == 'lower triangular':
|
927
|
+
A = np.tril(A)
|
928
|
+
elif assume_a == 'upper triangular':
|
929
|
+
A = np.triu(A)
|
930
|
+
elif assume_a == 'tridiagonal':
|
931
|
+
A = (np.diag(np.diag(A))
|
932
|
+
+ np.diag(np.diag(A, -1), -1)
|
933
|
+
+ np.diag(np.diag(A, 1), 1))
|
934
|
+
elif assume_a == 'banded':
|
935
|
+
A = np.triu(np.tril(A, 2), -1)
|
936
|
+
elif assume_a in {'symmetric', 'sym'}:
|
937
|
+
A = A + A.T
|
938
|
+
elif assume_a in {'hermitian', 'her'}:
|
939
|
+
A = A + A.conj().T
|
940
|
+
elif assume_a in {'positive definite', 'pos'}:
|
941
|
+
A = A + A.T
|
942
|
+
A += np.diag(A.sum(axis=1))
|
943
|
+
|
944
|
+
if fortran:
|
945
|
+
A = np.asfortranarray(A)
|
946
|
+
|
947
|
+
A_copy = A.copy(order='A')
|
948
|
+
b_copy = b.copy()
|
949
|
+
|
950
|
+
if np.issubdtype(dtype, np.complexfloating) and transposed:
|
951
|
+
message = "scipy.linalg.solve can currently..."
|
952
|
+
with pytest.raises(NotImplementedError, match=message):
|
953
|
+
solve(A, b, overwrite_a=overwrite, overwrite_b=overwrite,
|
954
|
+
transposed=transposed)
|
955
|
+
return
|
956
|
+
|
957
|
+
res = solve(A, b, overwrite_a=overwrite, overwrite_b=overwrite,
|
958
|
+
transposed=transposed, assume_a=assume_a)
|
959
|
+
|
960
|
+
# Check that solution this solution is *correct*
|
961
|
+
ref = np.linalg.solve(A_copy.T if transposed else A_copy, b_copy)
|
962
|
+
assert_allclose(res, ref)
|
963
|
+
|
964
|
+
# Check that `solve` correctly identifies the structure and returns
|
965
|
+
# *exactly* the same solution whether `assume_a` is specified or not
|
966
|
+
if assume_a != 'banded': # structure detection removed for banded
|
967
|
+
assert_equal(solve(A_copy, b_copy, transposed=transposed), res)
|
968
|
+
|
969
|
+
# Check that overwrite was respected
|
970
|
+
if not overwrite:
|
971
|
+
assert_equal(A, A_copy)
|
972
|
+
assert_equal(b, b_copy)
|
973
|
+
|
974
|
+
|
975
|
+
class TestSolveTriangular:
|
976
|
+
|
977
|
+
def test_simple(self):
|
978
|
+
"""
|
979
|
+
solve_triangular on a simple 2x2 matrix.
|
980
|
+
"""
|
981
|
+
A = array([[1, 0], [1, 2]])
|
982
|
+
b = [1, 1]
|
983
|
+
sol = solve_triangular(A, b, lower=True)
|
984
|
+
assert_array_almost_equal(sol, [1, 0])
|
985
|
+
|
986
|
+
# check that it works also for non-contiguous matrices
|
987
|
+
sol = solve_triangular(A.T, b, lower=False)
|
988
|
+
assert_array_almost_equal(sol, [.5, .5])
|
989
|
+
|
990
|
+
# and that it gives the same result as trans=1
|
991
|
+
sol = solve_triangular(A, b, lower=True, trans=1)
|
992
|
+
assert_array_almost_equal(sol, [.5, .5])
|
993
|
+
|
994
|
+
b = identity(2)
|
995
|
+
sol = solve_triangular(A, b, lower=True, trans=1)
|
996
|
+
assert_array_almost_equal(sol, [[1., -.5], [0, 0.5]])
|
997
|
+
|
998
|
+
def test_simple_complex(self):
|
999
|
+
"""
|
1000
|
+
solve_triangular on a simple 2x2 complex matrix
|
1001
|
+
"""
|
1002
|
+
A = array([[1+1j, 0], [1j, 2]])
|
1003
|
+
b = identity(2)
|
1004
|
+
sol = solve_triangular(A, b, lower=True, trans=1)
|
1005
|
+
assert_array_almost_equal(sol, [[.5-.5j, -.25-.25j], [0, 0.5]])
|
1006
|
+
|
1007
|
+
# check other option combinations with complex rhs
|
1008
|
+
b = np.diag([1+1j, 1+2j])
|
1009
|
+
sol = solve_triangular(A, b, lower=True, trans=0)
|
1010
|
+
assert_array_almost_equal(sol, [[1, 0], [-0.5j, 0.5+1j]])
|
1011
|
+
|
1012
|
+
sol = solve_triangular(A, b, lower=True, trans=1)
|
1013
|
+
assert_array_almost_equal(sol, [[1, 0.25-0.75j], [0, 0.5+1j]])
|
1014
|
+
|
1015
|
+
sol = solve_triangular(A, b, lower=True, trans=2)
|
1016
|
+
assert_array_almost_equal(sol, [[1j, -0.75-0.25j], [0, 0.5+1j]])
|
1017
|
+
|
1018
|
+
sol = solve_triangular(A.T, b, lower=False, trans=0)
|
1019
|
+
assert_array_almost_equal(sol, [[1, 0.25-0.75j], [0, 0.5+1j]])
|
1020
|
+
|
1021
|
+
sol = solve_triangular(A.T, b, lower=False, trans=1)
|
1022
|
+
assert_array_almost_equal(sol, [[1, 0], [-0.5j, 0.5+1j]])
|
1023
|
+
|
1024
|
+
sol = solve_triangular(A.T, b, lower=False, trans=2)
|
1025
|
+
assert_array_almost_equal(sol, [[1j, 0], [-0.5, 0.5+1j]])
|
1026
|
+
|
1027
|
+
def test_check_finite(self):
|
1028
|
+
"""
|
1029
|
+
solve_triangular on a simple 2x2 matrix.
|
1030
|
+
"""
|
1031
|
+
A = array([[1, 0], [1, 2]])
|
1032
|
+
b = [1, 1]
|
1033
|
+
sol = solve_triangular(A, b, lower=True, check_finite=False)
|
1034
|
+
assert_array_almost_equal(sol, [1, 0])
|
1035
|
+
|
1036
|
+
@pytest.mark.parametrize('dt_a', [int, float, np.float32, complex, np.complex64])
|
1037
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
1038
|
+
def test_empty(self, dt_a, dt_b):
|
1039
|
+
a = np.empty((0, 0), dtype=dt_a)
|
1040
|
+
b = np.empty(0, dtype=dt_b)
|
1041
|
+
x = solve_triangular(a, b)
|
1042
|
+
|
1043
|
+
assert x.size == 0
|
1044
|
+
dt_nonempty = solve_triangular(
|
1045
|
+
np.eye(2, dtype=dt_a), np.ones(2, dtype=dt_b)
|
1046
|
+
).dtype
|
1047
|
+
assert x.dtype == dt_nonempty
|
1048
|
+
|
1049
|
+
def test_empty_rhs(self):
|
1050
|
+
a = np.eye(2)
|
1051
|
+
b = [[], []]
|
1052
|
+
x = solve_triangular(a, b)
|
1053
|
+
assert_(x.size == 0, 'Returned array is not empty')
|
1054
|
+
assert_(x.shape == (2, 0), 'Returned empty array shape is wrong')
|
1055
|
+
|
1056
|
+
|
1057
|
+
class TestInv:
|
1058
|
+
def setup_method(self):
|
1059
|
+
np.random.seed(1234)
|
1060
|
+
|
1061
|
+
def test_simple(self):
|
1062
|
+
a = [[1, 2], [3, 4]]
|
1063
|
+
a_inv = inv(a)
|
1064
|
+
assert_array_almost_equal(dot(a, a_inv), np.eye(2))
|
1065
|
+
a = [[1, 2, 3], [4, 5, 6], [7, 8, 10]]
|
1066
|
+
a_inv = inv(a)
|
1067
|
+
assert_array_almost_equal(dot(a, a_inv), np.eye(3))
|
1068
|
+
|
1069
|
+
def test_random(self):
|
1070
|
+
n = 20
|
1071
|
+
for i in range(4):
|
1072
|
+
a = random([n, n])
|
1073
|
+
for i in range(n):
|
1074
|
+
a[i, i] = 20*(.1+a[i, i])
|
1075
|
+
a_inv = inv(a)
|
1076
|
+
assert_array_almost_equal(dot(a, a_inv),
|
1077
|
+
identity(n))
|
1078
|
+
|
1079
|
+
def test_simple_complex(self):
|
1080
|
+
a = [[1, 2], [3, 4j]]
|
1081
|
+
a_inv = inv(a)
|
1082
|
+
assert_array_almost_equal(dot(a, a_inv), [[1, 0], [0, 1]])
|
1083
|
+
|
1084
|
+
def test_random_complex(self):
|
1085
|
+
n = 20
|
1086
|
+
for i in range(4):
|
1087
|
+
a = random([n, n])+2j*random([n, n])
|
1088
|
+
for i in range(n):
|
1089
|
+
a[i, i] = 20*(.1+a[i, i])
|
1090
|
+
a_inv = inv(a)
|
1091
|
+
assert_array_almost_equal(dot(a, a_inv),
|
1092
|
+
identity(n))
|
1093
|
+
|
1094
|
+
def test_check_finite(self):
|
1095
|
+
a = [[1, 2], [3, 4]]
|
1096
|
+
a_inv = inv(a, check_finite=False)
|
1097
|
+
assert_array_almost_equal(dot(a, a_inv), [[1, 0], [0, 1]])
|
1098
|
+
|
1099
|
+
@pytest.mark.parametrize('dt', [int, float, np.float32, complex, np.complex64])
|
1100
|
+
def test_empty(self, dt):
|
1101
|
+
a = np.empty((0, 0), dtype=dt)
|
1102
|
+
a_inv = inv(a)
|
1103
|
+
assert a_inv.size == 0
|
1104
|
+
assert a_inv.dtype == inv(np.eye(2, dtype=dt)).dtype
|
1105
|
+
|
1106
|
+
|
1107
|
+
class TestDet:
|
1108
|
+
def setup_method(self):
|
1109
|
+
self.rng = np.random.default_rng(1680305949878959)
|
1110
|
+
|
1111
|
+
def test_1x1_all_singleton_dims(self):
|
1112
|
+
a = np.array([[1]])
|
1113
|
+
deta = det(a)
|
1114
|
+
assert deta.dtype.char == 'd'
|
1115
|
+
assert np.isscalar(deta)
|
1116
|
+
assert deta == 1.
|
1117
|
+
a = np.array([[[[1]]]], dtype='f')
|
1118
|
+
deta = det(a)
|
1119
|
+
assert deta.dtype.char == 'd'
|
1120
|
+
assert deta.shape == (1, 1)
|
1121
|
+
assert_equal(deta, [[1.0]])
|
1122
|
+
a = np.array([[[1 + 3.j]]], dtype=np.complex64)
|
1123
|
+
deta = det(a)
|
1124
|
+
assert deta.dtype.char == 'D'
|
1125
|
+
assert deta.shape == (1,)
|
1126
|
+
assert_equal(deta, [1.+3.j])
|
1127
|
+
|
1128
|
+
def test_1by1_stacked_input_output(self):
|
1129
|
+
a = self.rng.random([4, 5, 1, 1], dtype=np.float32)
|
1130
|
+
deta = det(a)
|
1131
|
+
assert deta.dtype.char == 'd'
|
1132
|
+
assert deta.shape == (4, 5)
|
1133
|
+
assert_allclose(deta, np.squeeze(a))
|
1134
|
+
|
1135
|
+
a = self.rng.random([4, 5, 1, 1], dtype=np.float32)*np.complex64(1.j)
|
1136
|
+
deta = det(a)
|
1137
|
+
assert deta.dtype.char == 'D'
|
1138
|
+
assert deta.shape == (4, 5)
|
1139
|
+
assert_allclose(deta, np.squeeze(a))
|
1140
|
+
|
1141
|
+
@pytest.mark.parametrize('shape', [[2, 2], [20, 20], [3, 2, 20, 20]])
|
1142
|
+
def test_simple_det_shapes_real_complex(self, shape):
|
1143
|
+
a = self.rng.uniform(-1., 1., size=shape)
|
1144
|
+
d1, d2 = det(a), np.linalg.det(a)
|
1145
|
+
assert_allclose(d1, d2)
|
1146
|
+
|
1147
|
+
b = self.rng.uniform(-1., 1., size=shape)*1j
|
1148
|
+
b += self.rng.uniform(-0.5, 0.5, size=shape)
|
1149
|
+
d3, d4 = det(b), np.linalg.det(b)
|
1150
|
+
assert_allclose(d3, d4)
|
1151
|
+
|
1152
|
+
def test_for_known_det_values(self):
|
1153
|
+
# Hadamard8
|
1154
|
+
a = np.array([[1, 1, 1, 1, 1, 1, 1, 1],
|
1155
|
+
[1, -1, 1, -1, 1, -1, 1, -1],
|
1156
|
+
[1, 1, -1, -1, 1, 1, -1, -1],
|
1157
|
+
[1, -1, -1, 1, 1, -1, -1, 1],
|
1158
|
+
[1, 1, 1, 1, -1, -1, -1, -1],
|
1159
|
+
[1, -1, 1, -1, -1, 1, -1, 1],
|
1160
|
+
[1, 1, -1, -1, -1, -1, 1, 1],
|
1161
|
+
[1, -1, -1, 1, -1, 1, 1, -1]])
|
1162
|
+
assert_allclose(det(a), 4096.)
|
1163
|
+
|
1164
|
+
# consecutive number array always singular
|
1165
|
+
assert_allclose(det(np.arange(25).reshape(5, 5)), 0.)
|
1166
|
+
|
1167
|
+
# simple anti-diagonal block array
|
1168
|
+
# Upper right has det (-2+1j) and lower right has (-2-1j)
|
1169
|
+
# det(a) = - (-2+1j) (-2-1j) = 5.
|
1170
|
+
a = np.array([[0.+0.j, 0.+0.j, 0.-1.j, 1.-1.j],
|
1171
|
+
[0.+0.j, 0.+0.j, 1.+0.j, 0.-1.j],
|
1172
|
+
[0.+1.j, 1.+1.j, 0.+0.j, 0.+0.j],
|
1173
|
+
[1.+0.j, 0.+1.j, 0.+0.j, 0.+0.j]], dtype=np.complex64)
|
1174
|
+
assert_allclose(det(a), 5.+0.j)
|
1175
|
+
|
1176
|
+
# Fiedler companion complexified
|
1177
|
+
# >>> a = scipy.linalg.fiedler_companion(np.arange(1, 10))
|
1178
|
+
a = np.array([[-2., -3., 1., 0., 0., 0., 0., 0.],
|
1179
|
+
[1., 0., 0., 0., 0., 0., 0., 0.],
|
1180
|
+
[0., -4., 0., -5., 1., 0., 0., 0.],
|
1181
|
+
[0., 1., 0., 0., 0., 0., 0., 0.],
|
1182
|
+
[0., 0., 0., -6., 0., -7., 1., 0.],
|
1183
|
+
[0., 0., 0., 1., 0., 0., 0., 0.],
|
1184
|
+
[0., 0., 0., 0., 0., -8., 0., -9.],
|
1185
|
+
[0., 0., 0., 0., 0., 1., 0., 0.]])*1.j
|
1186
|
+
assert_allclose(det(a), 9.)
|
1187
|
+
|
1188
|
+
# g and G dtypes are handled differently in windows and other platforms
|
1189
|
+
@pytest.mark.parametrize('typ', [x for x in np.typecodes['All'][:20]
|
1190
|
+
if x not in 'gG'])
|
1191
|
+
def test_sample_compatible_dtype_input(self, typ):
|
1192
|
+
n = 4
|
1193
|
+
a = self.rng.random([n, n]).astype(typ) # value is not important
|
1194
|
+
assert isinstance(det(a), (np.float64 | np.complex128))
|
1195
|
+
|
1196
|
+
def test_incompatible_dtype_input(self):
|
1197
|
+
# Double backslashes needed for escaping pytest regex.
|
1198
|
+
msg = 'cannot be cast to float\\(32, 64\\)'
|
1199
|
+
|
1200
|
+
for c, t in zip('SUO', ['bytes8', 'str32', 'object']):
|
1201
|
+
with assert_raises(TypeError, match=msg):
|
1202
|
+
det(np.array([['a', 'b']]*2, dtype=c))
|
1203
|
+
with assert_raises(TypeError, match=msg):
|
1204
|
+
det(np.array([[b'a', b'b']]*2, dtype='V'))
|
1205
|
+
with assert_raises(TypeError, match=msg):
|
1206
|
+
det(np.array([[100, 200]]*2, dtype='datetime64[s]'))
|
1207
|
+
with assert_raises(TypeError, match=msg):
|
1208
|
+
det(np.array([[100, 200]]*2, dtype='timedelta64[s]'))
|
1209
|
+
|
1210
|
+
def test_empty_edge_cases(self):
|
1211
|
+
assert_allclose(det(np.empty([0, 0])), 1.)
|
1212
|
+
assert_allclose(det(np.empty([0, 0, 0])), np.array([]))
|
1213
|
+
assert_allclose(det(np.empty([3, 0, 0])), np.array([1., 1., 1.]))
|
1214
|
+
with assert_raises(ValueError, match='Last 2 dimensions'):
|
1215
|
+
det(np.empty([0, 0, 3]))
|
1216
|
+
with assert_raises(ValueError, match='at least two-dimensional'):
|
1217
|
+
det(np.array([]))
|
1218
|
+
with assert_raises(ValueError, match='Last 2 dimensions'):
|
1219
|
+
det(np.array([[]]))
|
1220
|
+
with assert_raises(ValueError, match='Last 2 dimensions'):
|
1221
|
+
det(np.array([[[]]]))
|
1222
|
+
|
1223
|
+
@pytest.mark.parametrize('dt', [int, float, np.float32, complex, np.complex64])
|
1224
|
+
def test_empty_dtype(self, dt):
|
1225
|
+
a = np.empty((0, 0), dtype=dt)
|
1226
|
+
d = det(a)
|
1227
|
+
assert d.shape == ()
|
1228
|
+
assert d.dtype == det(np.eye(2, dtype=dt)).dtype
|
1229
|
+
|
1230
|
+
a = np.empty((3, 0, 0), dtype=dt)
|
1231
|
+
d = det(a)
|
1232
|
+
assert d.shape == (3,)
|
1233
|
+
assert d.dtype == det(np.zeros((3, 1, 1), dtype=dt)).dtype
|
1234
|
+
|
1235
|
+
def test_overwrite_a(self):
|
1236
|
+
# If all conditions are met then input should be overwritten;
|
1237
|
+
# - dtype is one of 'fdFD'
|
1238
|
+
# - C-contiguous
|
1239
|
+
# - writeable
|
1240
|
+
a = np.arange(9).reshape(3, 3).astype(np.float32)
|
1241
|
+
ac = a.copy()
|
1242
|
+
deta = det(ac, overwrite_a=True)
|
1243
|
+
assert_allclose(deta, 0.)
|
1244
|
+
assert not (a == ac).all()
|
1245
|
+
|
1246
|
+
def test_readonly_array(self):
|
1247
|
+
a = np.array([[2., 0., 1.], [5., 3., -1.], [1., 1., 1.]])
|
1248
|
+
a.setflags(write=False)
|
1249
|
+
# overwrite_a will be overridden
|
1250
|
+
assert_allclose(det(a, overwrite_a=True), 10.)
|
1251
|
+
|
1252
|
+
def test_simple_check_finite(self):
|
1253
|
+
a = [[1, 2], [3, np.inf]]
|
1254
|
+
with assert_raises(ValueError, match='array must not contain'):
|
1255
|
+
det(a)
|
1256
|
+
|
1257
|
+
|
1258
|
+
def direct_lstsq(a, b, cmplx=0):
|
1259
|
+
at = transpose(a)
|
1260
|
+
if cmplx:
|
1261
|
+
at = conjugate(at)
|
1262
|
+
a1 = dot(at, a)
|
1263
|
+
b1 = dot(at, b)
|
1264
|
+
return solve(a1, b1)
|
1265
|
+
|
1266
|
+
|
1267
|
+
class TestLstsq:
|
1268
|
+
lapack_drivers = ('gelsd', 'gelss', 'gelsy', None)
|
1269
|
+
|
1270
|
+
def test_simple_exact(self):
|
1271
|
+
for dtype in REAL_DTYPES:
|
1272
|
+
a = np.array([[1, 20], [-30, 4]], dtype=dtype)
|
1273
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1274
|
+
for overwrite in (True, False):
|
1275
|
+
for bt in (((1, 0), (0, 1)), (1, 0),
|
1276
|
+
((2, 1), (-30, 4))):
|
1277
|
+
# Store values in case they are overwritten
|
1278
|
+
# later
|
1279
|
+
a1 = a.copy()
|
1280
|
+
b = np.array(bt, dtype=dtype)
|
1281
|
+
b1 = b.copy()
|
1282
|
+
out = lstsq(a1, b1,
|
1283
|
+
lapack_driver=lapack_driver,
|
1284
|
+
overwrite_a=overwrite,
|
1285
|
+
overwrite_b=overwrite)
|
1286
|
+
x = out[0]
|
1287
|
+
r = out[2]
|
1288
|
+
assert_(r == 2,
|
1289
|
+
f'expected efficient rank 2, got {r}')
|
1290
|
+
assert_allclose(dot(a, x), b,
|
1291
|
+
atol=25 * _eps_cast(a1.dtype),
|
1292
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1293
|
+
err_msg=f"driver: {lapack_driver}")
|
1294
|
+
|
1295
|
+
def test_simple_overdet(self):
|
1296
|
+
for dtype in REAL_DTYPES:
|
1297
|
+
a = np.array([[1, 2], [4, 5], [3, 4]], dtype=dtype)
|
1298
|
+
b = np.array([1, 2, 3], dtype=dtype)
|
1299
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1300
|
+
for overwrite in (True, False):
|
1301
|
+
# Store values in case they are overwritten later
|
1302
|
+
a1 = a.copy()
|
1303
|
+
b1 = b.copy()
|
1304
|
+
out = lstsq(a1, b1, lapack_driver=lapack_driver,
|
1305
|
+
overwrite_a=overwrite,
|
1306
|
+
overwrite_b=overwrite)
|
1307
|
+
x = out[0]
|
1308
|
+
if lapack_driver == 'gelsy':
|
1309
|
+
residuals = np.sum((b - a.dot(x))**2)
|
1310
|
+
else:
|
1311
|
+
residuals = out[1]
|
1312
|
+
r = out[2]
|
1313
|
+
assert_(r == 2, f'expected efficient rank 2, got {r}')
|
1314
|
+
assert_allclose(abs((dot(a, x) - b)**2).sum(axis=0),
|
1315
|
+
residuals,
|
1316
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1317
|
+
atol=25 * _eps_cast(a1.dtype),
|
1318
|
+
err_msg=f"driver: {lapack_driver}")
|
1319
|
+
assert_allclose(x, (-0.428571428571429, 0.85714285714285),
|
1320
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1321
|
+
atol=25 * _eps_cast(a1.dtype),
|
1322
|
+
err_msg=f"driver: {lapack_driver}")
|
1323
|
+
|
1324
|
+
def test_simple_overdet_complex(self):
|
1325
|
+
for dtype in COMPLEX_DTYPES:
|
1326
|
+
a = np.array([[1+2j, 2], [4, 5], [3, 4]], dtype=dtype)
|
1327
|
+
b = np.array([1, 2+4j, 3], dtype=dtype)
|
1328
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1329
|
+
for overwrite in (True, False):
|
1330
|
+
# Store values in case they are overwritten later
|
1331
|
+
a1 = a.copy()
|
1332
|
+
b1 = b.copy()
|
1333
|
+
out = lstsq(a1, b1, lapack_driver=lapack_driver,
|
1334
|
+
overwrite_a=overwrite,
|
1335
|
+
overwrite_b=overwrite)
|
1336
|
+
|
1337
|
+
x = out[0]
|
1338
|
+
if lapack_driver == 'gelsy':
|
1339
|
+
res = b - a.dot(x)
|
1340
|
+
residuals = np.sum(res * res.conj())
|
1341
|
+
else:
|
1342
|
+
residuals = out[1]
|
1343
|
+
r = out[2]
|
1344
|
+
assert_(r == 2, f'expected efficient rank 2, got {r}')
|
1345
|
+
assert_allclose(abs((dot(a, x) - b)**2).sum(axis=0),
|
1346
|
+
residuals,
|
1347
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1348
|
+
atol=25 * _eps_cast(a1.dtype),
|
1349
|
+
err_msg=f"driver: {lapack_driver}")
|
1350
|
+
assert_allclose(
|
1351
|
+
x, (-0.4831460674157303 + 0.258426966292135j,
|
1352
|
+
0.921348314606741 + 0.292134831460674j),
|
1353
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1354
|
+
atol=25 * _eps_cast(a1.dtype),
|
1355
|
+
err_msg=f"driver: {lapack_driver}")
|
1356
|
+
|
1357
|
+
def test_simple_underdet(self):
|
1358
|
+
for dtype in REAL_DTYPES:
|
1359
|
+
a = np.array([[1, 2, 3], [4, 5, 6]], dtype=dtype)
|
1360
|
+
b = np.array([1, 2], dtype=dtype)
|
1361
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1362
|
+
for overwrite in (True, False):
|
1363
|
+
# Store values in case they are overwritten later
|
1364
|
+
a1 = a.copy()
|
1365
|
+
b1 = b.copy()
|
1366
|
+
out = lstsq(a1, b1, lapack_driver=lapack_driver,
|
1367
|
+
overwrite_a=overwrite,
|
1368
|
+
overwrite_b=overwrite)
|
1369
|
+
|
1370
|
+
x = out[0]
|
1371
|
+
r = out[2]
|
1372
|
+
assert_(r == 2, f'expected efficient rank 2, got {r}')
|
1373
|
+
assert_allclose(x, (-0.055555555555555, 0.111111111111111,
|
1374
|
+
0.277777777777777),
|
1375
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1376
|
+
atol=25 * _eps_cast(a1.dtype),
|
1377
|
+
err_msg=f"driver: {lapack_driver}")
|
1378
|
+
|
1379
|
+
@pytest.mark.parametrize("dtype", REAL_DTYPES)
|
1380
|
+
@pytest.mark.parametrize("n", (20, 200))
|
1381
|
+
@pytest.mark.parametrize("lapack_driver", lapack_drivers)
|
1382
|
+
@pytest.mark.parametrize("overwrite", (True, False))
|
1383
|
+
def test_random_exact(self, dtype, n, lapack_driver, overwrite):
|
1384
|
+
rng = np.random.RandomState(1234)
|
1385
|
+
|
1386
|
+
a = np.asarray(rng.random([n, n]), dtype=dtype)
|
1387
|
+
for i in range(n):
|
1388
|
+
a[i, i] = 20 * (0.1 + a[i, i])
|
1389
|
+
for i in range(4):
|
1390
|
+
b = np.asarray(rng.random([n, 3]), dtype=dtype)
|
1391
|
+
# Store values in case they are overwritten later
|
1392
|
+
a1 = a.copy()
|
1393
|
+
b1 = b.copy()
|
1394
|
+
out = lstsq(a1, b1,
|
1395
|
+
lapack_driver=lapack_driver,
|
1396
|
+
overwrite_a=overwrite,
|
1397
|
+
overwrite_b=overwrite)
|
1398
|
+
x = out[0]
|
1399
|
+
r = out[2]
|
1400
|
+
assert_(r == n, f'expected efficient rank {n}, '
|
1401
|
+
f'got {r}')
|
1402
|
+
if dtype is np.float32:
|
1403
|
+
assert_allclose(
|
1404
|
+
dot(a, x), b,
|
1405
|
+
rtol=500 * _eps_cast(a1.dtype),
|
1406
|
+
atol=500 * _eps_cast(a1.dtype),
|
1407
|
+
err_msg=f"driver: {lapack_driver}")
|
1408
|
+
else:
|
1409
|
+
assert_allclose(
|
1410
|
+
dot(a, x), b,
|
1411
|
+
rtol=1000 * _eps_cast(a1.dtype),
|
1412
|
+
atol=1000 * _eps_cast(a1.dtype),
|
1413
|
+
err_msg=f"driver: {lapack_driver}")
|
1414
|
+
|
1415
|
+
@pytest.mark.skipif(IS_MUSL, reason="may segfault on Alpine, see gh-17630")
|
1416
|
+
@pytest.mark.parametrize("dtype", COMPLEX_DTYPES)
|
1417
|
+
@pytest.mark.parametrize("n", (20, 200))
|
1418
|
+
@pytest.mark.parametrize("lapack_driver", lapack_drivers)
|
1419
|
+
@pytest.mark.parametrize("overwrite", (True, False))
|
1420
|
+
def test_random_complex_exact(self, dtype, n, lapack_driver, overwrite):
|
1421
|
+
rng = np.random.RandomState(1234)
|
1422
|
+
|
1423
|
+
a = np.asarray(rng.random([n, n]) + 1j*rng.random([n, n]),
|
1424
|
+
dtype=dtype)
|
1425
|
+
for i in range(n):
|
1426
|
+
a[i, i] = 20 * (0.1 + a[i, i])
|
1427
|
+
for i in range(2):
|
1428
|
+
b = np.asarray(rng.random([n, 3]), dtype=dtype)
|
1429
|
+
# Store values in case they are overwritten later
|
1430
|
+
a1 = a.copy()
|
1431
|
+
b1 = b.copy()
|
1432
|
+
out = lstsq(a1, b1, lapack_driver=lapack_driver,
|
1433
|
+
overwrite_a=overwrite,
|
1434
|
+
overwrite_b=overwrite)
|
1435
|
+
x = out[0]
|
1436
|
+
r = out[2]
|
1437
|
+
assert_(r == n, f'expected efficient rank {n}, '
|
1438
|
+
f'got {r}')
|
1439
|
+
if dtype is np.complex64:
|
1440
|
+
assert_allclose(
|
1441
|
+
dot(a, x), b,
|
1442
|
+
rtol=400 * _eps_cast(a1.dtype),
|
1443
|
+
atol=400 * _eps_cast(a1.dtype),
|
1444
|
+
err_msg=f"driver: {lapack_driver}")
|
1445
|
+
else:
|
1446
|
+
assert_allclose(
|
1447
|
+
dot(a, x), b,
|
1448
|
+
rtol=1000 * _eps_cast(a1.dtype),
|
1449
|
+
atol=1000 * _eps_cast(a1.dtype),
|
1450
|
+
err_msg=f"driver: {lapack_driver}")
|
1451
|
+
|
1452
|
+
def test_random_overdet(self):
|
1453
|
+
rng = np.random.RandomState(1234)
|
1454
|
+
for dtype in REAL_DTYPES:
|
1455
|
+
for (n, m) in ((20, 15), (200, 2)):
|
1456
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1457
|
+
for overwrite in (True, False):
|
1458
|
+
a = np.asarray(rng.random([n, m]), dtype=dtype)
|
1459
|
+
for i in range(m):
|
1460
|
+
a[i, i] = 20 * (0.1 + a[i, i])
|
1461
|
+
for i in range(4):
|
1462
|
+
b = np.asarray(rng.random([n, 3]), dtype=dtype)
|
1463
|
+
# Store values in case they are overwritten later
|
1464
|
+
a1 = a.copy()
|
1465
|
+
b1 = b.copy()
|
1466
|
+
out = lstsq(a1, b1,
|
1467
|
+
lapack_driver=lapack_driver,
|
1468
|
+
overwrite_a=overwrite,
|
1469
|
+
overwrite_b=overwrite)
|
1470
|
+
x = out[0]
|
1471
|
+
r = out[2]
|
1472
|
+
assert_(r == m, f'expected efficient rank {m}, '
|
1473
|
+
f'got {r}')
|
1474
|
+
assert_allclose(
|
1475
|
+
x, direct_lstsq(a, b, cmplx=0),
|
1476
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1477
|
+
atol=25 * _eps_cast(a1.dtype),
|
1478
|
+
err_msg=f"driver: {lapack_driver}")
|
1479
|
+
|
1480
|
+
def test_random_complex_overdet(self):
|
1481
|
+
rng = np.random.RandomState(1234)
|
1482
|
+
for dtype in COMPLEX_DTYPES:
|
1483
|
+
for (n, m) in ((20, 15), (200, 2)):
|
1484
|
+
for lapack_driver in TestLstsq.lapack_drivers:
|
1485
|
+
for overwrite in (True, False):
|
1486
|
+
a = np.asarray(rng.random([n, m]) + 1j*rng.random([n, m]),
|
1487
|
+
dtype=dtype)
|
1488
|
+
for i in range(m):
|
1489
|
+
a[i, i] = 20 * (0.1 + a[i, i])
|
1490
|
+
for i in range(2):
|
1491
|
+
b = np.asarray(rng.random([n, 3]), dtype=dtype)
|
1492
|
+
# Store values in case they are overwritten
|
1493
|
+
# later
|
1494
|
+
a1 = a.copy()
|
1495
|
+
b1 = b.copy()
|
1496
|
+
out = lstsq(a1, b1,
|
1497
|
+
lapack_driver=lapack_driver,
|
1498
|
+
overwrite_a=overwrite,
|
1499
|
+
overwrite_b=overwrite)
|
1500
|
+
x = out[0]
|
1501
|
+
r = out[2]
|
1502
|
+
assert_(r == m, f'expected efficient rank {m}, '
|
1503
|
+
f'got {r}')
|
1504
|
+
assert_allclose(
|
1505
|
+
x, direct_lstsq(a, b, cmplx=1),
|
1506
|
+
rtol=25 * _eps_cast(a1.dtype),
|
1507
|
+
atol=25 * _eps_cast(a1.dtype),
|
1508
|
+
err_msg=f"driver: {lapack_driver}")
|
1509
|
+
|
1510
|
+
def test_check_finite(self):
|
1511
|
+
with suppress_warnings() as sup:
|
1512
|
+
# On (some) OSX this tests triggers a warning (gh-7538)
|
1513
|
+
sup.filter(RuntimeWarning,
|
1514
|
+
"internal gelsd driver lwork query error,.*"
|
1515
|
+
"Falling back to 'gelss' driver.")
|
1516
|
+
|
1517
|
+
at = np.array(((1, 20), (-30, 4)))
|
1518
|
+
for dtype, bt, lapack_driver, overwrite, check_finite in \
|
1519
|
+
itertools.product(REAL_DTYPES,
|
1520
|
+
(((1, 0), (0, 1)), (1, 0), ((2, 1), (-30, 4))),
|
1521
|
+
TestLstsq.lapack_drivers,
|
1522
|
+
(True, False),
|
1523
|
+
(True, False)):
|
1524
|
+
|
1525
|
+
a = at.astype(dtype)
|
1526
|
+
b = np.array(bt, dtype=dtype)
|
1527
|
+
# Store values in case they are overwritten
|
1528
|
+
# later
|
1529
|
+
a1 = a.copy()
|
1530
|
+
b1 = b.copy()
|
1531
|
+
out = lstsq(a1, b1, lapack_driver=lapack_driver,
|
1532
|
+
check_finite=check_finite, overwrite_a=overwrite,
|
1533
|
+
overwrite_b=overwrite)
|
1534
|
+
x = out[0]
|
1535
|
+
r = out[2]
|
1536
|
+
assert_(r == 2, f'expected efficient rank 2, got {r}')
|
1537
|
+
assert_allclose(dot(a, x), b,
|
1538
|
+
rtol=25 * _eps_cast(a.dtype),
|
1539
|
+
atol=25 * _eps_cast(a.dtype),
|
1540
|
+
err_msg=f"driver: {lapack_driver}")
|
1541
|
+
|
1542
|
+
def test_empty(self):
|
1543
|
+
for a_shape, b_shape in (((0, 2), (0,)),
|
1544
|
+
((0, 4), (0, 2)),
|
1545
|
+
((4, 0), (4,)),
|
1546
|
+
((4, 0), (4, 2))):
|
1547
|
+
b = np.ones(b_shape)
|
1548
|
+
x, residues, rank, s = lstsq(np.zeros(a_shape), b)
|
1549
|
+
assert_equal(x, np.zeros((a_shape[1],) + b_shape[1:]))
|
1550
|
+
residues_should_be = (np.empty((0,)) if a_shape[1]
|
1551
|
+
else np.linalg.norm(b, axis=0)**2)
|
1552
|
+
assert_equal(residues, residues_should_be)
|
1553
|
+
assert_(rank == 0, 'expected rank 0')
|
1554
|
+
assert_equal(s, np.empty((0,)))
|
1555
|
+
|
1556
|
+
@pytest.mark.parametrize('dt_a', [int, float, np.float32, complex, np.complex64])
|
1557
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
1558
|
+
def test_empty_dtype(self, dt_a, dt_b):
|
1559
|
+
a = np.empty((0, 0), dtype=dt_a)
|
1560
|
+
b = np.empty(0, dtype=dt_b)
|
1561
|
+
x, residues, rank, s = lstsq(a, b)
|
1562
|
+
|
1563
|
+
assert x.size == 0
|
1564
|
+
dt_nonempty = lstsq(np.eye(2, dtype=dt_a), np.ones(2, dtype=dt_b))[0].dtype
|
1565
|
+
assert x.dtype == dt_nonempty
|
1566
|
+
|
1567
|
+
|
1568
|
+
class TestPinv:
|
1569
|
+
def setup_method(self):
|
1570
|
+
np.random.seed(1234)
|
1571
|
+
|
1572
|
+
def test_simple_real(self):
|
1573
|
+
a = array([[1, 2, 3], [4, 5, 6], [7, 8, 10]], dtype=float)
|
1574
|
+
a_pinv = pinv(a)
|
1575
|
+
assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
|
1576
|
+
|
1577
|
+
def test_simple_complex(self):
|
1578
|
+
a = (array([[1, 2, 3], [4, 5, 6], [7, 8, 10]],
|
1579
|
+
dtype=float) + 1j * array([[10, 8, 7], [6, 5, 4], [3, 2, 1]],
|
1580
|
+
dtype=float))
|
1581
|
+
a_pinv = pinv(a)
|
1582
|
+
assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
|
1583
|
+
|
1584
|
+
def test_simple_singular(self):
|
1585
|
+
a = array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=float)
|
1586
|
+
a_pinv = pinv(a)
|
1587
|
+
expected = array([[-6.38888889e-01, -1.66666667e-01, 3.05555556e-01],
|
1588
|
+
[-5.55555556e-02, 1.30136518e-16, 5.55555556e-02],
|
1589
|
+
[5.27777778e-01, 1.66666667e-01, -1.94444444e-01]])
|
1590
|
+
assert_array_almost_equal(a_pinv, expected)
|
1591
|
+
|
1592
|
+
def test_simple_cols(self):
|
1593
|
+
a = array([[1, 2, 3], [4, 5, 6]], dtype=float)
|
1594
|
+
a_pinv = pinv(a)
|
1595
|
+
expected = array([[-0.94444444, 0.44444444],
|
1596
|
+
[-0.11111111, 0.11111111],
|
1597
|
+
[0.72222222, -0.22222222]])
|
1598
|
+
assert_array_almost_equal(a_pinv, expected)
|
1599
|
+
|
1600
|
+
def test_simple_rows(self):
|
1601
|
+
a = array([[1, 2], [3, 4], [5, 6]], dtype=float)
|
1602
|
+
a_pinv = pinv(a)
|
1603
|
+
expected = array([[-1.33333333, -0.33333333, 0.66666667],
|
1604
|
+
[1.08333333, 0.33333333, -0.41666667]])
|
1605
|
+
assert_array_almost_equal(a_pinv, expected)
|
1606
|
+
|
1607
|
+
def test_check_finite(self):
|
1608
|
+
a = array([[1, 2, 3], [4, 5, 6.], [7, 8, 10]])
|
1609
|
+
a_pinv = pinv(a, check_finite=False)
|
1610
|
+
assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
|
1611
|
+
|
1612
|
+
def test_native_list_argument(self):
|
1613
|
+
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
1614
|
+
a_pinv = pinv(a)
|
1615
|
+
expected = array([[-6.38888889e-01, -1.66666667e-01, 3.05555556e-01],
|
1616
|
+
[-5.55555556e-02, 1.30136518e-16, 5.55555556e-02],
|
1617
|
+
[5.27777778e-01, 1.66666667e-01, -1.94444444e-01]])
|
1618
|
+
assert_array_almost_equal(a_pinv, expected)
|
1619
|
+
|
1620
|
+
def test_atol_rtol(self):
|
1621
|
+
n = 12
|
1622
|
+
# get a random ortho matrix for shuffling
|
1623
|
+
q, _ = qr(np.random.rand(n, n))
|
1624
|
+
a_m = np.arange(35.0).reshape(7, 5)
|
1625
|
+
a = a_m.copy()
|
1626
|
+
a[0, 0] = 0.001
|
1627
|
+
atol = 1e-5
|
1628
|
+
rtol = 0.05
|
1629
|
+
# svds of a_m is ~ [116.906, 4.234, tiny, tiny, tiny]
|
1630
|
+
# svds of a is ~ [116.906, 4.234, 4.62959e-04, tiny, tiny]
|
1631
|
+
# Just abs cutoff such that we arrive at a_modified
|
1632
|
+
a_p = pinv(a_m, atol=atol, rtol=0.)
|
1633
|
+
adiff1 = a @ a_p @ a - a
|
1634
|
+
adiff2 = a_m @ a_p @ a_m - a_m
|
1635
|
+
# Now adiff1 should be around atol value while adiff2 should be
|
1636
|
+
# relatively tiny
|
1637
|
+
assert_allclose(np.linalg.norm(adiff1), 5e-4, atol=5.e-4)
|
1638
|
+
assert_allclose(np.linalg.norm(adiff2), 5e-14, atol=5.e-14)
|
1639
|
+
|
1640
|
+
# Now do the same but remove another sv ~4.234 via rtol
|
1641
|
+
a_p = pinv(a_m, atol=atol, rtol=rtol)
|
1642
|
+
adiff1 = a @ a_p @ a - a
|
1643
|
+
adiff2 = a_m @ a_p @ a_m - a_m
|
1644
|
+
assert_allclose(np.linalg.norm(adiff1), 4.233, rtol=0.01)
|
1645
|
+
assert_allclose(np.linalg.norm(adiff2), 4.233, rtol=0.01)
|
1646
|
+
|
1647
|
+
@pytest.mark.parametrize('dt', [float, np.float32, complex, np.complex64])
|
1648
|
+
def test_empty(self, dt):
|
1649
|
+
a = np.empty((0, 0), dtype=dt)
|
1650
|
+
a_pinv = pinv(a)
|
1651
|
+
assert a_pinv.size == 0
|
1652
|
+
assert a_pinv.dtype == pinv(np.eye(2, dtype=dt)).dtype
|
1653
|
+
|
1654
|
+
|
1655
|
+
class TestPinvSymmetric:
|
1656
|
+
|
1657
|
+
def setup_method(self):
|
1658
|
+
np.random.seed(1234)
|
1659
|
+
|
1660
|
+
def test_simple_real(self):
|
1661
|
+
a = array([[1, 2, 3], [4, 5, 6], [7, 8, 10]], dtype=float)
|
1662
|
+
a = np.dot(a, a.T)
|
1663
|
+
a_pinv = pinvh(a)
|
1664
|
+
assert_array_almost_equal(np.dot(a, a_pinv), np.eye(3))
|
1665
|
+
|
1666
|
+
def test_nonpositive(self):
|
1667
|
+
a = array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=float)
|
1668
|
+
a = np.dot(a, a.T)
|
1669
|
+
u, s, vt = np.linalg.svd(a)
|
1670
|
+
s[0] *= -1
|
1671
|
+
a = np.dot(u * s, vt) # a is now symmetric non-positive and singular
|
1672
|
+
a_pinv = pinv(a)
|
1673
|
+
a_pinvh = pinvh(a)
|
1674
|
+
assert_array_almost_equal(a_pinv, a_pinvh)
|
1675
|
+
|
1676
|
+
def test_simple_complex(self):
|
1677
|
+
a = (array([[1, 2, 3], [4, 5, 6], [7, 8, 10]],
|
1678
|
+
dtype=float) + 1j * array([[10, 8, 7], [6, 5, 4], [3, 2, 1]],
|
1679
|
+
dtype=float))
|
1680
|
+
a = np.dot(a, a.conj().T)
|
1681
|
+
a_pinv = pinvh(a)
|
1682
|
+
assert_array_almost_equal(np.dot(a, a_pinv), np.eye(3))
|
1683
|
+
|
1684
|
+
def test_native_list_argument(self):
|
1685
|
+
a = array([[1, 2, 3], [4, 5, 6], [7, 8, 10]], dtype=float)
|
1686
|
+
a = np.dot(a, a.T)
|
1687
|
+
a_pinv = pinvh(a.tolist())
|
1688
|
+
assert_array_almost_equal(np.dot(a, a_pinv), np.eye(3))
|
1689
|
+
|
1690
|
+
def test_zero_eigenvalue(self):
|
1691
|
+
# https://github.com/scipy/scipy/issues/12515
|
1692
|
+
# the SYEVR eigh driver may give the zero eigenvalue > eps
|
1693
|
+
a = np.array([[1, -1, 0], [-1, 2, -1], [0, -1, 1]])
|
1694
|
+
p = pinvh(a)
|
1695
|
+
assert_allclose(p @ a @ p, p, atol=1e-15)
|
1696
|
+
assert_allclose(a @ p @ a, a, atol=1e-15)
|
1697
|
+
|
1698
|
+
def test_atol_rtol(self):
|
1699
|
+
n = 12
|
1700
|
+
# get a random ortho matrix for shuffling
|
1701
|
+
q, _ = qr(np.random.rand(n, n))
|
1702
|
+
a = np.diag([4, 3, 2, 1, 0.99e-4, 0.99e-5] + [0.99e-6]*(n-6))
|
1703
|
+
a = q.T @ a @ q
|
1704
|
+
a_m = np.diag([4, 3, 2, 1, 0.99e-4, 0.] + [0.]*(n-6))
|
1705
|
+
a_m = q.T @ a_m @ q
|
1706
|
+
atol = 1e-5
|
1707
|
+
rtol = (4.01e-4 - 4e-5)/4
|
1708
|
+
# Just abs cutoff such that we arrive at a_modified
|
1709
|
+
a_p = pinvh(a, atol=atol, rtol=0.)
|
1710
|
+
adiff1 = a @ a_p @ a - a
|
1711
|
+
adiff2 = a_m @ a_p @ a_m - a_m
|
1712
|
+
# Now adiff1 should dance around atol value since truncation
|
1713
|
+
# while adiff2 should be relatively tiny
|
1714
|
+
assert_allclose(norm(adiff1), atol, rtol=0.1)
|
1715
|
+
assert_allclose(norm(adiff2), 1e-12, atol=1e-11)
|
1716
|
+
|
1717
|
+
# Now do the same but through rtol cancelling atol value
|
1718
|
+
a_p = pinvh(a, atol=atol, rtol=rtol)
|
1719
|
+
adiff1 = a @ a_p @ a - a
|
1720
|
+
adiff2 = a_m @ a_p @ a_m - a_m
|
1721
|
+
# adiff1 and adiff2 should be elevated to ~1e-4 due to mismatch
|
1722
|
+
assert_allclose(norm(adiff1), 1e-4, rtol=0.1)
|
1723
|
+
assert_allclose(norm(adiff2), 1e-4, rtol=0.1)
|
1724
|
+
|
1725
|
+
@pytest.mark.parametrize('dt', [float, np.float32, complex, np.complex64])
|
1726
|
+
def test_empty(self, dt):
|
1727
|
+
a = np.empty((0, 0), dtype=dt)
|
1728
|
+
a_pinv = pinvh(a)
|
1729
|
+
assert a_pinv.size == 0
|
1730
|
+
assert a_pinv.dtype == pinv(np.eye(2, dtype=dt)).dtype
|
1731
|
+
|
1732
|
+
|
1733
|
+
@pytest.mark.parametrize('scale', (1e-20, 1., 1e20))
|
1734
|
+
@pytest.mark.parametrize('pinv_', (pinv, pinvh))
|
1735
|
+
def test_auto_rcond(scale, pinv_):
|
1736
|
+
x = np.array([[1, 0], [0, 1e-10]]) * scale
|
1737
|
+
expected = np.diag(1. / np.diag(x))
|
1738
|
+
x_inv = pinv_(x)
|
1739
|
+
assert_allclose(x_inv, expected)
|
1740
|
+
|
1741
|
+
|
1742
|
+
class TestVectorNorms:
|
1743
|
+
|
1744
|
+
def test_types(self):
|
1745
|
+
for dtype in np.typecodes['AllFloat']:
|
1746
|
+
x = np.array([1, 2, 3], dtype=dtype)
|
1747
|
+
tol = max(1e-15, np.finfo(dtype).eps.real * 20)
|
1748
|
+
assert_allclose(norm(x), np.sqrt(14), rtol=tol)
|
1749
|
+
assert_allclose(norm(x, 2), np.sqrt(14), rtol=tol)
|
1750
|
+
|
1751
|
+
for dtype in np.typecodes['Complex']:
|
1752
|
+
x = np.array([1j, 2j, 3j], dtype=dtype)
|
1753
|
+
tol = max(1e-15, np.finfo(dtype).eps.real * 20)
|
1754
|
+
assert_allclose(norm(x), np.sqrt(14), rtol=tol)
|
1755
|
+
assert_allclose(norm(x, 2), np.sqrt(14), rtol=tol)
|
1756
|
+
|
1757
|
+
def test_overflow(self):
|
1758
|
+
# unlike numpy's norm, this one is
|
1759
|
+
# safer on overflow
|
1760
|
+
a = array([1e20], dtype=float32)
|
1761
|
+
assert_almost_equal(norm(a), a)
|
1762
|
+
|
1763
|
+
def test_stable(self):
|
1764
|
+
# more stable than numpy's norm
|
1765
|
+
a = array([1e4] + [1]*10000, dtype=float32)
|
1766
|
+
try:
|
1767
|
+
# snrm in double precision; we obtain the same as for float64
|
1768
|
+
# -- large atol needed due to varying blas implementations
|
1769
|
+
assert_allclose(norm(a) - 1e4, 0.5, atol=1e-2)
|
1770
|
+
except AssertionError:
|
1771
|
+
# snrm implemented in single precision, == np.linalg.norm result
|
1772
|
+
msg = ": Result should equal either 0.0 or 0.5 (depending on " \
|
1773
|
+
"implementation of snrm2)."
|
1774
|
+
assert_almost_equal(norm(a) - 1e4, 0.0, err_msg=msg)
|
1775
|
+
|
1776
|
+
def test_zero_norm(self):
|
1777
|
+
assert_equal(norm([1, 0, 3], 0), 2)
|
1778
|
+
assert_equal(norm([1, 2, 3], 0), 3)
|
1779
|
+
|
1780
|
+
def test_axis_kwd(self):
|
1781
|
+
a = np.array([[[2, 1], [3, 4]]] * 2, 'd')
|
1782
|
+
assert_allclose(norm(a, axis=1), [[3.60555128, 4.12310563]] * 2)
|
1783
|
+
assert_allclose(norm(a, 1, axis=1), [[5.] * 2] * 2)
|
1784
|
+
|
1785
|
+
def test_keepdims_kwd(self):
|
1786
|
+
a = np.array([[[2, 1], [3, 4]]] * 2, 'd')
|
1787
|
+
b = norm(a, axis=1, keepdims=True)
|
1788
|
+
assert_allclose(b, [[[3.60555128, 4.12310563]]] * 2)
|
1789
|
+
assert_(b.shape == (2, 1, 2))
|
1790
|
+
assert_allclose(norm(a, 1, axis=2, keepdims=True), [[[3.], [7.]]] * 2)
|
1791
|
+
|
1792
|
+
@pytest.mark.skipif(not HAS_ILP64, reason="64-bit BLAS required")
|
1793
|
+
def test_large_vector(self):
|
1794
|
+
check_free_memory(free_mb=17000)
|
1795
|
+
x = np.zeros([2**31], dtype=np.float64)
|
1796
|
+
x[-1] = 1
|
1797
|
+
res = norm(x)
|
1798
|
+
del x
|
1799
|
+
assert_allclose(res, 1.0)
|
1800
|
+
|
1801
|
+
|
1802
|
+
class TestMatrixNorms:
|
1803
|
+
|
1804
|
+
def test_matrix_norms(self):
|
1805
|
+
# Not all of these are matrix norms in the most technical sense.
|
1806
|
+
np.random.seed(1234)
|
1807
|
+
for n, m in (1, 1), (1, 3), (3, 1), (4, 4), (4, 5), (5, 4):
|
1808
|
+
for t in np.float32, np.float64, np.complex64, np.complex128, np.int64:
|
1809
|
+
A = 10 * np.random.randn(n, m).astype(t)
|
1810
|
+
if np.issubdtype(A.dtype, np.complexfloating):
|
1811
|
+
A = (A + 10j * np.random.randn(n, m)).astype(t)
|
1812
|
+
t_high = np.complex128
|
1813
|
+
else:
|
1814
|
+
t_high = np.float64
|
1815
|
+
for order in (None, 'fro', 1, -1, 2, -2, np.inf, -np.inf):
|
1816
|
+
actual = norm(A, ord=order)
|
1817
|
+
desired = np.linalg.norm(A, ord=order)
|
1818
|
+
# SciPy may return higher precision matrix norms.
|
1819
|
+
# This is a consequence of using LAPACK.
|
1820
|
+
if not np.allclose(actual, desired):
|
1821
|
+
desired = np.linalg.norm(A.astype(t_high), ord=order)
|
1822
|
+
assert_allclose(actual, desired)
|
1823
|
+
|
1824
|
+
def test_axis_kwd(self):
|
1825
|
+
a = np.array([[[2, 1], [3, 4]]] * 2, 'd')
|
1826
|
+
b = norm(a, ord=np.inf, axis=(1, 0))
|
1827
|
+
c = norm(np.swapaxes(a, 0, 1), ord=np.inf, axis=(0, 1))
|
1828
|
+
d = norm(a, ord=1, axis=(0, 1))
|
1829
|
+
assert_allclose(b, c)
|
1830
|
+
assert_allclose(c, d)
|
1831
|
+
assert_allclose(b, d)
|
1832
|
+
assert_(b.shape == c.shape == d.shape)
|
1833
|
+
b = norm(a, ord=1, axis=(1, 0))
|
1834
|
+
c = norm(np.swapaxes(a, 0, 1), ord=1, axis=(0, 1))
|
1835
|
+
d = norm(a, ord=np.inf, axis=(0, 1))
|
1836
|
+
assert_allclose(b, c)
|
1837
|
+
assert_allclose(c, d)
|
1838
|
+
assert_allclose(b, d)
|
1839
|
+
assert_(b.shape == c.shape == d.shape)
|
1840
|
+
|
1841
|
+
def test_keepdims_kwd(self):
|
1842
|
+
a = np.arange(120, dtype='d').reshape(2, 3, 4, 5)
|
1843
|
+
b = norm(a, ord=np.inf, axis=(1, 0), keepdims=True)
|
1844
|
+
c = norm(a, ord=1, axis=(0, 1), keepdims=True)
|
1845
|
+
assert_allclose(b, c)
|
1846
|
+
assert_(b.shape == c.shape)
|
1847
|
+
|
1848
|
+
def test_empty(self):
|
1849
|
+
a = np.empty((0, 0))
|
1850
|
+
assert_allclose(norm(a), 0.)
|
1851
|
+
assert_allclose(norm(a, axis=0), np.zeros((0,)))
|
1852
|
+
assert_allclose(norm(a, keepdims=True), np.zeros((1, 1)))
|
1853
|
+
|
1854
|
+
a = np.empty((0, 3))
|
1855
|
+
assert_allclose(norm(a), 0.)
|
1856
|
+
assert_allclose(norm(a, axis=0), np.zeros((3,)))
|
1857
|
+
assert_allclose(norm(a, keepdims=True), np.zeros((1, 1)))
|
1858
|
+
|
1859
|
+
|
1860
|
+
class TestOverwrite:
|
1861
|
+
def test_solve(self):
|
1862
|
+
assert_no_overwrite(solve, [(3, 3), (3,)])
|
1863
|
+
|
1864
|
+
def test_solve_triangular(self):
|
1865
|
+
assert_no_overwrite(solve_triangular, [(3, 3), (3,)])
|
1866
|
+
|
1867
|
+
def test_solve_banded(self):
|
1868
|
+
assert_no_overwrite(lambda ab, b: solve_banded((2, 1), ab, b),
|
1869
|
+
[(4, 6), (6,)])
|
1870
|
+
|
1871
|
+
def test_solveh_banded(self):
|
1872
|
+
assert_no_overwrite(solveh_banded, [(2, 6), (6,)])
|
1873
|
+
|
1874
|
+
def test_inv(self):
|
1875
|
+
assert_no_overwrite(inv, [(3, 3)])
|
1876
|
+
|
1877
|
+
def test_det(self):
|
1878
|
+
assert_no_overwrite(det, [(3, 3)])
|
1879
|
+
|
1880
|
+
def test_lstsq(self):
|
1881
|
+
assert_no_overwrite(lstsq, [(3, 2), (3,)])
|
1882
|
+
|
1883
|
+
def test_pinv(self):
|
1884
|
+
assert_no_overwrite(pinv, [(3, 3)])
|
1885
|
+
|
1886
|
+
def test_pinvh(self):
|
1887
|
+
assert_no_overwrite(pinvh, [(3, 3)])
|
1888
|
+
|
1889
|
+
|
1890
|
+
class TestSolveCirculant:
|
1891
|
+
|
1892
|
+
def test_basic1(self):
|
1893
|
+
c = np.array([1, 2, 3, 5])
|
1894
|
+
b = np.array([1, -1, 1, 0])
|
1895
|
+
x = solve_circulant(c, b)
|
1896
|
+
y = solve(circulant(c), b)
|
1897
|
+
assert_allclose(x, y)
|
1898
|
+
|
1899
|
+
def test_basic2(self):
|
1900
|
+
# b is a 2-d matrix.
|
1901
|
+
c = np.array([1, 2, -3, -5])
|
1902
|
+
b = np.arange(12).reshape(4, 3)
|
1903
|
+
x = solve_circulant(c, b)
|
1904
|
+
y = solve(circulant(c), b)
|
1905
|
+
assert_allclose(x, y)
|
1906
|
+
|
1907
|
+
def test_basic3(self):
|
1908
|
+
# b is a 3-d matrix.
|
1909
|
+
c = np.array([1, 2, -3, -5])
|
1910
|
+
b = np.arange(24).reshape(4, 3, 2)
|
1911
|
+
x = solve_circulant(c, b)
|
1912
|
+
y = solve(circulant(c), b.reshape(4, -1)).reshape(b.shape)
|
1913
|
+
assert_allclose(x, y)
|
1914
|
+
|
1915
|
+
def test_complex(self):
|
1916
|
+
# Complex b and c
|
1917
|
+
c = np.array([1+2j, -3, 4j, 5])
|
1918
|
+
b = np.arange(8).reshape(4, 2) + 0.5j
|
1919
|
+
x = solve_circulant(c, b)
|
1920
|
+
y = solve(circulant(c), b)
|
1921
|
+
assert_allclose(x, y)
|
1922
|
+
|
1923
|
+
def test_random_b_and_c(self):
|
1924
|
+
# Random b and c
|
1925
|
+
rng = np.random.RandomState(54321)
|
1926
|
+
c = rng.randn(50)
|
1927
|
+
b = rng.randn(50)
|
1928
|
+
x = solve_circulant(c, b)
|
1929
|
+
y = solve(circulant(c), b)
|
1930
|
+
assert_allclose(x, y)
|
1931
|
+
|
1932
|
+
def test_singular(self):
|
1933
|
+
# c gives a singular circulant matrix.
|
1934
|
+
c = np.array([1, 1, 0, 0])
|
1935
|
+
b = np.array([1, 2, 3, 4])
|
1936
|
+
x = solve_circulant(c, b, singular='lstsq')
|
1937
|
+
y, res, rnk, s = lstsq(circulant(c), b)
|
1938
|
+
assert_allclose(x, y)
|
1939
|
+
assert_raises(LinAlgError, solve_circulant, x, y)
|
1940
|
+
|
1941
|
+
def test_axis_args(self):
|
1942
|
+
# Test use of caxis, baxis and outaxis.
|
1943
|
+
|
1944
|
+
# c has shape (2, 1, 4)
|
1945
|
+
c = np.array([[[-1, 2.5, 3, 3.5]], [[1, 6, 6, 6.5]]])
|
1946
|
+
|
1947
|
+
# b has shape (3, 4)
|
1948
|
+
b = np.array([[0, 0, 1, 1], [1, 1, 0, 0], [1, -1, 0, 0]])
|
1949
|
+
|
1950
|
+
x = solve_circulant(c, b, baxis=1)
|
1951
|
+
assert_equal(x.shape, (4, 2, 3))
|
1952
|
+
expected = np.empty_like(x)
|
1953
|
+
expected[:, 0, :] = solve(circulant(c[0].ravel()), b.T)
|
1954
|
+
expected[:, 1, :] = solve(circulant(c[1].ravel()), b.T)
|
1955
|
+
assert_allclose(x, expected)
|
1956
|
+
|
1957
|
+
x = solve_circulant(c, b, baxis=1, outaxis=-1)
|
1958
|
+
assert_equal(x.shape, (2, 3, 4))
|
1959
|
+
assert_allclose(np.moveaxis(x, -1, 0), expected)
|
1960
|
+
|
1961
|
+
# np.swapaxes(c, 1, 2) has shape (2, 4, 1); b.T has shape (4, 3).
|
1962
|
+
x = solve_circulant(np.swapaxes(c, 1, 2), b.T, caxis=1)
|
1963
|
+
assert_equal(x.shape, (4, 2, 3))
|
1964
|
+
assert_allclose(x, expected)
|
1965
|
+
|
1966
|
+
def test_native_list_arguments(self):
|
1967
|
+
# Same as test_basic1 using python's native list.
|
1968
|
+
c = [1, 2, 3, 5]
|
1969
|
+
b = [1, -1, 1, 0]
|
1970
|
+
x = solve_circulant(c, b)
|
1971
|
+
y = solve(circulant(c), b)
|
1972
|
+
assert_allclose(x, y)
|
1973
|
+
|
1974
|
+
@pytest.mark.parametrize('dt_c', [int, float, np.float32, complex, np.complex64])
|
1975
|
+
@pytest.mark.parametrize('dt_b', [int, float, np.float32, complex, np.complex64])
|
1976
|
+
def test_empty(self, dt_c, dt_b):
|
1977
|
+
c = np.array([], dtype=dt_c)
|
1978
|
+
b = np.array([], dtype=dt_b)
|
1979
|
+
x = solve_circulant(c, b)
|
1980
|
+
assert x.shape == (0,)
|
1981
|
+
assert x.dtype == solve_circulant(np.arange(3, dtype=dt_c),
|
1982
|
+
np.ones(3, dtype=dt_b)).dtype
|
1983
|
+
|
1984
|
+
b = np.empty((0, 0), dtype=dt_b)
|
1985
|
+
x1 = solve_circulant(c, b)
|
1986
|
+
assert x1.shape == (0, 0)
|
1987
|
+
assert x1.dtype == x.dtype
|
1988
|
+
|
1989
|
+
|
1990
|
+
class TestMatrix_Balance:
|
1991
|
+
|
1992
|
+
def test_string_arg(self):
|
1993
|
+
assert_raises(ValueError, matrix_balance, 'Some string for fail')
|
1994
|
+
|
1995
|
+
def test_infnan_arg(self):
|
1996
|
+
assert_raises(ValueError, matrix_balance,
|
1997
|
+
np.array([[1, 2], [3, np.inf]]))
|
1998
|
+
assert_raises(ValueError, matrix_balance,
|
1999
|
+
np.array([[1, 2], [3, np.nan]]))
|
2000
|
+
|
2001
|
+
def test_scaling(self):
|
2002
|
+
_, y = matrix_balance(np.array([[1000, 1], [1000, 0]]))
|
2003
|
+
# Pre/post LAPACK 3.5.0 gives the same result up to an offset
|
2004
|
+
# since in each case col norm is x1000 greater and
|
2005
|
+
# 1000 / 32 ~= 1 * 32 hence balanced with 2 ** 5.
|
2006
|
+
assert_allclose(np.diff(np.log2(np.diag(y))), [5])
|
2007
|
+
|
2008
|
+
def test_scaling_order(self):
|
2009
|
+
A = np.array([[1, 0, 1e-4], [1, 1, 1e-2], [1e4, 1e2, 1]])
|
2010
|
+
x, y = matrix_balance(A)
|
2011
|
+
assert_allclose(solve(y, A).dot(y), x)
|
2012
|
+
|
2013
|
+
def test_separate(self):
|
2014
|
+
_, (y, z) = matrix_balance(np.array([[1000, 1], [1000, 0]]),
|
2015
|
+
separate=1)
|
2016
|
+
assert_equal(np.diff(np.log2(y)), [5])
|
2017
|
+
assert_allclose(z, np.arange(2))
|
2018
|
+
|
2019
|
+
def test_permutation(self):
|
2020
|
+
A = block_diag(np.ones((2, 2)), np.tril(np.ones((2, 2))),
|
2021
|
+
np.ones((3, 3)))
|
2022
|
+
x, (y, z) = matrix_balance(A, separate=1)
|
2023
|
+
assert_allclose(y, np.ones_like(y))
|
2024
|
+
assert_allclose(z, np.array([0, 1, 6, 5, 4, 3, 2]))
|
2025
|
+
|
2026
|
+
def test_perm_and_scaling(self):
|
2027
|
+
# Matrix with its diagonal removed
|
2028
|
+
cases = ( # Case 0
|
2029
|
+
np.array([[0., 0., 0., 0., 0.000002],
|
2030
|
+
[0., 0., 0., 0., 0.],
|
2031
|
+
[2., 2., 0., 0., 0.],
|
2032
|
+
[2., 2., 0., 0., 0.],
|
2033
|
+
[0., 0., 0.000002, 0., 0.]]),
|
2034
|
+
# Case 1 user reported GH-7258
|
2035
|
+
np.array([[-0.5, 0., 0., 0.],
|
2036
|
+
[0., -1., 0., 0.],
|
2037
|
+
[1., 0., -0.5, 0.],
|
2038
|
+
[0., 1., 0., -1.]]),
|
2039
|
+
# Case 2 user reported GH-7258
|
2040
|
+
np.array([[-3., 0., 1., 0.],
|
2041
|
+
[-1., -1., -0., 1.],
|
2042
|
+
[-3., -0., -0., 0.],
|
2043
|
+
[-1., -0., 1., -1.]])
|
2044
|
+
)
|
2045
|
+
|
2046
|
+
for A in cases:
|
2047
|
+
x, y = matrix_balance(A)
|
2048
|
+
x, (s, p) = matrix_balance(A, separate=1)
|
2049
|
+
ip = np.empty_like(p)
|
2050
|
+
ip[p] = np.arange(A.shape[0])
|
2051
|
+
assert_allclose(y, np.diag(s)[ip, :])
|
2052
|
+
assert_allclose(solve(y, A).dot(y), x)
|
2053
|
+
|
2054
|
+
@pytest.mark.parametrize('dt', [int, float, np.float32, complex, np.complex64])
|
2055
|
+
def test_empty(self, dt):
|
2056
|
+
a = np.empty((0, 0), dtype=dt)
|
2057
|
+
b, t = matrix_balance(a)
|
2058
|
+
|
2059
|
+
assert b.size == 0
|
2060
|
+
assert t.size == 0
|
2061
|
+
|
2062
|
+
b_n, t_n = matrix_balance(np.eye(2, dtype=dt))
|
2063
|
+
assert b.dtype == b_n.dtype
|
2064
|
+
assert t.dtype == t_n.dtype
|
2065
|
+
|
2066
|
+
b, (scale, perm) = matrix_balance(a, separate=True)
|
2067
|
+
assert b.size == 0
|
2068
|
+
assert scale.size == 0
|
2069
|
+
assert perm.size == 0
|
2070
|
+
|
2071
|
+
b_n, (scale_n, perm_n) = matrix_balance(a, separate=True)
|
2072
|
+
assert b.dtype == b_n.dtype
|
2073
|
+
assert scale.dtype == scale_n.dtype
|
2074
|
+
assert perm.dtype == perm_n.dtype
|