scipy 1.16.2__cp312-cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_cyutility.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp312-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp312-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp312-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp312-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp312-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp312-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp312-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp312-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp312-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp312-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp312-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp312-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp312-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp312-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp312-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp312-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp312-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp312-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp312-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp312-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp312-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp312-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp312-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp312-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp312-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp312-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp312-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp312-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp312-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp312-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp312-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp312-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp312-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp312-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp312-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp312-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp312-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp312-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp312-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp312-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp312-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp312-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp312-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp312-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp312-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp312-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp312-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp312-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp312-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp312-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp312-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp312-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp312-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp312-win_arm64.lib +0 -0
- scipy/signal/_spline.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp312-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp312-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp312-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp312-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp312-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp312-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp312-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp312-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp312-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp312-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp312-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp312-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp312-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp312-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp312-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp312-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/special/_comb.cp312-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp312-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp312-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp312-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/special/_specfun.cp312-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp312-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp312-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp312-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp312-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp312-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/special/cython_special.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp312-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp312-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp312-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp312-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp312-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp312-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp312-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp312-win_arm64.lib +0 -0
- scipy/stats/_stats.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp312-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.cp312-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp312-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,2397 @@
|
|
1
|
+
"""
|
2
|
+
fitpack --- curve and surface fitting with splines
|
3
|
+
|
4
|
+
fitpack is based on a collection of Fortran routines DIERCKX
|
5
|
+
by P. Dierckx (see http://www.netlib.org/dierckx/) transformed
|
6
|
+
to double routines by Pearu Peterson.
|
7
|
+
"""
|
8
|
+
# Created by Pearu Peterson, June,August 2003
|
9
|
+
__all__ = [
|
10
|
+
'UnivariateSpline',
|
11
|
+
'InterpolatedUnivariateSpline',
|
12
|
+
'LSQUnivariateSpline',
|
13
|
+
'BivariateSpline',
|
14
|
+
'LSQBivariateSpline',
|
15
|
+
'SmoothBivariateSpline',
|
16
|
+
'LSQSphereBivariateSpline',
|
17
|
+
'SmoothSphereBivariateSpline',
|
18
|
+
'RectBivariateSpline',
|
19
|
+
'RectSphereBivariateSpline']
|
20
|
+
|
21
|
+
|
22
|
+
import warnings
|
23
|
+
from threading import Lock
|
24
|
+
|
25
|
+
from numpy import zeros, concatenate, ravel, diff, array
|
26
|
+
import numpy as np
|
27
|
+
|
28
|
+
from . import _fitpack_impl
|
29
|
+
from . import _dfitpack as dfitpack
|
30
|
+
|
31
|
+
|
32
|
+
dfitpack_int = dfitpack.types.intvar.dtype
|
33
|
+
FITPACK_LOCK = Lock()
|
34
|
+
|
35
|
+
|
36
|
+
# ############### Univariate spline ####################
|
37
|
+
|
38
|
+
_curfit_messages = {1: """
|
39
|
+
The required storage space exceeds the available storage space, as
|
40
|
+
specified by the parameter nest: nest too small. If nest is already
|
41
|
+
large (say nest > m/2), it may also indicate that s is too small.
|
42
|
+
The approximation returned is the weighted least-squares spline
|
43
|
+
according to the knots t[0],t[1],...,t[n-1]. (n=nest) the parameter fp
|
44
|
+
gives the corresponding weighted sum of squared residuals (fp>s).
|
45
|
+
""",
|
46
|
+
2: """
|
47
|
+
A theoretically impossible result was found during the iteration
|
48
|
+
process for finding a smoothing spline with fp = s: s too small.
|
49
|
+
There is an approximation returned but the corresponding weighted sum
|
50
|
+
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.""",
|
51
|
+
3: """
|
52
|
+
The maximal number of iterations maxit (set to 20 by the program)
|
53
|
+
allowed for finding a smoothing spline with fp=s has been reached: s
|
54
|
+
too small.
|
55
|
+
There is an approximation returned but the corresponding weighted sum
|
56
|
+
of squared residuals does not satisfy the condition abs(fp-s)/s < tol.""",
|
57
|
+
10: """
|
58
|
+
Error on entry, no approximation returned. The following conditions
|
59
|
+
must hold:
|
60
|
+
xb<=x[0]<x[1]<...<x[m-1]<=xe, w[i]>0, i=0..m-1
|
61
|
+
if iopt=-1:
|
62
|
+
xb<t[k+1]<t[k+2]<...<t[n-k-2]<xe"""
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
# UnivariateSpline, ext parameter can be an int or a string
|
67
|
+
_extrap_modes = {0: 0, 'extrapolate': 0,
|
68
|
+
1: 1, 'zeros': 1,
|
69
|
+
2: 2, 'raise': 2,
|
70
|
+
3: 3, 'const': 3}
|
71
|
+
|
72
|
+
|
73
|
+
class UnivariateSpline:
|
74
|
+
"""
|
75
|
+
1-D smoothing spline fit to a given set of data points.
|
76
|
+
|
77
|
+
.. legacy:: class
|
78
|
+
|
79
|
+
Specifically, we recommend using `make_splrep` instead.
|
80
|
+
|
81
|
+
Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data. `s`
|
82
|
+
specifies the number of knots by specifying a smoothing condition.
|
83
|
+
|
84
|
+
Parameters
|
85
|
+
----------
|
86
|
+
x : (N,) array_like
|
87
|
+
1-D array of independent input data. Must be increasing;
|
88
|
+
must be strictly increasing if `s` is 0.
|
89
|
+
y : (N,) array_like
|
90
|
+
1-D array of dependent input data, of the same length as `x`.
|
91
|
+
w : (N,) array_like, optional
|
92
|
+
Weights for spline fitting. Must be positive. If `w` is None,
|
93
|
+
weights are all 1. Default is None.
|
94
|
+
bbox : (2,) array_like, optional
|
95
|
+
2-sequence specifying the boundary of the approximation interval. If
|
96
|
+
`bbox` is None, ``bbox=[x[0], x[-1]]``. Default is None.
|
97
|
+
k : int, optional
|
98
|
+
Degree of the smoothing spline. Must be 1 <= `k` <= 5.
|
99
|
+
``k = 3`` is a cubic spline. Default is 3.
|
100
|
+
s : float or None, optional
|
101
|
+
Positive smoothing factor used to choose the number of knots. Number
|
102
|
+
of knots will be increased until the smoothing condition is satisfied::
|
103
|
+
|
104
|
+
sum((w[i] * (y[i]-spl(x[i])))**2, axis=0) <= s
|
105
|
+
|
106
|
+
However, because of numerical issues, the actual condition is::
|
107
|
+
|
108
|
+
abs(sum((w[i] * (y[i]-spl(x[i])))**2, axis=0) - s) < 0.001 * s
|
109
|
+
|
110
|
+
If `s` is None, `s` will be set as `len(w)` for a smoothing spline
|
111
|
+
that uses all data points.
|
112
|
+
If 0, spline will interpolate through all data points. This is
|
113
|
+
equivalent to `InterpolatedUnivariateSpline`.
|
114
|
+
Default is None.
|
115
|
+
The user can use the `s` to control the tradeoff between closeness
|
116
|
+
and smoothness of fit. Larger `s` means more smoothing while smaller
|
117
|
+
values of `s` indicate less smoothing.
|
118
|
+
Recommended values of `s` depend on the weights, `w`. If the weights
|
119
|
+
represent the inverse of the standard-deviation of `y`, then a good
|
120
|
+
`s` value should be found in the range (m-sqrt(2*m),m+sqrt(2*m))
|
121
|
+
where m is the number of datapoints in `x`, `y`, and `w`. This means
|
122
|
+
``s = len(w)`` should be a good value if ``1/w[i]`` is an
|
123
|
+
estimate of the standard deviation of ``y[i]``.
|
124
|
+
ext : int or str, optional
|
125
|
+
Controls the extrapolation mode for elements
|
126
|
+
not in the interval defined by the knot sequence.
|
127
|
+
|
128
|
+
* if ext=0 or 'extrapolate', return the extrapolated value.
|
129
|
+
* if ext=1 or 'zeros', return 0
|
130
|
+
* if ext=2 or 'raise', raise a ValueError
|
131
|
+
* if ext=3 or 'const', return the boundary value.
|
132
|
+
|
133
|
+
Default is 0.
|
134
|
+
|
135
|
+
check_finite : bool, optional
|
136
|
+
Whether to check that the input arrays contain only finite numbers.
|
137
|
+
Disabling may give a performance gain, but may result in problems
|
138
|
+
(crashes, non-termination or non-sensical results) if the inputs
|
139
|
+
do contain infinities or NaNs.
|
140
|
+
Default is False.
|
141
|
+
|
142
|
+
See Also
|
143
|
+
--------
|
144
|
+
BivariateSpline :
|
145
|
+
a base class for bivariate splines.
|
146
|
+
SmoothBivariateSpline :
|
147
|
+
a smoothing bivariate spline through the given points
|
148
|
+
LSQBivariateSpline :
|
149
|
+
a bivariate spline using weighted least-squares fitting
|
150
|
+
RectSphereBivariateSpline :
|
151
|
+
a bivariate spline over a rectangular mesh on a sphere
|
152
|
+
SmoothSphereBivariateSpline :
|
153
|
+
a smoothing bivariate spline in spherical coordinates
|
154
|
+
LSQSphereBivariateSpline :
|
155
|
+
a bivariate spline in spherical coordinates using weighted
|
156
|
+
least-squares fitting
|
157
|
+
RectBivariateSpline :
|
158
|
+
a bivariate spline over a rectangular mesh
|
159
|
+
InterpolatedUnivariateSpline :
|
160
|
+
a interpolating univariate spline for a given set of data points.
|
161
|
+
bisplrep :
|
162
|
+
a function to find a bivariate B-spline representation of a surface
|
163
|
+
bisplev :
|
164
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
165
|
+
splrep :
|
166
|
+
a function to find the B-spline representation of a 1-D curve
|
167
|
+
splev :
|
168
|
+
a function to evaluate a B-spline or its derivatives
|
169
|
+
sproot :
|
170
|
+
a function to find the roots of a cubic B-spline
|
171
|
+
splint :
|
172
|
+
a function to evaluate the definite integral of a B-spline between two
|
173
|
+
given points
|
174
|
+
spalde :
|
175
|
+
a function to evaluate all derivatives of a B-spline
|
176
|
+
|
177
|
+
Notes
|
178
|
+
-----
|
179
|
+
The number of data points must be larger than the spline degree `k`.
|
180
|
+
|
181
|
+
**NaN handling**: If the input arrays contain ``nan`` values, the result
|
182
|
+
is not useful, since the underlying spline fitting routines cannot deal
|
183
|
+
with ``nan``. A workaround is to use zero weights for not-a-number
|
184
|
+
data points:
|
185
|
+
|
186
|
+
>>> import numpy as np
|
187
|
+
>>> from scipy.interpolate import UnivariateSpline
|
188
|
+
>>> x, y = np.array([1, 2, 3, 4]), np.array([1, np.nan, 3, 4])
|
189
|
+
>>> w = np.isnan(y)
|
190
|
+
>>> y[w] = 0.
|
191
|
+
>>> spl = UnivariateSpline(x, y, w=~w)
|
192
|
+
|
193
|
+
Notice the need to replace a ``nan`` by a numerical value (precise value
|
194
|
+
does not matter as long as the corresponding weight is zero.)
|
195
|
+
|
196
|
+
References
|
197
|
+
----------
|
198
|
+
Based on algorithms described in [1]_, [2]_, [3]_, and [4]_:
|
199
|
+
|
200
|
+
.. [1] P. Dierckx, "An algorithm for smoothing, differentiation and
|
201
|
+
integration of experimental data using spline functions",
|
202
|
+
J.Comp.Appl.Maths 1 (1975) 165-184.
|
203
|
+
.. [2] P. Dierckx, "A fast algorithm for smoothing data on a rectangular
|
204
|
+
grid while using spline functions", SIAM J.Numer.Anal. 19 (1982)
|
205
|
+
1286-1304.
|
206
|
+
.. [3] P. Dierckx, "An improved algorithm for curve fitting with spline
|
207
|
+
functions", report tw54, Dept. Computer Science,K.U. Leuven, 1981.
|
208
|
+
.. [4] P. Dierckx, "Curve and surface fitting with splines", Monographs on
|
209
|
+
Numerical Analysis, Oxford University Press, 1993.
|
210
|
+
|
211
|
+
Examples
|
212
|
+
--------
|
213
|
+
>>> import numpy as np
|
214
|
+
>>> import matplotlib.pyplot as plt
|
215
|
+
>>> from scipy.interpolate import UnivariateSpline
|
216
|
+
>>> rng = np.random.default_rng()
|
217
|
+
>>> x = np.linspace(-3, 3, 50)
|
218
|
+
>>> y = np.exp(-x**2) + 0.1 * rng.standard_normal(50)
|
219
|
+
>>> plt.plot(x, y, 'ro', ms=5)
|
220
|
+
|
221
|
+
Use the default value for the smoothing parameter:
|
222
|
+
|
223
|
+
>>> spl = UnivariateSpline(x, y)
|
224
|
+
>>> xs = np.linspace(-3, 3, 1000)
|
225
|
+
>>> plt.plot(xs, spl(xs), 'g', lw=3)
|
226
|
+
|
227
|
+
Manually change the amount of smoothing:
|
228
|
+
|
229
|
+
>>> spl.set_smoothing_factor(0.5)
|
230
|
+
>>> plt.plot(xs, spl(xs), 'b', lw=3)
|
231
|
+
>>> plt.show()
|
232
|
+
|
233
|
+
"""
|
234
|
+
|
235
|
+
def __init__(self, x, y, w=None, bbox=[None]*2, k=3, s=None,
|
236
|
+
ext=0, check_finite=False):
|
237
|
+
|
238
|
+
x, y, w, bbox, self.ext = self.validate_input(x, y, w, bbox, k, s, ext,
|
239
|
+
check_finite)
|
240
|
+
|
241
|
+
# _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier
|
242
|
+
with FITPACK_LOCK:
|
243
|
+
data = dfitpack.fpcurf0(x, y, k, w=w, xb=bbox[0],
|
244
|
+
xe=bbox[1], s=s)
|
245
|
+
if data[-1] == 1:
|
246
|
+
# nest too small, setting to maximum bound
|
247
|
+
data = self._reset_nest(data)
|
248
|
+
self._data = data
|
249
|
+
self._reset_class()
|
250
|
+
|
251
|
+
@staticmethod
|
252
|
+
def validate_input(x, y, w, bbox, k, s, ext, check_finite):
|
253
|
+
x, y, bbox = np.asarray(x), np.asarray(y), np.asarray(bbox)
|
254
|
+
if w is not None:
|
255
|
+
w = np.asarray(w)
|
256
|
+
if check_finite:
|
257
|
+
w_finite = np.isfinite(w).all() if w is not None else True
|
258
|
+
if (not np.isfinite(x).all() or not np.isfinite(y).all() or
|
259
|
+
not w_finite):
|
260
|
+
raise ValueError("x and y array must not contain "
|
261
|
+
"NaNs or infs.")
|
262
|
+
if s is None or s > 0:
|
263
|
+
if not np.all(diff(x) >= 0.0):
|
264
|
+
raise ValueError("x must be increasing if s > 0")
|
265
|
+
else:
|
266
|
+
if not np.all(diff(x) > 0.0):
|
267
|
+
raise ValueError("x must be strictly increasing if s = 0")
|
268
|
+
if x.size != y.size:
|
269
|
+
raise ValueError("x and y should have a same length")
|
270
|
+
elif w is not None and not x.size == y.size == w.size:
|
271
|
+
raise ValueError("x, y, and w should have a same length")
|
272
|
+
elif bbox.shape != (2,):
|
273
|
+
raise ValueError("bbox shape should be (2,)")
|
274
|
+
elif not (1 <= k <= 5):
|
275
|
+
raise ValueError("k should be 1 <= k <= 5")
|
276
|
+
elif s is not None and not s >= 0.0:
|
277
|
+
raise ValueError("s should be s >= 0.0")
|
278
|
+
|
279
|
+
try:
|
280
|
+
ext = _extrap_modes[ext]
|
281
|
+
except KeyError as e:
|
282
|
+
raise ValueError(f"Unknown extrapolation mode {ext}.") from e
|
283
|
+
|
284
|
+
return x, y, w, bbox, ext
|
285
|
+
|
286
|
+
@classmethod
|
287
|
+
def _from_tck(cls, tck, ext=0):
|
288
|
+
"""Construct a spline object from given tck"""
|
289
|
+
self = cls.__new__(cls)
|
290
|
+
t, c, k = tck
|
291
|
+
self._eval_args = tck
|
292
|
+
# _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier
|
293
|
+
self._data = (None, None, None, None, None, k, None, len(t), t,
|
294
|
+
c, None, None, None, None)
|
295
|
+
self.ext = ext
|
296
|
+
return self
|
297
|
+
|
298
|
+
def _reset_class(self):
|
299
|
+
data = self._data
|
300
|
+
n, t, c, k, ier = data[7], data[8], data[9], data[5], data[-1]
|
301
|
+
self._eval_args = t[:n], c[:n], k
|
302
|
+
if ier == 0:
|
303
|
+
# the spline returned has a residual sum of squares fp
|
304
|
+
# such that abs(fp-s)/s <= tol with tol a relative
|
305
|
+
# tolerance set to 0.001 by the program
|
306
|
+
pass
|
307
|
+
elif ier == -1:
|
308
|
+
# the spline returned is an interpolating spline
|
309
|
+
self._set_class(InterpolatedUnivariateSpline)
|
310
|
+
elif ier == -2:
|
311
|
+
# the spline returned is the weighted least-squares
|
312
|
+
# polynomial of degree k. In this extreme case fp gives
|
313
|
+
# the upper bound fp0 for the smoothing factor s.
|
314
|
+
self._set_class(LSQUnivariateSpline)
|
315
|
+
else:
|
316
|
+
# error
|
317
|
+
if ier == 1:
|
318
|
+
self._set_class(LSQUnivariateSpline)
|
319
|
+
message = _curfit_messages.get(ier, f'ier={ier}')
|
320
|
+
warnings.warn(message, stacklevel=3)
|
321
|
+
|
322
|
+
def _set_class(self, cls):
|
323
|
+
self._spline_class = cls
|
324
|
+
if self.__class__ in (UnivariateSpline, InterpolatedUnivariateSpline,
|
325
|
+
LSQUnivariateSpline):
|
326
|
+
self.__class__ = cls
|
327
|
+
else:
|
328
|
+
# It's an unknown subclass -- don't change class. cf. #731
|
329
|
+
pass
|
330
|
+
|
331
|
+
def _reset_nest(self, data, nest=None):
|
332
|
+
n = data[10]
|
333
|
+
if nest is None:
|
334
|
+
k, m = data[5], len(data[0])
|
335
|
+
nest = m+k+1 # this is the maximum bound for nest
|
336
|
+
else:
|
337
|
+
if not n <= nest:
|
338
|
+
raise ValueError("`nest` can only be increased")
|
339
|
+
t, c, fpint, nrdata = (np.resize(data[j], nest) for j in
|
340
|
+
[8, 9, 11, 12])
|
341
|
+
|
342
|
+
args = data[:8] + (t, c, n, fpint, nrdata, data[13])
|
343
|
+
with FITPACK_LOCK:
|
344
|
+
data = dfitpack.fpcurf1(*args)
|
345
|
+
return data
|
346
|
+
|
347
|
+
def set_smoothing_factor(self, s):
|
348
|
+
""" Continue spline computation with the given smoothing
|
349
|
+
factor s and with the knots found at the last call.
|
350
|
+
|
351
|
+
This routine modifies the spline in place.
|
352
|
+
|
353
|
+
"""
|
354
|
+
data = self._data
|
355
|
+
if data[6] == -1:
|
356
|
+
warnings.warn('smoothing factor unchanged for'
|
357
|
+
'LSQ spline with fixed knots',
|
358
|
+
stacklevel=2)
|
359
|
+
return
|
360
|
+
args = data[:6] + (s,) + data[7:]
|
361
|
+
with FITPACK_LOCK:
|
362
|
+
data = dfitpack.fpcurf1(*args)
|
363
|
+
if data[-1] == 1:
|
364
|
+
# nest too small, setting to maximum bound
|
365
|
+
data = self._reset_nest(data)
|
366
|
+
self._data = data
|
367
|
+
self._reset_class()
|
368
|
+
|
369
|
+
def __call__(self, x, nu=0, ext=None):
|
370
|
+
"""
|
371
|
+
Evaluate spline (or its nu-th derivative) at positions x.
|
372
|
+
|
373
|
+
Parameters
|
374
|
+
----------
|
375
|
+
x : array_like
|
376
|
+
A 1-D array of points at which to return the value of the smoothed
|
377
|
+
spline or its derivatives. Note: `x` can be unordered but the
|
378
|
+
evaluation is more efficient if `x` is (partially) ordered.
|
379
|
+
nu : int
|
380
|
+
The order of derivative of the spline to compute.
|
381
|
+
ext : int
|
382
|
+
Controls the value returned for elements of `x` not in the
|
383
|
+
interval defined by the knot sequence.
|
384
|
+
|
385
|
+
* if ext=0 or 'extrapolate', return the extrapolated value.
|
386
|
+
* if ext=1 or 'zeros', return 0
|
387
|
+
* if ext=2 or 'raise', raise a ValueError
|
388
|
+
* if ext=3 or 'const', return the boundary value.
|
389
|
+
|
390
|
+
The default value is 0, passed from the initialization of
|
391
|
+
UnivariateSpline.
|
392
|
+
|
393
|
+
"""
|
394
|
+
x = np.asarray(x)
|
395
|
+
# empty input yields empty output
|
396
|
+
if x.size == 0:
|
397
|
+
return array([])
|
398
|
+
if ext is None:
|
399
|
+
ext = self.ext
|
400
|
+
else:
|
401
|
+
try:
|
402
|
+
ext = _extrap_modes[ext]
|
403
|
+
except KeyError as e:
|
404
|
+
raise ValueError(f"Unknown extrapolation mode {ext}.") from e
|
405
|
+
with FITPACK_LOCK:
|
406
|
+
return _fitpack_impl.splev(x, self._eval_args, der=nu, ext=ext)
|
407
|
+
|
408
|
+
def get_knots(self):
|
409
|
+
""" Return positions of interior knots of the spline.
|
410
|
+
|
411
|
+
Internally, the knot vector contains ``2*k`` additional boundary knots.
|
412
|
+
"""
|
413
|
+
data = self._data
|
414
|
+
k, n = data[5], data[7]
|
415
|
+
return data[8][k:n-k]
|
416
|
+
|
417
|
+
def get_coeffs(self):
|
418
|
+
"""Return spline coefficients."""
|
419
|
+
data = self._data
|
420
|
+
k, n = data[5], data[7]
|
421
|
+
return data[9][:n-k-1]
|
422
|
+
|
423
|
+
def get_residual(self):
|
424
|
+
"""Return weighted sum of squared residuals of the spline approximation.
|
425
|
+
|
426
|
+
This is equivalent to::
|
427
|
+
|
428
|
+
sum((w[i] * (y[i]-spl(x[i])))**2, axis=0)
|
429
|
+
|
430
|
+
"""
|
431
|
+
return self._data[10]
|
432
|
+
|
433
|
+
def integral(self, a, b):
|
434
|
+
""" Return definite integral of the spline between two given points.
|
435
|
+
|
436
|
+
Parameters
|
437
|
+
----------
|
438
|
+
a : float
|
439
|
+
Lower limit of integration.
|
440
|
+
b : float
|
441
|
+
Upper limit of integration.
|
442
|
+
|
443
|
+
Returns
|
444
|
+
-------
|
445
|
+
integral : float
|
446
|
+
The value of the definite integral of the spline between limits.
|
447
|
+
|
448
|
+
Examples
|
449
|
+
--------
|
450
|
+
>>> import numpy as np
|
451
|
+
>>> from scipy.interpolate import UnivariateSpline
|
452
|
+
>>> x = np.linspace(0, 3, 11)
|
453
|
+
>>> y = x**2
|
454
|
+
>>> spl = UnivariateSpline(x, y)
|
455
|
+
>>> spl.integral(0, 3)
|
456
|
+
9.0
|
457
|
+
|
458
|
+
which agrees with :math:`\\int x^2 dx = x^3 / 3` between the limits
|
459
|
+
of 0 and 3.
|
460
|
+
|
461
|
+
A caveat is that this routine assumes the spline to be zero outside of
|
462
|
+
the data limits:
|
463
|
+
|
464
|
+
>>> spl.integral(-1, 4)
|
465
|
+
9.0
|
466
|
+
>>> spl.integral(-1, 0)
|
467
|
+
0.0
|
468
|
+
|
469
|
+
"""
|
470
|
+
with FITPACK_LOCK:
|
471
|
+
return _fitpack_impl.splint(a, b, self._eval_args)
|
472
|
+
|
473
|
+
def derivatives(self, x):
|
474
|
+
""" Return all derivatives of the spline at the point x.
|
475
|
+
|
476
|
+
Parameters
|
477
|
+
----------
|
478
|
+
x : float
|
479
|
+
The point to evaluate the derivatives at.
|
480
|
+
|
481
|
+
Returns
|
482
|
+
-------
|
483
|
+
der : ndarray, shape(k+1,)
|
484
|
+
Derivatives of the orders 0 to k.
|
485
|
+
|
486
|
+
Examples
|
487
|
+
--------
|
488
|
+
>>> import numpy as np
|
489
|
+
>>> from scipy.interpolate import UnivariateSpline
|
490
|
+
>>> x = np.linspace(0, 3, 11)
|
491
|
+
>>> y = x**2
|
492
|
+
>>> spl = UnivariateSpline(x, y)
|
493
|
+
>>> spl.derivatives(1.5)
|
494
|
+
array([2.25, 3.0, 2.0, 0])
|
495
|
+
|
496
|
+
"""
|
497
|
+
with FITPACK_LOCK:
|
498
|
+
return _fitpack_impl.spalde(x, self._eval_args)
|
499
|
+
|
500
|
+
def roots(self):
|
501
|
+
""" Return the zeros of the spline.
|
502
|
+
|
503
|
+
Notes
|
504
|
+
-----
|
505
|
+
Restriction: only cubic splines are supported by FITPACK. For non-cubic
|
506
|
+
splines, use `PPoly.root` (see below for an example).
|
507
|
+
|
508
|
+
Examples
|
509
|
+
--------
|
510
|
+
|
511
|
+
For some data, this method may miss a root. This happens when one of
|
512
|
+
the spline knots (which FITPACK places automatically) happens to
|
513
|
+
coincide with the true root. A workaround is to convert to `PPoly`,
|
514
|
+
which uses a different root-finding algorithm.
|
515
|
+
|
516
|
+
For example,
|
517
|
+
|
518
|
+
>>> x = [1.96, 1.97, 1.98, 1.99, 2.00, 2.01, 2.02, 2.03, 2.04, 2.05]
|
519
|
+
>>> y = [-6.365470e-03, -4.790580e-03, -3.204320e-03, -1.607270e-03,
|
520
|
+
... 4.440892e-16, 1.616930e-03, 3.243000e-03, 4.877670e-03,
|
521
|
+
... 6.520430e-03, 8.170770e-03]
|
522
|
+
>>> from scipy.interpolate import UnivariateSpline
|
523
|
+
>>> spl = UnivariateSpline(x, y, s=0)
|
524
|
+
>>> spl.roots()
|
525
|
+
array([], dtype=float64)
|
526
|
+
|
527
|
+
Converting to a PPoly object does find the roots at `x=2`:
|
528
|
+
|
529
|
+
>>> from scipy.interpolate import splrep, PPoly
|
530
|
+
>>> tck = splrep(x, y, s=0)
|
531
|
+
>>> ppoly = PPoly.from_spline(tck)
|
532
|
+
>>> ppoly.roots(extrapolate=False)
|
533
|
+
array([2.])
|
534
|
+
|
535
|
+
See Also
|
536
|
+
--------
|
537
|
+
sproot
|
538
|
+
PPoly.roots
|
539
|
+
|
540
|
+
"""
|
541
|
+
k = self._data[5]
|
542
|
+
if k == 3:
|
543
|
+
t = self._eval_args[0]
|
544
|
+
mest = 3 * (len(t) - 7)
|
545
|
+
with FITPACK_LOCK:
|
546
|
+
return _fitpack_impl.sproot(self._eval_args, mest=mest)
|
547
|
+
raise NotImplementedError('finding roots unsupported for '
|
548
|
+
'non-cubic splines')
|
549
|
+
|
550
|
+
def derivative(self, n=1):
|
551
|
+
"""
|
552
|
+
Construct a new spline representing the derivative of this spline.
|
553
|
+
|
554
|
+
Parameters
|
555
|
+
----------
|
556
|
+
n : int, optional
|
557
|
+
Order of derivative to evaluate. Default: 1
|
558
|
+
|
559
|
+
Returns
|
560
|
+
-------
|
561
|
+
spline : UnivariateSpline
|
562
|
+
Spline of order k2=k-n representing the derivative of this
|
563
|
+
spline.
|
564
|
+
|
565
|
+
See Also
|
566
|
+
--------
|
567
|
+
splder, antiderivative
|
568
|
+
|
569
|
+
Notes
|
570
|
+
-----
|
571
|
+
|
572
|
+
.. versionadded:: 0.13.0
|
573
|
+
|
574
|
+
Examples
|
575
|
+
--------
|
576
|
+
This can be used for finding maxima of a curve:
|
577
|
+
|
578
|
+
>>> import numpy as np
|
579
|
+
>>> from scipy.interpolate import UnivariateSpline
|
580
|
+
>>> x = np.linspace(0, 10, 70)
|
581
|
+
>>> y = np.sin(x)
|
582
|
+
>>> spl = UnivariateSpline(x, y, k=4, s=0)
|
583
|
+
|
584
|
+
Now, differentiate the spline and find the zeros of the
|
585
|
+
derivative. (NB: `sproot` only works for order 3 splines, so we
|
586
|
+
fit an order 4 spline):
|
587
|
+
|
588
|
+
>>> spl.derivative().roots() / np.pi
|
589
|
+
array([ 0.50000001, 1.5 , 2.49999998])
|
590
|
+
|
591
|
+
This agrees well with roots :math:`\\pi/2 + n\\pi` of
|
592
|
+
:math:`\\cos(x) = \\sin'(x)`.
|
593
|
+
|
594
|
+
"""
|
595
|
+
with FITPACK_LOCK:
|
596
|
+
tck = _fitpack_impl.splder(self._eval_args, n)
|
597
|
+
# if self.ext is 'const', derivative.ext will be 'zeros'
|
598
|
+
ext = 1 if self.ext == 3 else self.ext
|
599
|
+
return UnivariateSpline._from_tck(tck, ext=ext)
|
600
|
+
|
601
|
+
def antiderivative(self, n=1):
|
602
|
+
"""
|
603
|
+
Construct a new spline representing the antiderivative of this spline.
|
604
|
+
|
605
|
+
Parameters
|
606
|
+
----------
|
607
|
+
n : int, optional
|
608
|
+
Order of antiderivative to evaluate. Default: 1
|
609
|
+
|
610
|
+
Returns
|
611
|
+
-------
|
612
|
+
spline : UnivariateSpline
|
613
|
+
Spline of order k2=k+n representing the antiderivative of this
|
614
|
+
spline.
|
615
|
+
|
616
|
+
Notes
|
617
|
+
-----
|
618
|
+
|
619
|
+
.. versionadded:: 0.13.0
|
620
|
+
|
621
|
+
See Also
|
622
|
+
--------
|
623
|
+
splantider, derivative
|
624
|
+
|
625
|
+
Examples
|
626
|
+
--------
|
627
|
+
>>> import numpy as np
|
628
|
+
>>> from scipy.interpolate import UnivariateSpline
|
629
|
+
>>> x = np.linspace(0, np.pi/2, 70)
|
630
|
+
>>> y = 1 / np.sqrt(1 - 0.8*np.sin(x)**2)
|
631
|
+
>>> spl = UnivariateSpline(x, y, s=0)
|
632
|
+
|
633
|
+
The derivative is the inverse operation of the antiderivative,
|
634
|
+
although some floating point error accumulates:
|
635
|
+
|
636
|
+
>>> spl(1.7), spl.antiderivative().derivative()(1.7)
|
637
|
+
(array(2.1565429877197317), array(2.1565429877201865))
|
638
|
+
|
639
|
+
Antiderivative can be used to evaluate definite integrals:
|
640
|
+
|
641
|
+
>>> ispl = spl.antiderivative()
|
642
|
+
>>> ispl(np.pi/2) - ispl(0)
|
643
|
+
2.2572053588768486
|
644
|
+
|
645
|
+
This is indeed an approximation to the complete elliptic integral
|
646
|
+
:math:`K(m) = \\int_0^{\\pi/2} [1 - m\\sin^2 x]^{-1/2} dx`:
|
647
|
+
|
648
|
+
>>> from scipy.special import ellipk
|
649
|
+
>>> ellipk(0.8)
|
650
|
+
2.2572053268208538
|
651
|
+
|
652
|
+
"""
|
653
|
+
with FITPACK_LOCK:
|
654
|
+
tck = _fitpack_impl.splantider(self._eval_args, n)
|
655
|
+
return UnivariateSpline._from_tck(tck, self.ext)
|
656
|
+
|
657
|
+
|
658
|
+
class InterpolatedUnivariateSpline(UnivariateSpline):
|
659
|
+
"""
|
660
|
+
1-D interpolating spline for a given set of data points.
|
661
|
+
|
662
|
+
.. legacy:: class
|
663
|
+
|
664
|
+
Specifically, we recommend using `make_interp_spline` instead.
|
665
|
+
|
666
|
+
Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data.
|
667
|
+
Spline function passes through all provided points. Equivalent to
|
668
|
+
`UnivariateSpline` with `s` = 0.
|
669
|
+
|
670
|
+
Parameters
|
671
|
+
----------
|
672
|
+
x : (N,) array_like
|
673
|
+
Input dimension of data points -- must be strictly increasing
|
674
|
+
y : (N,) array_like
|
675
|
+
input dimension of data points
|
676
|
+
w : (N,) array_like, optional
|
677
|
+
Weights for spline fitting. Must be positive. If None (default),
|
678
|
+
weights are all 1.
|
679
|
+
bbox : (2,) array_like, optional
|
680
|
+
2-sequence specifying the boundary of the approximation interval. If
|
681
|
+
None (default), ``bbox=[x[0], x[-1]]``.
|
682
|
+
k : int, optional
|
683
|
+
Degree of the smoothing spline. Must be ``1 <= k <= 5``. Default is
|
684
|
+
``k = 3``, a cubic spline.
|
685
|
+
ext : int or str, optional
|
686
|
+
Controls the extrapolation mode for elements
|
687
|
+
not in the interval defined by the knot sequence.
|
688
|
+
|
689
|
+
* if ext=0 or 'extrapolate', return the extrapolated value.
|
690
|
+
* if ext=1 or 'zeros', return 0
|
691
|
+
* if ext=2 or 'raise', raise a ValueError
|
692
|
+
* if ext=3 of 'const', return the boundary value.
|
693
|
+
|
694
|
+
The default value is 0.
|
695
|
+
|
696
|
+
check_finite : bool, optional
|
697
|
+
Whether to check that the input arrays contain only finite numbers.
|
698
|
+
Disabling may give a performance gain, but may result in problems
|
699
|
+
(crashes, non-termination or non-sensical results) if the inputs
|
700
|
+
do contain infinities or NaNs.
|
701
|
+
Default is False.
|
702
|
+
|
703
|
+
See Also
|
704
|
+
--------
|
705
|
+
UnivariateSpline :
|
706
|
+
a smooth univariate spline to fit a given set of data points.
|
707
|
+
LSQUnivariateSpline :
|
708
|
+
a spline for which knots are user-selected
|
709
|
+
SmoothBivariateSpline :
|
710
|
+
a smoothing bivariate spline through the given points
|
711
|
+
LSQBivariateSpline :
|
712
|
+
a bivariate spline using weighted least-squares fitting
|
713
|
+
splrep :
|
714
|
+
a function to find the B-spline representation of a 1-D curve
|
715
|
+
splev :
|
716
|
+
a function to evaluate a B-spline or its derivatives
|
717
|
+
sproot :
|
718
|
+
a function to find the roots of a cubic B-spline
|
719
|
+
splint :
|
720
|
+
a function to evaluate the definite integral of a B-spline between two
|
721
|
+
given points
|
722
|
+
spalde :
|
723
|
+
a function to evaluate all derivatives of a B-spline
|
724
|
+
|
725
|
+
Notes
|
726
|
+
-----
|
727
|
+
The number of data points must be larger than the spline degree `k`.
|
728
|
+
|
729
|
+
Examples
|
730
|
+
--------
|
731
|
+
>>> import numpy as np
|
732
|
+
>>> import matplotlib.pyplot as plt
|
733
|
+
>>> from scipy.interpolate import InterpolatedUnivariateSpline
|
734
|
+
>>> rng = np.random.default_rng()
|
735
|
+
>>> x = np.linspace(-3, 3, 50)
|
736
|
+
>>> y = np.exp(-x**2) + 0.1 * rng.standard_normal(50)
|
737
|
+
>>> spl = InterpolatedUnivariateSpline(x, y)
|
738
|
+
>>> plt.plot(x, y, 'ro', ms=5)
|
739
|
+
>>> xs = np.linspace(-3, 3, 1000)
|
740
|
+
>>> plt.plot(xs, spl(xs), 'g', lw=3, alpha=0.7)
|
741
|
+
>>> plt.show()
|
742
|
+
|
743
|
+
Notice that the ``spl(x)`` interpolates `y`:
|
744
|
+
|
745
|
+
>>> spl.get_residual()
|
746
|
+
0.0
|
747
|
+
|
748
|
+
"""
|
749
|
+
|
750
|
+
def __init__(self, x, y, w=None, bbox=[None]*2, k=3,
|
751
|
+
ext=0, check_finite=False):
|
752
|
+
|
753
|
+
x, y, w, bbox, self.ext = self.validate_input(x, y, w, bbox, k, None,
|
754
|
+
ext, check_finite)
|
755
|
+
if not np.all(diff(x) > 0.0):
|
756
|
+
raise ValueError('x must be strictly increasing')
|
757
|
+
|
758
|
+
# _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier
|
759
|
+
with FITPACK_LOCK:
|
760
|
+
self._data = dfitpack.fpcurf0(x, y, k, w=w, xb=bbox[0],
|
761
|
+
xe=bbox[1], s=0)
|
762
|
+
self._reset_class()
|
763
|
+
|
764
|
+
|
765
|
+
_fpchec_error_string = """The input parameters have been rejected by fpchec. \
|
766
|
+
This means that at least one of the following conditions is violated:
|
767
|
+
|
768
|
+
1) k+1 <= n-k-1 <= m
|
769
|
+
2) t(1) <= t(2) <= ... <= t(k+1)
|
770
|
+
t(n-k) <= t(n-k+1) <= ... <= t(n)
|
771
|
+
3) t(k+1) < t(k+2) < ... < t(n-k)
|
772
|
+
4) t(k+1) <= x(i) <= t(n-k)
|
773
|
+
5) The conditions specified by Schoenberg and Whitney must hold
|
774
|
+
for at least one subset of data points, i.e., there must be a
|
775
|
+
subset of data points y(j) such that
|
776
|
+
t(j) < y(j) < t(j+k+1), j=1,2,...,n-k-1
|
777
|
+
"""
|
778
|
+
|
779
|
+
|
780
|
+
class LSQUnivariateSpline(UnivariateSpline):
|
781
|
+
"""
|
782
|
+
1-D spline with explicit internal knots.
|
783
|
+
|
784
|
+
.. legacy:: class
|
785
|
+
|
786
|
+
Specifically, we recommend using `make_lsq_spline` instead.
|
787
|
+
|
788
|
+
|
789
|
+
Fits a spline y = spl(x) of degree `k` to the provided `x`, `y` data. `t`
|
790
|
+
specifies the internal knots of the spline
|
791
|
+
|
792
|
+
Parameters
|
793
|
+
----------
|
794
|
+
x : (N,) array_like
|
795
|
+
Input dimension of data points -- must be increasing
|
796
|
+
y : (N,) array_like
|
797
|
+
Input dimension of data points
|
798
|
+
t : (M,) array_like
|
799
|
+
interior knots of the spline. Must be in ascending order and::
|
800
|
+
|
801
|
+
bbox[0] < t[0] < ... < t[-1] < bbox[-1]
|
802
|
+
|
803
|
+
w : (N,) array_like, optional
|
804
|
+
weights for spline fitting. Must be positive. If None (default),
|
805
|
+
weights are all 1.
|
806
|
+
bbox : (2,) array_like, optional
|
807
|
+
2-sequence specifying the boundary of the approximation interval. If
|
808
|
+
None (default), ``bbox = [x[0], x[-1]]``.
|
809
|
+
k : int, optional
|
810
|
+
Degree of the smoothing spline. Must be 1 <= `k` <= 5.
|
811
|
+
Default is `k` = 3, a cubic spline.
|
812
|
+
ext : int or str, optional
|
813
|
+
Controls the extrapolation mode for elements
|
814
|
+
not in the interval defined by the knot sequence.
|
815
|
+
|
816
|
+
* if ext=0 or 'extrapolate', return the extrapolated value.
|
817
|
+
* if ext=1 or 'zeros', return 0
|
818
|
+
* if ext=2 or 'raise', raise a ValueError
|
819
|
+
* if ext=3 of 'const', return the boundary value.
|
820
|
+
|
821
|
+
The default value is 0.
|
822
|
+
|
823
|
+
check_finite : bool, optional
|
824
|
+
Whether to check that the input arrays contain only finite numbers.
|
825
|
+
Disabling may give a performance gain, but may result in problems
|
826
|
+
(crashes, non-termination or non-sensical results) if the inputs
|
827
|
+
do contain infinities or NaNs.
|
828
|
+
Default is False.
|
829
|
+
|
830
|
+
Raises
|
831
|
+
------
|
832
|
+
ValueError
|
833
|
+
If the interior knots do not satisfy the Schoenberg-Whitney conditions
|
834
|
+
|
835
|
+
See Also
|
836
|
+
--------
|
837
|
+
UnivariateSpline :
|
838
|
+
a smooth univariate spline to fit a given set of data points.
|
839
|
+
InterpolatedUnivariateSpline :
|
840
|
+
a interpolating univariate spline for a given set of data points.
|
841
|
+
splrep :
|
842
|
+
a function to find the B-spline representation of a 1-D curve
|
843
|
+
splev :
|
844
|
+
a function to evaluate a B-spline or its derivatives
|
845
|
+
sproot :
|
846
|
+
a function to find the roots of a cubic B-spline
|
847
|
+
splint :
|
848
|
+
a function to evaluate the definite integral of a B-spline between two
|
849
|
+
given points
|
850
|
+
spalde :
|
851
|
+
a function to evaluate all derivatives of a B-spline
|
852
|
+
|
853
|
+
Notes
|
854
|
+
-----
|
855
|
+
The number of data points must be larger than the spline degree `k`.
|
856
|
+
|
857
|
+
Knots `t` must satisfy the Schoenberg-Whitney conditions,
|
858
|
+
i.e., there must be a subset of data points ``x[j]`` such that
|
859
|
+
``t[j] < x[j] < t[j+k+1]``, for ``j=0, 1,...,n-k-2``.
|
860
|
+
|
861
|
+
Examples
|
862
|
+
--------
|
863
|
+
>>> import numpy as np
|
864
|
+
>>> from scipy.interpolate import LSQUnivariateSpline, UnivariateSpline
|
865
|
+
>>> import matplotlib.pyplot as plt
|
866
|
+
>>> rng = np.random.default_rng()
|
867
|
+
>>> x = np.linspace(-3, 3, 50)
|
868
|
+
>>> y = np.exp(-x**2) + 0.1 * rng.standard_normal(50)
|
869
|
+
|
870
|
+
Fit a smoothing spline with a pre-defined internal knots:
|
871
|
+
|
872
|
+
>>> t = [-1, 0, 1]
|
873
|
+
>>> spl = LSQUnivariateSpline(x, y, t)
|
874
|
+
|
875
|
+
>>> xs = np.linspace(-3, 3, 1000)
|
876
|
+
>>> plt.plot(x, y, 'ro', ms=5)
|
877
|
+
>>> plt.plot(xs, spl(xs), 'g-', lw=3)
|
878
|
+
>>> plt.show()
|
879
|
+
|
880
|
+
Check the knot vector:
|
881
|
+
|
882
|
+
>>> spl.get_knots()
|
883
|
+
array([-3., -1., 0., 1., 3.])
|
884
|
+
|
885
|
+
Constructing lsq spline using the knots from another spline:
|
886
|
+
|
887
|
+
>>> x = np.arange(10)
|
888
|
+
>>> s = UnivariateSpline(x, x, s=0)
|
889
|
+
>>> s.get_knots()
|
890
|
+
array([ 0., 2., 3., 4., 5., 6., 7., 9.])
|
891
|
+
>>> knt = s.get_knots()
|
892
|
+
>>> s1 = LSQUnivariateSpline(x, x, knt[1:-1]) # Chop 1st and last knot
|
893
|
+
>>> s1.get_knots()
|
894
|
+
array([ 0., 2., 3., 4., 5., 6., 7., 9.])
|
895
|
+
|
896
|
+
"""
|
897
|
+
|
898
|
+
def __init__(self, x, y, t, w=None, bbox=[None]*2, k=3,
|
899
|
+
ext=0, check_finite=False):
|
900
|
+
|
901
|
+
x, y, w, bbox, self.ext = self.validate_input(x, y, w, bbox, k, None,
|
902
|
+
ext, check_finite)
|
903
|
+
if not np.all(diff(x) >= 0.0):
|
904
|
+
raise ValueError('x must be increasing')
|
905
|
+
|
906
|
+
# _data == x,y,w,xb,xe,k,s,n,t,c,fp,fpint,nrdata,ier
|
907
|
+
xb = bbox[0]
|
908
|
+
xe = bbox[1]
|
909
|
+
if xb is None:
|
910
|
+
xb = x[0]
|
911
|
+
if xe is None:
|
912
|
+
xe = x[-1]
|
913
|
+
t = concatenate(([xb]*(k+1), t, [xe]*(k+1)))
|
914
|
+
n = len(t)
|
915
|
+
if not np.all(t[k+1:n-k]-t[k:n-k-1] > 0, axis=0):
|
916
|
+
raise ValueError('Interior knots t must satisfy '
|
917
|
+
'Schoenberg-Whitney conditions')
|
918
|
+
with FITPACK_LOCK:
|
919
|
+
if not dfitpack.fpchec(x, t, k) == 0:
|
920
|
+
raise ValueError(_fpchec_error_string)
|
921
|
+
data = dfitpack.fpcurfm1(x, y, k, t, w=w, xb=xb, xe=xe)
|
922
|
+
self._data = data[:-3] + (None, None, data[-1])
|
923
|
+
self._reset_class()
|
924
|
+
|
925
|
+
|
926
|
+
# ############### Bivariate spline ####################
|
927
|
+
|
928
|
+
class _BivariateSplineBase:
|
929
|
+
""" Base class for Bivariate spline s(x,y) interpolation on the rectangle
|
930
|
+
[xb,xe] x [yb, ye] calculated from a given set of data points
|
931
|
+
(x,y,z).
|
932
|
+
|
933
|
+
See Also
|
934
|
+
--------
|
935
|
+
bisplrep :
|
936
|
+
a function to find a bivariate B-spline representation of a surface
|
937
|
+
bisplev :
|
938
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
939
|
+
BivariateSpline :
|
940
|
+
a base class for bivariate splines.
|
941
|
+
SphereBivariateSpline :
|
942
|
+
a bivariate spline on a spherical grid
|
943
|
+
"""
|
944
|
+
|
945
|
+
@classmethod
|
946
|
+
def _from_tck(cls, tck):
|
947
|
+
"""Construct a spline object from given tck and degree"""
|
948
|
+
self = cls.__new__(cls)
|
949
|
+
if len(tck) != 5:
|
950
|
+
raise ValueError("tck should be a 5 element tuple of tx,"
|
951
|
+
" ty, c, kx, ky")
|
952
|
+
self.tck = tck[:3]
|
953
|
+
self.degrees = tck[3:]
|
954
|
+
return self
|
955
|
+
|
956
|
+
def get_residual(self):
|
957
|
+
""" Return weighted sum of squared residuals of the spline
|
958
|
+
approximation: sum ((w[i]*(z[i]-s(x[i],y[i])))**2,axis=0)
|
959
|
+
"""
|
960
|
+
return self.fp
|
961
|
+
|
962
|
+
def get_knots(self):
|
963
|
+
""" Return a tuple (tx,ty) where tx,ty contain knots positions
|
964
|
+
of the spline with respect to x-, y-variable, respectively.
|
965
|
+
The position of interior and additional knots are given as
|
966
|
+
t[k+1:-k-1] and t[:k+1]=b, t[-k-1:]=e, respectively.
|
967
|
+
"""
|
968
|
+
return self.tck[:2]
|
969
|
+
|
970
|
+
def get_coeffs(self):
|
971
|
+
""" Return spline coefficients."""
|
972
|
+
return self.tck[2]
|
973
|
+
|
974
|
+
def __call__(self, x, y, dx=0, dy=0, grid=True):
|
975
|
+
"""
|
976
|
+
Evaluate the spline or its derivatives at given positions.
|
977
|
+
|
978
|
+
Parameters
|
979
|
+
----------
|
980
|
+
x, y : array_like
|
981
|
+
Input coordinates.
|
982
|
+
|
983
|
+
If `grid` is False, evaluate the spline at points ``(x[i],
|
984
|
+
y[i]), i=0, ..., len(x)-1``. Standard Numpy broadcasting
|
985
|
+
is obeyed.
|
986
|
+
|
987
|
+
If `grid` is True: evaluate spline at the grid points
|
988
|
+
defined by the coordinate arrays x, y. The arrays must be
|
989
|
+
sorted to increasing order.
|
990
|
+
|
991
|
+
The ordering of axes is consistent with
|
992
|
+
``np.meshgrid(..., indexing="ij")`` and inconsistent with the
|
993
|
+
default ordering ``np.meshgrid(..., indexing="xy")``.
|
994
|
+
dx : int
|
995
|
+
Order of x-derivative
|
996
|
+
|
997
|
+
.. versionadded:: 0.14.0
|
998
|
+
dy : int
|
999
|
+
Order of y-derivative
|
1000
|
+
|
1001
|
+
.. versionadded:: 0.14.0
|
1002
|
+
grid : bool
|
1003
|
+
Whether to evaluate the results on a grid spanned by the
|
1004
|
+
input arrays, or at points specified by the input arrays.
|
1005
|
+
|
1006
|
+
.. versionadded:: 0.14.0
|
1007
|
+
|
1008
|
+
Examples
|
1009
|
+
--------
|
1010
|
+
Suppose that we want to bilinearly interpolate an exponentially decaying
|
1011
|
+
function in 2 dimensions.
|
1012
|
+
|
1013
|
+
>>> import numpy as np
|
1014
|
+
>>> from scipy.interpolate import RectBivariateSpline
|
1015
|
+
|
1016
|
+
We sample the function on a coarse grid. Note that the default indexing="xy"
|
1017
|
+
of meshgrid would result in an unexpected (transposed) result after
|
1018
|
+
interpolation.
|
1019
|
+
|
1020
|
+
>>> xarr = np.linspace(-3, 3, 100)
|
1021
|
+
>>> yarr = np.linspace(-3, 3, 100)
|
1022
|
+
>>> xgrid, ygrid = np.meshgrid(xarr, yarr, indexing="ij")
|
1023
|
+
|
1024
|
+
The function to interpolate decays faster along one axis than the other.
|
1025
|
+
|
1026
|
+
>>> zdata = np.exp(-np.sqrt((xgrid / 2) ** 2 + ygrid**2))
|
1027
|
+
|
1028
|
+
Next we sample on a finer grid using interpolation (kx=ky=1 for bilinear).
|
1029
|
+
|
1030
|
+
>>> rbs = RectBivariateSpline(xarr, yarr, zdata, kx=1, ky=1)
|
1031
|
+
>>> xarr_fine = np.linspace(-3, 3, 200)
|
1032
|
+
>>> yarr_fine = np.linspace(-3, 3, 200)
|
1033
|
+
>>> xgrid_fine, ygrid_fine = np.meshgrid(xarr_fine, yarr_fine, indexing="ij")
|
1034
|
+
>>> zdata_interp = rbs(xgrid_fine, ygrid_fine, grid=False)
|
1035
|
+
|
1036
|
+
And check that the result agrees with the input by plotting both.
|
1037
|
+
|
1038
|
+
>>> import matplotlib.pyplot as plt
|
1039
|
+
>>> fig = plt.figure()
|
1040
|
+
>>> ax1 = fig.add_subplot(1, 2, 1, aspect="equal")
|
1041
|
+
>>> ax2 = fig.add_subplot(1, 2, 2, aspect="equal")
|
1042
|
+
>>> ax1.imshow(zdata)
|
1043
|
+
>>> ax2.imshow(zdata_interp)
|
1044
|
+
>>> plt.show()
|
1045
|
+
"""
|
1046
|
+
x = np.asarray(x)
|
1047
|
+
y = np.asarray(y)
|
1048
|
+
|
1049
|
+
tx, ty, c = self.tck[:3]
|
1050
|
+
kx, ky = self.degrees
|
1051
|
+
if grid:
|
1052
|
+
if x.size == 0 or y.size == 0:
|
1053
|
+
return np.zeros((x.size, y.size), dtype=self.tck[2].dtype)
|
1054
|
+
|
1055
|
+
if (x.size >= 2) and (not np.all(np.diff(x) >= 0.0)):
|
1056
|
+
raise ValueError("x must be strictly increasing when `grid` is True")
|
1057
|
+
if (y.size >= 2) and (not np.all(np.diff(y) >= 0.0)):
|
1058
|
+
raise ValueError("y must be strictly increasing when `grid` is True")
|
1059
|
+
|
1060
|
+
if dx or dy:
|
1061
|
+
with FITPACK_LOCK:
|
1062
|
+
z, ier = dfitpack.parder(tx, ty, c, kx, ky, dx, dy, x, y)
|
1063
|
+
if not ier == 0:
|
1064
|
+
raise ValueError(f"Error code returned by parder: {ier}")
|
1065
|
+
else:
|
1066
|
+
with FITPACK_LOCK:
|
1067
|
+
z, ier = dfitpack.bispev(tx, ty, c, kx, ky, x, y)
|
1068
|
+
if not ier == 0:
|
1069
|
+
raise ValueError(f"Error code returned by bispev: {ier}")
|
1070
|
+
else:
|
1071
|
+
# standard Numpy broadcasting
|
1072
|
+
if x.shape != y.shape:
|
1073
|
+
x, y = np.broadcast_arrays(x, y)
|
1074
|
+
|
1075
|
+
shape = x.shape
|
1076
|
+
x = x.ravel()
|
1077
|
+
y = y.ravel()
|
1078
|
+
|
1079
|
+
if x.size == 0 or y.size == 0:
|
1080
|
+
return np.zeros(shape, dtype=self.tck[2].dtype)
|
1081
|
+
|
1082
|
+
if dx or dy:
|
1083
|
+
with FITPACK_LOCK:
|
1084
|
+
z, ier = dfitpack.pardeu(tx, ty, c, kx, ky, dx, dy, x, y)
|
1085
|
+
if not ier == 0:
|
1086
|
+
raise ValueError(f"Error code returned by pardeu: {ier}")
|
1087
|
+
else:
|
1088
|
+
with FITPACK_LOCK:
|
1089
|
+
z, ier = dfitpack.bispeu(tx, ty, c, kx, ky, x, y)
|
1090
|
+
if not ier == 0:
|
1091
|
+
raise ValueError(f"Error code returned by bispeu: {ier}")
|
1092
|
+
|
1093
|
+
z = z.reshape(shape)
|
1094
|
+
return z
|
1095
|
+
|
1096
|
+
def partial_derivative(self, dx, dy):
|
1097
|
+
"""Construct a new spline representing a partial derivative of this
|
1098
|
+
spline.
|
1099
|
+
|
1100
|
+
Parameters
|
1101
|
+
----------
|
1102
|
+
dx, dy : int
|
1103
|
+
Orders of the derivative in x and y respectively. They must be
|
1104
|
+
non-negative integers and less than the respective degree of the
|
1105
|
+
original spline (self) in that direction (``kx``, ``ky``).
|
1106
|
+
|
1107
|
+
Returns
|
1108
|
+
-------
|
1109
|
+
spline :
|
1110
|
+
A new spline of degrees (``kx - dx``, ``ky - dy``) representing the
|
1111
|
+
derivative of this spline.
|
1112
|
+
|
1113
|
+
Notes
|
1114
|
+
-----
|
1115
|
+
|
1116
|
+
.. versionadded:: 1.9.0
|
1117
|
+
|
1118
|
+
"""
|
1119
|
+
if dx == 0 and dy == 0:
|
1120
|
+
return self
|
1121
|
+
else:
|
1122
|
+
kx, ky = self.degrees
|
1123
|
+
if not (dx >= 0 and dy >= 0):
|
1124
|
+
raise ValueError("order of derivative must be positive or"
|
1125
|
+
" zero")
|
1126
|
+
if not (dx < kx and dy < ky):
|
1127
|
+
raise ValueError("order of derivative must be less than"
|
1128
|
+
" degree of spline")
|
1129
|
+
tx, ty, c = self.tck[:3]
|
1130
|
+
with FITPACK_LOCK:
|
1131
|
+
newc, ier = dfitpack.pardtc(tx, ty, c, kx, ky, dx, dy)
|
1132
|
+
if ier != 0:
|
1133
|
+
# This should not happen under normal conditions.
|
1134
|
+
raise ValueError(f"Unexpected error code returned by pardtc: {ier}")
|
1135
|
+
nx = len(tx)
|
1136
|
+
ny = len(ty)
|
1137
|
+
newtx = tx[dx:nx - dx]
|
1138
|
+
newty = ty[dy:ny - dy]
|
1139
|
+
newkx, newky = kx - dx, ky - dy
|
1140
|
+
newclen = (nx - dx - kx - 1) * (ny - dy - ky - 1)
|
1141
|
+
return _DerivedBivariateSpline._from_tck((newtx, newty,
|
1142
|
+
newc[:newclen],
|
1143
|
+
newkx, newky))
|
1144
|
+
|
1145
|
+
|
1146
|
+
_surfit_messages = {1: """
|
1147
|
+
The required storage space exceeds the available storage space: nxest
|
1148
|
+
or nyest too small, or s too small.
|
1149
|
+
The weighted least-squares spline corresponds to the current set of
|
1150
|
+
knots.""",
|
1151
|
+
2: """
|
1152
|
+
A theoretically impossible result was found during the iteration
|
1153
|
+
process for finding a smoothing spline with fp = s: s too small or
|
1154
|
+
badly chosen eps.
|
1155
|
+
Weighted sum of squared residuals does not satisfy abs(fp-s)/s < tol.""",
|
1156
|
+
3: """
|
1157
|
+
the maximal number of iterations maxit (set to 20 by the program)
|
1158
|
+
allowed for finding a smoothing spline with fp=s has been reached:
|
1159
|
+
s too small.
|
1160
|
+
Weighted sum of squared residuals does not satisfy abs(fp-s)/s < tol.
|
1161
|
+
Try increasing maxit by passing it as a keyword argument.""",
|
1162
|
+
4: """
|
1163
|
+
No more knots can be added because the number of b-spline coefficients
|
1164
|
+
(nx-kx-1)*(ny-ky-1) already exceeds the number of data points m:
|
1165
|
+
either s or m too small.
|
1166
|
+
The weighted least-squares spline corresponds to the current set of
|
1167
|
+
knots.""",
|
1168
|
+
5: """
|
1169
|
+
No more knots can be added because the additional knot would (quasi)
|
1170
|
+
coincide with an old one: s too small or too large a weight to an
|
1171
|
+
inaccurate data point.
|
1172
|
+
The weighted least-squares spline corresponds to the current set of
|
1173
|
+
knots.""",
|
1174
|
+
10: """
|
1175
|
+
Error on entry, no approximation returned. The following conditions
|
1176
|
+
must hold:
|
1177
|
+
xb<=x[i]<=xe, yb<=y[i]<=ye, w[i]>0, i=0..m-1
|
1178
|
+
If iopt==-1, then
|
1179
|
+
xb<tx[kx+1]<tx[kx+2]<...<tx[nx-kx-2]<xe
|
1180
|
+
yb<ty[ky+1]<ty[ky+2]<...<ty[ny-ky-2]<ye""",
|
1181
|
+
-3: """
|
1182
|
+
The coefficients of the spline returned have been computed as the
|
1183
|
+
minimal norm least-squares solution of a (numerically) rank deficient
|
1184
|
+
system (deficiency=%i). If deficiency is large, the results may be
|
1185
|
+
inaccurate. Deficiency may strongly depend on the value of eps."""
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
|
1189
|
+
class BivariateSpline(_BivariateSplineBase):
|
1190
|
+
"""
|
1191
|
+
Base class for bivariate splines.
|
1192
|
+
|
1193
|
+
This describes a spline ``s(x, y)`` of degrees ``kx`` and ``ky`` on
|
1194
|
+
the rectangle ``[xb, xe] * [yb, ye]`` calculated from a given set
|
1195
|
+
of data points ``(x, y, z)``.
|
1196
|
+
|
1197
|
+
This class is meant to be subclassed, not instantiated directly.
|
1198
|
+
To construct these splines, call either `SmoothBivariateSpline` or
|
1199
|
+
`LSQBivariateSpline` or `RectBivariateSpline`.
|
1200
|
+
|
1201
|
+
See Also
|
1202
|
+
--------
|
1203
|
+
UnivariateSpline :
|
1204
|
+
a smooth univariate spline to fit a given set of data points.
|
1205
|
+
SmoothBivariateSpline :
|
1206
|
+
a smoothing bivariate spline through the given points
|
1207
|
+
LSQBivariateSpline :
|
1208
|
+
a bivariate spline using weighted least-squares fitting
|
1209
|
+
RectSphereBivariateSpline :
|
1210
|
+
a bivariate spline over a rectangular mesh on a sphere
|
1211
|
+
SmoothSphereBivariateSpline :
|
1212
|
+
a smoothing bivariate spline in spherical coordinates
|
1213
|
+
LSQSphereBivariateSpline :
|
1214
|
+
a bivariate spline in spherical coordinates using weighted
|
1215
|
+
least-squares fitting
|
1216
|
+
RectBivariateSpline :
|
1217
|
+
a bivariate spline over a rectangular mesh.
|
1218
|
+
bisplrep :
|
1219
|
+
a function to find a bivariate B-spline representation of a surface
|
1220
|
+
bisplev :
|
1221
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1222
|
+
"""
|
1223
|
+
|
1224
|
+
def ev(self, xi, yi, dx=0, dy=0):
|
1225
|
+
"""
|
1226
|
+
Evaluate the spline at points
|
1227
|
+
|
1228
|
+
Returns the interpolated value at ``(xi[i], yi[i]),
|
1229
|
+
i=0,...,len(xi)-1``.
|
1230
|
+
|
1231
|
+
Parameters
|
1232
|
+
----------
|
1233
|
+
xi, yi : array_like
|
1234
|
+
Input coordinates. Standard Numpy broadcasting is obeyed.
|
1235
|
+
The ordering of axes is consistent with
|
1236
|
+
``np.meshgrid(..., indexing="ij")`` and inconsistent with the
|
1237
|
+
default ordering ``np.meshgrid(..., indexing="xy")``.
|
1238
|
+
dx : int, optional
|
1239
|
+
Order of x-derivative
|
1240
|
+
|
1241
|
+
.. versionadded:: 0.14.0
|
1242
|
+
dy : int, optional
|
1243
|
+
Order of y-derivative
|
1244
|
+
|
1245
|
+
.. versionadded:: 0.14.0
|
1246
|
+
|
1247
|
+
Examples
|
1248
|
+
--------
|
1249
|
+
Suppose that we want to bilinearly interpolate an exponentially decaying
|
1250
|
+
function in 2 dimensions.
|
1251
|
+
|
1252
|
+
>>> import numpy as np
|
1253
|
+
>>> from scipy.interpolate import RectBivariateSpline
|
1254
|
+
>>> def f(x, y):
|
1255
|
+
... return np.exp(-np.sqrt((x / 2) ** 2 + y**2))
|
1256
|
+
|
1257
|
+
We sample the function on a coarse grid and set up the interpolator. Note that
|
1258
|
+
the default ``indexing="xy"`` of meshgrid would result in an unexpected
|
1259
|
+
(transposed) result after interpolation.
|
1260
|
+
|
1261
|
+
>>> xarr = np.linspace(-3, 3, 21)
|
1262
|
+
>>> yarr = np.linspace(-3, 3, 21)
|
1263
|
+
>>> xgrid, ygrid = np.meshgrid(xarr, yarr, indexing="ij")
|
1264
|
+
>>> zdata = f(xgrid, ygrid)
|
1265
|
+
>>> rbs = RectBivariateSpline(xarr, yarr, zdata, kx=1, ky=1)
|
1266
|
+
|
1267
|
+
Next we sample the function along a diagonal slice through the coordinate space
|
1268
|
+
on a finer grid using interpolation.
|
1269
|
+
|
1270
|
+
>>> xinterp = np.linspace(-3, 3, 201)
|
1271
|
+
>>> yinterp = np.linspace(3, -3, 201)
|
1272
|
+
>>> zinterp = rbs.ev(xinterp, yinterp)
|
1273
|
+
|
1274
|
+
And check that the interpolation passes through the function evaluations as a
|
1275
|
+
function of the distance from the origin along the slice.
|
1276
|
+
|
1277
|
+
>>> import matplotlib.pyplot as plt
|
1278
|
+
>>> fig = plt.figure()
|
1279
|
+
>>> ax1 = fig.add_subplot(1, 1, 1)
|
1280
|
+
>>> ax1.plot(np.sqrt(xarr**2 + yarr**2), np.diag(zdata), "or")
|
1281
|
+
>>> ax1.plot(np.sqrt(xinterp**2 + yinterp**2), zinterp, "-b")
|
1282
|
+
>>> plt.show()
|
1283
|
+
"""
|
1284
|
+
return self.__call__(xi, yi, dx=dx, dy=dy, grid=False)
|
1285
|
+
|
1286
|
+
def integral(self, xa, xb, ya, yb):
|
1287
|
+
"""
|
1288
|
+
Evaluate the integral of the spline over area [xa,xb] x [ya,yb].
|
1289
|
+
|
1290
|
+
Parameters
|
1291
|
+
----------
|
1292
|
+
xa, xb : float
|
1293
|
+
The end-points of the x integration interval.
|
1294
|
+
ya, yb : float
|
1295
|
+
The end-points of the y integration interval.
|
1296
|
+
|
1297
|
+
Returns
|
1298
|
+
-------
|
1299
|
+
integ : float
|
1300
|
+
The value of the resulting integral.
|
1301
|
+
|
1302
|
+
"""
|
1303
|
+
tx, ty, c = self.tck[:3]
|
1304
|
+
kx, ky = self.degrees
|
1305
|
+
with FITPACK_LOCK:
|
1306
|
+
return dfitpack.dblint(tx, ty, c, kx, ky, xa, xb, ya, yb)
|
1307
|
+
|
1308
|
+
@staticmethod
|
1309
|
+
def _validate_input(x, y, z, w, kx, ky, eps):
|
1310
|
+
x, y, z = np.asarray(x), np.asarray(y), np.asarray(z)
|
1311
|
+
if not x.size == y.size == z.size:
|
1312
|
+
raise ValueError('x, y, and z should have a same length')
|
1313
|
+
|
1314
|
+
if w is not None:
|
1315
|
+
w = np.asarray(w)
|
1316
|
+
if x.size != w.size:
|
1317
|
+
raise ValueError('x, y, z, and w should have a same length')
|
1318
|
+
elif not np.all(w >= 0.0):
|
1319
|
+
raise ValueError('w should be positive')
|
1320
|
+
if (eps is not None) and (not 0.0 < eps < 1.0):
|
1321
|
+
raise ValueError('eps should be between (0, 1)')
|
1322
|
+
if not x.size >= (kx + 1) * (ky + 1):
|
1323
|
+
raise ValueError('The length of x, y and z should be at least'
|
1324
|
+
' (kx+1) * (ky+1)')
|
1325
|
+
return x, y, z, w
|
1326
|
+
|
1327
|
+
|
1328
|
+
class _DerivedBivariateSpline(_BivariateSplineBase):
|
1329
|
+
"""Bivariate spline constructed from the coefficients and knots of another
|
1330
|
+
spline.
|
1331
|
+
|
1332
|
+
Notes
|
1333
|
+
-----
|
1334
|
+
The class is not meant to be instantiated directly from the data to be
|
1335
|
+
interpolated or smoothed. As a result, its ``fp`` attribute and
|
1336
|
+
``get_residual`` method are inherited but overridden; ``AttributeError`` is
|
1337
|
+
raised when they are accessed.
|
1338
|
+
|
1339
|
+
The other inherited attributes can be used as usual.
|
1340
|
+
"""
|
1341
|
+
_invalid_why = ("is unavailable, because _DerivedBivariateSpline"
|
1342
|
+
" instance is not constructed from data that are to be"
|
1343
|
+
" interpolated or smoothed, but derived from the"
|
1344
|
+
" underlying knots and coefficients of another spline"
|
1345
|
+
" object")
|
1346
|
+
|
1347
|
+
@property
|
1348
|
+
def fp(self):
|
1349
|
+
raise AttributeError(f"attribute \"fp\" {self._invalid_why}")
|
1350
|
+
|
1351
|
+
def get_residual(self):
|
1352
|
+
raise AttributeError(f"method \"get_residual\" {self._invalid_why}")
|
1353
|
+
|
1354
|
+
|
1355
|
+
class SmoothBivariateSpline(BivariateSpline):
|
1356
|
+
"""
|
1357
|
+
Smooth bivariate spline approximation.
|
1358
|
+
|
1359
|
+
Parameters
|
1360
|
+
----------
|
1361
|
+
x, y, z : array_like
|
1362
|
+
1-D sequences of data points (order is not important).
|
1363
|
+
w : array_like, optional
|
1364
|
+
Positive 1-D sequence of weights, of same length as `x`, `y` and `z`.
|
1365
|
+
bbox : array_like, optional
|
1366
|
+
Sequence of length 4 specifying the boundary of the rectangular
|
1367
|
+
approximation domain. By default,
|
1368
|
+
``bbox=[min(x), max(x), min(y), max(y)]``.
|
1369
|
+
kx, ky : ints, optional
|
1370
|
+
Degrees of the bivariate spline. Default is 3.
|
1371
|
+
s : float, optional
|
1372
|
+
Positive smoothing factor defined for estimation condition:
|
1373
|
+
``sum((w[i]*(z[i]-s(x[i], y[i])))**2, axis=0) <= s``
|
1374
|
+
Default ``s=len(w)`` which should be a good value if ``1/w[i]`` is an
|
1375
|
+
estimate of the standard deviation of ``z[i]``.
|
1376
|
+
eps : float, optional
|
1377
|
+
A threshold for determining the effective rank of an over-determined
|
1378
|
+
linear system of equations. `eps` should have a value within the open
|
1379
|
+
interval ``(0, 1)``, the default is 1e-16.
|
1380
|
+
|
1381
|
+
See Also
|
1382
|
+
--------
|
1383
|
+
BivariateSpline :
|
1384
|
+
a base class for bivariate splines.
|
1385
|
+
UnivariateSpline :
|
1386
|
+
a smooth univariate spline to fit a given set of data points.
|
1387
|
+
LSQBivariateSpline :
|
1388
|
+
a bivariate spline using weighted least-squares fitting
|
1389
|
+
RectSphereBivariateSpline :
|
1390
|
+
a bivariate spline over a rectangular mesh on a sphere
|
1391
|
+
SmoothSphereBivariateSpline :
|
1392
|
+
a smoothing bivariate spline in spherical coordinates
|
1393
|
+
LSQSphereBivariateSpline :
|
1394
|
+
a bivariate spline in spherical coordinates using weighted
|
1395
|
+
least-squares fitting
|
1396
|
+
RectBivariateSpline :
|
1397
|
+
a bivariate spline over a rectangular mesh
|
1398
|
+
bisplrep :
|
1399
|
+
a function to find a bivariate B-spline representation of a surface
|
1400
|
+
bisplev :
|
1401
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1402
|
+
|
1403
|
+
Notes
|
1404
|
+
-----
|
1405
|
+
The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``.
|
1406
|
+
|
1407
|
+
If the input data is such that input dimensions have incommensurate
|
1408
|
+
units and differ by many orders of magnitude, the interpolant may have
|
1409
|
+
numerical artifacts. Consider rescaling the data before interpolating.
|
1410
|
+
|
1411
|
+
This routine constructs spline knot vectors automatically via the FITPACK
|
1412
|
+
algorithm. The spline knots may be placed away from the data points. For
|
1413
|
+
some data sets, this routine may fail to construct an interpolating spline,
|
1414
|
+
even if one is requested via ``s=0`` parameter. In such situations, it is
|
1415
|
+
recommended to use `bisplrep` / `bisplev` directly instead of this routine
|
1416
|
+
and, if needed, increase the values of ``nxest`` and ``nyest`` parameters
|
1417
|
+
of `bisplrep`.
|
1418
|
+
|
1419
|
+
For linear interpolation, prefer `LinearNDInterpolator`.
|
1420
|
+
See ``https://gist.github.com/ev-br/8544371b40f414b7eaf3fe6217209bff``
|
1421
|
+
for discussion.
|
1422
|
+
|
1423
|
+
"""
|
1424
|
+
|
1425
|
+
def __init__(self, x, y, z, w=None, bbox=[None] * 4, kx=3, ky=3, s=None,
|
1426
|
+
eps=1e-16):
|
1427
|
+
|
1428
|
+
x, y, z, w = self._validate_input(x, y, z, w, kx, ky, eps)
|
1429
|
+
bbox = ravel(bbox)
|
1430
|
+
if not bbox.shape == (4,):
|
1431
|
+
raise ValueError('bbox shape should be (4,)')
|
1432
|
+
if s is not None and not s >= 0.0:
|
1433
|
+
raise ValueError("s should be s >= 0.0")
|
1434
|
+
|
1435
|
+
xb, xe, yb, ye = bbox
|
1436
|
+
with FITPACK_LOCK:
|
1437
|
+
nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
|
1438
|
+
x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps, lwrk2=1)
|
1439
|
+
if ier > 10: # lwrk2 was to small, re-run
|
1440
|
+
nx, tx, ny, ty, c, fp, wrk1, ier = dfitpack.surfit_smth(
|
1441
|
+
x, y, z, w, xb, xe, yb, ye, kx, ky, s=s, eps=eps,
|
1442
|
+
lwrk2=ier)
|
1443
|
+
if ier in [0, -1, -2]: # normal return
|
1444
|
+
pass
|
1445
|
+
else:
|
1446
|
+
message = _surfit_messages.get(ier, f'ier={ier}')
|
1447
|
+
warnings.warn(message, stacklevel=2)
|
1448
|
+
|
1449
|
+
self.fp = fp
|
1450
|
+
self.tck = tx[:nx], ty[:ny], c[:(nx-kx-1)*(ny-ky-1)]
|
1451
|
+
self.degrees = kx, ky
|
1452
|
+
|
1453
|
+
|
1454
|
+
class LSQBivariateSpline(BivariateSpline):
|
1455
|
+
"""
|
1456
|
+
Weighted least-squares bivariate spline approximation.
|
1457
|
+
|
1458
|
+
Parameters
|
1459
|
+
----------
|
1460
|
+
x, y, z : array_like
|
1461
|
+
1-D sequences of data points (order is not important).
|
1462
|
+
tx, ty : array_like
|
1463
|
+
Strictly ordered 1-D sequences of knots coordinates.
|
1464
|
+
w : array_like, optional
|
1465
|
+
Positive 1-D array of weights, of the same length as `x`, `y` and `z`.
|
1466
|
+
bbox : (4,) array_like, optional
|
1467
|
+
Sequence of length 4 specifying the boundary of the rectangular
|
1468
|
+
approximation domain. By default,
|
1469
|
+
``bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)]``.
|
1470
|
+
kx, ky : ints, optional
|
1471
|
+
Degrees of the bivariate spline. Default is 3.
|
1472
|
+
eps : float, optional
|
1473
|
+
A threshold for determining the effective rank of an over-determined
|
1474
|
+
linear system of equations. `eps` should have a value within the open
|
1475
|
+
interval ``(0, 1)``, the default is 1e-16.
|
1476
|
+
|
1477
|
+
See Also
|
1478
|
+
--------
|
1479
|
+
BivariateSpline :
|
1480
|
+
a base class for bivariate splines.
|
1481
|
+
UnivariateSpline :
|
1482
|
+
a smooth univariate spline to fit a given set of data points.
|
1483
|
+
SmoothBivariateSpline :
|
1484
|
+
a smoothing bivariate spline through the given points
|
1485
|
+
RectSphereBivariateSpline :
|
1486
|
+
a bivariate spline over a rectangular mesh on a sphere
|
1487
|
+
SmoothSphereBivariateSpline :
|
1488
|
+
a smoothing bivariate spline in spherical coordinates
|
1489
|
+
LSQSphereBivariateSpline :
|
1490
|
+
a bivariate spline in spherical coordinates using weighted
|
1491
|
+
least-squares fitting
|
1492
|
+
RectBivariateSpline :
|
1493
|
+
a bivariate spline over a rectangular mesh.
|
1494
|
+
bisplrep :
|
1495
|
+
a function to find a bivariate B-spline representation of a surface
|
1496
|
+
bisplev :
|
1497
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1498
|
+
|
1499
|
+
Notes
|
1500
|
+
-----
|
1501
|
+
The length of `x`, `y` and `z` should be at least ``(kx+1) * (ky+1)``.
|
1502
|
+
|
1503
|
+
If the input data is such that input dimensions have incommensurate
|
1504
|
+
units and differ by many orders of magnitude, the interpolant may have
|
1505
|
+
numerical artifacts. Consider rescaling the data before interpolating.
|
1506
|
+
|
1507
|
+
"""
|
1508
|
+
|
1509
|
+
def __init__(self, x, y, z, tx, ty, w=None, bbox=[None]*4, kx=3, ky=3,
|
1510
|
+
eps=None):
|
1511
|
+
|
1512
|
+
x, y, z, w = self._validate_input(x, y, z, w, kx, ky, eps)
|
1513
|
+
bbox = ravel(bbox)
|
1514
|
+
if not bbox.shape == (4,):
|
1515
|
+
raise ValueError('bbox shape should be (4,)')
|
1516
|
+
|
1517
|
+
nx = 2*kx+2+len(tx)
|
1518
|
+
ny = 2*ky+2+len(ty)
|
1519
|
+
# The Fortran subroutine "surfit" (called as dfitpack.surfit_lsq)
|
1520
|
+
# requires that the knot arrays passed as input should be "real
|
1521
|
+
# array(s) of dimension nmax" where "nmax" refers to the greater of nx
|
1522
|
+
# and ny. We pad the tx1/ty1 arrays here so that this is satisfied, and
|
1523
|
+
# slice them to the desired sizes upon return.
|
1524
|
+
nmax = max(nx, ny)
|
1525
|
+
tx1 = zeros((nmax,), float)
|
1526
|
+
ty1 = zeros((nmax,), float)
|
1527
|
+
tx1[kx+1:nx-kx-1] = tx
|
1528
|
+
ty1[ky+1:ny-ky-1] = ty
|
1529
|
+
|
1530
|
+
xb, xe, yb, ye = bbox
|
1531
|
+
with FITPACK_LOCK:
|
1532
|
+
tx1, ty1, c, fp, ier = dfitpack.surfit_lsq(x, y, z, nx, tx1, ny, ty1,
|
1533
|
+
w, xb, xe, yb, ye,
|
1534
|
+
kx, ky, eps, lwrk2=1)
|
1535
|
+
if ier > 10:
|
1536
|
+
tx1, ty1, c, fp, ier = dfitpack.surfit_lsq(x, y, z,
|
1537
|
+
nx, tx1, ny, ty1, w,
|
1538
|
+
xb, xe, yb, ye,
|
1539
|
+
kx, ky, eps, lwrk2=ier)
|
1540
|
+
if ier in [0, -1, -2]: # normal return
|
1541
|
+
pass
|
1542
|
+
else:
|
1543
|
+
if ier < -2:
|
1544
|
+
deficiency = (nx-kx-1)*(ny-ky-1)+ier
|
1545
|
+
message = _surfit_messages.get(-3) % (deficiency)
|
1546
|
+
else:
|
1547
|
+
message = _surfit_messages.get(ier, f'ier={ier}')
|
1548
|
+
warnings.warn(message, stacklevel=2)
|
1549
|
+
self.fp = fp
|
1550
|
+
self.tck = tx1[:nx], ty1[:ny], c
|
1551
|
+
self.degrees = kx, ky
|
1552
|
+
|
1553
|
+
|
1554
|
+
class RectBivariateSpline(BivariateSpline):
|
1555
|
+
"""
|
1556
|
+
Bivariate spline approximation over a rectangular mesh.
|
1557
|
+
|
1558
|
+
Can be used for both smoothing and interpolating data.
|
1559
|
+
|
1560
|
+
Parameters
|
1561
|
+
----------
|
1562
|
+
x,y : array_like
|
1563
|
+
1-D arrays of coordinates in strictly ascending order.
|
1564
|
+
Evaluated points outside the data range will be extrapolated.
|
1565
|
+
z : array_like
|
1566
|
+
2-D array of data with shape (x.size,y.size).
|
1567
|
+
bbox : array_like, optional
|
1568
|
+
Sequence of length 4 specifying the boundary of the rectangular
|
1569
|
+
approximation domain, which means the start and end spline knots of
|
1570
|
+
each dimension are set by these values. By default,
|
1571
|
+
``bbox=[min(x), max(x), min(y), max(y)]``.
|
1572
|
+
kx, ky : ints, optional
|
1573
|
+
Degrees of the bivariate spline. Default is 3.
|
1574
|
+
s : float, optional
|
1575
|
+
Positive smoothing factor defined for estimation condition:
|
1576
|
+
``sum((z[i]-f(x[i], y[i]))**2, axis=0) <= s`` where f is a spline
|
1577
|
+
function. Default is ``s=0``, which is for interpolation.
|
1578
|
+
maxit : int, optional
|
1579
|
+
The maximal number of iterations maxit allowed for finding a
|
1580
|
+
smoothing spline with fp=s. Default is ``maxit=20``.
|
1581
|
+
|
1582
|
+
See Also
|
1583
|
+
--------
|
1584
|
+
BivariateSpline :
|
1585
|
+
a base class for bivariate splines.
|
1586
|
+
UnivariateSpline :
|
1587
|
+
a smooth univariate spline to fit a given set of data points.
|
1588
|
+
SmoothBivariateSpline :
|
1589
|
+
a smoothing bivariate spline through the given points
|
1590
|
+
LSQBivariateSpline :
|
1591
|
+
a bivariate spline using weighted least-squares fitting
|
1592
|
+
RectSphereBivariateSpline :
|
1593
|
+
a bivariate spline over a rectangular mesh on a sphere
|
1594
|
+
SmoothSphereBivariateSpline :
|
1595
|
+
a smoothing bivariate spline in spherical coordinates
|
1596
|
+
LSQSphereBivariateSpline :
|
1597
|
+
a bivariate spline in spherical coordinates using weighted
|
1598
|
+
least-squares fitting
|
1599
|
+
bisplrep :
|
1600
|
+
a function to find a bivariate B-spline representation of a surface
|
1601
|
+
bisplev :
|
1602
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1603
|
+
|
1604
|
+
Notes
|
1605
|
+
-----
|
1606
|
+
|
1607
|
+
If the input data is such that input dimensions have incommensurate
|
1608
|
+
units and differ by many orders of magnitude, the interpolant may have
|
1609
|
+
numerical artifacts. Consider rescaling the data before interpolating.
|
1610
|
+
|
1611
|
+
"""
|
1612
|
+
|
1613
|
+
def __init__(self, x, y, z, bbox=[None] * 4, kx=3, ky=3, s=0, maxit=20):
|
1614
|
+
x, y, bbox = ravel(x), ravel(y), ravel(bbox)
|
1615
|
+
z = np.asarray(z)
|
1616
|
+
if not np.all(diff(x) > 0.0):
|
1617
|
+
raise ValueError('x must be strictly increasing')
|
1618
|
+
if not np.all(diff(y) > 0.0):
|
1619
|
+
raise ValueError('y must be strictly increasing')
|
1620
|
+
if not x.size == z.shape[0]:
|
1621
|
+
raise ValueError('x dimension of z must have same number of '
|
1622
|
+
'elements as x')
|
1623
|
+
if not y.size == z.shape[1]:
|
1624
|
+
raise ValueError('y dimension of z must have same number of '
|
1625
|
+
'elements as y')
|
1626
|
+
if not bbox.shape == (4,):
|
1627
|
+
raise ValueError('bbox shape should be (4,)')
|
1628
|
+
if s is not None and not s >= 0.0:
|
1629
|
+
raise ValueError("s should be s >= 0.0")
|
1630
|
+
|
1631
|
+
z = ravel(z)
|
1632
|
+
xb, xe, yb, ye = bbox
|
1633
|
+
with FITPACK_LOCK:
|
1634
|
+
nx, tx, ny, ty, c, fp, ier = dfitpack.regrid_smth(x, y, z, xb, xe, yb,
|
1635
|
+
ye, kx, ky, s, maxit)
|
1636
|
+
|
1637
|
+
if ier not in [0, -1, -2]:
|
1638
|
+
msg = _surfit_messages.get(ier, f'ier={ier}')
|
1639
|
+
raise ValueError(msg)
|
1640
|
+
|
1641
|
+
self.fp = fp
|
1642
|
+
self.tck = tx[:nx], ty[:ny], c[:(nx - kx - 1) * (ny - ky - 1)]
|
1643
|
+
self.degrees = kx, ky
|
1644
|
+
|
1645
|
+
|
1646
|
+
_spherefit_messages = _surfit_messages.copy()
|
1647
|
+
_spherefit_messages[10] = """
|
1648
|
+
ERROR. On entry, the input data are controlled on validity. The following
|
1649
|
+
restrictions must be satisfied:
|
1650
|
+
-1<=iopt<=1, m>=2, ntest>=8 ,npest >=8, 0<eps<1,
|
1651
|
+
0<=teta(i)<=pi, 0<=phi(i)<=2*pi, w(i)>0, i=1,...,m
|
1652
|
+
lwrk1 >= 185+52*v+10*u+14*u*v+8*(u-1)*v**2+8*m
|
1653
|
+
kwrk >= m+(ntest-7)*(npest-7)
|
1654
|
+
if iopt=-1: 8<=nt<=ntest , 9<=np<=npest
|
1655
|
+
0<tt(5)<tt(6)<...<tt(nt-4)<pi
|
1656
|
+
0<tp(5)<tp(6)<...<tp(np-4)<2*pi
|
1657
|
+
if iopt>=0: s>=0
|
1658
|
+
if one of these conditions is found to be violated,control
|
1659
|
+
is immediately repassed to the calling program. in that
|
1660
|
+
case there is no approximation returned."""
|
1661
|
+
_spherefit_messages[-3] = """
|
1662
|
+
WARNING. The coefficients of the spline returned have been computed as the
|
1663
|
+
minimal norm least-squares solution of a (numerically) rank
|
1664
|
+
deficient system (deficiency=%i, rank=%i). Especially if the rank
|
1665
|
+
deficiency, which is computed by 6+(nt-8)*(np-7)+ier, is large,
|
1666
|
+
the results may be inaccurate. They could also seriously depend on
|
1667
|
+
the value of eps."""
|
1668
|
+
|
1669
|
+
|
1670
|
+
class SphereBivariateSpline(_BivariateSplineBase):
|
1671
|
+
"""
|
1672
|
+
Bivariate spline s(x,y) of degrees 3 on a sphere, calculated from a
|
1673
|
+
given set of data points (theta,phi,r).
|
1674
|
+
|
1675
|
+
.. versionadded:: 0.11.0
|
1676
|
+
|
1677
|
+
See Also
|
1678
|
+
--------
|
1679
|
+
bisplrep :
|
1680
|
+
a function to find a bivariate B-spline representation of a surface
|
1681
|
+
bisplev :
|
1682
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1683
|
+
UnivariateSpline :
|
1684
|
+
a smooth univariate spline to fit a given set of data points.
|
1685
|
+
SmoothBivariateSpline :
|
1686
|
+
a smoothing bivariate spline through the given points
|
1687
|
+
LSQUnivariateSpline :
|
1688
|
+
a univariate spline using weighted least-squares fitting
|
1689
|
+
"""
|
1690
|
+
|
1691
|
+
def __call__(self, theta, phi, dtheta=0, dphi=0, grid=True):
|
1692
|
+
"""
|
1693
|
+
Evaluate the spline or its derivatives at given positions.
|
1694
|
+
|
1695
|
+
Parameters
|
1696
|
+
----------
|
1697
|
+
theta, phi : array_like
|
1698
|
+
Input coordinates.
|
1699
|
+
|
1700
|
+
If `grid` is False, evaluate the spline at points
|
1701
|
+
``(theta[i], phi[i]), i=0, ..., len(x)-1``. Standard
|
1702
|
+
Numpy broadcasting is obeyed.
|
1703
|
+
|
1704
|
+
If `grid` is True: evaluate spline at the grid points
|
1705
|
+
defined by the coordinate arrays theta, phi. The arrays
|
1706
|
+
must be sorted to increasing order.
|
1707
|
+
The ordering of axes is consistent with
|
1708
|
+
``np.meshgrid(..., indexing="ij")`` and inconsistent with the
|
1709
|
+
default ordering ``np.meshgrid(..., indexing="xy")``.
|
1710
|
+
dtheta : int, optional
|
1711
|
+
Order of theta-derivative
|
1712
|
+
|
1713
|
+
.. versionadded:: 0.14.0
|
1714
|
+
dphi : int
|
1715
|
+
Order of phi-derivative
|
1716
|
+
|
1717
|
+
.. versionadded:: 0.14.0
|
1718
|
+
grid : bool
|
1719
|
+
Whether to evaluate the results on a grid spanned by the
|
1720
|
+
input arrays, or at points specified by the input arrays.
|
1721
|
+
|
1722
|
+
.. versionadded:: 0.14.0
|
1723
|
+
|
1724
|
+
Examples
|
1725
|
+
--------
|
1726
|
+
|
1727
|
+
Suppose that we want to use splines to interpolate a bivariate function on a
|
1728
|
+
sphere. The value of the function is known on a grid of longitudes and
|
1729
|
+
colatitudes.
|
1730
|
+
|
1731
|
+
>>> import numpy as np
|
1732
|
+
>>> from scipy.interpolate import RectSphereBivariateSpline
|
1733
|
+
>>> def f(theta, phi):
|
1734
|
+
... return np.sin(theta) * np.cos(phi)
|
1735
|
+
|
1736
|
+
We evaluate the function on the grid. Note that the default indexing="xy"
|
1737
|
+
of meshgrid would result in an unexpected (transposed) result after
|
1738
|
+
interpolation.
|
1739
|
+
|
1740
|
+
>>> thetaarr = np.linspace(0, np.pi, 22)[1:-1]
|
1741
|
+
>>> phiarr = np.linspace(0, 2 * np.pi, 21)[:-1]
|
1742
|
+
>>> thetagrid, phigrid = np.meshgrid(thetaarr, phiarr, indexing="ij")
|
1743
|
+
>>> zdata = f(thetagrid, phigrid)
|
1744
|
+
|
1745
|
+
We next set up the interpolator and use it to evaluate the function
|
1746
|
+
on a finer grid.
|
1747
|
+
|
1748
|
+
>>> rsbs = RectSphereBivariateSpline(thetaarr, phiarr, zdata)
|
1749
|
+
>>> thetaarr_fine = np.linspace(0, np.pi, 200)
|
1750
|
+
>>> phiarr_fine = np.linspace(0, 2 * np.pi, 200)
|
1751
|
+
>>> zdata_fine = rsbs(thetaarr_fine, phiarr_fine)
|
1752
|
+
|
1753
|
+
Finally we plot the coarsly-sampled input data alongside the
|
1754
|
+
finely-sampled interpolated data to check that they agree.
|
1755
|
+
|
1756
|
+
>>> import matplotlib.pyplot as plt
|
1757
|
+
>>> fig = plt.figure()
|
1758
|
+
>>> ax1 = fig.add_subplot(1, 2, 1)
|
1759
|
+
>>> ax2 = fig.add_subplot(1, 2, 2)
|
1760
|
+
>>> ax1.imshow(zdata)
|
1761
|
+
>>> ax2.imshow(zdata_fine)
|
1762
|
+
>>> plt.show()
|
1763
|
+
"""
|
1764
|
+
theta = np.asarray(theta)
|
1765
|
+
phi = np.asarray(phi)
|
1766
|
+
|
1767
|
+
if theta.size > 0 and (theta.min() < 0. or theta.max() > np.pi):
|
1768
|
+
raise ValueError("requested theta out of bounds.")
|
1769
|
+
|
1770
|
+
return _BivariateSplineBase.__call__(self, theta, phi,
|
1771
|
+
dx=dtheta, dy=dphi, grid=grid)
|
1772
|
+
|
1773
|
+
def ev(self, theta, phi, dtheta=0, dphi=0):
|
1774
|
+
"""
|
1775
|
+
Evaluate the spline at points
|
1776
|
+
|
1777
|
+
Returns the interpolated value at ``(theta[i], phi[i]),
|
1778
|
+
i=0,...,len(theta)-1``.
|
1779
|
+
|
1780
|
+
Parameters
|
1781
|
+
----------
|
1782
|
+
theta, phi : array_like
|
1783
|
+
Input coordinates. Standard Numpy broadcasting is obeyed.
|
1784
|
+
The ordering of axes is consistent with
|
1785
|
+
np.meshgrid(..., indexing="ij") and inconsistent with the
|
1786
|
+
default ordering np.meshgrid(..., indexing="xy").
|
1787
|
+
dtheta : int, optional
|
1788
|
+
Order of theta-derivative
|
1789
|
+
|
1790
|
+
.. versionadded:: 0.14.0
|
1791
|
+
dphi : int, optional
|
1792
|
+
Order of phi-derivative
|
1793
|
+
|
1794
|
+
.. versionadded:: 0.14.0
|
1795
|
+
|
1796
|
+
Examples
|
1797
|
+
--------
|
1798
|
+
Suppose that we want to use splines to interpolate a bivariate function on a
|
1799
|
+
sphere. The value of the function is known on a grid of longitudes and
|
1800
|
+
colatitudes.
|
1801
|
+
|
1802
|
+
>>> import numpy as np
|
1803
|
+
>>> from scipy.interpolate import RectSphereBivariateSpline
|
1804
|
+
>>> def f(theta, phi):
|
1805
|
+
... return np.sin(theta) * np.cos(phi)
|
1806
|
+
|
1807
|
+
We evaluate the function on the grid. Note that the default indexing="xy"
|
1808
|
+
of meshgrid would result in an unexpected (transposed) result after
|
1809
|
+
interpolation.
|
1810
|
+
|
1811
|
+
>>> thetaarr = np.linspace(0, np.pi, 22)[1:-1]
|
1812
|
+
>>> phiarr = np.linspace(0, 2 * np.pi, 21)[:-1]
|
1813
|
+
>>> thetagrid, phigrid = np.meshgrid(thetaarr, phiarr, indexing="ij")
|
1814
|
+
>>> zdata = f(thetagrid, phigrid)
|
1815
|
+
|
1816
|
+
We next set up the interpolator and use it to evaluate the function
|
1817
|
+
at points not on the original grid.
|
1818
|
+
|
1819
|
+
>>> rsbs = RectSphereBivariateSpline(thetaarr, phiarr, zdata)
|
1820
|
+
>>> thetainterp = np.linspace(thetaarr[0], thetaarr[-1], 200)
|
1821
|
+
>>> phiinterp = np.linspace(phiarr[0], phiarr[-1], 200)
|
1822
|
+
>>> zinterp = rsbs.ev(thetainterp, phiinterp)
|
1823
|
+
|
1824
|
+
Finally we plot the original data for a diagonal slice through the
|
1825
|
+
initial grid, and the spline approximation along the same slice.
|
1826
|
+
|
1827
|
+
>>> import matplotlib.pyplot as plt
|
1828
|
+
>>> fig = plt.figure()
|
1829
|
+
>>> ax1 = fig.add_subplot(1, 1, 1)
|
1830
|
+
>>> ax1.plot(np.sin(thetaarr) * np.sin(phiarr), np.diag(zdata), "or")
|
1831
|
+
>>> ax1.plot(np.sin(thetainterp) * np.sin(phiinterp), zinterp, "-b")
|
1832
|
+
>>> plt.show()
|
1833
|
+
"""
|
1834
|
+
return self.__call__(theta, phi, dtheta=dtheta, dphi=dphi, grid=False)
|
1835
|
+
|
1836
|
+
|
1837
|
+
class SmoothSphereBivariateSpline(SphereBivariateSpline):
|
1838
|
+
"""
|
1839
|
+
Smooth bivariate spline approximation in spherical coordinates.
|
1840
|
+
|
1841
|
+
.. versionadded:: 0.11.0
|
1842
|
+
|
1843
|
+
Parameters
|
1844
|
+
----------
|
1845
|
+
theta, phi, r : array_like
|
1846
|
+
1-D sequences of data points (order is not important). Coordinates
|
1847
|
+
must be given in radians. Theta must lie within the interval
|
1848
|
+
``[0, pi]``, and phi must lie within the interval ``[0, 2pi]``.
|
1849
|
+
w : array_like, optional
|
1850
|
+
Positive 1-D sequence of weights.
|
1851
|
+
s : float, optional
|
1852
|
+
Positive smoothing factor defined for estimation condition:
|
1853
|
+
``sum((w(i)*(r(i) - s(theta(i), phi(i))))**2, axis=0) <= s``
|
1854
|
+
Default ``s=len(w)`` which should be a good value if ``1/w[i]`` is an
|
1855
|
+
estimate of the standard deviation of ``r[i]``.
|
1856
|
+
eps : float, optional
|
1857
|
+
A threshold for determining the effective rank of an over-determined
|
1858
|
+
linear system of equations. `eps` should have a value within the open
|
1859
|
+
interval ``(0, 1)``, the default is 1e-16.
|
1860
|
+
|
1861
|
+
See Also
|
1862
|
+
--------
|
1863
|
+
BivariateSpline :
|
1864
|
+
a base class for bivariate splines.
|
1865
|
+
UnivariateSpline :
|
1866
|
+
a smooth univariate spline to fit a given set of data points.
|
1867
|
+
SmoothBivariateSpline :
|
1868
|
+
a smoothing bivariate spline through the given points
|
1869
|
+
LSQBivariateSpline :
|
1870
|
+
a bivariate spline using weighted least-squares fitting
|
1871
|
+
RectSphereBivariateSpline :
|
1872
|
+
a bivariate spline over a rectangular mesh on a sphere
|
1873
|
+
LSQSphereBivariateSpline :
|
1874
|
+
a bivariate spline in spherical coordinates using weighted
|
1875
|
+
least-squares fitting
|
1876
|
+
RectBivariateSpline :
|
1877
|
+
a bivariate spline over a rectangular mesh.
|
1878
|
+
bisplrep :
|
1879
|
+
a function to find a bivariate B-spline representation of a surface
|
1880
|
+
bisplev :
|
1881
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
1882
|
+
|
1883
|
+
Notes
|
1884
|
+
-----
|
1885
|
+
For more information, see the FITPACK_ site about this function.
|
1886
|
+
|
1887
|
+
.. _FITPACK: http://www.netlib.org/dierckx/sphere.f
|
1888
|
+
|
1889
|
+
Examples
|
1890
|
+
--------
|
1891
|
+
Suppose we have global data on a coarse grid (the input data does not
|
1892
|
+
have to be on a grid):
|
1893
|
+
|
1894
|
+
>>> import numpy as np
|
1895
|
+
>>> theta = np.linspace(0., np.pi, 7)
|
1896
|
+
>>> phi = np.linspace(0., 2*np.pi, 9)
|
1897
|
+
>>> data = np.empty((theta.shape[0], phi.shape[0]))
|
1898
|
+
>>> data[:,0], data[0,:], data[-1,:] = 0., 0., 0.
|
1899
|
+
>>> data[1:-1,1], data[1:-1,-1] = 1., 1.
|
1900
|
+
>>> data[1,1:-1], data[-2,1:-1] = 1., 1.
|
1901
|
+
>>> data[2:-2,2], data[2:-2,-2] = 2., 2.
|
1902
|
+
>>> data[2,2:-2], data[-3,2:-2] = 2., 2.
|
1903
|
+
>>> data[3,3:-2] = 3.
|
1904
|
+
>>> data = np.roll(data, 4, 1)
|
1905
|
+
|
1906
|
+
We need to set up the interpolator object
|
1907
|
+
|
1908
|
+
>>> lats, lons = np.meshgrid(theta, phi)
|
1909
|
+
>>> from scipy.interpolate import SmoothSphereBivariateSpline
|
1910
|
+
>>> lut = SmoothSphereBivariateSpline(lats.ravel(), lons.ravel(),
|
1911
|
+
... data.T.ravel(), s=3.5)
|
1912
|
+
|
1913
|
+
As a first test, we'll see what the algorithm returns when run on the
|
1914
|
+
input coordinates
|
1915
|
+
|
1916
|
+
>>> data_orig = lut(theta, phi)
|
1917
|
+
|
1918
|
+
Finally we interpolate the data to a finer grid
|
1919
|
+
|
1920
|
+
>>> fine_lats = np.linspace(0., np.pi, 70)
|
1921
|
+
>>> fine_lons = np.linspace(0., 2 * np.pi, 90)
|
1922
|
+
|
1923
|
+
>>> data_smth = lut(fine_lats, fine_lons)
|
1924
|
+
|
1925
|
+
>>> import matplotlib.pyplot as plt
|
1926
|
+
>>> fig = plt.figure()
|
1927
|
+
>>> ax1 = fig.add_subplot(131)
|
1928
|
+
>>> ax1.imshow(data, interpolation='nearest')
|
1929
|
+
>>> ax2 = fig.add_subplot(132)
|
1930
|
+
>>> ax2.imshow(data_orig, interpolation='nearest')
|
1931
|
+
>>> ax3 = fig.add_subplot(133)
|
1932
|
+
>>> ax3.imshow(data_smth, interpolation='nearest')
|
1933
|
+
>>> plt.show()
|
1934
|
+
|
1935
|
+
"""
|
1936
|
+
|
1937
|
+
def __init__(self, theta, phi, r, w=None, s=0., eps=1E-16):
|
1938
|
+
|
1939
|
+
theta, phi, r = np.asarray(theta), np.asarray(phi), np.asarray(r)
|
1940
|
+
|
1941
|
+
# input validation
|
1942
|
+
if not ((0.0 <= theta).all() and (theta <= np.pi).all()):
|
1943
|
+
raise ValueError('theta should be between [0, pi]')
|
1944
|
+
if not ((0.0 <= phi).all() and (phi <= 2.0 * np.pi).all()):
|
1945
|
+
raise ValueError('phi should be between [0, 2pi]')
|
1946
|
+
if w is not None:
|
1947
|
+
w = np.asarray(w)
|
1948
|
+
if not (w >= 0.0).all():
|
1949
|
+
raise ValueError('w should be positive')
|
1950
|
+
if not s >= 0.0:
|
1951
|
+
raise ValueError('s should be positive')
|
1952
|
+
if not 0.0 < eps < 1.0:
|
1953
|
+
raise ValueError('eps should be between (0, 1)')
|
1954
|
+
|
1955
|
+
with FITPACK_LOCK:
|
1956
|
+
nt_, tt_, np_, tp_, c, fp, ier = dfitpack.spherfit_smth(theta, phi,
|
1957
|
+
r, w=w, s=s,
|
1958
|
+
eps=eps)
|
1959
|
+
if ier not in [0, -1, -2]:
|
1960
|
+
message = _spherefit_messages.get(ier, f'ier={ier}')
|
1961
|
+
raise ValueError(message)
|
1962
|
+
|
1963
|
+
self.fp = fp
|
1964
|
+
self.tck = tt_[:nt_], tp_[:np_], c[:(nt_ - 4) * (np_ - 4)]
|
1965
|
+
self.degrees = (3, 3)
|
1966
|
+
|
1967
|
+
def __call__(self, theta, phi, dtheta=0, dphi=0, grid=True):
|
1968
|
+
|
1969
|
+
theta = np.asarray(theta)
|
1970
|
+
phi = np.asarray(phi)
|
1971
|
+
|
1972
|
+
if phi.size > 0 and (phi.min() < 0. or phi.max() > 2. * np.pi):
|
1973
|
+
raise ValueError("requested phi out of bounds.")
|
1974
|
+
|
1975
|
+
return SphereBivariateSpline.__call__(self, theta, phi, dtheta=dtheta,
|
1976
|
+
dphi=dphi, grid=grid)
|
1977
|
+
|
1978
|
+
|
1979
|
+
class LSQSphereBivariateSpline(SphereBivariateSpline):
|
1980
|
+
"""
|
1981
|
+
Weighted least-squares bivariate spline approximation in spherical
|
1982
|
+
coordinates.
|
1983
|
+
|
1984
|
+
Determines a smoothing bicubic spline according to a given
|
1985
|
+
set of knots in the `theta` and `phi` directions.
|
1986
|
+
|
1987
|
+
.. versionadded:: 0.11.0
|
1988
|
+
|
1989
|
+
Parameters
|
1990
|
+
----------
|
1991
|
+
theta, phi, r : array_like
|
1992
|
+
1-D sequences of data points (order is not important). Coordinates
|
1993
|
+
must be given in radians. Theta must lie within the interval
|
1994
|
+
``[0, pi]``, and phi must lie within the interval ``[0, 2pi]``.
|
1995
|
+
tt, tp : array_like
|
1996
|
+
Strictly ordered 1-D sequences of knots coordinates.
|
1997
|
+
Coordinates must satisfy ``0 < tt[i] < pi``, ``0 < tp[i] < 2*pi``.
|
1998
|
+
w : array_like, optional
|
1999
|
+
Positive 1-D sequence of weights, of the same length as `theta`, `phi`
|
2000
|
+
and `r`.
|
2001
|
+
eps : float, optional
|
2002
|
+
A threshold for determining the effective rank of an over-determined
|
2003
|
+
linear system of equations. `eps` should have a value within the
|
2004
|
+
open interval ``(0, 1)``, the default is 1e-16.
|
2005
|
+
|
2006
|
+
See Also
|
2007
|
+
--------
|
2008
|
+
BivariateSpline :
|
2009
|
+
a base class for bivariate splines.
|
2010
|
+
UnivariateSpline :
|
2011
|
+
a smooth univariate spline to fit a given set of data points.
|
2012
|
+
SmoothBivariateSpline :
|
2013
|
+
a smoothing bivariate spline through the given points
|
2014
|
+
LSQBivariateSpline :
|
2015
|
+
a bivariate spline using weighted least-squares fitting
|
2016
|
+
RectSphereBivariateSpline :
|
2017
|
+
a bivariate spline over a rectangular mesh on a sphere
|
2018
|
+
SmoothSphereBivariateSpline :
|
2019
|
+
a smoothing bivariate spline in spherical coordinates
|
2020
|
+
RectBivariateSpline :
|
2021
|
+
a bivariate spline over a rectangular mesh.
|
2022
|
+
bisplrep :
|
2023
|
+
a function to find a bivariate B-spline representation of a surface
|
2024
|
+
bisplev :
|
2025
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
2026
|
+
|
2027
|
+
Notes
|
2028
|
+
-----
|
2029
|
+
For more information, see the FITPACK_ site about this function.
|
2030
|
+
|
2031
|
+
.. _FITPACK: http://www.netlib.org/dierckx/sphere.f
|
2032
|
+
|
2033
|
+
Examples
|
2034
|
+
--------
|
2035
|
+
Suppose we have global data on a coarse grid (the input data does not
|
2036
|
+
have to be on a grid):
|
2037
|
+
|
2038
|
+
>>> from scipy.interpolate import LSQSphereBivariateSpline
|
2039
|
+
>>> import numpy as np
|
2040
|
+
>>> import matplotlib.pyplot as plt
|
2041
|
+
|
2042
|
+
>>> theta = np.linspace(0, np.pi, num=7)
|
2043
|
+
>>> phi = np.linspace(0, 2*np.pi, num=9)
|
2044
|
+
>>> data = np.empty((theta.shape[0], phi.shape[0]))
|
2045
|
+
>>> data[:,0], data[0,:], data[-1,:] = 0., 0., 0.
|
2046
|
+
>>> data[1:-1,1], data[1:-1,-1] = 1., 1.
|
2047
|
+
>>> data[1,1:-1], data[-2,1:-1] = 1., 1.
|
2048
|
+
>>> data[2:-2,2], data[2:-2,-2] = 2., 2.
|
2049
|
+
>>> data[2,2:-2], data[-3,2:-2] = 2., 2.
|
2050
|
+
>>> data[3,3:-2] = 3.
|
2051
|
+
>>> data = np.roll(data, 4, 1)
|
2052
|
+
|
2053
|
+
We need to set up the interpolator object. Here, we must also specify the
|
2054
|
+
coordinates of the knots to use.
|
2055
|
+
|
2056
|
+
>>> lats, lons = np.meshgrid(theta, phi)
|
2057
|
+
>>> knotst, knotsp = theta.copy(), phi.copy()
|
2058
|
+
>>> knotst[0] += .0001
|
2059
|
+
>>> knotst[-1] -= .0001
|
2060
|
+
>>> knotsp[0] += .0001
|
2061
|
+
>>> knotsp[-1] -= .0001
|
2062
|
+
>>> lut = LSQSphereBivariateSpline(lats.ravel(), lons.ravel(),
|
2063
|
+
... data.T.ravel(), knotst, knotsp)
|
2064
|
+
|
2065
|
+
As a first test, we'll see what the algorithm returns when run on the
|
2066
|
+
input coordinates
|
2067
|
+
|
2068
|
+
>>> data_orig = lut(theta, phi)
|
2069
|
+
|
2070
|
+
Finally we interpolate the data to a finer grid
|
2071
|
+
|
2072
|
+
>>> fine_lats = np.linspace(0., np.pi, 70)
|
2073
|
+
>>> fine_lons = np.linspace(0., 2*np.pi, 90)
|
2074
|
+
>>> data_lsq = lut(fine_lats, fine_lons)
|
2075
|
+
|
2076
|
+
>>> fig = plt.figure()
|
2077
|
+
>>> ax1 = fig.add_subplot(131)
|
2078
|
+
>>> ax1.imshow(data, interpolation='nearest')
|
2079
|
+
>>> ax2 = fig.add_subplot(132)
|
2080
|
+
>>> ax2.imshow(data_orig, interpolation='nearest')
|
2081
|
+
>>> ax3 = fig.add_subplot(133)
|
2082
|
+
>>> ax3.imshow(data_lsq, interpolation='nearest')
|
2083
|
+
>>> plt.show()
|
2084
|
+
|
2085
|
+
"""
|
2086
|
+
|
2087
|
+
def __init__(self, theta, phi, r, tt, tp, w=None, eps=1E-16):
|
2088
|
+
|
2089
|
+
theta, phi, r = np.asarray(theta), np.asarray(phi), np.asarray(r)
|
2090
|
+
tt, tp = np.asarray(tt), np.asarray(tp)
|
2091
|
+
|
2092
|
+
if not ((0.0 <= theta).all() and (theta <= np.pi).all()):
|
2093
|
+
raise ValueError('theta should be between [0, pi]')
|
2094
|
+
if not ((0.0 <= phi).all() and (phi <= 2*np.pi).all()):
|
2095
|
+
raise ValueError('phi should be between [0, 2pi]')
|
2096
|
+
if not ((0.0 < tt).all() and (tt < np.pi).all()):
|
2097
|
+
raise ValueError('tt should be between (0, pi)')
|
2098
|
+
if not ((0.0 < tp).all() and (tp < 2*np.pi).all()):
|
2099
|
+
raise ValueError('tp should be between (0, 2pi)')
|
2100
|
+
if w is not None:
|
2101
|
+
w = np.asarray(w)
|
2102
|
+
if not (w >= 0.0).all():
|
2103
|
+
raise ValueError('w should be positive')
|
2104
|
+
if not 0.0 < eps < 1.0:
|
2105
|
+
raise ValueError('eps should be between (0, 1)')
|
2106
|
+
|
2107
|
+
nt_, np_ = 8 + len(tt), 8 + len(tp)
|
2108
|
+
tt_, tp_ = zeros((nt_,), float), zeros((np_,), float)
|
2109
|
+
tt_[4:-4], tp_[4:-4] = tt, tp
|
2110
|
+
tt_[-4:], tp_[-4:] = np.pi, 2. * np.pi
|
2111
|
+
with FITPACK_LOCK:
|
2112
|
+
tt_, tp_, c, fp, ier = dfitpack.spherfit_lsq(theta, phi, r, tt_, tp_,
|
2113
|
+
w=w, eps=eps)
|
2114
|
+
if ier > 0:
|
2115
|
+
message = _spherefit_messages.get(ier, f'ier={ier}')
|
2116
|
+
raise ValueError(message)
|
2117
|
+
|
2118
|
+
self.fp = fp
|
2119
|
+
self.tck = tt_, tp_, c
|
2120
|
+
self.degrees = (3, 3)
|
2121
|
+
|
2122
|
+
def __call__(self, theta, phi, dtheta=0, dphi=0, grid=True):
|
2123
|
+
|
2124
|
+
theta = np.asarray(theta)
|
2125
|
+
phi = np.asarray(phi)
|
2126
|
+
|
2127
|
+
if phi.size > 0 and (phi.min() < 0. or phi.max() > 2. * np.pi):
|
2128
|
+
raise ValueError("requested phi out of bounds.")
|
2129
|
+
|
2130
|
+
return SphereBivariateSpline.__call__(self, theta, phi, dtheta=dtheta,
|
2131
|
+
dphi=dphi, grid=grid)
|
2132
|
+
|
2133
|
+
|
2134
|
+
_spfit_messages = _surfit_messages.copy()
|
2135
|
+
_spfit_messages[10] = """
|
2136
|
+
ERROR: on entry, the input data are controlled on validity
|
2137
|
+
the following restrictions must be satisfied.
|
2138
|
+
-1<=iopt(1)<=1, 0<=iopt(2)<=1, 0<=iopt(3)<=1,
|
2139
|
+
-1<=ider(1)<=1, 0<=ider(2)<=1, ider(2)=0 if iopt(2)=0.
|
2140
|
+
-1<=ider(3)<=1, 0<=ider(4)<=1, ider(4)=0 if iopt(3)=0.
|
2141
|
+
mu >= mumin (see above), mv >= 4, nuest >=8, nvest >= 8,
|
2142
|
+
kwrk>=5+mu+mv+nuest+nvest,
|
2143
|
+
lwrk >= 12+nuest*(mv+nvest+3)+nvest*24+4*mu+8*mv+max(nuest,mv+nvest)
|
2144
|
+
0< u(i-1)<u(i)< pi,i=2,..,mu,
|
2145
|
+
-pi<=v(1)< pi, v(1)<v(i-1)<v(i)<v(1)+2*pi, i=3,...,mv
|
2146
|
+
if iopt(1)=-1: 8<=nu<=min(nuest,mu+6+iopt(2)+iopt(3))
|
2147
|
+
0<tu(5)<tu(6)<...<tu(nu-4)< pi
|
2148
|
+
8<=nv<=min(nvest,mv+7)
|
2149
|
+
v(1)<tv(5)<tv(6)<...<tv(nv-4)<v(1)+2*pi
|
2150
|
+
the schoenberg-whitney conditions, i.e. there must be
|
2151
|
+
subset of grid coordinates uu(p) and vv(q) such that
|
2152
|
+
tu(p) < uu(p) < tu(p+4) ,p=1,...,nu-4
|
2153
|
+
(iopt(2)=1 and iopt(3)=1 also count for a uu-value
|
2154
|
+
tv(q) < vv(q) < tv(q+4) ,q=1,...,nv-4
|
2155
|
+
(vv(q) is either a value v(j) or v(j)+2*pi)
|
2156
|
+
if iopt(1)>=0: s>=0
|
2157
|
+
if s=0: nuest>=mu+6+iopt(2)+iopt(3), nvest>=mv+7
|
2158
|
+
if one of these conditions is found to be violated,control is
|
2159
|
+
immediately repassed to the calling program. in that case there is no
|
2160
|
+
approximation returned."""
|
2161
|
+
|
2162
|
+
|
2163
|
+
class RectSphereBivariateSpline(SphereBivariateSpline):
|
2164
|
+
"""
|
2165
|
+
Bivariate spline approximation over a rectangular mesh on a sphere.
|
2166
|
+
|
2167
|
+
Can be used for smoothing data.
|
2168
|
+
|
2169
|
+
.. versionadded:: 0.11.0
|
2170
|
+
|
2171
|
+
Parameters
|
2172
|
+
----------
|
2173
|
+
u : array_like
|
2174
|
+
1-D array of colatitude coordinates in strictly ascending order.
|
2175
|
+
Coordinates must be given in radians and lie within the open interval
|
2176
|
+
``(0, pi)``.
|
2177
|
+
v : array_like
|
2178
|
+
1-D array of longitude coordinates in strictly ascending order.
|
2179
|
+
Coordinates must be given in radians. First element (``v[0]``) must lie
|
2180
|
+
within the interval ``[-pi, pi)``. Last element (``v[-1]``) must satisfy
|
2181
|
+
``v[-1] <= v[0] + 2*pi``.
|
2182
|
+
r : array_like
|
2183
|
+
2-D array of data with shape ``(u.size, v.size)``.
|
2184
|
+
s : float, optional
|
2185
|
+
Positive smoothing factor defined for estimation condition
|
2186
|
+
(``s=0`` is for interpolation).
|
2187
|
+
pole_continuity : bool or (bool, bool), optional
|
2188
|
+
Order of continuity at the poles ``u=0`` (``pole_continuity[0]``) and
|
2189
|
+
``u=pi`` (``pole_continuity[1]``). The order of continuity at the pole
|
2190
|
+
will be 1 or 0 when this is True or False, respectively.
|
2191
|
+
Defaults to False.
|
2192
|
+
pole_values : float or (float, float), optional
|
2193
|
+
Data values at the poles ``u=0`` and ``u=pi``. Either the whole
|
2194
|
+
parameter or each individual element can be None. Defaults to None.
|
2195
|
+
pole_exact : bool or (bool, bool), optional
|
2196
|
+
Data value exactness at the poles ``u=0`` and ``u=pi``. If True, the
|
2197
|
+
value is considered to be the right function value, and it will be
|
2198
|
+
fitted exactly. If False, the value will be considered to be a data
|
2199
|
+
value just like the other data values. Defaults to False.
|
2200
|
+
pole_flat : bool or (bool, bool), optional
|
2201
|
+
For the poles at ``u=0`` and ``u=pi``, specify whether or not the
|
2202
|
+
approximation has vanishing derivatives. Defaults to False.
|
2203
|
+
|
2204
|
+
See Also
|
2205
|
+
--------
|
2206
|
+
BivariateSpline :
|
2207
|
+
a base class for bivariate splines.
|
2208
|
+
UnivariateSpline :
|
2209
|
+
a smooth univariate spline to fit a given set of data points.
|
2210
|
+
SmoothBivariateSpline :
|
2211
|
+
a smoothing bivariate spline through the given points
|
2212
|
+
LSQBivariateSpline :
|
2213
|
+
a bivariate spline using weighted least-squares fitting
|
2214
|
+
SmoothSphereBivariateSpline :
|
2215
|
+
a smoothing bivariate spline in spherical coordinates
|
2216
|
+
LSQSphereBivariateSpline :
|
2217
|
+
a bivariate spline in spherical coordinates using weighted
|
2218
|
+
least-squares fitting
|
2219
|
+
RectBivariateSpline :
|
2220
|
+
a bivariate spline over a rectangular mesh.
|
2221
|
+
bisplrep :
|
2222
|
+
a function to find a bivariate B-spline representation of a surface
|
2223
|
+
bisplev :
|
2224
|
+
a function to evaluate a bivariate B-spline and its derivatives
|
2225
|
+
|
2226
|
+
Notes
|
2227
|
+
-----
|
2228
|
+
Currently, only the smoothing spline approximation (``iopt[0] = 0`` and
|
2229
|
+
``iopt[0] = 1`` in the FITPACK routine) is supported. The exact
|
2230
|
+
least-squares spline approximation is not implemented yet.
|
2231
|
+
|
2232
|
+
When actually performing the interpolation, the requested `v` values must
|
2233
|
+
lie within the same length 2pi interval that the original `v` values were
|
2234
|
+
chosen from.
|
2235
|
+
|
2236
|
+
For more information, see the FITPACK_ site about this function.
|
2237
|
+
|
2238
|
+
.. _FITPACK: http://www.netlib.org/dierckx/spgrid.f
|
2239
|
+
|
2240
|
+
Examples
|
2241
|
+
--------
|
2242
|
+
Suppose we have global data on a coarse grid
|
2243
|
+
|
2244
|
+
>>> import numpy as np
|
2245
|
+
>>> lats = np.linspace(10, 170, 9) * np.pi / 180.
|
2246
|
+
>>> lons = np.linspace(0, 350, 18) * np.pi / 180.
|
2247
|
+
>>> data = np.dot(np.atleast_2d(90. - np.linspace(-80., 80., 18)).T,
|
2248
|
+
... np.atleast_2d(180. - np.abs(np.linspace(0., 350., 9)))).T
|
2249
|
+
|
2250
|
+
We want to interpolate it to a global one-degree grid
|
2251
|
+
|
2252
|
+
>>> new_lats = np.linspace(1, 180, 180) * np.pi / 180
|
2253
|
+
>>> new_lons = np.linspace(1, 360, 360) * np.pi / 180
|
2254
|
+
>>> new_lats, new_lons = np.meshgrid(new_lats, new_lons)
|
2255
|
+
|
2256
|
+
We need to set up the interpolator object
|
2257
|
+
|
2258
|
+
>>> from scipy.interpolate import RectSphereBivariateSpline
|
2259
|
+
>>> lut = RectSphereBivariateSpline(lats, lons, data)
|
2260
|
+
|
2261
|
+
Finally we interpolate the data. The `RectSphereBivariateSpline` object
|
2262
|
+
only takes 1-D arrays as input, therefore we need to do some reshaping.
|
2263
|
+
|
2264
|
+
>>> data_interp = lut.ev(new_lats.ravel(),
|
2265
|
+
... new_lons.ravel()).reshape((360, 180)).T
|
2266
|
+
|
2267
|
+
Looking at the original and the interpolated data, one can see that the
|
2268
|
+
interpolant reproduces the original data very well:
|
2269
|
+
|
2270
|
+
>>> import matplotlib.pyplot as plt
|
2271
|
+
>>> fig = plt.figure()
|
2272
|
+
>>> ax1 = fig.add_subplot(211)
|
2273
|
+
>>> ax1.imshow(data, interpolation='nearest')
|
2274
|
+
>>> ax2 = fig.add_subplot(212)
|
2275
|
+
>>> ax2.imshow(data_interp, interpolation='nearest')
|
2276
|
+
>>> plt.show()
|
2277
|
+
|
2278
|
+
Choosing the optimal value of ``s`` can be a delicate task. Recommended
|
2279
|
+
values for ``s`` depend on the accuracy of the data values. If the user
|
2280
|
+
has an idea of the statistical errors on the data, she can also find a
|
2281
|
+
proper estimate for ``s``. By assuming that, if she specifies the
|
2282
|
+
right ``s``, the interpolator will use a spline ``f(u,v)`` which exactly
|
2283
|
+
reproduces the function underlying the data, she can evaluate
|
2284
|
+
``sum((r(i,j)-s(u(i),v(j)))**2)`` to find a good estimate for this ``s``.
|
2285
|
+
For example, if she knows that the statistical errors on her
|
2286
|
+
``r(i,j)``-values are not greater than 0.1, she may expect that a good
|
2287
|
+
``s`` should have a value not larger than ``u.size * v.size * (0.1)**2``.
|
2288
|
+
|
2289
|
+
If nothing is known about the statistical error in ``r(i,j)``, ``s`` must
|
2290
|
+
be determined by trial and error. The best is then to start with a very
|
2291
|
+
large value of ``s`` (to determine the least-squares polynomial and the
|
2292
|
+
corresponding upper bound ``fp0`` for ``s``) and then to progressively
|
2293
|
+
decrease the value of ``s`` (say by a factor 10 in the beginning, i.e.
|
2294
|
+
``s = fp0 / 10, fp0 / 100, ...`` and more carefully as the approximation
|
2295
|
+
shows more detail) to obtain closer fits.
|
2296
|
+
|
2297
|
+
The interpolation results for different values of ``s`` give some insight
|
2298
|
+
into this process:
|
2299
|
+
|
2300
|
+
>>> fig2 = plt.figure()
|
2301
|
+
>>> s = [3e9, 2e9, 1e9, 1e8]
|
2302
|
+
>>> for idx, sval in enumerate(s, 1):
|
2303
|
+
... lut = RectSphereBivariateSpline(lats, lons, data, s=sval)
|
2304
|
+
... data_interp = lut.ev(new_lats.ravel(),
|
2305
|
+
... new_lons.ravel()).reshape((360, 180)).T
|
2306
|
+
... ax = fig2.add_subplot(2, 2, idx)
|
2307
|
+
... ax.imshow(data_interp, interpolation='nearest')
|
2308
|
+
... ax.set_title(f"s = {sval:g}")
|
2309
|
+
>>> plt.show()
|
2310
|
+
|
2311
|
+
"""
|
2312
|
+
|
2313
|
+
def __init__(self, u, v, r, s=0., pole_continuity=False, pole_values=None,
|
2314
|
+
pole_exact=False, pole_flat=False):
|
2315
|
+
iopt = np.array([0, 0, 0], dtype=dfitpack_int)
|
2316
|
+
ider = np.array([-1, 0, -1, 0], dtype=dfitpack_int)
|
2317
|
+
if pole_values is None:
|
2318
|
+
pole_values = (None, None)
|
2319
|
+
elif isinstance(pole_values, float | np.float32 | np.float64):
|
2320
|
+
pole_values = (pole_values, pole_values)
|
2321
|
+
if isinstance(pole_continuity, bool):
|
2322
|
+
pole_continuity = (pole_continuity, pole_continuity)
|
2323
|
+
if isinstance(pole_exact, bool):
|
2324
|
+
pole_exact = (pole_exact, pole_exact)
|
2325
|
+
if isinstance(pole_flat, bool):
|
2326
|
+
pole_flat = (pole_flat, pole_flat)
|
2327
|
+
|
2328
|
+
r0, r1 = pole_values
|
2329
|
+
iopt[1:] = pole_continuity
|
2330
|
+
if r0 is None:
|
2331
|
+
ider[0] = -1
|
2332
|
+
else:
|
2333
|
+
ider[0] = pole_exact[0]
|
2334
|
+
|
2335
|
+
if r1 is None:
|
2336
|
+
ider[2] = -1
|
2337
|
+
else:
|
2338
|
+
ider[2] = pole_exact[1]
|
2339
|
+
|
2340
|
+
ider[1], ider[3] = pole_flat
|
2341
|
+
|
2342
|
+
u, v = np.ravel(u), np.ravel(v)
|
2343
|
+
r = np.asarray(r)
|
2344
|
+
|
2345
|
+
if not (0.0 < u[0] and u[-1] < np.pi):
|
2346
|
+
raise ValueError('u should be between (0, pi)')
|
2347
|
+
if not -np.pi <= v[0] < np.pi:
|
2348
|
+
raise ValueError('v[0] should be between [-pi, pi)')
|
2349
|
+
if not v[-1] <= v[0] + 2*np.pi:
|
2350
|
+
raise ValueError('v[-1] should be v[0] + 2pi or less ')
|
2351
|
+
|
2352
|
+
if not np.all(np.diff(u) > 0.0):
|
2353
|
+
raise ValueError('u must be strictly increasing')
|
2354
|
+
if not np.all(np.diff(v) > 0.0):
|
2355
|
+
raise ValueError('v must be strictly increasing')
|
2356
|
+
|
2357
|
+
if not u.size == r.shape[0]:
|
2358
|
+
raise ValueError('u dimension of r must have same number of '
|
2359
|
+
'elements as u')
|
2360
|
+
if not v.size == r.shape[1]:
|
2361
|
+
raise ValueError('v dimension of r must have same number of '
|
2362
|
+
'elements as v')
|
2363
|
+
|
2364
|
+
if pole_continuity[1] is False and pole_flat[1] is True:
|
2365
|
+
raise ValueError('if pole_continuity is False, so must be '
|
2366
|
+
'pole_flat')
|
2367
|
+
if pole_continuity[0] is False and pole_flat[0] is True:
|
2368
|
+
raise ValueError('if pole_continuity is False, so must be '
|
2369
|
+
'pole_flat')
|
2370
|
+
|
2371
|
+
if not s >= 0.0:
|
2372
|
+
raise ValueError('s should be positive')
|
2373
|
+
|
2374
|
+
r = np.ravel(r)
|
2375
|
+
with FITPACK_LOCK:
|
2376
|
+
nu, tu, nv, tv, c, fp, ier = dfitpack.regrid_smth_spher(iopt, ider,
|
2377
|
+
u.copy(),
|
2378
|
+
v.copy(),
|
2379
|
+
r.copy(),
|
2380
|
+
r0, r1, s)
|
2381
|
+
|
2382
|
+
if ier not in [0, -1, -2]:
|
2383
|
+
msg = _spfit_messages.get(ier, f'ier={ier}')
|
2384
|
+
raise ValueError(msg)
|
2385
|
+
|
2386
|
+
self.fp = fp
|
2387
|
+
self.tck = tu[:nu], tv[:nv], c[:(nu - 4) * (nv-4)]
|
2388
|
+
self.degrees = (3, 3)
|
2389
|
+
self.v0 = v[0]
|
2390
|
+
|
2391
|
+
def __call__(self, theta, phi, dtheta=0, dphi=0, grid=True):
|
2392
|
+
|
2393
|
+
theta = np.asarray(theta)
|
2394
|
+
phi = np.asarray(phi)
|
2395
|
+
|
2396
|
+
return SphereBivariateSpline.__call__(self, theta, phi, dtheta=dtheta,
|
2397
|
+
dphi=dphi, grid=grid)
|