scipy 1.16.2__cp311-cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_cyutility.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_lib/_ccallback_c.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_lib/_fpumode.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_ccallback.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_call.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_call.cp311-win_arm64.pyd +0 -0
- scipy/_lib/_test_deprecation_def.cp311-win_arm64.lib +0 -0
- scipy/_lib/_test_deprecation_def.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_lib/_uarray/_uarray.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/_lib/messagestream.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/cluster/_hierarchy.cp311-win_arm64.pyd +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp311-win_arm64.lib +0 -0
- scipy/cluster/_optimal_leaf_ordering.cp311-win_arm64.pyd +0 -0
- scipy/cluster/_vq.cp311-win_arm64.lib +0 -0
- scipy/cluster/_vq.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/fft/_pocketfft/pypocketfft.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/fftpack/convolve.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/integrate/_dop.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/integrate/_lsoda.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_ode.py +1395 -0
- scipy/integrate/_odepack.cp311-win_arm64.lib +0 -0
- scipy/integrate/_odepack.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_odepack_py.py +273 -0
- scipy/integrate/_quad_vec.py +674 -0
- scipy/integrate/_quadpack.cp311-win_arm64.lib +0 -0
- scipy/integrate/_quadpack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/integrate/_test_multivariate.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_test_odeint_banded.cp311-win_arm64.lib +0 -0
- scipy/integrate/_test_odeint_banded.cp311-win_arm64.pyd +0 -0
- scipy/integrate/_vode.cp311-win_arm64.lib +0 -0
- scipy/integrate/_vode.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_dfitpack.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_dierckx.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_dierckx.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_fitpack.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_fitpack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_interpnd.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_ppoly.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_rbf.py +290 -0
- scipy/interpolate/_rbfinterp.py +550 -0
- scipy/interpolate/_rbfinterp_pythran.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_rbfinterp_pythran.cp311-win_arm64.pyd +0 -0
- scipy/interpolate/_rgi.py +764 -0
- scipy/interpolate/_rgi_cython.cp311-win_arm64.lib +0 -0
- scipy/interpolate/_rgi_cython.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/io/_fast_matrix_market/_fmm_core.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/io/_test_fortran.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_mio5_utils.cp311-win_arm64.pyd +0 -0
- scipy/io/matlab/_mio_utils.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_mio_utils.cp311-win_arm64.pyd +0 -0
- scipy/io/matlab/_miobase.py +435 -0
- scipy/io/matlab/_streams.cp311-win_arm64.lib +0 -0
- scipy/io/matlab/_streams.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/_cythonized_array_utils.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_interpolative.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_decomp_ldl.py +356 -0
- scipy/linalg/_decomp_lu.py +401 -0
- scipy/linalg/_decomp_lu_cython.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_lu_cython.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/_decomp_update.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_expm_frechet.py +417 -0
- scipy/linalg/_fblas.cp311-win_arm64.lib +0 -0
- scipy/linalg/_fblas.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_flapack.cp311-win_arm64.lib +0 -0
- scipy/linalg/_flapack.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_lapack_subroutines.h +1521 -0
- scipy/linalg/_linalg_pythran.cp311-win_arm64.lib +0 -0
- scipy/linalg/_linalg_pythran.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs.py +1050 -0
- scipy/linalg/_matfuncs_expm.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_expm.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_schur_sqrtm.cp311-win_arm64.pyd +0 -0
- scipy/linalg/_matfuncs_sqrtm.py +107 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp311-win_arm64.lib +0 -0
- scipy/linalg/_matfuncs_sqrtm_triu.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/_solve_toeplitz.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/linalg/cython_blas.cp311-win_arm64.pyd +0 -0
- scipy/linalg/cython_blas.pxd +169 -0
- scipy/linalg/cython_blas.pyx +1432 -0
- scipy/linalg/cython_lapack.cp311-win_arm64.lib +0 -0
- scipy/linalg/cython_lapack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_ctest.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_cytest.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_cytest.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_nd_image.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_ndimage_api.py +16 -0
- scipy/ndimage/_ni_docstrings.py +214 -0
- scipy/ndimage/_ni_label.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_ni_label.cp311-win_arm64.pyd +0 -0
- scipy/ndimage/_ni_support.py +139 -0
- scipy/ndimage/_rank_filter_1d.cp311-win_arm64.lib +0 -0
- scipy/ndimage/_rank_filter_1d.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/odr/__odrpack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_bglu_dense.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_direct.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_group_columns.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_hessian_update_strategy.py +479 -0
- scipy/optimize/_highspy/__init__.py +0 -0
- scipy/optimize/_highspy/_core.cp311-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_core.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_options.cp311-win_arm64.lib +0 -0
- scipy/optimize/_highspy/_highs_options.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_highspy/_highs_wrapper.py +338 -0
- scipy/optimize/_isotonic.py +157 -0
- scipy/optimize/_lbfgsb.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lbfgsb.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lsap.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_lsq/givens_elimination.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_minpack.cp311-win_arm64.pyd +0 -0
- scipy/optimize/_minpack_py.py +1178 -0
- scipy/optimize/_moduleTNC.cp311-win_arm64.lib +0 -0
- scipy/optimize/_moduleTNC.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_pava_pybind.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_slsqplib.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_trlib/_trlib.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/_zeros.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/optimize/cython_optimize/_zeros.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/signal/_max_len_seq_inner.cp311-win_arm64.pyd +0 -0
- scipy/signal/_peak_finding.py +1310 -0
- scipy/signal/_peak_finding_utils.cp311-win_arm64.lib +0 -0
- scipy/signal/_peak_finding_utils.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/signal/_sigtools.cp311-win_arm64.pyd +0 -0
- scipy/signal/_sosfilt.cp311-win_arm64.lib +0 -0
- scipy/signal/_sosfilt.cp311-win_arm64.pyd +0 -0
- scipy/signal/_spectral_py.py +2471 -0
- scipy/signal/_spline.cp311-win_arm64.lib +0 -0
- scipy/signal/_spline.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/signal/_upfirdn_apply.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/_csparsetools.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/_sparsetools.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_flow.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_laplacian.py +563 -0
- scipy/sparse/csgraph/_matching.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_matching.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_min_spanning_tree.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_reordering.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_reordering.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_shortest_path.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_shortest_path.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_tools.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_tools.cp311-win_arm64.pyd +0 -0
- scipy/sparse/csgraph/_traversal.cp311-win_arm64.lib +0 -0
- scipy/sparse/csgraph/_traversal.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_dsolve/_superlu.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_eigen/arpack/_arpack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_cpropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_dpropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_spropack.cp311-win_arm64.pyd +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp311-win_arm64.lib +0 -0
- scipy/sparse/linalg/_propack/_zpropack.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/spatial/_ckdtree.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_distance_pybind.cp311-win_arm64.lib +0 -0
- scipy/spatial/_distance_pybind.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_distance_wrap.cp311-win_arm64.lib +0 -0
- scipy/spatial/_distance_wrap.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_geometric_slerp.py +238 -0
- scipy/spatial/_hausdorff.cp311-win_arm64.lib +0 -0
- scipy/spatial/_hausdorff.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/spatial/_qhull.cp311-win_arm64.pyd +0 -0
- scipy/spatial/_qhull.pyi +213 -0
- scipy/spatial/_spherical_voronoi.py +341 -0
- scipy/spatial/_voronoi.cp311-win_arm64.lib +0 -0
- scipy/spatial/_voronoi.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/spatial/transform/_rigid_transform.cp311-win_arm64.pyd +0 -0
- scipy/spatial/transform/_rotation.cp311-win_arm64.lib +0 -0
- scipy/spatial/transform/_rotation.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/special/_comb.cp311-win_arm64.pyd +0 -0
- scipy/special/_ellip_harm.py +214 -0
- scipy/special/_ellip_harm_2.cp311-win_arm64.lib +0 -0
- scipy/special/_ellip_harm_2.cp311-win_arm64.pyd +0 -0
- scipy/special/_gufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_gufuncs.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/special/_specfun.cp311-win_arm64.pyd +0 -0
- scipy/special/_special_ufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_special_ufuncs.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/special/_test_internal.cp311-win_arm64.pyd +0 -0
- scipy/special/_test_internal.pyi +9 -0
- scipy/special/_testutils.py +321 -0
- scipy/special/_ufuncs.cp311-win_arm64.lib +0 -0
- scipy/special/_ufuncs.cp311-win_arm64.pyd +0 -0
- scipy/special/_ufuncs.pyi +522 -0
- scipy/special/_ufuncs.pyx +13173 -0
- scipy/special/_ufuncs_cxx.cp311-win_arm64.lib +0 -0
- scipy/special/_ufuncs_cxx.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/special/cython_special.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_ansari_swilk_statistics.cp311-win_arm64.pyd +0 -0
- scipy/stats/_axis_nan_policy.py +692 -0
- scipy/stats/_biasedurn.cp311-win_arm64.lib +0 -0
- scipy/stats/_biasedurn.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_levy_stable/levyst.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_qmc_cy.cp311-win_arm64.pyd +0 -0
- scipy/stats/_qmc_cy.pyi +54 -0
- scipy/stats/_qmvnt.py +454 -0
- scipy/stats/_qmvnt_cy.cp311-win_arm64.lib +0 -0
- scipy/stats/_qmvnt_cy.cp311-win_arm64.pyd +0 -0
- scipy/stats/_quantile.py +335 -0
- scipy/stats/_rcont/__init__.py +4 -0
- scipy/stats/_rcont/rcont.cp311-win_arm64.lib +0 -0
- scipy/stats/_rcont/rcont.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_sobol.cp311-win_arm64.pyd +0 -0
- scipy/stats/_sobol.pyi +54 -0
- scipy/stats/_sobol_direction_numbers.npz +0 -0
- scipy/stats/_stats.cp311-win_arm64.lib +0 -0
- scipy/stats/_stats.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_stats_pythran.cp311-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.cp311-win_arm64.lib +0 -0
- scipy/stats/_unuran/unuran_wrapper.cp311-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,2071 @@
|
|
1
|
+
"""
|
2
|
+
Tests for the stats.mstats module (support for masked arrays)
|
3
|
+
"""
|
4
|
+
import warnings
|
5
|
+
import platform
|
6
|
+
|
7
|
+
import numpy as np
|
8
|
+
from numpy import nan
|
9
|
+
import numpy.ma as ma
|
10
|
+
from numpy.ma import masked, nomask
|
11
|
+
|
12
|
+
import scipy.stats.mstats as mstats
|
13
|
+
from scipy import stats
|
14
|
+
from .common_tests import check_named_results
|
15
|
+
import pytest
|
16
|
+
from pytest import raises as assert_raises
|
17
|
+
from numpy.ma.testutils import (assert_equal, assert_almost_equal,
|
18
|
+
assert_array_almost_equal,
|
19
|
+
assert_array_almost_equal_nulp, assert_,
|
20
|
+
assert_allclose, assert_array_equal)
|
21
|
+
from numpy.testing import suppress_warnings
|
22
|
+
from scipy.stats import _mstats_basic, _stats_py
|
23
|
+
from scipy.conftest import skip_xp_invalid_arg
|
24
|
+
from scipy.stats._axis_nan_policy import SmallSampleWarning, too_small_1d_not_omit
|
25
|
+
|
26
|
+
class TestMquantiles:
|
27
|
+
def test_mquantiles_limit_keyword(self):
|
28
|
+
# Regression test for Trac ticket #867
|
29
|
+
data = np.array([[6., 7., 1.],
|
30
|
+
[47., 15., 2.],
|
31
|
+
[49., 36., 3.],
|
32
|
+
[15., 39., 4.],
|
33
|
+
[42., 40., -999.],
|
34
|
+
[41., 41., -999.],
|
35
|
+
[7., -999., -999.],
|
36
|
+
[39., -999., -999.],
|
37
|
+
[43., -999., -999.],
|
38
|
+
[40., -999., -999.],
|
39
|
+
[36., -999., -999.]])
|
40
|
+
desired = [[19.2, 14.6, 1.45],
|
41
|
+
[40.0, 37.5, 2.5],
|
42
|
+
[42.8, 40.05, 3.55]]
|
43
|
+
quants = mstats.mquantiles(data, axis=0, limit=(0, 50))
|
44
|
+
assert_almost_equal(quants, desired)
|
45
|
+
|
46
|
+
|
47
|
+
def check_equal_gmean(array_like, desired, axis=None, dtype=None, rtol=1e-7):
|
48
|
+
# Note this doesn't test when axis is not specified
|
49
|
+
x = mstats.gmean(array_like, axis=axis, dtype=dtype)
|
50
|
+
assert_allclose(x, desired, rtol=rtol)
|
51
|
+
assert_equal(x.dtype, dtype)
|
52
|
+
|
53
|
+
|
54
|
+
def check_equal_hmean(array_like, desired, axis=None, dtype=None, rtol=1e-7):
|
55
|
+
x = stats.hmean(array_like, axis=axis, dtype=dtype)
|
56
|
+
assert_allclose(x, desired, rtol=rtol)
|
57
|
+
assert_equal(x.dtype, dtype)
|
58
|
+
|
59
|
+
|
60
|
+
@skip_xp_invalid_arg
|
61
|
+
class TestGeoMean:
|
62
|
+
def test_1d(self):
|
63
|
+
a = [1, 2, 3, 4]
|
64
|
+
desired = np.power(1*2*3*4, 1./4.)
|
65
|
+
check_equal_gmean(a, desired, rtol=1e-14)
|
66
|
+
|
67
|
+
def test_1d_ma(self):
|
68
|
+
# Test a 1d masked array
|
69
|
+
a = ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
|
70
|
+
desired = 45.2872868812
|
71
|
+
check_equal_gmean(a, desired)
|
72
|
+
|
73
|
+
a = ma.array([1, 2, 3, 4], mask=[0, 0, 0, 1])
|
74
|
+
desired = np.power(1*2*3, 1./3.)
|
75
|
+
check_equal_gmean(a, desired, rtol=1e-14)
|
76
|
+
|
77
|
+
def test_1d_ma_value(self):
|
78
|
+
# Test a 1d masked array with a masked value
|
79
|
+
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
|
80
|
+
mask=[0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
81
|
+
desired = 41.4716627439
|
82
|
+
check_equal_gmean(a, desired)
|
83
|
+
|
84
|
+
def test_1d_ma0(self):
|
85
|
+
# Test a 1d masked array with zero element
|
86
|
+
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 0])
|
87
|
+
desired = 0
|
88
|
+
check_equal_gmean(a, desired)
|
89
|
+
|
90
|
+
def test_1d_ma_inf(self):
|
91
|
+
# Test a 1d masked array with negative element
|
92
|
+
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, -1])
|
93
|
+
desired = np.nan
|
94
|
+
with np.errstate(invalid='ignore'):
|
95
|
+
check_equal_gmean(a, desired)
|
96
|
+
|
97
|
+
@pytest.mark.skipif(not hasattr(np, 'float96'),
|
98
|
+
reason='cannot find float96 so skipping')
|
99
|
+
def test_1d_float96(self):
|
100
|
+
a = ma.array([1, 2, 3, 4], mask=[0, 0, 0, 1])
|
101
|
+
desired_dt = np.power(1*2*3, 1./3.).astype(np.float96)
|
102
|
+
check_equal_gmean(a, desired_dt, dtype=np.float96, rtol=1e-14)
|
103
|
+
|
104
|
+
def test_2d_ma(self):
|
105
|
+
a = ma.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
|
106
|
+
mask=[[0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]])
|
107
|
+
desired = np.array([1, 2, 3, 4])
|
108
|
+
check_equal_gmean(a, desired, axis=0, rtol=1e-14)
|
109
|
+
|
110
|
+
desired = ma.array([np.power(1*2*3*4, 1./4.),
|
111
|
+
np.power(2*3, 1./2.),
|
112
|
+
np.power(1*4, 1./2.)])
|
113
|
+
check_equal_gmean(a, desired, axis=-1, rtol=1e-14)
|
114
|
+
|
115
|
+
# Test a 2d masked array
|
116
|
+
a = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]
|
117
|
+
desired = 52.8885199
|
118
|
+
check_equal_gmean(np.ma.array(a), desired)
|
119
|
+
|
120
|
+
|
121
|
+
@skip_xp_invalid_arg
|
122
|
+
class TestHarMean:
|
123
|
+
def test_1d(self):
|
124
|
+
a = ma.array([1, 2, 3, 4], mask=[0, 0, 0, 1])
|
125
|
+
desired = 3. / (1./1 + 1./2 + 1./3)
|
126
|
+
check_equal_hmean(a, desired, rtol=1e-14)
|
127
|
+
|
128
|
+
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
|
129
|
+
desired = 34.1417152147
|
130
|
+
check_equal_hmean(a, desired)
|
131
|
+
|
132
|
+
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
|
133
|
+
mask=[0, 0, 0, 0, 0, 0, 0, 0, 0, 1])
|
134
|
+
desired = 31.8137186141
|
135
|
+
check_equal_hmean(a, desired)
|
136
|
+
|
137
|
+
@pytest.mark.skipif(not hasattr(np, 'float96'),
|
138
|
+
reason='cannot find float96 so skipping')
|
139
|
+
def test_1d_float96(self):
|
140
|
+
a = ma.array([1, 2, 3, 4], mask=[0, 0, 0, 1])
|
141
|
+
desired_dt = np.asarray(3. / (1./1 + 1./2 + 1./3), dtype=np.float96)
|
142
|
+
check_equal_hmean(a, desired_dt, dtype=np.float96)
|
143
|
+
|
144
|
+
def test_2d(self):
|
145
|
+
a = ma.array([[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]],
|
146
|
+
mask=[[0, 0, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]])
|
147
|
+
desired = ma.array([1, 2, 3, 4])
|
148
|
+
check_equal_hmean(a, desired, axis=0, rtol=1e-14)
|
149
|
+
|
150
|
+
desired = [4./(1/1.+1/2.+1/3.+1/4.), 2./(1/2.+1/3.), 2./(1/1.+1/4.)]
|
151
|
+
check_equal_hmean(a, desired, axis=-1, rtol=1e-14)
|
152
|
+
|
153
|
+
a = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]
|
154
|
+
desired = 38.6696271841
|
155
|
+
check_equal_hmean(np.ma.array(a), desired)
|
156
|
+
|
157
|
+
|
158
|
+
class TestRanking:
|
159
|
+
def test_ranking(self):
|
160
|
+
x = ma.array([0,1,1,1,2,3,4,5,5,6,])
|
161
|
+
assert_almost_equal(mstats.rankdata(x),
|
162
|
+
[1,3,3,3,5,6,7,8.5,8.5,10])
|
163
|
+
x[[3,4]] = masked
|
164
|
+
assert_almost_equal(mstats.rankdata(x),
|
165
|
+
[1,2.5,2.5,0,0,4,5,6.5,6.5,8])
|
166
|
+
assert_almost_equal(mstats.rankdata(x, use_missing=True),
|
167
|
+
[1,2.5,2.5,4.5,4.5,4,5,6.5,6.5,8])
|
168
|
+
x = ma.array([0,1,5,1,2,4,3,5,1,6,])
|
169
|
+
assert_almost_equal(mstats.rankdata(x),
|
170
|
+
[1,3,8.5,3,5,7,6,8.5,3,10])
|
171
|
+
x = ma.array([[0,1,1,1,2], [3,4,5,5,6,]])
|
172
|
+
assert_almost_equal(mstats.rankdata(x),
|
173
|
+
[[1,3,3,3,5], [6,7,8.5,8.5,10]])
|
174
|
+
assert_almost_equal(mstats.rankdata(x, axis=1),
|
175
|
+
[[1,3,3,3,5], [1,2,3.5,3.5,5]])
|
176
|
+
assert_almost_equal(mstats.rankdata(x,axis=0),
|
177
|
+
[[1,1,1,1,1], [2,2,2,2,2,]])
|
178
|
+
|
179
|
+
|
180
|
+
class TestCorr:
|
181
|
+
def test_pearsonr(self):
|
182
|
+
# Tests some computations of Pearson's r
|
183
|
+
x = ma.arange(10)
|
184
|
+
with warnings.catch_warnings():
|
185
|
+
# The tests in this context are edge cases, with perfect
|
186
|
+
# correlation or anticorrelation, or totally masked data.
|
187
|
+
# None of these should trigger a RuntimeWarning.
|
188
|
+
warnings.simplefilter("error", RuntimeWarning)
|
189
|
+
|
190
|
+
assert_almost_equal(mstats.pearsonr(x, x)[0], 1.0)
|
191
|
+
assert_almost_equal(mstats.pearsonr(x, x[::-1])[0], -1.0)
|
192
|
+
|
193
|
+
x = ma.array(x, mask=True)
|
194
|
+
pr = mstats.pearsonr(x, x)
|
195
|
+
assert_(pr[0] is masked)
|
196
|
+
assert_(pr[1] is masked)
|
197
|
+
|
198
|
+
x1 = ma.array([-1.0, 0.0, 1.0])
|
199
|
+
y1 = ma.array([0, 0, 3])
|
200
|
+
r, p = mstats.pearsonr(x1, y1)
|
201
|
+
assert_almost_equal(r, np.sqrt(3)/2)
|
202
|
+
assert_almost_equal(p, 1.0/3)
|
203
|
+
|
204
|
+
# (x2, y2) have the same unmasked data as (x1, y1).
|
205
|
+
mask = [False, False, False, True]
|
206
|
+
x2 = ma.array([-1.0, 0.0, 1.0, 99.0], mask=mask)
|
207
|
+
y2 = ma.array([0, 0, 3, -1], mask=mask)
|
208
|
+
r, p = mstats.pearsonr(x2, y2)
|
209
|
+
assert_almost_equal(r, np.sqrt(3)/2)
|
210
|
+
assert_almost_equal(p, 1.0/3)
|
211
|
+
|
212
|
+
def test_pearsonr_misaligned_mask(self):
|
213
|
+
mx = np.ma.masked_array([1, 2, 3, 4, 5, 6], mask=[0, 1, 0, 0, 0, 0])
|
214
|
+
my = np.ma.masked_array([9, 8, 7, 6, 5, 9], mask=[0, 0, 1, 0, 0, 0])
|
215
|
+
x = np.array([1, 4, 5, 6])
|
216
|
+
y = np.array([9, 6, 5, 9])
|
217
|
+
mr, mp = mstats.pearsonr(mx, my)
|
218
|
+
r, p = stats.pearsonr(x, y)
|
219
|
+
assert_equal(mr, r)
|
220
|
+
assert_equal(mp, p)
|
221
|
+
|
222
|
+
def test_spearmanr(self):
|
223
|
+
# Tests some computations of Spearman's rho
|
224
|
+
(x, y) = ([5.05,6.75,3.21,2.66], [1.65,2.64,2.64,6.95])
|
225
|
+
assert_almost_equal(mstats.spearmanr(x,y)[0], -0.6324555)
|
226
|
+
(x, y) = ([5.05,6.75,3.21,2.66,np.nan],[1.65,2.64,2.64,6.95,np.nan])
|
227
|
+
(x, y) = (ma.fix_invalid(x), ma.fix_invalid(y))
|
228
|
+
assert_almost_equal(mstats.spearmanr(x,y)[0], -0.6324555)
|
229
|
+
|
230
|
+
x = [2.0, 47.4, 42.0, 10.8, 60.1, 1.7, 64.0, 63.1,
|
231
|
+
1.0, 1.4, 7.9, 0.3, 3.9, 0.3, 6.7]
|
232
|
+
y = [22.6, 8.3, 44.4, 11.9, 24.6, 0.6, 5.7, 41.6,
|
233
|
+
0.0, 0.6, 6.7, 3.8, 1.0, 1.2, 1.4]
|
234
|
+
assert_almost_equal(mstats.spearmanr(x,y)[0], 0.6887299)
|
235
|
+
x = [2.0, 47.4, 42.0, 10.8, 60.1, 1.7, 64.0, 63.1,
|
236
|
+
1.0, 1.4, 7.9, 0.3, 3.9, 0.3, 6.7, np.nan]
|
237
|
+
y = [22.6, 8.3, 44.4, 11.9, 24.6, 0.6, 5.7, 41.6,
|
238
|
+
0.0, 0.6, 6.7, 3.8, 1.0, 1.2, 1.4, np.nan]
|
239
|
+
(x, y) = (ma.fix_invalid(x), ma.fix_invalid(y))
|
240
|
+
assert_almost_equal(mstats.spearmanr(x,y)[0], 0.6887299)
|
241
|
+
# Next test is to make sure calculation uses sufficient precision.
|
242
|
+
# The denominator's value is ~n^3 and used to be represented as an
|
243
|
+
# int. 2000**3 > 2**32 so these arrays would cause overflow on
|
244
|
+
# some machines.
|
245
|
+
x = list(range(2000))
|
246
|
+
y = list(range(2000))
|
247
|
+
y[0], y[9] = y[9], y[0]
|
248
|
+
y[10], y[434] = y[434], y[10]
|
249
|
+
y[435], y[1509] = y[1509], y[435]
|
250
|
+
# rho = 1 - 6 * (2 * (9^2 + 424^2 + 1074^2))/(2000 * (2000^2 - 1))
|
251
|
+
# = 1 - (1 / 500)
|
252
|
+
# = 0.998
|
253
|
+
assert_almost_equal(mstats.spearmanr(x,y)[0], 0.998)
|
254
|
+
|
255
|
+
# test for namedtuple attributes
|
256
|
+
res = mstats.spearmanr(x, y)
|
257
|
+
attributes = ('correlation', 'pvalue')
|
258
|
+
check_named_results(res, attributes, ma=True)
|
259
|
+
|
260
|
+
def test_spearmanr_alternative(self):
|
261
|
+
# check against R
|
262
|
+
# options(digits=16)
|
263
|
+
# cor.test(c(2.0, 47.4, 42.0, 10.8, 60.1, 1.7, 64.0, 63.1,
|
264
|
+
# 1.0, 1.4, 7.9, 0.3, 3.9, 0.3, 6.7),
|
265
|
+
# c(22.6, 8.3, 44.4, 11.9, 24.6, 0.6, 5.7, 41.6,
|
266
|
+
# 0.0, 0.6, 6.7, 3.8, 1.0, 1.2, 1.4),
|
267
|
+
# alternative='two.sided', method='spearman')
|
268
|
+
x = [2.0, 47.4, 42.0, 10.8, 60.1, 1.7, 64.0, 63.1,
|
269
|
+
1.0, 1.4, 7.9, 0.3, 3.9, 0.3, 6.7]
|
270
|
+
y = [22.6, 8.3, 44.4, 11.9, 24.6, 0.6, 5.7, 41.6,
|
271
|
+
0.0, 0.6, 6.7, 3.8, 1.0, 1.2, 1.4]
|
272
|
+
|
273
|
+
r_exp = 0.6887298747763864 # from cor.test
|
274
|
+
|
275
|
+
r, p = mstats.spearmanr(x, y)
|
276
|
+
assert_allclose(r, r_exp)
|
277
|
+
assert_allclose(p, 0.004519192910756)
|
278
|
+
|
279
|
+
r, p = mstats.spearmanr(x, y, alternative='greater')
|
280
|
+
assert_allclose(r, r_exp)
|
281
|
+
assert_allclose(p, 0.002259596455378)
|
282
|
+
|
283
|
+
r, p = mstats.spearmanr(x, y, alternative='less')
|
284
|
+
assert_allclose(r, r_exp)
|
285
|
+
assert_allclose(p, 0.9977404035446)
|
286
|
+
|
287
|
+
# intuitive test (with obvious positive correlation)
|
288
|
+
n = 100
|
289
|
+
x = np.linspace(0, 5, n)
|
290
|
+
y = 0.1*x + np.random.rand(n) # y is positively correlated w/ x
|
291
|
+
|
292
|
+
stat1, p1 = mstats.spearmanr(x, y)
|
293
|
+
|
294
|
+
stat2, p2 = mstats.spearmanr(x, y, alternative="greater")
|
295
|
+
assert_allclose(p2, p1 / 2) # positive correlation -> small p
|
296
|
+
|
297
|
+
stat3, p3 = mstats.spearmanr(x, y, alternative="less")
|
298
|
+
assert_allclose(p3, 1 - p1 / 2) # positive correlation -> large p
|
299
|
+
|
300
|
+
assert stat1 == stat2 == stat3
|
301
|
+
|
302
|
+
with pytest.raises(ValueError, match="alternative must be 'less'..."):
|
303
|
+
mstats.spearmanr(x, y, alternative="ekki-ekki")
|
304
|
+
|
305
|
+
@pytest.mark.skipif(platform.machine() == 'ppc64le',
|
306
|
+
reason="fails/crashes on ppc64le")
|
307
|
+
def test_kendalltau(self):
|
308
|
+
# check case with maximum disorder and p=1
|
309
|
+
x = ma.array(np.array([9, 2, 5, 6]))
|
310
|
+
y = ma.array(np.array([4, 7, 9, 11]))
|
311
|
+
# Cross-check with exact result from R:
|
312
|
+
# cor.test(x,y,method="kendall",exact=1)
|
313
|
+
expected = [0.0, 1.0]
|
314
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
315
|
+
|
316
|
+
# simple case without ties
|
317
|
+
x = ma.array(np.arange(10))
|
318
|
+
y = ma.array(np.arange(10))
|
319
|
+
# Cross-check with exact result from R:
|
320
|
+
# cor.test(x,y,method="kendall",exact=1)
|
321
|
+
expected = [1.0, 5.511463844797e-07]
|
322
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
323
|
+
|
324
|
+
# check exception in case of invalid method keyword
|
325
|
+
assert_raises(ValueError, mstats.kendalltau, x, y, method='banana')
|
326
|
+
|
327
|
+
# swap a couple of values
|
328
|
+
b = y[1]
|
329
|
+
y[1] = y[2]
|
330
|
+
y[2] = b
|
331
|
+
# Cross-check with exact result from R:
|
332
|
+
# cor.test(x,y,method="kendall",exact=1)
|
333
|
+
expected = [0.9555555555555556, 5.511463844797e-06]
|
334
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
335
|
+
|
336
|
+
# swap a couple more
|
337
|
+
b = y[5]
|
338
|
+
y[5] = y[6]
|
339
|
+
y[6] = b
|
340
|
+
# Cross-check with exact result from R:
|
341
|
+
# cor.test(x,y,method="kendall",exact=1)
|
342
|
+
expected = [0.9111111111111111, 2.976190476190e-05]
|
343
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
344
|
+
|
345
|
+
# same in opposite direction
|
346
|
+
x = ma.array(np.arange(10))
|
347
|
+
y = ma.array(np.arange(10)[::-1])
|
348
|
+
# Cross-check with exact result from R:
|
349
|
+
# cor.test(x,y,method="kendall",exact=1)
|
350
|
+
expected = [-1.0, 5.511463844797e-07]
|
351
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
352
|
+
|
353
|
+
# swap a couple of values
|
354
|
+
b = y[1]
|
355
|
+
y[1] = y[2]
|
356
|
+
y[2] = b
|
357
|
+
# Cross-check with exact result from R:
|
358
|
+
# cor.test(x,y,method="kendall",exact=1)
|
359
|
+
expected = [-0.9555555555555556, 5.511463844797e-06]
|
360
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
361
|
+
|
362
|
+
# swap a couple more
|
363
|
+
b = y[5]
|
364
|
+
y[5] = y[6]
|
365
|
+
y[6] = b
|
366
|
+
# Cross-check with exact result from R:
|
367
|
+
# cor.test(x,y,method="kendall",exact=1)
|
368
|
+
expected = [-0.9111111111111111, 2.976190476190e-05]
|
369
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)), expected)
|
370
|
+
|
371
|
+
# Tests some computations of Kendall's tau
|
372
|
+
x = ma.fix_invalid([5.05, 6.75, 3.21, 2.66, np.nan])
|
373
|
+
y = ma.fix_invalid([1.65, 26.5, -5.93, 7.96, np.nan])
|
374
|
+
z = ma.fix_invalid([1.65, 2.64, 2.64, 6.95, np.nan])
|
375
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y)),
|
376
|
+
[+0.3333333, 0.75])
|
377
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, y, method='asymptotic')),
|
378
|
+
[+0.3333333, 0.4969059])
|
379
|
+
assert_almost_equal(np.asarray(mstats.kendalltau(x, z)),
|
380
|
+
[-0.5477226, 0.2785987])
|
381
|
+
#
|
382
|
+
x = ma.fix_invalid([0, 0, 0, 0, 20, 20, 0, 60, 0, 20,
|
383
|
+
10, 10, 0, 40, 0, 20, 0, 0, 0, 0, 0, np.nan])
|
384
|
+
y = ma.fix_invalid([0, 80, 80, 80, 10, 33, 60, 0, 67, 27,
|
385
|
+
25, 80, 80, 80, 80, 80, 80, 0, 10, 45, np.nan, 0])
|
386
|
+
result = mstats.kendalltau(x, y)
|
387
|
+
assert_almost_equal(np.asarray(result), [-0.1585188, 0.4128009])
|
388
|
+
|
389
|
+
# test for namedtuple attributes
|
390
|
+
attributes = ('correlation', 'pvalue')
|
391
|
+
check_named_results(result, attributes, ma=True)
|
392
|
+
|
393
|
+
@pytest.mark.skipif(platform.machine() == 'ppc64le',
|
394
|
+
reason="fails/crashes on ppc64le")
|
395
|
+
@pytest.mark.slow
|
396
|
+
def test_kendalltau_large(self):
|
397
|
+
# make sure internal variable use correct precision with
|
398
|
+
# larger arrays
|
399
|
+
x = np.arange(2000, dtype=float)
|
400
|
+
x = ma.masked_greater(x, 1995)
|
401
|
+
y = np.arange(2000, dtype=float)
|
402
|
+
y = np.concatenate((y[1000:], y[:1000]))
|
403
|
+
assert_(np.isfinite(mstats.kendalltau(x, y)[1]))
|
404
|
+
|
405
|
+
def test_kendalltau_seasonal(self):
|
406
|
+
# Tests the seasonal Kendall tau.
|
407
|
+
x = [[nan, nan, 4, 2, 16, 26, 5, 1, 5, 1, 2, 3, 1],
|
408
|
+
[4, 3, 5, 3, 2, 7, 3, 1, 1, 2, 3, 5, 3],
|
409
|
+
[3, 2, 5, 6, 18, 4, 9, 1, 1, nan, 1, 1, nan],
|
410
|
+
[nan, 6, 11, 4, 17, nan, 6, 1, 1, 2, 5, 1, 1]]
|
411
|
+
x = ma.fix_invalid(x).T
|
412
|
+
output = mstats.kendalltau_seasonal(x)
|
413
|
+
assert_almost_equal(output['global p-value (indep)'], 0.008, 3)
|
414
|
+
assert_almost_equal(output['seasonal p-value'].round(2),
|
415
|
+
[0.18,0.53,0.20,0.04])
|
416
|
+
|
417
|
+
@pytest.mark.parametrize("method", ("exact", "asymptotic"))
|
418
|
+
@pytest.mark.parametrize("alternative", ("two-sided", "greater", "less"))
|
419
|
+
def test_kendalltau_mstats_vs_stats(self, method, alternative):
|
420
|
+
# Test that mstats.kendalltau and stats.kendalltau with
|
421
|
+
# nan_policy='omit' matches behavior of stats.kendalltau
|
422
|
+
# Accuracy of the alternatives is tested in stats/tests/test_stats.py
|
423
|
+
|
424
|
+
np.random.seed(0)
|
425
|
+
n = 50
|
426
|
+
x = np.random.rand(n)
|
427
|
+
y = np.random.rand(n)
|
428
|
+
mask = np.random.rand(n) > 0.5
|
429
|
+
|
430
|
+
x_masked = ma.array(x, mask=mask)
|
431
|
+
y_masked = ma.array(y, mask=mask)
|
432
|
+
res_masked = mstats.kendalltau(
|
433
|
+
x_masked, y_masked, method=method, alternative=alternative)
|
434
|
+
|
435
|
+
x_compressed = x_masked.compressed()
|
436
|
+
y_compressed = y_masked.compressed()
|
437
|
+
res_compressed = stats.kendalltau(
|
438
|
+
x_compressed, y_compressed, method=method, alternative=alternative)
|
439
|
+
|
440
|
+
x[mask] = np.nan
|
441
|
+
y[mask] = np.nan
|
442
|
+
res_nan = stats.kendalltau(
|
443
|
+
x, y, method=method, nan_policy='omit', alternative=alternative)
|
444
|
+
|
445
|
+
assert_allclose(res_masked, res_compressed)
|
446
|
+
assert_allclose(res_nan, res_compressed)
|
447
|
+
|
448
|
+
def test_kendall_p_exact_medium(self):
|
449
|
+
# Test for the exact method with medium samples (some n >= 171)
|
450
|
+
# expected values generated using SymPy
|
451
|
+
expectations = {(100, 2393): 0.62822615287956040664,
|
452
|
+
(101, 2436): 0.60439525773513602669,
|
453
|
+
(170, 0): 2.755801935583541e-307,
|
454
|
+
(171, 0): 0.0,
|
455
|
+
(171, 1): 2.755801935583541e-307,
|
456
|
+
(172, 1): 0.0,
|
457
|
+
(200, 9797): 0.74753983745929675209,
|
458
|
+
(201, 9656): 0.40959218958120363618}
|
459
|
+
for nc, expected in expectations.items():
|
460
|
+
res = _mstats_basic._kendall_p_exact(nc[0], nc[1])
|
461
|
+
assert_almost_equal(res, expected)
|
462
|
+
|
463
|
+
@pytest.mark.xslow
|
464
|
+
def test_kendall_p_exact_large(self):
|
465
|
+
# Test for the exact method with large samples (n >= 171)
|
466
|
+
# expected values generated using SymPy
|
467
|
+
expectations = {(400, 38965): 0.48444283672113314099,
|
468
|
+
(401, 39516): 0.66363159823474837662,
|
469
|
+
(800, 156772): 0.42265448483120932055,
|
470
|
+
(801, 157849): 0.53437553412194416236,
|
471
|
+
(1600, 637472): 0.84200727400323538419,
|
472
|
+
(1601, 630304): 0.34465255088058593946}
|
473
|
+
|
474
|
+
for nc, expected in expectations.items():
|
475
|
+
res = _mstats_basic._kendall_p_exact(nc[0], nc[1])
|
476
|
+
assert_almost_equal(res, expected)
|
477
|
+
|
478
|
+
@skip_xp_invalid_arg
|
479
|
+
# mstats.pointbiserialr returns a NumPy float for the statistic, but converts
|
480
|
+
# it to a masked array with no masked elements before calling `special.betainc`,
|
481
|
+
# which won't accept masked arrays when `SCIPY_ARRAY_API=1`.
|
482
|
+
def test_pointbiserial(self):
|
483
|
+
x = [1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
|
484
|
+
0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, -1]
|
485
|
+
y = [14.8, 13.8, 12.4, 10.1, 7.1, 6.1, 5.8, 4.6, 4.3, 3.5, 3.3, 3.2,
|
486
|
+
3.0, 2.8, 2.8, 2.5, 2.4, 2.3, 2.1, 1.7, 1.7, 1.5, 1.3, 1.3, 1.2,
|
487
|
+
1.2, 1.1, 0.8, 0.7, 0.6, 0.5, 0.2, 0.2, 0.1, np.nan]
|
488
|
+
assert_almost_equal(mstats.pointbiserialr(x, y)[0], 0.36149, 5)
|
489
|
+
|
490
|
+
# test for namedtuple attributes
|
491
|
+
res = mstats.pointbiserialr(x, y)
|
492
|
+
attributes = ('correlation', 'pvalue')
|
493
|
+
check_named_results(res, attributes, ma=True)
|
494
|
+
|
495
|
+
|
496
|
+
@skip_xp_invalid_arg
|
497
|
+
class TestTrimming:
|
498
|
+
|
499
|
+
def test_trim(self):
|
500
|
+
a = ma.arange(10)
|
501
|
+
assert_equal(mstats.trim(a), [0,1,2,3,4,5,6,7,8,9])
|
502
|
+
a = ma.arange(10)
|
503
|
+
assert_equal(mstats.trim(a,(2,8)), [None,None,2,3,4,5,6,7,8,None])
|
504
|
+
a = ma.arange(10)
|
505
|
+
assert_equal(mstats.trim(a,limits=(2,8),inclusive=(False,False)),
|
506
|
+
[None,None,None,3,4,5,6,7,None,None])
|
507
|
+
a = ma.arange(10)
|
508
|
+
assert_equal(mstats.trim(a,limits=(0.1,0.2),relative=True),
|
509
|
+
[None,1,2,3,4,5,6,7,None,None])
|
510
|
+
|
511
|
+
a = ma.arange(12)
|
512
|
+
a[[0,-1]] = a[5] = masked
|
513
|
+
assert_equal(mstats.trim(a, (2,8)),
|
514
|
+
[None, None, 2, 3, 4, None, 6, 7, 8, None, None, None])
|
515
|
+
|
516
|
+
x = ma.arange(100).reshape(10, 10)
|
517
|
+
expected = [1]*10 + [0]*70 + [1]*20
|
518
|
+
trimx = mstats.trim(x, (0.1,0.2), relative=True, axis=None)
|
519
|
+
assert_equal(trimx._mask.ravel(), expected)
|
520
|
+
trimx = mstats.trim(x, (0.1,0.2), relative=True, axis=0)
|
521
|
+
assert_equal(trimx._mask.ravel(), expected)
|
522
|
+
trimx = mstats.trim(x, (0.1,0.2), relative=True, axis=-1)
|
523
|
+
assert_equal(trimx._mask.T.ravel(), expected)
|
524
|
+
|
525
|
+
# same as above, but with an extra masked row inserted
|
526
|
+
x = ma.arange(110).reshape(11, 10)
|
527
|
+
x[1] = masked
|
528
|
+
expected = [1]*20 + [0]*70 + [1]*20
|
529
|
+
trimx = mstats.trim(x, (0.1,0.2), relative=True, axis=None)
|
530
|
+
assert_equal(trimx._mask.ravel(), expected)
|
531
|
+
trimx = mstats.trim(x, (0.1,0.2), relative=True, axis=0)
|
532
|
+
assert_equal(trimx._mask.ravel(), expected)
|
533
|
+
trimx = mstats.trim(x.T, (0.1,0.2), relative=True, axis=-1)
|
534
|
+
assert_equal(trimx.T._mask.ravel(), expected)
|
535
|
+
|
536
|
+
def test_trim_old(self):
|
537
|
+
x = ma.arange(100)
|
538
|
+
assert_equal(mstats.trimboth(x).count(), 60)
|
539
|
+
assert_equal(mstats.trimtail(x,tail='r').count(), 80)
|
540
|
+
x[50:70] = masked
|
541
|
+
trimx = mstats.trimboth(x)
|
542
|
+
assert_equal(trimx.count(), 48)
|
543
|
+
assert_equal(trimx._mask, [1]*16 + [0]*34 + [1]*20 + [0]*14 + [1]*16)
|
544
|
+
x._mask = nomask
|
545
|
+
x.shape = (10,10)
|
546
|
+
assert_equal(mstats.trimboth(x).count(), 60)
|
547
|
+
assert_equal(mstats.trimtail(x).count(), 80)
|
548
|
+
|
549
|
+
def test_trimr(self):
|
550
|
+
x = ma.arange(10)
|
551
|
+
result = mstats.trimr(x, limits=(0.15, 0.14), inclusive=(False, False))
|
552
|
+
expected = ma.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
|
553
|
+
mask=[1, 1, 0, 0, 0, 0, 0, 0, 0, 1])
|
554
|
+
assert_equal(result, expected)
|
555
|
+
assert_equal(result.mask, expected.mask)
|
556
|
+
|
557
|
+
def test_trimmedmean(self):
|
558
|
+
data = ma.array([77, 87, 88,114,151,210,219,246,253,262,
|
559
|
+
296,299,306,376,428,515,666,1310,2611])
|
560
|
+
assert_almost_equal(mstats.trimmed_mean(data,0.1), 343, 0)
|
561
|
+
assert_almost_equal(mstats.trimmed_mean(data,(0.1,0.1)), 343, 0)
|
562
|
+
assert_almost_equal(mstats.trimmed_mean(data,(0.2,0.2)), 283, 0)
|
563
|
+
|
564
|
+
def test_trimmedvar(self):
|
565
|
+
# Basic test. Additional tests of all arguments, edge cases,
|
566
|
+
# input validation, and proper treatment of masked arrays are needed.
|
567
|
+
rng = np.random.default_rng(3262323289434724460)
|
568
|
+
data_orig = rng.random(size=20)
|
569
|
+
data = np.sort(data_orig)
|
570
|
+
data = ma.array(data, mask=[1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
571
|
+
0, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
572
|
+
assert_allclose(mstats.trimmed_var(data_orig, 0.1), data.var())
|
573
|
+
|
574
|
+
def test_trimmedstd(self):
|
575
|
+
# Basic test. Additional tests of all arguments, edge cases,
|
576
|
+
# input validation, and proper treatment of masked arrays are needed.
|
577
|
+
rng = np.random.default_rng(7121029245207162780)
|
578
|
+
data_orig = rng.random(size=20)
|
579
|
+
data = np.sort(data_orig)
|
580
|
+
data = ma.array(data, mask=[1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
581
|
+
0, 0, 0, 0, 0, 0, 0, 0, 1, 1])
|
582
|
+
assert_allclose(mstats.trimmed_std(data_orig, 0.1), data.std())
|
583
|
+
|
584
|
+
def test_trimmed_stde(self):
|
585
|
+
data = ma.array([77, 87, 88,114,151,210,219,246,253,262,
|
586
|
+
296,299,306,376,428,515,666,1310,2611])
|
587
|
+
assert_almost_equal(mstats.trimmed_stde(data,(0.2,0.2)), 56.13193, 5)
|
588
|
+
assert_almost_equal(mstats.trimmed_stde(data,0.2), 56.13193, 5)
|
589
|
+
|
590
|
+
def test_winsorization(self):
|
591
|
+
data = ma.array([77, 87, 88,114,151,210,219,246,253,262,
|
592
|
+
296,299,306,376,428,515,666,1310,2611])
|
593
|
+
assert_almost_equal(mstats.winsorize(data,(0.2,0.2)).var(ddof=1),
|
594
|
+
21551.4, 1)
|
595
|
+
assert_almost_equal(
|
596
|
+
mstats.winsorize(data, (0.2,0.2),(False,False)).var(ddof=1),
|
597
|
+
11887.3, 1)
|
598
|
+
data[5] = masked
|
599
|
+
winsorized = mstats.winsorize(data)
|
600
|
+
assert_equal(winsorized.mask, data.mask)
|
601
|
+
|
602
|
+
def test_winsorization_nan(self):
|
603
|
+
data = ma.array([np.nan, np.nan, 0, 1, 2])
|
604
|
+
assert_raises(ValueError, mstats.winsorize, data, (0.05, 0.05),
|
605
|
+
nan_policy='raise')
|
606
|
+
# Testing propagate (default behavior)
|
607
|
+
assert_equal(mstats.winsorize(data, (0.4, 0.4)),
|
608
|
+
ma.array([2, 2, 2, 2, 2]))
|
609
|
+
assert_equal(mstats.winsorize(data, (0.8, 0.8)),
|
610
|
+
ma.array([np.nan, np.nan, np.nan, np.nan, np.nan]))
|
611
|
+
assert_equal(mstats.winsorize(data, (0.4, 0.4), nan_policy='omit'),
|
612
|
+
ma.array([np.nan, np.nan, 2, 2, 2]))
|
613
|
+
assert_equal(mstats.winsorize(data, (0.8, 0.8), nan_policy='omit'),
|
614
|
+
ma.array([np.nan, np.nan, 2, 2, 2]))
|
615
|
+
|
616
|
+
|
617
|
+
@skip_xp_invalid_arg
|
618
|
+
class TestMoments:
|
619
|
+
# Comparison numbers are found using R v.1.5.1
|
620
|
+
# note that length(testcase) = 4
|
621
|
+
# testmathworks comes from documentation for the
|
622
|
+
# Statistics Toolbox for Matlab and can be found at both
|
623
|
+
# https://www.mathworks.com/help/stats/kurtosis.html
|
624
|
+
# https://www.mathworks.com/help/stats/skewness.html
|
625
|
+
# Note that both test cases came from here.
|
626
|
+
testcase = [1,2,3,4]
|
627
|
+
testmathworks = ma.fix_invalid([1.165, 0.6268, 0.0751, 0.3516, -0.6965,
|
628
|
+
np.nan])
|
629
|
+
testcase_2d = ma.array(
|
630
|
+
np.array([[0.05245846, 0.50344235, 0.86589117, 0.36936353, 0.46961149],
|
631
|
+
[0.11574073, 0.31299969, 0.45925772, 0.72618805, 0.75194407],
|
632
|
+
[0.67696689, 0.91878127, 0.09769044, 0.04645137, 0.37615733],
|
633
|
+
[0.05903624, 0.29908861, 0.34088298, 0.66216337, 0.83160998],
|
634
|
+
[0.64619526, 0.94894632, 0.27855892, 0.0706151, 0.39962917]]),
|
635
|
+
mask=np.array([[True, False, False, True, False],
|
636
|
+
[True, True, True, False, True],
|
637
|
+
[False, False, False, False, False],
|
638
|
+
[True, True, True, True, True],
|
639
|
+
[False, False, True, False, False]], dtype=bool))
|
640
|
+
|
641
|
+
def _assert_equal(self, actual, expect, *, shape=None, dtype=None):
|
642
|
+
expect = np.asarray(expect)
|
643
|
+
if shape is not None:
|
644
|
+
expect = np.broadcast_to(expect, shape)
|
645
|
+
assert_array_equal(actual, expect)
|
646
|
+
if dtype is None:
|
647
|
+
dtype = expect.dtype
|
648
|
+
assert actual.dtype == dtype
|
649
|
+
|
650
|
+
def test_moment(self):
|
651
|
+
y = mstats.moment(self.testcase,1)
|
652
|
+
assert_almost_equal(y,0.0,10)
|
653
|
+
y = mstats.moment(self.testcase,2)
|
654
|
+
assert_almost_equal(y,1.25)
|
655
|
+
y = mstats.moment(self.testcase,3)
|
656
|
+
assert_almost_equal(y,0.0)
|
657
|
+
y = mstats.moment(self.testcase,4)
|
658
|
+
assert_almost_equal(y,2.5625)
|
659
|
+
|
660
|
+
# check array_like input for moment
|
661
|
+
y = mstats.moment(self.testcase, [1, 2, 3, 4])
|
662
|
+
assert_allclose(y, [0, 1.25, 0, 2.5625])
|
663
|
+
|
664
|
+
# check moment input consists only of integers
|
665
|
+
y = mstats.moment(self.testcase, 0.0)
|
666
|
+
assert_allclose(y, 1.0)
|
667
|
+
assert_raises(ValueError, mstats.moment, self.testcase, 1.2)
|
668
|
+
y = mstats.moment(self.testcase, [1.0, 2, 3, 4.0])
|
669
|
+
assert_allclose(y, [0, 1.25, 0, 2.5625])
|
670
|
+
|
671
|
+
# test empty input
|
672
|
+
y = mstats.moment([])
|
673
|
+
self._assert_equal(y, np.nan, dtype=np.float64)
|
674
|
+
y = mstats.moment(np.array([], dtype=np.float32))
|
675
|
+
self._assert_equal(y, np.nan, dtype=np.float32)
|
676
|
+
y = mstats.moment(np.zeros((1, 0)), axis=0)
|
677
|
+
self._assert_equal(y, [], shape=(0,), dtype=np.float64)
|
678
|
+
y = mstats.moment([[]], axis=1)
|
679
|
+
self._assert_equal(y, np.nan, shape=(1,), dtype=np.float64)
|
680
|
+
y = mstats.moment([[]], moment=[0, 1], axis=0)
|
681
|
+
self._assert_equal(y, [], shape=(2, 0))
|
682
|
+
|
683
|
+
x = np.arange(10.)
|
684
|
+
x[9] = np.nan
|
685
|
+
assert_equal(mstats.moment(x, 2), ma.masked) # NaN value is ignored
|
686
|
+
|
687
|
+
def test_variation(self):
|
688
|
+
y = mstats.variation(self.testcase)
|
689
|
+
assert_almost_equal(y,0.44721359549996, 10)
|
690
|
+
|
691
|
+
def test_variation_ddof(self):
|
692
|
+
# test variation with delta degrees of freedom
|
693
|
+
# regression test for gh-13341
|
694
|
+
a = np.array([1, 2, 3, 4, 5])
|
695
|
+
y = mstats.variation(a, ddof=1)
|
696
|
+
assert_almost_equal(y, 0.5270462766947299)
|
697
|
+
|
698
|
+
def test_skewness(self):
|
699
|
+
y = mstats.skew(self.testmathworks)
|
700
|
+
assert_almost_equal(y,-0.29322304336607,10)
|
701
|
+
y = mstats.skew(self.testmathworks,bias=0)
|
702
|
+
assert_almost_equal(y,-0.437111105023940,10)
|
703
|
+
y = mstats.skew(self.testcase)
|
704
|
+
assert_almost_equal(y,0.0,10)
|
705
|
+
|
706
|
+
# test that skew works on multidimensional masked arrays
|
707
|
+
correct_2d = ma.array(
|
708
|
+
np.array([0.6882870394455785, 0, 0.2665647526856708,
|
709
|
+
0, -0.05211472114254485]),
|
710
|
+
mask=np.array([False, False, False, True, False], dtype=bool)
|
711
|
+
)
|
712
|
+
assert_allclose(mstats.skew(self.testcase_2d, 1), correct_2d)
|
713
|
+
for i, row in enumerate(self.testcase_2d):
|
714
|
+
assert_almost_equal(mstats.skew(row), correct_2d[i])
|
715
|
+
|
716
|
+
correct_2d_bias_corrected = ma.array(
|
717
|
+
np.array([1.685952043212545, 0.0, 0.3973712716070531, 0,
|
718
|
+
-0.09026534484117164]),
|
719
|
+
mask=np.array([False, False, False, True, False], dtype=bool)
|
720
|
+
)
|
721
|
+
assert_allclose(mstats.skew(self.testcase_2d, 1, bias=False),
|
722
|
+
correct_2d_bias_corrected)
|
723
|
+
for i, row in enumerate(self.testcase_2d):
|
724
|
+
assert_almost_equal(mstats.skew(row, bias=False),
|
725
|
+
correct_2d_bias_corrected[i])
|
726
|
+
|
727
|
+
# Check consistency between stats and mstats implementations
|
728
|
+
assert_allclose(mstats.skew(self.testcase_2d[2, :]),
|
729
|
+
stats.skew(self.testcase_2d[2, :]))
|
730
|
+
|
731
|
+
def test_kurtosis(self):
|
732
|
+
# Set flags for axis = 0 and fisher=0 (Pearson's definition of kurtosis
|
733
|
+
# for compatibility with Matlab)
|
734
|
+
y = mstats.kurtosis(self.testmathworks, 0, fisher=0, bias=1)
|
735
|
+
assert_almost_equal(y, 2.1658856802973, 10)
|
736
|
+
# Note that MATLAB has confusing docs for the following case
|
737
|
+
# kurtosis(x,0) gives an unbiased estimate of Pearson's skewness
|
738
|
+
# kurtosis(x) gives a biased estimate of Fisher's skewness (Pearson-3)
|
739
|
+
# The MATLAB docs imply that both should give Fisher's
|
740
|
+
y = mstats.kurtosis(self.testmathworks, fisher=0, bias=0)
|
741
|
+
assert_almost_equal(y, 3.663542721189047, 10)
|
742
|
+
y = mstats.kurtosis(self.testcase, 0, 0)
|
743
|
+
assert_almost_equal(y, 1.64)
|
744
|
+
|
745
|
+
# test that kurtosis works on multidimensional masked arrays
|
746
|
+
correct_2d = ma.array(np.array([-1.5, -3., -1.47247052385, 0.,
|
747
|
+
-1.26979517952]),
|
748
|
+
mask=np.array([False, False, False, True,
|
749
|
+
False], dtype=bool))
|
750
|
+
assert_array_almost_equal(mstats.kurtosis(self.testcase_2d, 1),
|
751
|
+
correct_2d)
|
752
|
+
for i, row in enumerate(self.testcase_2d):
|
753
|
+
assert_almost_equal(mstats.kurtosis(row), correct_2d[i])
|
754
|
+
|
755
|
+
correct_2d_bias_corrected = ma.array(
|
756
|
+
np.array([-1.5, -3., -1.88988209538, 0., -0.5234638463918877]),
|
757
|
+
mask=np.array([False, False, False, True, False], dtype=bool))
|
758
|
+
assert_array_almost_equal(mstats.kurtosis(self.testcase_2d, 1,
|
759
|
+
bias=False),
|
760
|
+
correct_2d_bias_corrected)
|
761
|
+
for i, row in enumerate(self.testcase_2d):
|
762
|
+
assert_almost_equal(mstats.kurtosis(row, bias=False),
|
763
|
+
correct_2d_bias_corrected[i])
|
764
|
+
|
765
|
+
# Check consistency between stats and mstats implementations
|
766
|
+
assert_array_almost_equal_nulp(mstats.kurtosis(self.testcase_2d[2, :]),
|
767
|
+
stats.kurtosis(self.testcase_2d[2, :]),
|
768
|
+
nulp=4)
|
769
|
+
|
770
|
+
|
771
|
+
class TestMode:
|
772
|
+
def test_mode(self):
|
773
|
+
a1 = [0,0,0,1,1,1,2,3,3,3,3,4,5,6,7]
|
774
|
+
a2 = np.reshape(a1, (3,5))
|
775
|
+
a3 = np.array([1,2,3,4,5,6])
|
776
|
+
a4 = np.reshape(a3, (3,2))
|
777
|
+
ma1 = ma.masked_where(ma.array(a1) > 2, a1)
|
778
|
+
ma2 = ma.masked_where(a2 > 2, a2)
|
779
|
+
ma3 = ma.masked_where(a3 < 2, a3)
|
780
|
+
ma4 = ma.masked_where(ma.array(a4) < 2, a4)
|
781
|
+
assert_equal(mstats.mode(a1, axis=None), (3,4))
|
782
|
+
assert_equal(mstats.mode(a1, axis=0), (3,4))
|
783
|
+
assert_equal(mstats.mode(ma1, axis=None), (0,3))
|
784
|
+
assert_equal(mstats.mode(a2, axis=None), (3,4))
|
785
|
+
assert_equal(mstats.mode(ma2, axis=None), (0,3))
|
786
|
+
assert_equal(mstats.mode(a3, axis=None), (1,1))
|
787
|
+
assert_equal(mstats.mode(ma3, axis=None), (2,1))
|
788
|
+
assert_equal(mstats.mode(a2, axis=0), ([[0,0,0,1,1]], [[1,1,1,1,1]]))
|
789
|
+
assert_equal(mstats.mode(ma2, axis=0), ([[0,0,0,1,1]], [[1,1,1,1,1]]))
|
790
|
+
assert_equal(mstats.mode(a2, axis=-1), ([[0],[3],[3]], [[3],[3],[1]]))
|
791
|
+
assert_equal(mstats.mode(ma2, axis=-1), ([[0],[1],[0]], [[3],[1],[0]]))
|
792
|
+
assert_equal(mstats.mode(ma4, axis=0), ([[3,2]], [[1,1]]))
|
793
|
+
assert_equal(mstats.mode(ma4, axis=-1), ([[2],[3],[5]], [[1],[1],[1]]))
|
794
|
+
|
795
|
+
a1_res = mstats.mode(a1, axis=None)
|
796
|
+
|
797
|
+
# test for namedtuple attributes
|
798
|
+
attributes = ('mode', 'count')
|
799
|
+
check_named_results(a1_res, attributes, ma=True)
|
800
|
+
|
801
|
+
def test_mode_modifies_input(self):
|
802
|
+
# regression test for gh-6428: mode(..., axis=None) may not modify
|
803
|
+
# the input array
|
804
|
+
im = np.zeros((100, 100))
|
805
|
+
im[:50, :] += 1
|
806
|
+
im[:, :50] += 1
|
807
|
+
cp = im.copy()
|
808
|
+
mstats.mode(im, None)
|
809
|
+
assert_equal(im, cp)
|
810
|
+
|
811
|
+
|
812
|
+
class TestPercentile:
|
813
|
+
def setup_method(self):
|
814
|
+
self.a1 = [3, 4, 5, 10, -3, -5, 6]
|
815
|
+
self.a2 = [3, -6, -2, 8, 7, 4, 2, 1]
|
816
|
+
self.a3 = [3., 4, 5, 10, -3, -5, -6, 7.0]
|
817
|
+
|
818
|
+
def test_percentile(self):
|
819
|
+
x = np.arange(8) * 0.5
|
820
|
+
assert_equal(mstats.scoreatpercentile(x, 0), 0.)
|
821
|
+
assert_equal(mstats.scoreatpercentile(x, 100), 3.5)
|
822
|
+
assert_equal(mstats.scoreatpercentile(x, 50), 1.75)
|
823
|
+
|
824
|
+
def test_2D(self):
|
825
|
+
x = ma.array([[1, 1, 1],
|
826
|
+
[1, 1, 1],
|
827
|
+
[4, 4, 3],
|
828
|
+
[1, 1, 1],
|
829
|
+
[1, 1, 1]])
|
830
|
+
assert_equal(mstats.scoreatpercentile(x, 50), [1, 1, 1])
|
831
|
+
|
832
|
+
|
833
|
+
@skip_xp_invalid_arg
|
834
|
+
class TestVariability:
|
835
|
+
""" Comparison numbers are found using R v.1.5.1
|
836
|
+
note that length(testcase) = 4
|
837
|
+
"""
|
838
|
+
testcase = ma.fix_invalid([1,2,3,4,np.nan])
|
839
|
+
|
840
|
+
def test_sem(self):
|
841
|
+
# This is not in R, so used: sqrt(var(testcase)*3/4) / sqrt(3)
|
842
|
+
y = mstats.sem(self.testcase)
|
843
|
+
assert_almost_equal(y, 0.6454972244)
|
844
|
+
n = self.testcase.count()
|
845
|
+
assert_allclose(mstats.sem(self.testcase, ddof=0) * np.sqrt(n/(n-2)),
|
846
|
+
mstats.sem(self.testcase, ddof=2))
|
847
|
+
|
848
|
+
def test_zmap(self):
|
849
|
+
# This is not in R, so tested by using:
|
850
|
+
# (testcase[i]-mean(testcase,axis=0)) / sqrt(var(testcase)*3/4)
|
851
|
+
y = mstats.zmap(self.testcase, self.testcase)
|
852
|
+
desired_unmaskedvals = ([-1.3416407864999, -0.44721359549996,
|
853
|
+
0.44721359549996, 1.3416407864999])
|
854
|
+
assert_array_almost_equal(desired_unmaskedvals,
|
855
|
+
y.data[y.mask == False], decimal=12) # noqa: E712
|
856
|
+
|
857
|
+
def test_zscore(self):
|
858
|
+
# This is not in R, so tested by using:
|
859
|
+
# (testcase[i]-mean(testcase,axis=0)) / sqrt(var(testcase)*3/4)
|
860
|
+
y = mstats.zscore(self.testcase)
|
861
|
+
desired = ma.fix_invalid([-1.3416407864999, -0.44721359549996,
|
862
|
+
0.44721359549996, 1.3416407864999, np.nan])
|
863
|
+
assert_almost_equal(desired, y, decimal=12)
|
864
|
+
|
865
|
+
|
866
|
+
@skip_xp_invalid_arg
|
867
|
+
class TestMisc:
|
868
|
+
|
869
|
+
def test_obrientransform(self):
|
870
|
+
args = [[5]*5+[6]*11+[7]*9+[8]*3+[9]*2+[10]*2,
|
871
|
+
[6]+[7]*2+[8]*4+[9]*9+[10]*16]
|
872
|
+
result = [5*[3.1828]+11*[0.5591]+9*[0.0344]+3*[1.6086]+2*[5.2817]+2*[11.0538],
|
873
|
+
[10.4352]+2*[4.8599]+4*[1.3836]+9*[0.0061]+16*[0.7277]]
|
874
|
+
assert_almost_equal(np.round(mstats.obrientransform(*args).T, 4),
|
875
|
+
result, 4)
|
876
|
+
|
877
|
+
def test_ks_2samp(self):
|
878
|
+
x = [[nan,nan, 4, 2, 16, 26, 5, 1, 5, 1, 2, 3, 1],
|
879
|
+
[4, 3, 5, 3, 2, 7, 3, 1, 1, 2, 3, 5, 3],
|
880
|
+
[3, 2, 5, 6, 18, 4, 9, 1, 1, nan, 1, 1, nan],
|
881
|
+
[nan, 6, 11, 4, 17, nan, 6, 1, 1, 2, 5, 1, 1]]
|
882
|
+
x = ma.fix_invalid(x).T
|
883
|
+
(winter, spring, summer, fall) = x.T
|
884
|
+
|
885
|
+
assert_almost_equal(np.round(mstats.ks_2samp(winter, spring), 4),
|
886
|
+
(0.1818, 0.9628))
|
887
|
+
assert_almost_equal(np.round(mstats.ks_2samp(winter, spring, 'g'), 4),
|
888
|
+
(0.1469, 0.6886))
|
889
|
+
assert_almost_equal(np.round(mstats.ks_2samp(winter, spring, 'l'), 4),
|
890
|
+
(0.1818, 0.6011))
|
891
|
+
|
892
|
+
def test_friedmanchisq(self):
|
893
|
+
# No missing values
|
894
|
+
args = ([9.0,9.5,5.0,7.5,9.5,7.5,8.0,7.0,8.5,6.0],
|
895
|
+
[7.0,6.5,7.0,7.5,5.0,8.0,6.0,6.5,7.0,7.0],
|
896
|
+
[6.0,8.0,4.0,6.0,7.0,6.5,6.0,4.0,6.5,3.0])
|
897
|
+
result = mstats.friedmanchisquare(*args)
|
898
|
+
assert_almost_equal(result[0], 10.4737, 4)
|
899
|
+
assert_almost_equal(result[1], 0.005317, 6)
|
900
|
+
# Missing values
|
901
|
+
x = [[nan,nan, 4, 2, 16, 26, 5, 1, 5, 1, 2, 3, 1],
|
902
|
+
[4, 3, 5, 3, 2, 7, 3, 1, 1, 2, 3, 5, 3],
|
903
|
+
[3, 2, 5, 6, 18, 4, 9, 1, 1,nan, 1, 1,nan],
|
904
|
+
[nan, 6, 11, 4, 17,nan, 6, 1, 1, 2, 5, 1, 1]]
|
905
|
+
x = ma.fix_invalid(x)
|
906
|
+
result = mstats.friedmanchisquare(*x)
|
907
|
+
assert_almost_equal(result[0], 2.0156, 4)
|
908
|
+
assert_almost_equal(result[1], 0.5692, 4)
|
909
|
+
|
910
|
+
# test for namedtuple attributes
|
911
|
+
attributes = ('statistic', 'pvalue')
|
912
|
+
check_named_results(result, attributes, ma=True)
|
913
|
+
|
914
|
+
|
915
|
+
def test_regress_simple():
|
916
|
+
# Regress a line with sinusoidal noise. Test for #1273.
|
917
|
+
x = np.linspace(0, 100, 100)
|
918
|
+
y = 0.2 * np.linspace(0, 100, 100) + 10
|
919
|
+
y += np.sin(np.linspace(0, 20, 100))
|
920
|
+
|
921
|
+
result = mstats.linregress(x, y)
|
922
|
+
|
923
|
+
# Result is of a correct class and with correct fields
|
924
|
+
lr = _stats_py.LinregressResult
|
925
|
+
assert_(isinstance(result, lr))
|
926
|
+
attributes = ('slope', 'intercept', 'rvalue', 'pvalue', 'stderr')
|
927
|
+
check_named_results(result, attributes, ma=True)
|
928
|
+
assert 'intercept_stderr' in dir(result)
|
929
|
+
|
930
|
+
# Slope and intercept are estimated correctly
|
931
|
+
assert_almost_equal(result.slope, 0.19644990055858422)
|
932
|
+
assert_almost_equal(result.intercept, 10.211269918932341)
|
933
|
+
assert_almost_equal(result.stderr, 0.002395781449783862)
|
934
|
+
assert_almost_equal(result.intercept_stderr, 0.13866936078570702)
|
935
|
+
|
936
|
+
|
937
|
+
def test_linregress_identical_x():
|
938
|
+
x = np.zeros(10)
|
939
|
+
y = np.random.random(10)
|
940
|
+
msg = "Cannot calculate a linear regression if all x values are identical"
|
941
|
+
with assert_raises(ValueError, match=msg):
|
942
|
+
mstats.linregress(x, y)
|
943
|
+
|
944
|
+
|
945
|
+
class TestTheilslopes:
|
946
|
+
def test_theilslopes(self):
|
947
|
+
# Test for basic slope and intercept.
|
948
|
+
slope, intercept, lower, upper = mstats.theilslopes([0, 1, 1])
|
949
|
+
assert_almost_equal(slope, 0.5)
|
950
|
+
assert_almost_equal(intercept, 0.5)
|
951
|
+
|
952
|
+
slope, intercept, lower, upper = mstats.theilslopes([0, 1, 1],
|
953
|
+
method='joint')
|
954
|
+
assert_almost_equal(slope, 0.5)
|
955
|
+
assert_almost_equal(intercept, 0.0)
|
956
|
+
|
957
|
+
# Test for correct masking.
|
958
|
+
y = np.ma.array([0, 1, 100, 1], mask=[False, False, True, False])
|
959
|
+
slope, intercept, lower, upper = mstats.theilslopes(y)
|
960
|
+
assert_almost_equal(slope, 1./3)
|
961
|
+
assert_almost_equal(intercept, 2./3)
|
962
|
+
|
963
|
+
slope, intercept, lower, upper = mstats.theilslopes(y,
|
964
|
+
method='joint')
|
965
|
+
assert_almost_equal(slope, 1./3)
|
966
|
+
assert_almost_equal(intercept, 0.0)
|
967
|
+
|
968
|
+
# Test of confidence intervals from example in Sen (1968).
|
969
|
+
x = [1, 2, 3, 4, 10, 12, 18]
|
970
|
+
y = [9, 15, 19, 20, 45, 55, 78]
|
971
|
+
slope, intercept, lower, upper = mstats.theilslopes(y, x, 0.07)
|
972
|
+
assert_almost_equal(slope, 4)
|
973
|
+
assert_almost_equal(intercept, 4.0)
|
974
|
+
assert_almost_equal(upper, 4.38, decimal=2)
|
975
|
+
assert_almost_equal(lower, 3.71, decimal=2)
|
976
|
+
|
977
|
+
slope, intercept, lower, upper = mstats.theilslopes(y, x, 0.07,
|
978
|
+
method='joint')
|
979
|
+
assert_almost_equal(slope, 4)
|
980
|
+
assert_almost_equal(intercept, 6.0)
|
981
|
+
assert_almost_equal(upper, 4.38, decimal=2)
|
982
|
+
assert_almost_equal(lower, 3.71, decimal=2)
|
983
|
+
|
984
|
+
|
985
|
+
def test_theilslopes_warnings(self):
|
986
|
+
# Test `theilslopes` with degenerate input; see gh-15943
|
987
|
+
msg = "All `x` coordinates.*|Mean of empty slice.|invalid value encountered.*"
|
988
|
+
with pytest.warns(RuntimeWarning, match=msg):
|
989
|
+
res = mstats.theilslopes([0, 1], [0, 0])
|
990
|
+
assert np.all(np.isnan(res))
|
991
|
+
with suppress_warnings() as sup:
|
992
|
+
sup.filter(RuntimeWarning, "invalid value encountered...")
|
993
|
+
res = mstats.theilslopes([0, 0, 0], [0, 1, 0])
|
994
|
+
assert_allclose(res, (0, 0, np.nan, np.nan))
|
995
|
+
|
996
|
+
|
997
|
+
def test_theilslopes_namedtuple_consistency(self):
|
998
|
+
"""
|
999
|
+
Simple test to ensure tuple backwards-compatibility of the returned
|
1000
|
+
TheilslopesResult object
|
1001
|
+
"""
|
1002
|
+
y = [1, 2, 4]
|
1003
|
+
x = [4, 6, 8]
|
1004
|
+
slope, intercept, low_slope, high_slope = mstats.theilslopes(y, x)
|
1005
|
+
result = mstats.theilslopes(y, x)
|
1006
|
+
|
1007
|
+
# note all four returned values are distinct here
|
1008
|
+
assert_equal(slope, result.slope)
|
1009
|
+
assert_equal(intercept, result.intercept)
|
1010
|
+
assert_equal(low_slope, result.low_slope)
|
1011
|
+
assert_equal(high_slope, result.high_slope)
|
1012
|
+
|
1013
|
+
def test_gh19678_uint8(self):
|
1014
|
+
# `theilslopes` returned unexpected results when `y` was an unsigned type.
|
1015
|
+
# Check that this is resolved.
|
1016
|
+
rng = np.random.default_rng(2549824598234528)
|
1017
|
+
y = rng.integers(0, 255, size=10, dtype=np.uint8)
|
1018
|
+
res = stats.theilslopes(y, y)
|
1019
|
+
np.testing.assert_allclose(res.slope, 1)
|
1020
|
+
|
1021
|
+
|
1022
|
+
def test_siegelslopes():
|
1023
|
+
# method should be exact for straight line
|
1024
|
+
y = 2 * np.arange(10) + 0.5
|
1025
|
+
assert_equal(mstats.siegelslopes(y), (2.0, 0.5))
|
1026
|
+
assert_equal(mstats.siegelslopes(y, method='separate'), (2.0, 0.5))
|
1027
|
+
|
1028
|
+
x = 2 * np.arange(10)
|
1029
|
+
y = 5 * x - 3.0
|
1030
|
+
assert_equal(mstats.siegelslopes(y, x), (5.0, -3.0))
|
1031
|
+
assert_equal(mstats.siegelslopes(y, x, method='separate'), (5.0, -3.0))
|
1032
|
+
|
1033
|
+
# method is robust to outliers: brekdown point of 50%
|
1034
|
+
y[:4] = 1000
|
1035
|
+
assert_equal(mstats.siegelslopes(y, x), (5.0, -3.0))
|
1036
|
+
|
1037
|
+
# if there are no outliers, results should be comparable to linregress
|
1038
|
+
x = np.arange(10)
|
1039
|
+
y = -2.3 + 0.3*x + stats.norm.rvs(size=10, random_state=231)
|
1040
|
+
slope_ols, intercept_ols, _, _, _ = stats.linregress(x, y)
|
1041
|
+
|
1042
|
+
slope, intercept = mstats.siegelslopes(y, x)
|
1043
|
+
assert_allclose(slope, slope_ols, rtol=0.1)
|
1044
|
+
assert_allclose(intercept, intercept_ols, rtol=0.1)
|
1045
|
+
|
1046
|
+
slope, intercept = mstats.siegelslopes(y, x, method='separate')
|
1047
|
+
assert_allclose(slope, slope_ols, rtol=0.1)
|
1048
|
+
assert_allclose(intercept, intercept_ols, rtol=0.1)
|
1049
|
+
|
1050
|
+
|
1051
|
+
def test_siegelslopes_namedtuple_consistency():
|
1052
|
+
"""
|
1053
|
+
Simple test to ensure tuple backwards-compatibility of the returned
|
1054
|
+
SiegelslopesResult object.
|
1055
|
+
"""
|
1056
|
+
y = [1, 2, 4]
|
1057
|
+
x = [4, 6, 8]
|
1058
|
+
slope, intercept = mstats.siegelslopes(y, x)
|
1059
|
+
result = mstats.siegelslopes(y, x)
|
1060
|
+
|
1061
|
+
# note both returned values are distinct here
|
1062
|
+
assert_equal(slope, result.slope)
|
1063
|
+
assert_equal(intercept, result.intercept)
|
1064
|
+
|
1065
|
+
|
1066
|
+
def test_sen_seasonal_slopes():
|
1067
|
+
rng = np.random.default_rng(5765986256978575148)
|
1068
|
+
x = rng.random(size=(100, 4))
|
1069
|
+
intra_slope, inter_slope = mstats.sen_seasonal_slopes(x)
|
1070
|
+
|
1071
|
+
# reference implementation from the `sen_seasonal_slopes` documentation
|
1072
|
+
def dijk(yi):
|
1073
|
+
n = len(yi)
|
1074
|
+
x = np.arange(n)
|
1075
|
+
dy = yi - yi[:, np.newaxis]
|
1076
|
+
dx = x - x[:, np.newaxis]
|
1077
|
+
mask = np.triu(np.ones((n, n), dtype=bool), k=1)
|
1078
|
+
return dy[mask]/dx[mask]
|
1079
|
+
|
1080
|
+
for i in range(4):
|
1081
|
+
assert_allclose(np.median(dijk(x[:, i])), intra_slope[i])
|
1082
|
+
|
1083
|
+
all_slopes = np.concatenate([dijk(x[:, i]) for i in range(x.shape[1])])
|
1084
|
+
assert_allclose(np.median(all_slopes), inter_slope)
|
1085
|
+
|
1086
|
+
|
1087
|
+
def test_plotting_positions():
|
1088
|
+
# Regression test for #1256
|
1089
|
+
pos = mstats.plotting_positions(np.arange(3), 0, 0)
|
1090
|
+
assert_array_almost_equal(pos.data, np.array([0.25, 0.5, 0.75]))
|
1091
|
+
|
1092
|
+
|
1093
|
+
@skip_xp_invalid_arg
|
1094
|
+
class TestNormalitytests:
|
1095
|
+
|
1096
|
+
def test_vs_nonmasked(self):
|
1097
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1098
|
+
assert_array_almost_equal(mstats.normaltest(x),
|
1099
|
+
stats.normaltest(x))
|
1100
|
+
assert_array_almost_equal(mstats.skewtest(x),
|
1101
|
+
stats.skewtest(x))
|
1102
|
+
assert_array_almost_equal(mstats.kurtosistest(x),
|
1103
|
+
stats.kurtosistest(x))
|
1104
|
+
|
1105
|
+
funcs = [stats.normaltest, stats.skewtest, stats.kurtosistest]
|
1106
|
+
mfuncs = [mstats.normaltest, mstats.skewtest, mstats.kurtosistest]
|
1107
|
+
x = [1, 2, 3, 4]
|
1108
|
+
for func, mfunc in zip(funcs, mfuncs):
|
1109
|
+
with pytest.warns(SmallSampleWarning, match=too_small_1d_not_omit):
|
1110
|
+
res = func(x)
|
1111
|
+
assert np.isnan(res.statistic)
|
1112
|
+
assert np.isnan(res.pvalue)
|
1113
|
+
assert_raises(ValueError, mfunc, x)
|
1114
|
+
|
1115
|
+
def test_axis_None(self):
|
1116
|
+
# Test axis=None (equal to axis=0 for 1-D input)
|
1117
|
+
x = np.array((-2,-1,0,1,2,3)*4)**2
|
1118
|
+
assert_allclose(mstats.normaltest(x, axis=None), mstats.normaltest(x))
|
1119
|
+
assert_allclose(mstats.skewtest(x, axis=None), mstats.skewtest(x))
|
1120
|
+
assert_allclose(mstats.kurtosistest(x, axis=None),
|
1121
|
+
mstats.kurtosistest(x))
|
1122
|
+
|
1123
|
+
def test_maskedarray_input(self):
|
1124
|
+
# Add some masked values, test result doesn't change
|
1125
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1126
|
+
xm = np.ma.array(np.r_[np.inf, x, 10],
|
1127
|
+
mask=np.r_[True, [False] * x.size, True])
|
1128
|
+
assert_allclose(mstats.normaltest(xm), stats.normaltest(x))
|
1129
|
+
assert_allclose(mstats.skewtest(xm), stats.skewtest(x))
|
1130
|
+
assert_allclose(mstats.kurtosistest(xm), stats.kurtosistest(x))
|
1131
|
+
|
1132
|
+
def test_nd_input(self):
|
1133
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1134
|
+
x_2d = np.vstack([x] * 2).T
|
1135
|
+
for func in [mstats.normaltest, mstats.skewtest, mstats.kurtosistest]:
|
1136
|
+
res_1d = func(x)
|
1137
|
+
res_2d = func(x_2d)
|
1138
|
+
assert_allclose(res_2d[0], [res_1d[0]] * 2)
|
1139
|
+
assert_allclose(res_2d[1], [res_1d[1]] * 2)
|
1140
|
+
|
1141
|
+
def test_normaltest_result_attributes(self):
|
1142
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1143
|
+
res = mstats.normaltest(x)
|
1144
|
+
attributes = ('statistic', 'pvalue')
|
1145
|
+
check_named_results(res, attributes, ma=True)
|
1146
|
+
|
1147
|
+
def test_kurtosistest_result_attributes(self):
|
1148
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1149
|
+
res = mstats.kurtosistest(x)
|
1150
|
+
attributes = ('statistic', 'pvalue')
|
1151
|
+
check_named_results(res, attributes, ma=True)
|
1152
|
+
|
1153
|
+
def test_regression_9033(self):
|
1154
|
+
# x clearly non-normal but power of negative denom needs
|
1155
|
+
# to be handled correctly to reject normality
|
1156
|
+
counts = [128, 0, 58, 7, 0, 41, 16, 0, 0, 167]
|
1157
|
+
x = np.hstack([np.full(c, i) for i, c in enumerate(counts)])
|
1158
|
+
assert_equal(mstats.kurtosistest(x)[1] < 0.01, True)
|
1159
|
+
|
1160
|
+
@pytest.mark.parametrize("test", ["skewtest", "kurtosistest"])
|
1161
|
+
@pytest.mark.parametrize("alternative", ["less", "greater"])
|
1162
|
+
def test_alternative(self, test, alternative):
|
1163
|
+
x = stats.norm.rvs(loc=10, scale=2.5, size=30, random_state=123)
|
1164
|
+
|
1165
|
+
stats_test = getattr(stats, test)
|
1166
|
+
mstats_test = getattr(mstats, test)
|
1167
|
+
|
1168
|
+
z_ex, p_ex = stats_test(x, alternative=alternative)
|
1169
|
+
z, p = mstats_test(x, alternative=alternative)
|
1170
|
+
assert_allclose(z, z_ex, atol=1e-12)
|
1171
|
+
assert_allclose(p, p_ex, atol=1e-12)
|
1172
|
+
|
1173
|
+
# test with masked arrays
|
1174
|
+
x[1:5] = np.nan
|
1175
|
+
x = np.ma.masked_array(x, mask=np.isnan(x))
|
1176
|
+
z_ex, p_ex = stats_test(x.compressed(), alternative=alternative)
|
1177
|
+
z, p = mstats_test(x, alternative=alternative)
|
1178
|
+
assert_allclose(z, z_ex, atol=1e-12)
|
1179
|
+
assert_allclose(p, p_ex, atol=1e-12)
|
1180
|
+
|
1181
|
+
def test_bad_alternative(self):
|
1182
|
+
x = stats.norm.rvs(size=20, random_state=123)
|
1183
|
+
msg = r"`alternative` must be..."
|
1184
|
+
|
1185
|
+
with pytest.raises(ValueError, match=msg):
|
1186
|
+
mstats.skewtest(x, alternative='error')
|
1187
|
+
|
1188
|
+
with pytest.raises(ValueError, match=msg):
|
1189
|
+
mstats.kurtosistest(x, alternative='error')
|
1190
|
+
|
1191
|
+
|
1192
|
+
class TestFOneway:
|
1193
|
+
def test_result_attributes(self):
|
1194
|
+
a = np.array([655, 788], dtype=np.uint16)
|
1195
|
+
b = np.array([789, 772], dtype=np.uint16)
|
1196
|
+
res = mstats.f_oneway(a, b)
|
1197
|
+
attributes = ('statistic', 'pvalue')
|
1198
|
+
check_named_results(res, attributes, ma=True)
|
1199
|
+
|
1200
|
+
|
1201
|
+
class TestMannwhitneyu:
|
1202
|
+
# data from gh-1428
|
1203
|
+
x = np.array([1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1204
|
+
1., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 1.,
|
1205
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1206
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1207
|
+
1., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 1.,
|
1208
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1209
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 2.,
|
1210
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1211
|
+
1., 1., 2., 1., 1., 1., 1., 2., 1., 1., 2., 1., 1., 2.,
|
1212
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1213
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 2., 1.,
|
1214
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1215
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1216
|
+
1., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 1.,
|
1217
|
+
1., 1., 1., 2., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1218
|
+
1., 1., 1., 1., 1., 1., 1., 1., 3., 1., 1., 1., 1., 1.,
|
1219
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1220
|
+
1., 1., 1., 1., 1., 1.])
|
1221
|
+
|
1222
|
+
y = np.array([1., 1., 1., 1., 1., 1., 1., 2., 1., 2., 1., 1., 1., 1.,
|
1223
|
+
2., 1., 1., 1., 2., 1., 1., 1., 1., 1., 2., 1., 1., 3.,
|
1224
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 2., 1., 2., 1.,
|
1225
|
+
1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1226
|
+
1., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1., 2.,
|
1227
|
+
2., 1., 1., 2., 1., 1., 2., 1., 2., 1., 1., 1., 1., 2.,
|
1228
|
+
2., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1229
|
+
1., 2., 1., 1., 1., 1., 1., 2., 2., 2., 1., 1., 1., 1.,
|
1230
|
+
1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
|
1231
|
+
2., 1., 1., 2., 1., 1., 1., 1., 2., 1., 1., 1., 1., 1.,
|
1232
|
+
1., 1., 1., 1., 1., 1., 1., 2., 1., 1., 1., 2., 1., 1.,
|
1233
|
+
1., 1., 1., 1.])
|
1234
|
+
|
1235
|
+
def test_result_attributes(self):
|
1236
|
+
res = mstats.mannwhitneyu(self.x, self.y)
|
1237
|
+
attributes = ('statistic', 'pvalue')
|
1238
|
+
check_named_results(res, attributes, ma=True)
|
1239
|
+
|
1240
|
+
def test_against_stats(self):
|
1241
|
+
# gh-4641 reported that stats.mannwhitneyu returned half the p-value
|
1242
|
+
# of mstats.mannwhitneyu. Default alternative of stats.mannwhitneyu
|
1243
|
+
# is now two-sided, so they match.
|
1244
|
+
res1 = mstats.mannwhitneyu(self.x, self.y)
|
1245
|
+
res2 = stats.mannwhitneyu(self.x, self.y)
|
1246
|
+
assert res1.statistic == res2.statistic
|
1247
|
+
assert_allclose(res1.pvalue, res2.pvalue)
|
1248
|
+
|
1249
|
+
|
1250
|
+
class TestKruskal:
|
1251
|
+
def test_result_attributes(self):
|
1252
|
+
x = [1, 3, 5, 7, 9]
|
1253
|
+
y = [2, 4, 6, 8, 10]
|
1254
|
+
|
1255
|
+
res = mstats.kruskal(x, y)
|
1256
|
+
attributes = ('statistic', 'pvalue')
|
1257
|
+
check_named_results(res, attributes, ma=True)
|
1258
|
+
|
1259
|
+
|
1260
|
+
# TODO: for all ttest functions, add tests with masked array inputs
|
1261
|
+
class TestTtest_rel:
|
1262
|
+
def test_vs_nonmasked(self):
|
1263
|
+
np.random.seed(1234567)
|
1264
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1265
|
+
|
1266
|
+
# 1-D inputs
|
1267
|
+
res1 = stats.ttest_rel(outcome[:, 0], outcome[:, 1])
|
1268
|
+
res2 = mstats.ttest_rel(outcome[:, 0], outcome[:, 1])
|
1269
|
+
assert_allclose(res1, res2)
|
1270
|
+
|
1271
|
+
# 2-D inputs
|
1272
|
+
res1 = stats.ttest_rel(outcome[:, 0], outcome[:, 1], axis=None)
|
1273
|
+
res2 = mstats.ttest_rel(outcome[:, 0], outcome[:, 1], axis=None)
|
1274
|
+
assert_allclose(res1, res2)
|
1275
|
+
res1 = stats.ttest_rel(outcome[:, :2], outcome[:, 2:], axis=0)
|
1276
|
+
res2 = mstats.ttest_rel(outcome[:, :2], outcome[:, 2:], axis=0)
|
1277
|
+
assert_allclose(res1, res2)
|
1278
|
+
|
1279
|
+
# Check default is axis=0
|
1280
|
+
res3 = mstats.ttest_rel(outcome[:, :2], outcome[:, 2:])
|
1281
|
+
assert_allclose(res2, res3)
|
1282
|
+
|
1283
|
+
def test_fully_masked(self):
|
1284
|
+
np.random.seed(1234567)
|
1285
|
+
outcome = ma.masked_array(np.random.randn(3, 2),
|
1286
|
+
mask=[[1, 1, 1], [0, 0, 0]])
|
1287
|
+
with suppress_warnings() as sup:
|
1288
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1289
|
+
for pair in [(outcome[:, 0], outcome[:, 1]),
|
1290
|
+
([np.nan, np.nan], [1.0, 2.0])]:
|
1291
|
+
t, p = mstats.ttest_rel(*pair)
|
1292
|
+
assert_array_equal(t, (np.nan, np.nan))
|
1293
|
+
assert_array_equal(p, (np.nan, np.nan))
|
1294
|
+
|
1295
|
+
def test_result_attributes(self):
|
1296
|
+
np.random.seed(1234567)
|
1297
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1298
|
+
|
1299
|
+
res = mstats.ttest_rel(outcome[:, 0], outcome[:, 1])
|
1300
|
+
attributes = ('statistic', 'pvalue')
|
1301
|
+
check_named_results(res, attributes, ma=True)
|
1302
|
+
|
1303
|
+
def test_invalid_input_size(self):
|
1304
|
+
assert_raises(ValueError, mstats.ttest_rel,
|
1305
|
+
np.arange(10), np.arange(11))
|
1306
|
+
x = np.arange(24)
|
1307
|
+
assert_raises(ValueError, mstats.ttest_rel,
|
1308
|
+
x.reshape(2, 3, 4), x.reshape(2, 4, 3), axis=1)
|
1309
|
+
assert_raises(ValueError, mstats.ttest_rel,
|
1310
|
+
x.reshape(2, 3, 4), x.reshape(2, 4, 3), axis=2)
|
1311
|
+
|
1312
|
+
def test_empty(self):
|
1313
|
+
res1 = mstats.ttest_rel([], [])
|
1314
|
+
assert_(np.all(np.isnan(res1)))
|
1315
|
+
|
1316
|
+
def test_zero_division(self):
|
1317
|
+
t, p = mstats.ttest_ind([0, 0, 0], [1, 1, 1])
|
1318
|
+
assert_equal((np.abs(t), p), (np.inf, 0))
|
1319
|
+
|
1320
|
+
with suppress_warnings() as sup:
|
1321
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1322
|
+
t, p = mstats.ttest_ind([0, 0, 0], [0, 0, 0])
|
1323
|
+
assert_array_equal(t, np.array([np.nan, np.nan]))
|
1324
|
+
assert_array_equal(p, np.array([np.nan, np.nan]))
|
1325
|
+
|
1326
|
+
def test_bad_alternative(self):
|
1327
|
+
msg = r"alternative must be 'less', 'greater' or 'two-sided'"
|
1328
|
+
with pytest.raises(ValueError, match=msg):
|
1329
|
+
mstats.ttest_ind([1, 2, 3], [4, 5, 6], alternative='foo')
|
1330
|
+
|
1331
|
+
@pytest.mark.parametrize("alternative", ["less", "greater"])
|
1332
|
+
def test_alternative(self, alternative):
|
1333
|
+
x = stats.norm.rvs(loc=10, scale=5, size=25, random_state=42)
|
1334
|
+
y = stats.norm.rvs(loc=8, scale=2, size=25, random_state=42)
|
1335
|
+
|
1336
|
+
t_ex, p_ex = stats.ttest_rel(x, y, alternative=alternative)
|
1337
|
+
t, p = mstats.ttest_rel(x, y, alternative=alternative)
|
1338
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1339
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1340
|
+
|
1341
|
+
# test with masked arrays
|
1342
|
+
x[1:10] = np.nan
|
1343
|
+
y[1:10] = np.nan
|
1344
|
+
x = np.ma.masked_array(x, mask=np.isnan(x))
|
1345
|
+
y = np.ma.masked_array(y, mask=np.isnan(y))
|
1346
|
+
t, p = mstats.ttest_rel(x, y, alternative=alternative)
|
1347
|
+
t_ex, p_ex = stats.ttest_rel(x.compressed(), y.compressed(),
|
1348
|
+
alternative=alternative)
|
1349
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1350
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1351
|
+
|
1352
|
+
|
1353
|
+
class TestTtest_ind:
|
1354
|
+
def test_vs_nonmasked(self):
|
1355
|
+
np.random.seed(1234567)
|
1356
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1357
|
+
|
1358
|
+
# 1-D inputs
|
1359
|
+
res1 = stats.ttest_ind(outcome[:, 0], outcome[:, 1])
|
1360
|
+
res2 = mstats.ttest_ind(outcome[:, 0], outcome[:, 1])
|
1361
|
+
assert_allclose(res1, res2)
|
1362
|
+
|
1363
|
+
# 2-D inputs
|
1364
|
+
res1 = stats.ttest_ind(outcome[:, 0], outcome[:, 1], axis=None)
|
1365
|
+
res2 = mstats.ttest_ind(outcome[:, 0], outcome[:, 1], axis=None)
|
1366
|
+
assert_allclose(res1, res2)
|
1367
|
+
res1 = stats.ttest_ind(outcome[:, :2], outcome[:, 2:], axis=0)
|
1368
|
+
res2 = mstats.ttest_ind(outcome[:, :2], outcome[:, 2:], axis=0)
|
1369
|
+
assert_allclose(res1, res2)
|
1370
|
+
|
1371
|
+
# Check default is axis=0
|
1372
|
+
res3 = mstats.ttest_ind(outcome[:, :2], outcome[:, 2:])
|
1373
|
+
assert_allclose(res2, res3)
|
1374
|
+
|
1375
|
+
# Check equal_var
|
1376
|
+
res4 = stats.ttest_ind(outcome[:, 0], outcome[:, 1], equal_var=True)
|
1377
|
+
res5 = mstats.ttest_ind(outcome[:, 0], outcome[:, 1], equal_var=True)
|
1378
|
+
assert_allclose(res4, res5)
|
1379
|
+
res4 = stats.ttest_ind(outcome[:, 0], outcome[:, 1], equal_var=False)
|
1380
|
+
res5 = mstats.ttest_ind(outcome[:, 0], outcome[:, 1], equal_var=False)
|
1381
|
+
assert_allclose(res4, res5)
|
1382
|
+
|
1383
|
+
def test_fully_masked(self):
|
1384
|
+
np.random.seed(1234567)
|
1385
|
+
outcome = ma.masked_array(np.random.randn(3, 2), mask=[[1, 1, 1], [0, 0, 0]])
|
1386
|
+
with suppress_warnings() as sup:
|
1387
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1388
|
+
for pair in [(outcome[:, 0], outcome[:, 1]),
|
1389
|
+
([np.nan, np.nan], [1.0, 2.0])]:
|
1390
|
+
t, p = mstats.ttest_ind(*pair)
|
1391
|
+
assert_array_equal(t, (np.nan, np.nan))
|
1392
|
+
assert_array_equal(p, (np.nan, np.nan))
|
1393
|
+
|
1394
|
+
def test_result_attributes(self):
|
1395
|
+
np.random.seed(1234567)
|
1396
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1397
|
+
|
1398
|
+
res = mstats.ttest_ind(outcome[:, 0], outcome[:, 1])
|
1399
|
+
attributes = ('statistic', 'pvalue')
|
1400
|
+
check_named_results(res, attributes, ma=True)
|
1401
|
+
|
1402
|
+
def test_empty(self):
|
1403
|
+
res1 = mstats.ttest_ind([], [])
|
1404
|
+
assert_(np.all(np.isnan(res1)))
|
1405
|
+
|
1406
|
+
def test_zero_division(self):
|
1407
|
+
t, p = mstats.ttest_ind([0, 0, 0], [1, 1, 1])
|
1408
|
+
assert_equal((np.abs(t), p), (np.inf, 0))
|
1409
|
+
|
1410
|
+
with suppress_warnings() as sup:
|
1411
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1412
|
+
t, p = mstats.ttest_ind([0, 0, 0], [0, 0, 0])
|
1413
|
+
assert_array_equal(t, (np.nan, np.nan))
|
1414
|
+
assert_array_equal(p, (np.nan, np.nan))
|
1415
|
+
|
1416
|
+
t, p = mstats.ttest_ind([0, 0, 0], [1, 1, 1], equal_var=False)
|
1417
|
+
assert_equal((np.abs(t), p), (np.inf, 0))
|
1418
|
+
assert_array_equal(mstats.ttest_ind([0, 0, 0], [0, 0, 0],
|
1419
|
+
equal_var=False), (np.nan, np.nan))
|
1420
|
+
|
1421
|
+
def test_bad_alternative(self):
|
1422
|
+
msg = r"alternative must be 'less', 'greater' or 'two-sided'"
|
1423
|
+
with pytest.raises(ValueError, match=msg):
|
1424
|
+
mstats.ttest_ind([1, 2, 3], [4, 5, 6], alternative='foo')
|
1425
|
+
|
1426
|
+
@pytest.mark.parametrize("alternative", ["less", "greater"])
|
1427
|
+
def test_alternative(self, alternative):
|
1428
|
+
x = stats.norm.rvs(loc=10, scale=2, size=100, random_state=123)
|
1429
|
+
y = stats.norm.rvs(loc=8, scale=2, size=100, random_state=123)
|
1430
|
+
|
1431
|
+
t_ex, p_ex = stats.ttest_ind(x, y, alternative=alternative)
|
1432
|
+
t, p = mstats.ttest_ind(x, y, alternative=alternative)
|
1433
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1434
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1435
|
+
|
1436
|
+
# test with masked arrays
|
1437
|
+
x[1:10] = np.nan
|
1438
|
+
y[80:90] = np.nan
|
1439
|
+
x = np.ma.masked_array(x, mask=np.isnan(x))
|
1440
|
+
y = np.ma.masked_array(y, mask=np.isnan(y))
|
1441
|
+
t_ex, p_ex = stats.ttest_ind(x.compressed(), y.compressed(),
|
1442
|
+
alternative=alternative)
|
1443
|
+
t, p = mstats.ttest_ind(x, y, alternative=alternative)
|
1444
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1445
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1446
|
+
|
1447
|
+
|
1448
|
+
class TestTtest_1samp:
|
1449
|
+
def test_vs_nonmasked(self):
|
1450
|
+
np.random.seed(1234567)
|
1451
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1452
|
+
|
1453
|
+
# 1-D inputs
|
1454
|
+
res1 = stats.ttest_1samp(outcome[:, 0], 1)
|
1455
|
+
res2 = mstats.ttest_1samp(outcome[:, 0], 1)
|
1456
|
+
assert_allclose(res1, res2)
|
1457
|
+
|
1458
|
+
def test_fully_masked(self):
|
1459
|
+
np.random.seed(1234567)
|
1460
|
+
outcome = ma.masked_array(np.random.randn(3), mask=[1, 1, 1])
|
1461
|
+
expected = (np.nan, np.nan)
|
1462
|
+
with suppress_warnings() as sup:
|
1463
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1464
|
+
for pair in [((np.nan, np.nan), 0.0), (outcome, 0.0)]:
|
1465
|
+
t, p = mstats.ttest_1samp(*pair)
|
1466
|
+
assert_array_equal(p, expected)
|
1467
|
+
assert_array_equal(t, expected)
|
1468
|
+
|
1469
|
+
def test_result_attributes(self):
|
1470
|
+
np.random.seed(1234567)
|
1471
|
+
outcome = np.random.randn(20, 4) + [0, 0, 1, 2]
|
1472
|
+
|
1473
|
+
res = mstats.ttest_1samp(outcome[:, 0], 1)
|
1474
|
+
attributes = ('statistic', 'pvalue')
|
1475
|
+
check_named_results(res, attributes, ma=True)
|
1476
|
+
|
1477
|
+
def test_empty(self):
|
1478
|
+
res1 = mstats.ttest_1samp([], 1)
|
1479
|
+
assert_(np.all(np.isnan(res1)))
|
1480
|
+
|
1481
|
+
def test_zero_division(self):
|
1482
|
+
t, p = mstats.ttest_1samp([0, 0, 0], 1)
|
1483
|
+
assert_equal((np.abs(t), p), (np.inf, 0))
|
1484
|
+
|
1485
|
+
with suppress_warnings() as sup:
|
1486
|
+
sup.filter(RuntimeWarning, "invalid value encountered in absolute")
|
1487
|
+
t, p = mstats.ttest_1samp([0, 0, 0], 0)
|
1488
|
+
assert_(np.isnan(t))
|
1489
|
+
assert_array_equal(p, (np.nan, np.nan))
|
1490
|
+
|
1491
|
+
def test_bad_alternative(self):
|
1492
|
+
msg = r"alternative must be 'less', 'greater' or 'two-sided'"
|
1493
|
+
with pytest.raises(ValueError, match=msg):
|
1494
|
+
mstats.ttest_1samp([1, 2, 3], 4, alternative='foo')
|
1495
|
+
|
1496
|
+
@pytest.mark.parametrize("alternative", ["less", "greater"])
|
1497
|
+
def test_alternative(self, alternative):
|
1498
|
+
x = stats.norm.rvs(loc=10, scale=2, size=100, random_state=123)
|
1499
|
+
|
1500
|
+
t_ex, p_ex = stats.ttest_1samp(x, 9, alternative=alternative)
|
1501
|
+
t, p = mstats.ttest_1samp(x, 9, alternative=alternative)
|
1502
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1503
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1504
|
+
|
1505
|
+
# test with masked arrays
|
1506
|
+
x[1:10] = np.nan
|
1507
|
+
x = np.ma.masked_array(x, mask=np.isnan(x))
|
1508
|
+
t_ex, p_ex = stats.ttest_1samp(x.compressed(), 9,
|
1509
|
+
alternative=alternative)
|
1510
|
+
t, p = mstats.ttest_1samp(x, 9, alternative=alternative)
|
1511
|
+
assert_allclose(t, t_ex, rtol=1e-14)
|
1512
|
+
assert_allclose(p, p_ex, rtol=1e-14)
|
1513
|
+
|
1514
|
+
|
1515
|
+
class TestDescribe:
|
1516
|
+
"""
|
1517
|
+
Tests for mstats.describe.
|
1518
|
+
|
1519
|
+
Note that there are also tests for `mstats.describe` in the
|
1520
|
+
class TestCompareWithStats.
|
1521
|
+
"""
|
1522
|
+
def test_basic_with_axis(self):
|
1523
|
+
# This is a basic test that is also a regression test for gh-7303.
|
1524
|
+
a = np.ma.masked_array([[0, 1, 2, 3, 4, 9],
|
1525
|
+
[5, 5, 0, 9, 3, 3]],
|
1526
|
+
mask=[[0, 0, 0, 0, 0, 1],
|
1527
|
+
[0, 0, 1, 1, 0, 0]])
|
1528
|
+
result = mstats.describe(a, axis=1)
|
1529
|
+
assert_equal(result.nobs, [5, 4])
|
1530
|
+
amin, amax = result.minmax
|
1531
|
+
assert_equal(amin, [0, 3])
|
1532
|
+
assert_equal(amax, [4, 5])
|
1533
|
+
assert_equal(result.mean, [2.0, 4.0])
|
1534
|
+
assert_equal(result.variance, [2.0, 1.0])
|
1535
|
+
assert_equal(result.skewness, [0.0, 0.0])
|
1536
|
+
assert_allclose(result.kurtosis, [-1.3, -2.0])
|
1537
|
+
|
1538
|
+
|
1539
|
+
@skip_xp_invalid_arg
|
1540
|
+
class TestCompareWithStats:
|
1541
|
+
"""
|
1542
|
+
Class to compare mstats results with stats results.
|
1543
|
+
|
1544
|
+
It is in general assumed that scipy.stats is at a more mature stage than
|
1545
|
+
stats.mstats. If a routine in mstats results in similar results like in
|
1546
|
+
scipy.stats, this is considered also as a proper validation of scipy.mstats
|
1547
|
+
routine.
|
1548
|
+
|
1549
|
+
Different sample sizes are used for testing, as some problems between stats
|
1550
|
+
and mstats are dependent on sample size.
|
1551
|
+
|
1552
|
+
Author: Alexander Loew
|
1553
|
+
|
1554
|
+
NOTE that some tests fail. This might be caused by
|
1555
|
+
a) actual differences or bugs between stats and mstats
|
1556
|
+
b) numerical inaccuracies
|
1557
|
+
c) different definitions of routine interfaces
|
1558
|
+
|
1559
|
+
These failures need to be checked. Current workaround is to have disabled these
|
1560
|
+
tests, but issuing reports on scipy-dev
|
1561
|
+
|
1562
|
+
"""
|
1563
|
+
def get_n(self):
|
1564
|
+
""" Returns list of sample sizes to be used for comparison. """
|
1565
|
+
return [1000, 100, 10, 5]
|
1566
|
+
|
1567
|
+
def generate_xy_sample(self, n):
|
1568
|
+
# This routine generates numpy arrays and corresponding masked arrays
|
1569
|
+
# with the same data, but additional masked values
|
1570
|
+
rng = np.random.RandomState(1234567)
|
1571
|
+
x = rng.randn(n)
|
1572
|
+
y = x + rng.randn(n)
|
1573
|
+
xm = np.full(len(x) + 5, 1e16)
|
1574
|
+
ym = np.full(len(y) + 5, 1e16)
|
1575
|
+
xm[0:len(x)] = x
|
1576
|
+
ym[0:len(y)] = y
|
1577
|
+
mask = xm > 9e15
|
1578
|
+
xm = np.ma.array(xm, mask=mask)
|
1579
|
+
ym = np.ma.array(ym, mask=mask)
|
1580
|
+
return x, y, xm, ym
|
1581
|
+
|
1582
|
+
def generate_xy_sample2D(self, n, nx):
|
1583
|
+
x = np.full((n, nx), np.nan)
|
1584
|
+
y = np.full((n, nx), np.nan)
|
1585
|
+
xm = np.full((n+5, nx), np.nan)
|
1586
|
+
ym = np.full((n+5, nx), np.nan)
|
1587
|
+
|
1588
|
+
for i in range(nx):
|
1589
|
+
x[:, i], y[:, i], dx, dy = self.generate_xy_sample(n)
|
1590
|
+
|
1591
|
+
xm[0:n, :] = x[0:n]
|
1592
|
+
ym[0:n, :] = y[0:n]
|
1593
|
+
xm = np.ma.array(xm, mask=np.isnan(xm))
|
1594
|
+
ym = np.ma.array(ym, mask=np.isnan(ym))
|
1595
|
+
return x, y, xm, ym
|
1596
|
+
|
1597
|
+
def test_linregress(self):
|
1598
|
+
for n in self.get_n():
|
1599
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1600
|
+
result1 = stats.linregress(x, y)
|
1601
|
+
result2 = stats.mstats.linregress(xm, ym)
|
1602
|
+
assert_allclose(np.asarray(result1), np.asarray(result2))
|
1603
|
+
|
1604
|
+
def test_pearsonr(self):
|
1605
|
+
for n in self.get_n():
|
1606
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1607
|
+
r, p = stats.pearsonr(x, y)
|
1608
|
+
rm, pm = stats.mstats.pearsonr(xm, ym)
|
1609
|
+
|
1610
|
+
assert_almost_equal(r, rm, decimal=14)
|
1611
|
+
assert_almost_equal(p, pm, decimal=14)
|
1612
|
+
|
1613
|
+
def test_spearmanr(self):
|
1614
|
+
for n in self.get_n():
|
1615
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1616
|
+
r, p = stats.spearmanr(x, y)
|
1617
|
+
rm, pm = stats.mstats.spearmanr(xm, ym)
|
1618
|
+
assert_almost_equal(r, rm, 14)
|
1619
|
+
assert_almost_equal(p, pm, 14)
|
1620
|
+
|
1621
|
+
def test_spearmanr_backcompat_useties(self):
|
1622
|
+
# A regression test to ensure we don't break backwards compat
|
1623
|
+
# more than we have to (see gh-9204).
|
1624
|
+
x = np.arange(6)
|
1625
|
+
assert_raises(ValueError, mstats.spearmanr, x, x, False)
|
1626
|
+
|
1627
|
+
def test_gmean(self):
|
1628
|
+
for n in self.get_n():
|
1629
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1630
|
+
r = stats.gmean(abs(x))
|
1631
|
+
rm = stats.mstats.gmean(abs(xm))
|
1632
|
+
assert_allclose(r, rm, rtol=1e-13)
|
1633
|
+
|
1634
|
+
r = stats.gmean(abs(y))
|
1635
|
+
rm = stats.mstats.gmean(abs(ym))
|
1636
|
+
assert_allclose(r, rm, rtol=1e-13)
|
1637
|
+
|
1638
|
+
def test_hmean(self):
|
1639
|
+
for n in self.get_n():
|
1640
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1641
|
+
|
1642
|
+
r = stats.hmean(abs(x))
|
1643
|
+
rm = stats.mstats.hmean(abs(xm))
|
1644
|
+
assert_almost_equal(r, rm, 10)
|
1645
|
+
|
1646
|
+
r = stats.hmean(abs(y))
|
1647
|
+
rm = stats.mstats.hmean(abs(ym))
|
1648
|
+
assert_almost_equal(r, rm, 10)
|
1649
|
+
|
1650
|
+
def test_skew(self):
|
1651
|
+
for n in self.get_n():
|
1652
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1653
|
+
|
1654
|
+
r = stats.skew(x)
|
1655
|
+
rm = stats.mstats.skew(xm)
|
1656
|
+
assert_almost_equal(r, rm, 10)
|
1657
|
+
|
1658
|
+
r = stats.skew(y)
|
1659
|
+
rm = stats.mstats.skew(ym)
|
1660
|
+
assert_almost_equal(r, rm, 10)
|
1661
|
+
|
1662
|
+
def test_moment(self):
|
1663
|
+
for n in self.get_n():
|
1664
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1665
|
+
|
1666
|
+
r = stats.moment(x)
|
1667
|
+
rm = stats.mstats.moment(xm)
|
1668
|
+
assert_almost_equal(r, rm, 10)
|
1669
|
+
|
1670
|
+
r = stats.moment(y)
|
1671
|
+
rm = stats.mstats.moment(ym)
|
1672
|
+
assert_almost_equal(r, rm, 10)
|
1673
|
+
|
1674
|
+
def test_zscore(self):
|
1675
|
+
for n in self.get_n():
|
1676
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1677
|
+
|
1678
|
+
# reference solution
|
1679
|
+
zx = (x - x.mean()) / x.std()
|
1680
|
+
zy = (y - y.mean()) / y.std()
|
1681
|
+
|
1682
|
+
# validate stats
|
1683
|
+
assert_allclose(stats.zscore(x), zx, rtol=1e-10)
|
1684
|
+
assert_allclose(stats.zscore(y), zy, rtol=1e-10)
|
1685
|
+
|
1686
|
+
# compare stats and mstats
|
1687
|
+
assert_allclose(stats.zscore(x), stats.mstats.zscore(xm[0:len(x)]),
|
1688
|
+
rtol=1e-10)
|
1689
|
+
assert_allclose(stats.zscore(y), stats.mstats.zscore(ym[0:len(y)]),
|
1690
|
+
rtol=1e-10)
|
1691
|
+
|
1692
|
+
def test_kurtosis(self):
|
1693
|
+
for n in self.get_n():
|
1694
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1695
|
+
r = stats.kurtosis(x)
|
1696
|
+
rm = stats.mstats.kurtosis(xm)
|
1697
|
+
assert_almost_equal(r, rm, 10)
|
1698
|
+
|
1699
|
+
r = stats.kurtosis(y)
|
1700
|
+
rm = stats.mstats.kurtosis(ym)
|
1701
|
+
assert_almost_equal(r, rm, 10)
|
1702
|
+
|
1703
|
+
def test_sem(self):
|
1704
|
+
# example from stats.sem doc
|
1705
|
+
a = np.arange(20).reshape(5, 4)
|
1706
|
+
am = np.ma.array(a)
|
1707
|
+
r = stats.sem(a, ddof=1)
|
1708
|
+
rm = stats.mstats.sem(am, ddof=1)
|
1709
|
+
|
1710
|
+
assert_allclose(r, 2.82842712, atol=1e-5)
|
1711
|
+
assert_allclose(rm, 2.82842712, atol=1e-5)
|
1712
|
+
|
1713
|
+
for n in self.get_n():
|
1714
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1715
|
+
assert_almost_equal(stats.mstats.sem(xm, axis=None, ddof=0),
|
1716
|
+
stats.sem(x, axis=None, ddof=0), decimal=13)
|
1717
|
+
assert_almost_equal(stats.mstats.sem(ym, axis=None, ddof=0),
|
1718
|
+
stats.sem(y, axis=None, ddof=0), decimal=13)
|
1719
|
+
assert_almost_equal(stats.mstats.sem(xm, axis=None, ddof=1),
|
1720
|
+
stats.sem(x, axis=None, ddof=1), decimal=13)
|
1721
|
+
assert_almost_equal(stats.mstats.sem(ym, axis=None, ddof=1),
|
1722
|
+
stats.sem(y, axis=None, ddof=1), decimal=13)
|
1723
|
+
|
1724
|
+
def test_describe(self):
|
1725
|
+
for n in self.get_n():
|
1726
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1727
|
+
r = stats.describe(x, ddof=1)
|
1728
|
+
rm = stats.mstats.describe(xm, ddof=1)
|
1729
|
+
for ii in range(6):
|
1730
|
+
assert_almost_equal(np.asarray(r[ii]),
|
1731
|
+
np.asarray(rm[ii]),
|
1732
|
+
decimal=12)
|
1733
|
+
|
1734
|
+
def test_describe_result_attributes(self):
|
1735
|
+
actual = mstats.describe(np.arange(5))
|
1736
|
+
attributes = ('nobs', 'minmax', 'mean', 'variance', 'skewness',
|
1737
|
+
'kurtosis')
|
1738
|
+
check_named_results(actual, attributes, ma=True)
|
1739
|
+
|
1740
|
+
def test_rankdata(self):
|
1741
|
+
for n in self.get_n():
|
1742
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1743
|
+
r = stats.rankdata(x)
|
1744
|
+
rm = stats.mstats.rankdata(x)
|
1745
|
+
assert_allclose(r, rm)
|
1746
|
+
|
1747
|
+
def test_tmean(self):
|
1748
|
+
for n in self.get_n():
|
1749
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1750
|
+
assert_almost_equal(stats.tmean(x),stats.mstats.tmean(xm), 14)
|
1751
|
+
assert_almost_equal(stats.tmean(y),stats.mstats.tmean(ym), 14)
|
1752
|
+
|
1753
|
+
def test_tmax(self):
|
1754
|
+
for n in self.get_n():
|
1755
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1756
|
+
assert_almost_equal(stats.tmax(x,2.),
|
1757
|
+
stats.mstats.tmax(xm,2.), 10)
|
1758
|
+
assert_almost_equal(stats.tmax(y,2.),
|
1759
|
+
stats.mstats.tmax(ym,2.), 10)
|
1760
|
+
|
1761
|
+
assert_almost_equal(stats.tmax(x, upperlimit=3.),
|
1762
|
+
stats.mstats.tmax(xm, upperlimit=3.), 10)
|
1763
|
+
assert_almost_equal(stats.tmax(y, upperlimit=3.),
|
1764
|
+
stats.mstats.tmax(ym, upperlimit=3.), 10)
|
1765
|
+
|
1766
|
+
def test_tmin(self):
|
1767
|
+
for n in self.get_n():
|
1768
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1769
|
+
assert_equal(stats.tmin(x), stats.mstats.tmin(xm))
|
1770
|
+
assert_equal(stats.tmin(y), stats.mstats.tmin(ym))
|
1771
|
+
|
1772
|
+
assert_almost_equal(stats.tmin(x, lowerlimit=-1.),
|
1773
|
+
stats.mstats.tmin(xm, lowerlimit=-1.), 10)
|
1774
|
+
assert_almost_equal(stats.tmin(y, lowerlimit=-1.),
|
1775
|
+
stats.mstats.tmin(ym, lowerlimit=-1.), 10)
|
1776
|
+
|
1777
|
+
def test_zmap(self):
|
1778
|
+
for n in self.get_n():
|
1779
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1780
|
+
z = stats.zmap(x, y)
|
1781
|
+
zm = stats.mstats.zmap(xm, ym)
|
1782
|
+
assert_allclose(z, zm[0:len(z)], atol=1e-10)
|
1783
|
+
|
1784
|
+
def test_variation(self):
|
1785
|
+
for n in self.get_n():
|
1786
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1787
|
+
assert_almost_equal(stats.variation(x), stats.mstats.variation(xm),
|
1788
|
+
decimal=12)
|
1789
|
+
assert_almost_equal(stats.variation(y), stats.mstats.variation(ym),
|
1790
|
+
decimal=12)
|
1791
|
+
|
1792
|
+
def test_tvar(self):
|
1793
|
+
for n in self.get_n():
|
1794
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1795
|
+
assert_almost_equal(stats.tvar(x), stats.mstats.tvar(xm),
|
1796
|
+
decimal=12)
|
1797
|
+
assert_almost_equal(stats.tvar(y), stats.mstats.tvar(ym),
|
1798
|
+
decimal=12)
|
1799
|
+
|
1800
|
+
def test_trimboth(self):
|
1801
|
+
a = np.arange(20)
|
1802
|
+
b = stats.trimboth(a, 0.1)
|
1803
|
+
bm = stats.mstats.trimboth(a, 0.1)
|
1804
|
+
assert_allclose(np.sort(b), bm.data[~bm.mask])
|
1805
|
+
|
1806
|
+
def test_tsem(self):
|
1807
|
+
for n in self.get_n():
|
1808
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1809
|
+
assert_almost_equal(stats.tsem(x), stats.mstats.tsem(xm),
|
1810
|
+
decimal=14)
|
1811
|
+
assert_almost_equal(stats.tsem(y), stats.mstats.tsem(ym),
|
1812
|
+
decimal=14)
|
1813
|
+
assert_almost_equal(stats.tsem(x, limits=(-2., 2.)),
|
1814
|
+
stats.mstats.tsem(xm, limits=(-2., 2.)),
|
1815
|
+
decimal=14)
|
1816
|
+
|
1817
|
+
def test_skewtest(self):
|
1818
|
+
# this test is for 1D data
|
1819
|
+
for n in self.get_n():
|
1820
|
+
if n > 8:
|
1821
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1822
|
+
r = stats.skewtest(x)
|
1823
|
+
rm = stats.mstats.skewtest(xm)
|
1824
|
+
assert_allclose(r, rm)
|
1825
|
+
|
1826
|
+
def test_skewtest_result_attributes(self):
|
1827
|
+
x = np.array((-2, -1, 0, 1, 2, 3)*4)**2
|
1828
|
+
res = mstats.skewtest(x)
|
1829
|
+
attributes = ('statistic', 'pvalue')
|
1830
|
+
check_named_results(res, attributes, ma=True)
|
1831
|
+
|
1832
|
+
def test_skewtest_2D_notmasked(self):
|
1833
|
+
# a normal ndarray is passed to the masked function
|
1834
|
+
x = np.random.random((20, 2)) * 20.
|
1835
|
+
r = stats.skewtest(x)
|
1836
|
+
rm = stats.mstats.skewtest(x)
|
1837
|
+
assert_allclose(np.asarray(r), np.asarray(rm))
|
1838
|
+
|
1839
|
+
def test_skewtest_2D_WithMask(self):
|
1840
|
+
nx = 2
|
1841
|
+
for n in self.get_n():
|
1842
|
+
if n > 8:
|
1843
|
+
x, y, xm, ym = self.generate_xy_sample2D(n, nx)
|
1844
|
+
r = stats.skewtest(x)
|
1845
|
+
rm = stats.mstats.skewtest(xm)
|
1846
|
+
|
1847
|
+
assert_allclose(r[0][0], rm[0][0], rtol=1e-14)
|
1848
|
+
assert_allclose(r[0][1], rm[0][1], rtol=1e-14)
|
1849
|
+
|
1850
|
+
def test_normaltest(self):
|
1851
|
+
with np.errstate(over='raise'), suppress_warnings() as sup:
|
1852
|
+
sup.filter(UserWarning, "`kurtosistest` p-value may be inaccurate")
|
1853
|
+
sup.filter(UserWarning, "kurtosistest only valid for n>=20")
|
1854
|
+
for n in self.get_n():
|
1855
|
+
if n > 8:
|
1856
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1857
|
+
r = stats.normaltest(x)
|
1858
|
+
rm = stats.mstats.normaltest(xm)
|
1859
|
+
assert_allclose(np.asarray(r), np.asarray(rm))
|
1860
|
+
|
1861
|
+
def test_find_repeats(self):
|
1862
|
+
x = np.asarray([1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4]).astype('float')
|
1863
|
+
tmp = np.asarray([1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]).astype('float')
|
1864
|
+
mask = (tmp == 5.)
|
1865
|
+
xm = np.ma.array(tmp, mask=mask)
|
1866
|
+
x_orig, xm_orig = x.copy(), xm.copy()
|
1867
|
+
|
1868
|
+
unique, unique_counts = np.unique(x, return_counts=True)
|
1869
|
+
r = unique[unique_counts > 1], unique_counts[unique_counts > 1]
|
1870
|
+
rm = stats.mstats.find_repeats(xm)
|
1871
|
+
|
1872
|
+
assert_equal(r, rm)
|
1873
|
+
assert_equal(x, x_orig)
|
1874
|
+
assert_equal(xm, xm_orig)
|
1875
|
+
|
1876
|
+
# This crazy behavior is expected by count_tied_groups, but is not
|
1877
|
+
# in the docstring...
|
1878
|
+
_, counts = stats.mstats.find_repeats([])
|
1879
|
+
assert_equal(counts, np.array(0, dtype=np.intp))
|
1880
|
+
|
1881
|
+
def test_kendalltau(self):
|
1882
|
+
for n in self.get_n():
|
1883
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1884
|
+
r = stats.kendalltau(x, y)
|
1885
|
+
rm = stats.mstats.kendalltau(xm, ym)
|
1886
|
+
assert_almost_equal(r[0], rm[0], decimal=10)
|
1887
|
+
assert_almost_equal(r[1], rm[1], decimal=7)
|
1888
|
+
|
1889
|
+
def test_obrientransform(self):
|
1890
|
+
for n in self.get_n():
|
1891
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1892
|
+
r = stats.obrientransform(x)
|
1893
|
+
rm = stats.mstats.obrientransform(xm)
|
1894
|
+
assert_almost_equal(r.T, rm[0:len(x)])
|
1895
|
+
|
1896
|
+
def test_ks_1samp(self):
|
1897
|
+
"""Checks that mstats.ks_1samp and stats.ks_1samp agree on masked arrays."""
|
1898
|
+
for mode in ['auto', 'exact', 'asymp']:
|
1899
|
+
with suppress_warnings():
|
1900
|
+
for alternative in ['less', 'greater', 'two-sided']:
|
1901
|
+
for n in self.get_n():
|
1902
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1903
|
+
res1 = stats.ks_1samp(x, stats.norm.cdf,
|
1904
|
+
alternative=alternative, mode=mode)
|
1905
|
+
res2 = stats.mstats.ks_1samp(xm, stats.norm.cdf,
|
1906
|
+
alternative=alternative, mode=mode)
|
1907
|
+
assert_equal(np.asarray(res1), np.asarray(res2))
|
1908
|
+
res3 = stats.ks_1samp(xm, stats.norm.cdf,
|
1909
|
+
alternative=alternative, mode=mode)
|
1910
|
+
assert_equal(np.asarray(res1), np.asarray(res3))
|
1911
|
+
|
1912
|
+
def test_kstest_1samp(self):
|
1913
|
+
"""
|
1914
|
+
Checks that 1-sample mstats.kstest and stats.kstest agree on masked arrays.
|
1915
|
+
"""
|
1916
|
+
for mode in ['auto', 'exact', 'asymp']:
|
1917
|
+
with suppress_warnings():
|
1918
|
+
for alternative in ['less', 'greater', 'two-sided']:
|
1919
|
+
for n in self.get_n():
|
1920
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1921
|
+
res1 = stats.kstest(x, 'norm',
|
1922
|
+
alternative=alternative, mode=mode)
|
1923
|
+
res2 = stats.mstats.kstest(xm, 'norm',
|
1924
|
+
alternative=alternative, mode=mode)
|
1925
|
+
assert_equal(np.asarray(res1), np.asarray(res2))
|
1926
|
+
res3 = stats.kstest(xm, 'norm',
|
1927
|
+
alternative=alternative, mode=mode)
|
1928
|
+
assert_equal(np.asarray(res1), np.asarray(res3))
|
1929
|
+
|
1930
|
+
def test_ks_2samp(self):
|
1931
|
+
"""Checks that mstats.ks_2samp and stats.ks_2samp agree on masked arrays.
|
1932
|
+
gh-8431"""
|
1933
|
+
for mode in ['auto', 'exact', 'asymp']:
|
1934
|
+
with suppress_warnings() as sup:
|
1935
|
+
if mode in ['auto', 'exact']:
|
1936
|
+
message = "ks_2samp: Exact calculation unsuccessful."
|
1937
|
+
sup.filter(RuntimeWarning, message)
|
1938
|
+
for alternative in ['less', 'greater', 'two-sided']:
|
1939
|
+
for n in self.get_n():
|
1940
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1941
|
+
res1 = stats.ks_2samp(x, y,
|
1942
|
+
alternative=alternative, mode=mode)
|
1943
|
+
res2 = stats.mstats.ks_2samp(xm, ym,
|
1944
|
+
alternative=alternative, mode=mode)
|
1945
|
+
assert_equal(np.asarray(res1), np.asarray(res2))
|
1946
|
+
res3 = stats.ks_2samp(xm, y,
|
1947
|
+
alternative=alternative, mode=mode)
|
1948
|
+
assert_equal(np.asarray(res1), np.asarray(res3))
|
1949
|
+
|
1950
|
+
def test_kstest_2samp(self):
|
1951
|
+
"""
|
1952
|
+
Checks that 2-sample mstats.kstest and stats.kstest agree on masked arrays.
|
1953
|
+
"""
|
1954
|
+
for mode in ['auto', 'exact', 'asymp']:
|
1955
|
+
with suppress_warnings() as sup:
|
1956
|
+
if mode in ['auto', 'exact']:
|
1957
|
+
message = "ks_2samp: Exact calculation unsuccessful."
|
1958
|
+
sup.filter(RuntimeWarning, message)
|
1959
|
+
for alternative in ['less', 'greater', 'two-sided']:
|
1960
|
+
for n in self.get_n():
|
1961
|
+
x, y, xm, ym = self.generate_xy_sample(n)
|
1962
|
+
res1 = stats.kstest(x, y,
|
1963
|
+
alternative=alternative, mode=mode)
|
1964
|
+
res2 = stats.mstats.kstest(xm, ym,
|
1965
|
+
alternative=alternative, mode=mode)
|
1966
|
+
assert_equal(np.asarray(res1), np.asarray(res2))
|
1967
|
+
res3 = stats.kstest(xm, y,
|
1968
|
+
alternative=alternative, mode=mode)
|
1969
|
+
assert_equal(np.asarray(res1), np.asarray(res3))
|
1970
|
+
|
1971
|
+
|
1972
|
+
class TestBrunnerMunzel:
|
1973
|
+
# Data from (Lumley, 1996)
|
1974
|
+
X = np.ma.masked_invalid([1, 2, 1, 1, 1, np.nan, 1, 1,
|
1975
|
+
1, 1, 1, 2, 4, 1, 1, np.nan])
|
1976
|
+
Y = np.ma.masked_invalid([3, 3, 4, 3, np.nan, 1, 2, 3, 1, 1, 5, 4])
|
1977
|
+
significant = 14
|
1978
|
+
|
1979
|
+
def test_brunnermunzel_one_sided(self):
|
1980
|
+
# Results are compared with R's lawstat package.
|
1981
|
+
u1, p1 = mstats.brunnermunzel(self.X, self.Y, alternative='less')
|
1982
|
+
u2, p2 = mstats.brunnermunzel(self.Y, self.X, alternative='greater')
|
1983
|
+
u3, p3 = mstats.brunnermunzel(self.X, self.Y, alternative='greater')
|
1984
|
+
u4, p4 = mstats.brunnermunzel(self.Y, self.X, alternative='less')
|
1985
|
+
|
1986
|
+
assert_almost_equal(p1, p2, decimal=self.significant)
|
1987
|
+
assert_almost_equal(p3, p4, decimal=self.significant)
|
1988
|
+
assert_(p1 != p3)
|
1989
|
+
assert_almost_equal(u1, 3.1374674823029505,
|
1990
|
+
decimal=self.significant)
|
1991
|
+
assert_almost_equal(u2, -3.1374674823029505,
|
1992
|
+
decimal=self.significant)
|
1993
|
+
assert_almost_equal(u3, 3.1374674823029505,
|
1994
|
+
decimal=self.significant)
|
1995
|
+
assert_almost_equal(u4, -3.1374674823029505,
|
1996
|
+
decimal=self.significant)
|
1997
|
+
assert_almost_equal(p1, 0.0028931043330757342,
|
1998
|
+
decimal=self.significant)
|
1999
|
+
assert_almost_equal(p3, 0.99710689566692423,
|
2000
|
+
decimal=self.significant)
|
2001
|
+
|
2002
|
+
def test_brunnermunzel_two_sided(self):
|
2003
|
+
# Results are compared with R's lawstat package.
|
2004
|
+
u1, p1 = mstats.brunnermunzel(self.X, self.Y, alternative='two-sided')
|
2005
|
+
u2, p2 = mstats.brunnermunzel(self.Y, self.X, alternative='two-sided')
|
2006
|
+
|
2007
|
+
assert_almost_equal(p1, p2, decimal=self.significant)
|
2008
|
+
assert_almost_equal(u1, 3.1374674823029505,
|
2009
|
+
decimal=self.significant)
|
2010
|
+
assert_almost_equal(u2, -3.1374674823029505,
|
2011
|
+
decimal=self.significant)
|
2012
|
+
assert_almost_equal(p1, 0.0057862086661515377,
|
2013
|
+
decimal=self.significant)
|
2014
|
+
|
2015
|
+
def test_brunnermunzel_default(self):
|
2016
|
+
# The default value for alternative is two-sided
|
2017
|
+
u1, p1 = mstats.brunnermunzel(self.X, self.Y)
|
2018
|
+
u2, p2 = mstats.brunnermunzel(self.Y, self.X)
|
2019
|
+
|
2020
|
+
assert_almost_equal(p1, p2, decimal=self.significant)
|
2021
|
+
assert_almost_equal(u1, 3.1374674823029505,
|
2022
|
+
decimal=self.significant)
|
2023
|
+
assert_almost_equal(u2, -3.1374674823029505,
|
2024
|
+
decimal=self.significant)
|
2025
|
+
assert_almost_equal(p1, 0.0057862086661515377,
|
2026
|
+
decimal=self.significant)
|
2027
|
+
|
2028
|
+
def test_brunnermunzel_alternative_error(self):
|
2029
|
+
alternative = "error"
|
2030
|
+
distribution = "t"
|
2031
|
+
assert_(alternative not in ["two-sided", "greater", "less"])
|
2032
|
+
assert_raises(ValueError,
|
2033
|
+
mstats.brunnermunzel,
|
2034
|
+
self.X,
|
2035
|
+
self.Y,
|
2036
|
+
alternative,
|
2037
|
+
distribution)
|
2038
|
+
|
2039
|
+
def test_brunnermunzel_distribution_norm(self):
|
2040
|
+
u1, p1 = mstats.brunnermunzel(self.X, self.Y, distribution="normal")
|
2041
|
+
u2, p2 = mstats.brunnermunzel(self.Y, self.X, distribution="normal")
|
2042
|
+
assert_almost_equal(p1, p2, decimal=self.significant)
|
2043
|
+
assert_almost_equal(u1, 3.1374674823029505,
|
2044
|
+
decimal=self.significant)
|
2045
|
+
assert_almost_equal(u2, -3.1374674823029505,
|
2046
|
+
decimal=self.significant)
|
2047
|
+
assert_almost_equal(p1, 0.0017041417600383024,
|
2048
|
+
decimal=self.significant)
|
2049
|
+
|
2050
|
+
def test_brunnermunzel_distribution_error(self):
|
2051
|
+
alternative = "two-sided"
|
2052
|
+
distribution = "error"
|
2053
|
+
assert_(alternative not in ["t", "normal"])
|
2054
|
+
assert_raises(ValueError,
|
2055
|
+
mstats.brunnermunzel,
|
2056
|
+
self.X,
|
2057
|
+
self.Y,
|
2058
|
+
alternative,
|
2059
|
+
distribution)
|
2060
|
+
|
2061
|
+
def test_brunnermunzel_empty_imput(self):
|
2062
|
+
u1, p1 = mstats.brunnermunzel(self.X, [])
|
2063
|
+
u2, p2 = mstats.brunnermunzel([], self.Y)
|
2064
|
+
u3, p3 = mstats.brunnermunzel([], [])
|
2065
|
+
|
2066
|
+
assert_(np.isnan(u1))
|
2067
|
+
assert_(np.isnan(p1))
|
2068
|
+
assert_(np.isnan(u2))
|
2069
|
+
assert_(np.isnan(p2))
|
2070
|
+
assert_(np.isnan(u3))
|
2071
|
+
assert_(np.isnan(p3))
|