scipy 1.16.0__cp313-cp313t-macosx_10_14_x86_64.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.
Files changed (1416) hide show
  1. scipy/.dylibs/libgcc_s.1.1.dylib +0 -0
  2. scipy/.dylibs/libgfortran.5.dylib +0 -0
  3. scipy/.dylibs/libquadmath.0.dylib +0 -0
  4. scipy/.dylibs/libscipy_openblas.dylib +0 -0
  5. scipy/__config__.py +161 -0
  6. scipy/__init__.py +138 -0
  7. scipy/_cyutility.cpython-313t-darwin.so +0 -0
  8. scipy/_distributor_init.py +18 -0
  9. scipy/_lib/__init__.py +14 -0
  10. scipy/_lib/_array_api.py +931 -0
  11. scipy/_lib/_array_api_compat_vendor.py +9 -0
  12. scipy/_lib/_array_api_no_0d.py +103 -0
  13. scipy/_lib/_bunch.py +229 -0
  14. scipy/_lib/_ccallback.py +251 -0
  15. scipy/_lib/_ccallback_c.cpython-313t-darwin.so +0 -0
  16. scipy/_lib/_disjoint_set.py +254 -0
  17. scipy/_lib/_docscrape.py +761 -0
  18. scipy/_lib/_elementwise_iterative_method.py +346 -0
  19. scipy/_lib/_fpumode.cpython-313t-darwin.so +0 -0
  20. scipy/_lib/_gcutils.py +105 -0
  21. scipy/_lib/_pep440.py +487 -0
  22. scipy/_lib/_sparse.py +41 -0
  23. scipy/_lib/_test_ccallback.cpython-313t-darwin.so +0 -0
  24. scipy/_lib/_test_deprecation_call.cpython-313t-darwin.so +0 -0
  25. scipy/_lib/_test_deprecation_def.cpython-313t-darwin.so +0 -0
  26. scipy/_lib/_testutils.py +373 -0
  27. scipy/_lib/_threadsafety.py +58 -0
  28. scipy/_lib/_tmpdirs.py +86 -0
  29. scipy/_lib/_uarray/LICENSE +29 -0
  30. scipy/_lib/_uarray/__init__.py +116 -0
  31. scipy/_lib/_uarray/_backend.py +707 -0
  32. scipy/_lib/_uarray/_uarray.cpython-313t-darwin.so +0 -0
  33. scipy/_lib/_util.py +1276 -0
  34. scipy/_lib/array_api_compat/__init__.py +22 -0
  35. scipy/_lib/array_api_compat/_internal.py +59 -0
  36. scipy/_lib/array_api_compat/common/__init__.py +1 -0
  37. scipy/_lib/array_api_compat/common/_aliases.py +727 -0
  38. scipy/_lib/array_api_compat/common/_fft.py +213 -0
  39. scipy/_lib/array_api_compat/common/_helpers.py +1058 -0
  40. scipy/_lib/array_api_compat/common/_linalg.py +232 -0
  41. scipy/_lib/array_api_compat/common/_typing.py +192 -0
  42. scipy/_lib/array_api_compat/cupy/__init__.py +13 -0
  43. scipy/_lib/array_api_compat/cupy/_aliases.py +156 -0
  44. scipy/_lib/array_api_compat/cupy/_info.py +336 -0
  45. scipy/_lib/array_api_compat/cupy/_typing.py +31 -0
  46. scipy/_lib/array_api_compat/cupy/fft.py +36 -0
  47. scipy/_lib/array_api_compat/cupy/linalg.py +49 -0
  48. scipy/_lib/array_api_compat/dask/__init__.py +0 -0
  49. scipy/_lib/array_api_compat/dask/array/__init__.py +12 -0
  50. scipy/_lib/array_api_compat/dask/array/_aliases.py +376 -0
  51. scipy/_lib/array_api_compat/dask/array/_info.py +416 -0
  52. scipy/_lib/array_api_compat/dask/array/fft.py +21 -0
  53. scipy/_lib/array_api_compat/dask/array/linalg.py +72 -0
  54. scipy/_lib/array_api_compat/numpy/__init__.py +28 -0
  55. scipy/_lib/array_api_compat/numpy/_aliases.py +190 -0
  56. scipy/_lib/array_api_compat/numpy/_info.py +366 -0
  57. scipy/_lib/array_api_compat/numpy/_typing.py +30 -0
  58. scipy/_lib/array_api_compat/numpy/fft.py +35 -0
  59. scipy/_lib/array_api_compat/numpy/linalg.py +143 -0
  60. scipy/_lib/array_api_compat/torch/__init__.py +22 -0
  61. scipy/_lib/array_api_compat/torch/_aliases.py +855 -0
  62. scipy/_lib/array_api_compat/torch/_info.py +369 -0
  63. scipy/_lib/array_api_compat/torch/_typing.py +3 -0
  64. scipy/_lib/array_api_compat/torch/fft.py +85 -0
  65. scipy/_lib/array_api_compat/torch/linalg.py +121 -0
  66. scipy/_lib/array_api_extra/__init__.py +38 -0
  67. scipy/_lib/array_api_extra/_delegation.py +171 -0
  68. scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
  69. scipy/_lib/array_api_extra/_lib/_at.py +463 -0
  70. scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
  71. scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
  72. scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
  73. scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
  74. scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
  75. scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
  76. scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
  77. scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
  78. scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
  79. scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
  80. scipy/_lib/array_api_extra/testing.py +359 -0
  81. scipy/_lib/cobyqa/__init__.py +20 -0
  82. scipy/_lib/cobyqa/framework.py +1240 -0
  83. scipy/_lib/cobyqa/main.py +1506 -0
  84. scipy/_lib/cobyqa/models.py +1529 -0
  85. scipy/_lib/cobyqa/problem.py +1296 -0
  86. scipy/_lib/cobyqa/settings.py +132 -0
  87. scipy/_lib/cobyqa/subsolvers/__init__.py +14 -0
  88. scipy/_lib/cobyqa/subsolvers/geometry.py +387 -0
  89. scipy/_lib/cobyqa/subsolvers/optim.py +1203 -0
  90. scipy/_lib/cobyqa/utils/__init__.py +18 -0
  91. scipy/_lib/cobyqa/utils/exceptions.py +22 -0
  92. scipy/_lib/cobyqa/utils/math.py +77 -0
  93. scipy/_lib/cobyqa/utils/versions.py +67 -0
  94. scipy/_lib/decorator.py +399 -0
  95. scipy/_lib/deprecation.py +274 -0
  96. scipy/_lib/doccer.py +366 -0
  97. scipy/_lib/messagestream.cpython-313t-darwin.so +0 -0
  98. scipy/_lib/pyprima/__init__.py +212 -0
  99. scipy/_lib/pyprima/cobyla/__init__.py +0 -0
  100. scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
  101. scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
  102. scipy/_lib/pyprima/cobyla/geometry.py +226 -0
  103. scipy/_lib/pyprima/cobyla/initialize.py +215 -0
  104. scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
  105. scipy/_lib/pyprima/cobyla/update.py +289 -0
  106. scipy/_lib/pyprima/common/__init__.py +0 -0
  107. scipy/_lib/pyprima/common/_bounds.py +34 -0
  108. scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
  109. scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
  110. scipy/_lib/pyprima/common/_project.py +173 -0
  111. scipy/_lib/pyprima/common/checkbreak.py +93 -0
  112. scipy/_lib/pyprima/common/consts.py +47 -0
  113. scipy/_lib/pyprima/common/evaluate.py +99 -0
  114. scipy/_lib/pyprima/common/history.py +38 -0
  115. scipy/_lib/pyprima/common/infos.py +30 -0
  116. scipy/_lib/pyprima/common/linalg.py +435 -0
  117. scipy/_lib/pyprima/common/message.py +290 -0
  118. scipy/_lib/pyprima/common/powalg.py +131 -0
  119. scipy/_lib/pyprima/common/preproc.py +277 -0
  120. scipy/_lib/pyprima/common/present.py +5 -0
  121. scipy/_lib/pyprima/common/ratio.py +54 -0
  122. scipy/_lib/pyprima/common/redrho.py +47 -0
  123. scipy/_lib/pyprima/common/selectx.py +296 -0
  124. scipy/_lib/tests/__init__.py +0 -0
  125. scipy/_lib/tests/test__gcutils.py +110 -0
  126. scipy/_lib/tests/test__pep440.py +67 -0
  127. scipy/_lib/tests/test__testutils.py +32 -0
  128. scipy/_lib/tests/test__threadsafety.py +51 -0
  129. scipy/_lib/tests/test__util.py +641 -0
  130. scipy/_lib/tests/test_array_api.py +322 -0
  131. scipy/_lib/tests/test_bunch.py +169 -0
  132. scipy/_lib/tests/test_ccallback.py +196 -0
  133. scipy/_lib/tests/test_config.py +45 -0
  134. scipy/_lib/tests/test_deprecation.py +10 -0
  135. scipy/_lib/tests/test_doccer.py +143 -0
  136. scipy/_lib/tests/test_import_cycles.py +18 -0
  137. scipy/_lib/tests/test_public_api.py +482 -0
  138. scipy/_lib/tests/test_scipy_version.py +28 -0
  139. scipy/_lib/tests/test_tmpdirs.py +48 -0
  140. scipy/_lib/tests/test_warnings.py +137 -0
  141. scipy/_lib/uarray.py +31 -0
  142. scipy/cluster/__init__.py +31 -0
  143. scipy/cluster/_hierarchy.cpython-313t-darwin.so +0 -0
  144. scipy/cluster/_optimal_leaf_ordering.cpython-313t-darwin.so +0 -0
  145. scipy/cluster/_vq.cpython-313t-darwin.so +0 -0
  146. scipy/cluster/hierarchy.py +4348 -0
  147. scipy/cluster/tests/__init__.py +0 -0
  148. scipy/cluster/tests/hierarchy_test_data.py +145 -0
  149. scipy/cluster/tests/test_disjoint_set.py +202 -0
  150. scipy/cluster/tests/test_hierarchy.py +1238 -0
  151. scipy/cluster/tests/test_vq.py +434 -0
  152. scipy/cluster/vq.py +832 -0
  153. scipy/conftest.py +683 -0
  154. scipy/constants/__init__.py +358 -0
  155. scipy/constants/_codata.py +2266 -0
  156. scipy/constants/_constants.py +369 -0
  157. scipy/constants/codata.py +21 -0
  158. scipy/constants/constants.py +53 -0
  159. scipy/constants/tests/__init__.py +0 -0
  160. scipy/constants/tests/test_codata.py +78 -0
  161. scipy/constants/tests/test_constants.py +83 -0
  162. scipy/datasets/__init__.py +90 -0
  163. scipy/datasets/_download_all.py +71 -0
  164. scipy/datasets/_fetchers.py +225 -0
  165. scipy/datasets/_registry.py +26 -0
  166. scipy/datasets/_utils.py +81 -0
  167. scipy/datasets/tests/__init__.py +0 -0
  168. scipy/datasets/tests/test_data.py +128 -0
  169. scipy/differentiate/__init__.py +27 -0
  170. scipy/differentiate/_differentiate.py +1129 -0
  171. scipy/differentiate/tests/__init__.py +0 -0
  172. scipy/differentiate/tests/test_differentiate.py +694 -0
  173. scipy/fft/__init__.py +114 -0
  174. scipy/fft/_backend.py +196 -0
  175. scipy/fft/_basic.py +1650 -0
  176. scipy/fft/_basic_backend.py +197 -0
  177. scipy/fft/_debug_backends.py +22 -0
  178. scipy/fft/_fftlog.py +223 -0
  179. scipy/fft/_fftlog_backend.py +200 -0
  180. scipy/fft/_helper.py +348 -0
  181. scipy/fft/_pocketfft/LICENSE.md +25 -0
  182. scipy/fft/_pocketfft/__init__.py +9 -0
  183. scipy/fft/_pocketfft/basic.py +251 -0
  184. scipy/fft/_pocketfft/helper.py +249 -0
  185. scipy/fft/_pocketfft/pypocketfft.cpython-313t-darwin.so +0 -0
  186. scipy/fft/_pocketfft/realtransforms.py +109 -0
  187. scipy/fft/_pocketfft/tests/__init__.py +0 -0
  188. scipy/fft/_pocketfft/tests/test_basic.py +1011 -0
  189. scipy/fft/_pocketfft/tests/test_real_transforms.py +505 -0
  190. scipy/fft/_realtransforms.py +706 -0
  191. scipy/fft/_realtransforms_backend.py +63 -0
  192. scipy/fft/tests/__init__.py +0 -0
  193. scipy/fft/tests/mock_backend.py +96 -0
  194. scipy/fft/tests/test_backend.py +98 -0
  195. scipy/fft/tests/test_basic.py +504 -0
  196. scipy/fft/tests/test_fftlog.py +215 -0
  197. scipy/fft/tests/test_helper.py +558 -0
  198. scipy/fft/tests/test_multithreading.py +84 -0
  199. scipy/fft/tests/test_real_transforms.py +247 -0
  200. scipy/fftpack/__init__.py +103 -0
  201. scipy/fftpack/_basic.py +428 -0
  202. scipy/fftpack/_helper.py +115 -0
  203. scipy/fftpack/_pseudo_diffs.py +554 -0
  204. scipy/fftpack/_realtransforms.py +598 -0
  205. scipy/fftpack/basic.py +20 -0
  206. scipy/fftpack/convolve.cpython-313t-darwin.so +0 -0
  207. scipy/fftpack/helper.py +19 -0
  208. scipy/fftpack/pseudo_diffs.py +22 -0
  209. scipy/fftpack/realtransforms.py +19 -0
  210. scipy/fftpack/tests/__init__.py +0 -0
  211. scipy/fftpack/tests/fftw_double_ref.npz +0 -0
  212. scipy/fftpack/tests/fftw_longdouble_ref.npz +0 -0
  213. scipy/fftpack/tests/fftw_single_ref.npz +0 -0
  214. scipy/fftpack/tests/test.npz +0 -0
  215. scipy/fftpack/tests/test_basic.py +877 -0
  216. scipy/fftpack/tests/test_helper.py +54 -0
  217. scipy/fftpack/tests/test_import.py +33 -0
  218. scipy/fftpack/tests/test_pseudo_diffs.py +388 -0
  219. scipy/fftpack/tests/test_real_transforms.py +836 -0
  220. scipy/integrate/__init__.py +122 -0
  221. scipy/integrate/_bvp.py +1160 -0
  222. scipy/integrate/_cubature.py +729 -0
  223. scipy/integrate/_dop.cpython-313t-darwin.so +0 -0
  224. scipy/integrate/_ivp/__init__.py +8 -0
  225. scipy/integrate/_ivp/base.py +290 -0
  226. scipy/integrate/_ivp/bdf.py +478 -0
  227. scipy/integrate/_ivp/common.py +451 -0
  228. scipy/integrate/_ivp/dop853_coefficients.py +193 -0
  229. scipy/integrate/_ivp/ivp.py +755 -0
  230. scipy/integrate/_ivp/lsoda.py +224 -0
  231. scipy/integrate/_ivp/radau.py +572 -0
  232. scipy/integrate/_ivp/rk.py +601 -0
  233. scipy/integrate/_ivp/tests/__init__.py +0 -0
  234. scipy/integrate/_ivp/tests/test_ivp.py +1287 -0
  235. scipy/integrate/_ivp/tests/test_rk.py +37 -0
  236. scipy/integrate/_lebedev.py +5450 -0
  237. scipy/integrate/_lsoda.cpython-313t-darwin.so +0 -0
  238. scipy/integrate/_ode.py +1395 -0
  239. scipy/integrate/_odepack.cpython-313t-darwin.so +0 -0
  240. scipy/integrate/_odepack_py.py +273 -0
  241. scipy/integrate/_quad_vec.py +674 -0
  242. scipy/integrate/_quadpack.cpython-313t-darwin.so +0 -0
  243. scipy/integrate/_quadpack_py.py +1283 -0
  244. scipy/integrate/_quadrature.py +1336 -0
  245. scipy/integrate/_rules/__init__.py +12 -0
  246. scipy/integrate/_rules/_base.py +518 -0
  247. scipy/integrate/_rules/_gauss_kronrod.py +202 -0
  248. scipy/integrate/_rules/_gauss_legendre.py +62 -0
  249. scipy/integrate/_rules/_genz_malik.py +210 -0
  250. scipy/integrate/_tanhsinh.py +1385 -0
  251. scipy/integrate/_test_multivariate.cpython-313t-darwin.so +0 -0
  252. scipy/integrate/_test_odeint_banded.cpython-313t-darwin.so +0 -0
  253. scipy/integrate/_vode.cpython-313t-darwin.so +0 -0
  254. scipy/integrate/dop.py +15 -0
  255. scipy/integrate/lsoda.py +15 -0
  256. scipy/integrate/odepack.py +17 -0
  257. scipy/integrate/quadpack.py +23 -0
  258. scipy/integrate/tests/__init__.py +0 -0
  259. scipy/integrate/tests/test__quad_vec.py +211 -0
  260. scipy/integrate/tests/test_banded_ode_solvers.py +305 -0
  261. scipy/integrate/tests/test_bvp.py +714 -0
  262. scipy/integrate/tests/test_cubature.py +1375 -0
  263. scipy/integrate/tests/test_integrate.py +840 -0
  264. scipy/integrate/tests/test_odeint_jac.py +74 -0
  265. scipy/integrate/tests/test_quadpack.py +680 -0
  266. scipy/integrate/tests/test_quadrature.py +730 -0
  267. scipy/integrate/tests/test_tanhsinh.py +1171 -0
  268. scipy/integrate/vode.py +15 -0
  269. scipy/interpolate/__init__.py +228 -0
  270. scipy/interpolate/_bary_rational.py +715 -0
  271. scipy/interpolate/_bsplines.py +2469 -0
  272. scipy/interpolate/_cubic.py +973 -0
  273. scipy/interpolate/_dfitpack.cpython-313t-darwin.so +0 -0
  274. scipy/interpolate/_dierckx.cpython-313t-darwin.so +0 -0
  275. scipy/interpolate/_fitpack.cpython-313t-darwin.so +0 -0
  276. scipy/interpolate/_fitpack2.py +2397 -0
  277. scipy/interpolate/_fitpack_impl.py +811 -0
  278. scipy/interpolate/_fitpack_py.py +898 -0
  279. scipy/interpolate/_fitpack_repro.py +996 -0
  280. scipy/interpolate/_interpnd.cpython-313t-darwin.so +0 -0
  281. scipy/interpolate/_interpolate.py +2266 -0
  282. scipy/interpolate/_ndbspline.py +415 -0
  283. scipy/interpolate/_ndgriddata.py +329 -0
  284. scipy/interpolate/_pade.py +67 -0
  285. scipy/interpolate/_polyint.py +1025 -0
  286. scipy/interpolate/_ppoly.cpython-313t-darwin.so +0 -0
  287. scipy/interpolate/_rbf.py +290 -0
  288. scipy/interpolate/_rbfinterp.py +550 -0
  289. scipy/interpolate/_rbfinterp_pythran.cpython-313t-darwin.so +0 -0
  290. scipy/interpolate/_rgi.py +764 -0
  291. scipy/interpolate/_rgi_cython.cpython-313t-darwin.so +0 -0
  292. scipy/interpolate/dfitpack.py +24 -0
  293. scipy/interpolate/fitpack.py +31 -0
  294. scipy/interpolate/fitpack2.py +29 -0
  295. scipy/interpolate/interpnd.py +24 -0
  296. scipy/interpolate/interpolate.py +30 -0
  297. scipy/interpolate/ndgriddata.py +23 -0
  298. scipy/interpolate/polyint.py +24 -0
  299. scipy/interpolate/rbf.py +18 -0
  300. scipy/interpolate/tests/__init__.py +0 -0
  301. scipy/interpolate/tests/data/bug-1310.npz +0 -0
  302. scipy/interpolate/tests/data/estimate_gradients_hang.npy +0 -0
  303. scipy/interpolate/tests/data/gcvspl.npz +0 -0
  304. scipy/interpolate/tests/test_bary_rational.py +368 -0
  305. scipy/interpolate/tests/test_bsplines.py +3754 -0
  306. scipy/interpolate/tests/test_fitpack.py +519 -0
  307. scipy/interpolate/tests/test_fitpack2.py +1431 -0
  308. scipy/interpolate/tests/test_gil.py +64 -0
  309. scipy/interpolate/tests/test_interpnd.py +452 -0
  310. scipy/interpolate/tests/test_interpolate.py +2630 -0
  311. scipy/interpolate/tests/test_ndgriddata.py +308 -0
  312. scipy/interpolate/tests/test_pade.py +107 -0
  313. scipy/interpolate/tests/test_polyint.py +972 -0
  314. scipy/interpolate/tests/test_rbf.py +246 -0
  315. scipy/interpolate/tests/test_rbfinterp.py +534 -0
  316. scipy/interpolate/tests/test_rgi.py +1151 -0
  317. scipy/io/__init__.py +116 -0
  318. scipy/io/_fast_matrix_market/__init__.py +600 -0
  319. scipy/io/_fast_matrix_market/_fmm_core.cpython-313t-darwin.so +0 -0
  320. scipy/io/_fortran.py +354 -0
  321. scipy/io/_harwell_boeing/__init__.py +7 -0
  322. scipy/io/_harwell_boeing/_fortran_format_parser.py +316 -0
  323. scipy/io/_harwell_boeing/hb.py +571 -0
  324. scipy/io/_harwell_boeing/tests/__init__.py +0 -0
  325. scipy/io/_harwell_boeing/tests/test_fortran_format.py +74 -0
  326. scipy/io/_harwell_boeing/tests/test_hb.py +70 -0
  327. scipy/io/_idl.py +917 -0
  328. scipy/io/_mmio.py +968 -0
  329. scipy/io/_netcdf.py +1104 -0
  330. scipy/io/_test_fortran.cpython-313t-darwin.so +0 -0
  331. scipy/io/arff/__init__.py +28 -0
  332. scipy/io/arff/_arffread.py +873 -0
  333. scipy/io/arff/arffread.py +19 -0
  334. scipy/io/arff/tests/__init__.py +0 -0
  335. scipy/io/arff/tests/data/iris.arff +225 -0
  336. scipy/io/arff/tests/data/missing.arff +8 -0
  337. scipy/io/arff/tests/data/nodata.arff +11 -0
  338. scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
  339. scipy/io/arff/tests/data/quoted_nominal_spaces.arff +13 -0
  340. scipy/io/arff/tests/data/test1.arff +10 -0
  341. scipy/io/arff/tests/data/test10.arff +8 -0
  342. scipy/io/arff/tests/data/test11.arff +11 -0
  343. scipy/io/arff/tests/data/test2.arff +15 -0
  344. scipy/io/arff/tests/data/test3.arff +6 -0
  345. scipy/io/arff/tests/data/test4.arff +11 -0
  346. scipy/io/arff/tests/data/test5.arff +26 -0
  347. scipy/io/arff/tests/data/test6.arff +12 -0
  348. scipy/io/arff/tests/data/test7.arff +15 -0
  349. scipy/io/arff/tests/data/test8.arff +12 -0
  350. scipy/io/arff/tests/data/test9.arff +14 -0
  351. scipy/io/arff/tests/test_arffread.py +421 -0
  352. scipy/io/harwell_boeing.py +17 -0
  353. scipy/io/idl.py +17 -0
  354. scipy/io/matlab/__init__.py +66 -0
  355. scipy/io/matlab/_byteordercodes.py +75 -0
  356. scipy/io/matlab/_mio.py +375 -0
  357. scipy/io/matlab/_mio4.py +632 -0
  358. scipy/io/matlab/_mio5.py +901 -0
  359. scipy/io/matlab/_mio5_params.py +281 -0
  360. scipy/io/matlab/_mio5_utils.cpython-313t-darwin.so +0 -0
  361. scipy/io/matlab/_mio_utils.cpython-313t-darwin.so +0 -0
  362. scipy/io/matlab/_miobase.py +435 -0
  363. scipy/io/matlab/_streams.cpython-313t-darwin.so +0 -0
  364. scipy/io/matlab/byteordercodes.py +17 -0
  365. scipy/io/matlab/mio.py +16 -0
  366. scipy/io/matlab/mio4.py +17 -0
  367. scipy/io/matlab/mio5.py +19 -0
  368. scipy/io/matlab/mio5_params.py +18 -0
  369. scipy/io/matlab/mio5_utils.py +17 -0
  370. scipy/io/matlab/mio_utils.py +17 -0
  371. scipy/io/matlab/miobase.py +16 -0
  372. scipy/io/matlab/streams.py +16 -0
  373. scipy/io/matlab/tests/__init__.py +0 -0
  374. scipy/io/matlab/tests/data/bad_miuint32.mat +0 -0
  375. scipy/io/matlab/tests/data/bad_miutf8_array_name.mat +0 -0
  376. scipy/io/matlab/tests/data/big_endian.mat +0 -0
  377. scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
  378. scipy/io/matlab/tests/data/corrupted_zlib_checksum.mat +0 -0
  379. scipy/io/matlab/tests/data/corrupted_zlib_data.mat +0 -0
  380. scipy/io/matlab/tests/data/debigged_m4.mat +0 -0
  381. scipy/io/matlab/tests/data/japanese_utf8.txt +5 -0
  382. scipy/io/matlab/tests/data/little_endian.mat +0 -0
  383. scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
  384. scipy/io/matlab/tests/data/malformed1.mat +0 -0
  385. scipy/io/matlab/tests/data/miuint32_for_miint32.mat +0 -0
  386. scipy/io/matlab/tests/data/miutf8_array_name.mat +0 -0
  387. scipy/io/matlab/tests/data/nasty_duplicate_fieldnames.mat +0 -0
  388. scipy/io/matlab/tests/data/one_by_zero_char.mat +0 -0
  389. scipy/io/matlab/tests/data/parabola.mat +0 -0
  390. scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
  391. scipy/io/matlab/tests/data/some_functions.mat +0 -0
  392. scipy/io/matlab/tests/data/sqr.mat +0 -0
  393. scipy/io/matlab/tests/data/test3dmatrix_6.1_SOL2.mat +0 -0
  394. scipy/io/matlab/tests/data/test3dmatrix_6.5.1_GLNX86.mat +0 -0
  395. scipy/io/matlab/tests/data/test3dmatrix_7.1_GLNX86.mat +0 -0
  396. scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat +0 -0
  397. scipy/io/matlab/tests/data/test_empty_struct.mat +0 -0
  398. scipy/io/matlab/tests/data/test_mat4_le_floats.mat +0 -0
  399. scipy/io/matlab/tests/data/test_skip_variable.mat +0 -0
  400. scipy/io/matlab/tests/data/testbool_8_WIN64.mat +0 -0
  401. scipy/io/matlab/tests/data/testcell_6.1_SOL2.mat +0 -0
  402. scipy/io/matlab/tests/data/testcell_6.5.1_GLNX86.mat +0 -0
  403. scipy/io/matlab/tests/data/testcell_7.1_GLNX86.mat +0 -0
  404. scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat +0 -0
  405. scipy/io/matlab/tests/data/testcellnest_6.1_SOL2.mat +0 -0
  406. scipy/io/matlab/tests/data/testcellnest_6.5.1_GLNX86.mat +0 -0
  407. scipy/io/matlab/tests/data/testcellnest_7.1_GLNX86.mat +0 -0
  408. scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat +0 -0
  409. scipy/io/matlab/tests/data/testcomplex_4.2c_SOL2.mat +0 -0
  410. scipy/io/matlab/tests/data/testcomplex_6.1_SOL2.mat +0 -0
  411. scipy/io/matlab/tests/data/testcomplex_6.5.1_GLNX86.mat +0 -0
  412. scipy/io/matlab/tests/data/testcomplex_7.1_GLNX86.mat +0 -0
  413. scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat +0 -0
  414. scipy/io/matlab/tests/data/testdouble_4.2c_SOL2.mat +0 -0
  415. scipy/io/matlab/tests/data/testdouble_6.1_SOL2.mat +0 -0
  416. scipy/io/matlab/tests/data/testdouble_6.5.1_GLNX86.mat +0 -0
  417. scipy/io/matlab/tests/data/testdouble_7.1_GLNX86.mat +0 -0
  418. scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat +0 -0
  419. scipy/io/matlab/tests/data/testemptycell_5.3_SOL2.mat +0 -0
  420. scipy/io/matlab/tests/data/testemptycell_6.5.1_GLNX86.mat +0 -0
  421. scipy/io/matlab/tests/data/testemptycell_7.1_GLNX86.mat +0 -0
  422. scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat +0 -0
  423. scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat +0 -0
  424. scipy/io/matlab/tests/data/testhdf5_7.4_GLNX86.mat +0 -0
  425. scipy/io/matlab/tests/data/testmatrix_4.2c_SOL2.mat +0 -0
  426. scipy/io/matlab/tests/data/testmatrix_6.1_SOL2.mat +0 -0
  427. scipy/io/matlab/tests/data/testmatrix_6.5.1_GLNX86.mat +0 -0
  428. scipy/io/matlab/tests/data/testmatrix_7.1_GLNX86.mat +0 -0
  429. scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat +0 -0
  430. scipy/io/matlab/tests/data/testminus_4.2c_SOL2.mat +0 -0
  431. scipy/io/matlab/tests/data/testminus_6.1_SOL2.mat +0 -0
  432. scipy/io/matlab/tests/data/testminus_6.5.1_GLNX86.mat +0 -0
  433. scipy/io/matlab/tests/data/testminus_7.1_GLNX86.mat +0 -0
  434. scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat +0 -0
  435. scipy/io/matlab/tests/data/testmulti_4.2c_SOL2.mat +0 -0
  436. scipy/io/matlab/tests/data/testmulti_7.1_GLNX86.mat +0 -0
  437. scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat +0 -0
  438. scipy/io/matlab/tests/data/testobject_6.1_SOL2.mat +0 -0
  439. scipy/io/matlab/tests/data/testobject_6.5.1_GLNX86.mat +0 -0
  440. scipy/io/matlab/tests/data/testobject_7.1_GLNX86.mat +0 -0
  441. scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat +0 -0
  442. scipy/io/matlab/tests/data/testonechar_4.2c_SOL2.mat +0 -0
  443. scipy/io/matlab/tests/data/testonechar_6.1_SOL2.mat +0 -0
  444. scipy/io/matlab/tests/data/testonechar_6.5.1_GLNX86.mat +0 -0
  445. scipy/io/matlab/tests/data/testonechar_7.1_GLNX86.mat +0 -0
  446. scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat +0 -0
  447. scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat +0 -0
  448. scipy/io/matlab/tests/data/testsimplecell.mat +0 -0
  449. scipy/io/matlab/tests/data/testsparse_4.2c_SOL2.mat +0 -0
  450. scipy/io/matlab/tests/data/testsparse_6.1_SOL2.mat +0 -0
  451. scipy/io/matlab/tests/data/testsparse_6.5.1_GLNX86.mat +0 -0
  452. scipy/io/matlab/tests/data/testsparse_7.1_GLNX86.mat +0 -0
  453. scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat +0 -0
  454. scipy/io/matlab/tests/data/testsparsecomplex_4.2c_SOL2.mat +0 -0
  455. scipy/io/matlab/tests/data/testsparsecomplex_6.1_SOL2.mat +0 -0
  456. scipy/io/matlab/tests/data/testsparsecomplex_6.5.1_GLNX86.mat +0 -0
  457. scipy/io/matlab/tests/data/testsparsecomplex_7.1_GLNX86.mat +0 -0
  458. scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat +0 -0
  459. scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat +0 -0
  460. scipy/io/matlab/tests/data/teststring_4.2c_SOL2.mat +0 -0
  461. scipy/io/matlab/tests/data/teststring_6.1_SOL2.mat +0 -0
  462. scipy/io/matlab/tests/data/teststring_6.5.1_GLNX86.mat +0 -0
  463. scipy/io/matlab/tests/data/teststring_7.1_GLNX86.mat +0 -0
  464. scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat +0 -0
  465. scipy/io/matlab/tests/data/teststringarray_4.2c_SOL2.mat +0 -0
  466. scipy/io/matlab/tests/data/teststringarray_6.1_SOL2.mat +0 -0
  467. scipy/io/matlab/tests/data/teststringarray_6.5.1_GLNX86.mat +0 -0
  468. scipy/io/matlab/tests/data/teststringarray_7.1_GLNX86.mat +0 -0
  469. scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat +0 -0
  470. scipy/io/matlab/tests/data/teststruct_6.1_SOL2.mat +0 -0
  471. scipy/io/matlab/tests/data/teststruct_6.5.1_GLNX86.mat +0 -0
  472. scipy/io/matlab/tests/data/teststruct_7.1_GLNX86.mat +0 -0
  473. scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat +0 -0
  474. scipy/io/matlab/tests/data/teststructarr_6.1_SOL2.mat +0 -0
  475. scipy/io/matlab/tests/data/teststructarr_6.5.1_GLNX86.mat +0 -0
  476. scipy/io/matlab/tests/data/teststructarr_7.1_GLNX86.mat +0 -0
  477. scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat +0 -0
  478. scipy/io/matlab/tests/data/teststructnest_6.1_SOL2.mat +0 -0
  479. scipy/io/matlab/tests/data/teststructnest_6.5.1_GLNX86.mat +0 -0
  480. scipy/io/matlab/tests/data/teststructnest_7.1_GLNX86.mat +0 -0
  481. scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat +0 -0
  482. scipy/io/matlab/tests/data/testunicode_7.1_GLNX86.mat +0 -0
  483. scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat +0 -0
  484. scipy/io/matlab/tests/data/testvec_4_GLNX86.mat +0 -0
  485. scipy/io/matlab/tests/test_byteordercodes.py +29 -0
  486. scipy/io/matlab/tests/test_mio.py +1399 -0
  487. scipy/io/matlab/tests/test_mio5_utils.py +179 -0
  488. scipy/io/matlab/tests/test_mio_funcs.py +51 -0
  489. scipy/io/matlab/tests/test_mio_utils.py +45 -0
  490. scipy/io/matlab/tests/test_miobase.py +32 -0
  491. scipy/io/matlab/tests/test_pathological.py +33 -0
  492. scipy/io/matlab/tests/test_streams.py +232 -0
  493. scipy/io/mmio.py +17 -0
  494. scipy/io/netcdf.py +17 -0
  495. scipy/io/tests/__init__.py +0 -0
  496. scipy/io/tests/data/Transparent Busy.ani +0 -0
  497. scipy/io/tests/data/array_float32_1d.sav +0 -0
  498. scipy/io/tests/data/array_float32_2d.sav +0 -0
  499. scipy/io/tests/data/array_float32_3d.sav +0 -0
  500. scipy/io/tests/data/array_float32_4d.sav +0 -0
  501. scipy/io/tests/data/array_float32_5d.sav +0 -0
  502. scipy/io/tests/data/array_float32_6d.sav +0 -0
  503. scipy/io/tests/data/array_float32_7d.sav +0 -0
  504. scipy/io/tests/data/array_float32_8d.sav +0 -0
  505. scipy/io/tests/data/array_float32_pointer_1d.sav +0 -0
  506. scipy/io/tests/data/array_float32_pointer_2d.sav +0 -0
  507. scipy/io/tests/data/array_float32_pointer_3d.sav +0 -0
  508. scipy/io/tests/data/array_float32_pointer_4d.sav +0 -0
  509. scipy/io/tests/data/array_float32_pointer_5d.sav +0 -0
  510. scipy/io/tests/data/array_float32_pointer_6d.sav +0 -0
  511. scipy/io/tests/data/array_float32_pointer_7d.sav +0 -0
  512. scipy/io/tests/data/array_float32_pointer_8d.sav +0 -0
  513. scipy/io/tests/data/example_1.nc +0 -0
  514. scipy/io/tests/data/example_2.nc +0 -0
  515. scipy/io/tests/data/example_3_maskedvals.nc +0 -0
  516. scipy/io/tests/data/fortran-3x3d-2i.dat +0 -0
  517. scipy/io/tests/data/fortran-mixed.dat +0 -0
  518. scipy/io/tests/data/fortran-sf8-11x1x10.dat +0 -0
  519. scipy/io/tests/data/fortran-sf8-15x10x22.dat +0 -0
  520. scipy/io/tests/data/fortran-sf8-1x1x1.dat +0 -0
  521. scipy/io/tests/data/fortran-sf8-1x1x5.dat +0 -0
  522. scipy/io/tests/data/fortran-sf8-1x1x7.dat +0 -0
  523. scipy/io/tests/data/fortran-sf8-1x3x5.dat +0 -0
  524. scipy/io/tests/data/fortran-si4-11x1x10.dat +0 -0
  525. scipy/io/tests/data/fortran-si4-15x10x22.dat +0 -0
  526. scipy/io/tests/data/fortran-si4-1x1x1.dat +0 -0
  527. scipy/io/tests/data/fortran-si4-1x1x5.dat +0 -0
  528. scipy/io/tests/data/fortran-si4-1x1x7.dat +0 -0
  529. scipy/io/tests/data/fortran-si4-1x3x5.dat +0 -0
  530. scipy/io/tests/data/invalid_pointer.sav +0 -0
  531. scipy/io/tests/data/null_pointer.sav +0 -0
  532. scipy/io/tests/data/scalar_byte.sav +0 -0
  533. scipy/io/tests/data/scalar_byte_descr.sav +0 -0
  534. scipy/io/tests/data/scalar_complex32.sav +0 -0
  535. scipy/io/tests/data/scalar_complex64.sav +0 -0
  536. scipy/io/tests/data/scalar_float32.sav +0 -0
  537. scipy/io/tests/data/scalar_float64.sav +0 -0
  538. scipy/io/tests/data/scalar_heap_pointer.sav +0 -0
  539. scipy/io/tests/data/scalar_int16.sav +0 -0
  540. scipy/io/tests/data/scalar_int32.sav +0 -0
  541. scipy/io/tests/data/scalar_int64.sav +0 -0
  542. scipy/io/tests/data/scalar_string.sav +0 -0
  543. scipy/io/tests/data/scalar_uint16.sav +0 -0
  544. scipy/io/tests/data/scalar_uint32.sav +0 -0
  545. scipy/io/tests/data/scalar_uint64.sav +0 -0
  546. scipy/io/tests/data/struct_arrays.sav +0 -0
  547. scipy/io/tests/data/struct_arrays_byte_idl80.sav +0 -0
  548. scipy/io/tests/data/struct_arrays_replicated.sav +0 -0
  549. scipy/io/tests/data/struct_arrays_replicated_3d.sav +0 -0
  550. scipy/io/tests/data/struct_inherit.sav +0 -0
  551. scipy/io/tests/data/struct_pointer_arrays.sav +0 -0
  552. scipy/io/tests/data/struct_pointer_arrays_replicated.sav +0 -0
  553. scipy/io/tests/data/struct_pointer_arrays_replicated_3d.sav +0 -0
  554. scipy/io/tests/data/struct_pointers.sav +0 -0
  555. scipy/io/tests/data/struct_pointers_replicated.sav +0 -0
  556. scipy/io/tests/data/struct_pointers_replicated_3d.sav +0 -0
  557. scipy/io/tests/data/struct_scalars.sav +0 -0
  558. scipy/io/tests/data/struct_scalars_replicated.sav +0 -0
  559. scipy/io/tests/data/struct_scalars_replicated_3d.sav +0 -0
  560. scipy/io/tests/data/test-1234Hz-le-1ch-10S-20bit-extra.wav +0 -0
  561. scipy/io/tests/data/test-44100Hz-2ch-32bit-float-be.wav +0 -0
  562. scipy/io/tests/data/test-44100Hz-2ch-32bit-float-le.wav +0 -0
  563. scipy/io/tests/data/test-44100Hz-be-1ch-4bytes.wav +0 -0
  564. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof-no-data.wav +0 -0
  565. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof.wav +0 -0
  566. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +0 -0
  567. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-rf64.wav +0 -0
  568. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes.wav +0 -0
  569. scipy/io/tests/data/test-48000Hz-2ch-64bit-float-le-wavex.wav +0 -0
  570. scipy/io/tests/data/test-8000Hz-be-3ch-5S-24bit.wav +0 -0
  571. scipy/io/tests/data/test-8000Hz-le-1ch-1byte-ulaw.wav +0 -0
  572. scipy/io/tests/data/test-8000Hz-le-2ch-1byteu.wav +0 -0
  573. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-inconsistent.wav +0 -0
  574. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-rf64.wav +0 -0
  575. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit.wav +0 -0
  576. scipy/io/tests/data/test-8000Hz-le-3ch-5S-36bit.wav +0 -0
  577. scipy/io/tests/data/test-8000Hz-le-3ch-5S-45bit.wav +0 -0
  578. scipy/io/tests/data/test-8000Hz-le-3ch-5S-53bit.wav +0 -0
  579. scipy/io/tests/data/test-8000Hz-le-3ch-5S-64bit.wav +0 -0
  580. scipy/io/tests/data/test-8000Hz-le-4ch-9S-12bit.wav +0 -0
  581. scipy/io/tests/data/test-8000Hz-le-5ch-9S-5bit.wav +0 -0
  582. scipy/io/tests/data/various_compressed.sav +0 -0
  583. scipy/io/tests/test_fortran.py +264 -0
  584. scipy/io/tests/test_idl.py +483 -0
  585. scipy/io/tests/test_mmio.py +831 -0
  586. scipy/io/tests/test_netcdf.py +550 -0
  587. scipy/io/tests/test_paths.py +93 -0
  588. scipy/io/tests/test_wavfile.py +501 -0
  589. scipy/io/wavfile.py +938 -0
  590. scipy/linalg/__init__.pxd +1 -0
  591. scipy/linalg/__init__.py +236 -0
  592. scipy/linalg/_basic.py +2146 -0
  593. scipy/linalg/_blas_subroutines.h +164 -0
  594. scipy/linalg/_cythonized_array_utils.cpython-313t-darwin.so +0 -0
  595. scipy/linalg/_cythonized_array_utils.pxd +40 -0
  596. scipy/linalg/_cythonized_array_utils.pyi +16 -0
  597. scipy/linalg/_decomp.py +1645 -0
  598. scipy/linalg/_decomp_cholesky.py +413 -0
  599. scipy/linalg/_decomp_cossin.py +236 -0
  600. scipy/linalg/_decomp_interpolative.cpython-313t-darwin.so +0 -0
  601. scipy/linalg/_decomp_ldl.py +356 -0
  602. scipy/linalg/_decomp_lu.py +401 -0
  603. scipy/linalg/_decomp_lu_cython.cpython-313t-darwin.so +0 -0
  604. scipy/linalg/_decomp_lu_cython.pyi +6 -0
  605. scipy/linalg/_decomp_polar.py +113 -0
  606. scipy/linalg/_decomp_qr.py +494 -0
  607. scipy/linalg/_decomp_qz.py +452 -0
  608. scipy/linalg/_decomp_schur.py +336 -0
  609. scipy/linalg/_decomp_svd.py +545 -0
  610. scipy/linalg/_decomp_update.cpython-313t-darwin.so +0 -0
  611. scipy/linalg/_expm_frechet.py +417 -0
  612. scipy/linalg/_fblas.cpython-313t-darwin.so +0 -0
  613. scipy/linalg/_flapack.cpython-313t-darwin.so +0 -0
  614. scipy/linalg/_lapack_subroutines.h +1521 -0
  615. scipy/linalg/_linalg_pythran.cpython-313t-darwin.so +0 -0
  616. scipy/linalg/_matfuncs.py +1050 -0
  617. scipy/linalg/_matfuncs_expm.cpython-313t-darwin.so +0 -0
  618. scipy/linalg/_matfuncs_expm.pyi +6 -0
  619. scipy/linalg/_matfuncs_inv_ssq.py +886 -0
  620. scipy/linalg/_matfuncs_schur_sqrtm.cpython-313t-darwin.so +0 -0
  621. scipy/linalg/_matfuncs_sqrtm.py +107 -0
  622. scipy/linalg/_matfuncs_sqrtm_triu.cpython-313t-darwin.so +0 -0
  623. scipy/linalg/_misc.py +191 -0
  624. scipy/linalg/_procrustes.py +113 -0
  625. scipy/linalg/_sketches.py +189 -0
  626. scipy/linalg/_solve_toeplitz.cpython-313t-darwin.so +0 -0
  627. scipy/linalg/_solvers.py +862 -0
  628. scipy/linalg/_special_matrices.py +1322 -0
  629. scipy/linalg/_testutils.py +65 -0
  630. scipy/linalg/basic.py +23 -0
  631. scipy/linalg/blas.py +495 -0
  632. scipy/linalg/cython_blas.cpython-313t-darwin.so +0 -0
  633. scipy/linalg/cython_blas.pxd +169 -0
  634. scipy/linalg/cython_blas.pyx +1432 -0
  635. scipy/linalg/cython_lapack.cpython-313t-darwin.so +0 -0
  636. scipy/linalg/cython_lapack.pxd +1528 -0
  637. scipy/linalg/cython_lapack.pyx +12045 -0
  638. scipy/linalg/decomp.py +23 -0
  639. scipy/linalg/decomp_cholesky.py +21 -0
  640. scipy/linalg/decomp_lu.py +21 -0
  641. scipy/linalg/decomp_qr.py +20 -0
  642. scipy/linalg/decomp_schur.py +21 -0
  643. scipy/linalg/decomp_svd.py +21 -0
  644. scipy/linalg/interpolative.py +989 -0
  645. scipy/linalg/lapack.py +1081 -0
  646. scipy/linalg/matfuncs.py +23 -0
  647. scipy/linalg/misc.py +21 -0
  648. scipy/linalg/special_matrices.py +22 -0
  649. scipy/linalg/tests/__init__.py +0 -0
  650. scipy/linalg/tests/_cython_examples/extending.pyx +23 -0
  651. scipy/linalg/tests/_cython_examples/meson.build +34 -0
  652. scipy/linalg/tests/data/carex_15_data.npz +0 -0
  653. scipy/linalg/tests/data/carex_18_data.npz +0 -0
  654. scipy/linalg/tests/data/carex_19_data.npz +0 -0
  655. scipy/linalg/tests/data/carex_20_data.npz +0 -0
  656. scipy/linalg/tests/data/carex_6_data.npz +0 -0
  657. scipy/linalg/tests/data/gendare_20170120_data.npz +0 -0
  658. scipy/linalg/tests/test_basic.py +2074 -0
  659. scipy/linalg/tests/test_batch.py +588 -0
  660. scipy/linalg/tests/test_blas.py +1127 -0
  661. scipy/linalg/tests/test_cython_blas.py +118 -0
  662. scipy/linalg/tests/test_cython_lapack.py +22 -0
  663. scipy/linalg/tests/test_cythonized_array_utils.py +130 -0
  664. scipy/linalg/tests/test_decomp.py +3189 -0
  665. scipy/linalg/tests/test_decomp_cholesky.py +268 -0
  666. scipy/linalg/tests/test_decomp_cossin.py +314 -0
  667. scipy/linalg/tests/test_decomp_ldl.py +137 -0
  668. scipy/linalg/tests/test_decomp_lu.py +308 -0
  669. scipy/linalg/tests/test_decomp_polar.py +110 -0
  670. scipy/linalg/tests/test_decomp_update.py +1701 -0
  671. scipy/linalg/tests/test_extending.py +46 -0
  672. scipy/linalg/tests/test_fblas.py +607 -0
  673. scipy/linalg/tests/test_interpolative.py +232 -0
  674. scipy/linalg/tests/test_lapack.py +3616 -0
  675. scipy/linalg/tests/test_matfuncs.py +1118 -0
  676. scipy/linalg/tests/test_matmul_toeplitz.py +136 -0
  677. scipy/linalg/tests/test_procrustes.py +214 -0
  678. scipy/linalg/tests/test_sketches.py +118 -0
  679. scipy/linalg/tests/test_solve_toeplitz.py +150 -0
  680. scipy/linalg/tests/test_solvers.py +844 -0
  681. scipy/linalg/tests/test_special_matrices.py +636 -0
  682. scipy/misc/__init__.py +6 -0
  683. scipy/misc/common.py +6 -0
  684. scipy/misc/doccer.py +6 -0
  685. scipy/ndimage/__init__.py +174 -0
  686. scipy/ndimage/_ctest.cpython-313t-darwin.so +0 -0
  687. scipy/ndimage/_cytest.cpython-313t-darwin.so +0 -0
  688. scipy/ndimage/_delegators.py +303 -0
  689. scipy/ndimage/_filters.py +2413 -0
  690. scipy/ndimage/_fourier.py +306 -0
  691. scipy/ndimage/_interpolation.py +1033 -0
  692. scipy/ndimage/_measurements.py +1689 -0
  693. scipy/ndimage/_morphology.py +2634 -0
  694. scipy/ndimage/_nd_image.cpython-313t-darwin.so +0 -0
  695. scipy/ndimage/_ndimage_api.py +16 -0
  696. scipy/ndimage/_ni_docstrings.py +214 -0
  697. scipy/ndimage/_ni_label.cpython-313t-darwin.so +0 -0
  698. scipy/ndimage/_ni_support.py +139 -0
  699. scipy/ndimage/_rank_filter_1d.cpython-313t-darwin.so +0 -0
  700. scipy/ndimage/_support_alternative_backends.py +84 -0
  701. scipy/ndimage/filters.py +27 -0
  702. scipy/ndimage/fourier.py +21 -0
  703. scipy/ndimage/interpolation.py +22 -0
  704. scipy/ndimage/measurements.py +24 -0
  705. scipy/ndimage/morphology.py +27 -0
  706. scipy/ndimage/tests/__init__.py +12 -0
  707. scipy/ndimage/tests/data/label_inputs.txt +21 -0
  708. scipy/ndimage/tests/data/label_results.txt +294 -0
  709. scipy/ndimage/tests/data/label_strels.txt +42 -0
  710. scipy/ndimage/tests/dots.png +0 -0
  711. scipy/ndimage/tests/test_c_api.py +102 -0
  712. scipy/ndimage/tests/test_datatypes.py +67 -0
  713. scipy/ndimage/tests/test_filters.py +3031 -0
  714. scipy/ndimage/tests/test_fourier.py +187 -0
  715. scipy/ndimage/tests/test_interpolation.py +1491 -0
  716. scipy/ndimage/tests/test_measurements.py +1592 -0
  717. scipy/ndimage/tests/test_morphology.py +2950 -0
  718. scipy/ndimage/tests/test_ni_support.py +78 -0
  719. scipy/ndimage/tests/test_splines.py +70 -0
  720. scipy/odr/__init__.py +131 -0
  721. scipy/odr/__odrpack.cpython-313t-darwin.so +0 -0
  722. scipy/odr/_add_newdocs.py +34 -0
  723. scipy/odr/_models.py +315 -0
  724. scipy/odr/_odrpack.py +1154 -0
  725. scipy/odr/models.py +20 -0
  726. scipy/odr/odrpack.py +21 -0
  727. scipy/odr/tests/__init__.py +0 -0
  728. scipy/odr/tests/test_odr.py +607 -0
  729. scipy/optimize/__init__.pxd +1 -0
  730. scipy/optimize/__init__.py +460 -0
  731. scipy/optimize/_basinhopping.py +741 -0
  732. scipy/optimize/_bglu_dense.cpython-313t-darwin.so +0 -0
  733. scipy/optimize/_bracket.py +706 -0
  734. scipy/optimize/_chandrupatla.py +551 -0
  735. scipy/optimize/_cobyla_py.py +297 -0
  736. scipy/optimize/_cobyqa_py.py +72 -0
  737. scipy/optimize/_constraints.py +598 -0
  738. scipy/optimize/_dcsrch.py +728 -0
  739. scipy/optimize/_differentiable_functions.py +835 -0
  740. scipy/optimize/_differentialevolution.py +1970 -0
  741. scipy/optimize/_direct.cpython-313t-darwin.so +0 -0
  742. scipy/optimize/_direct_py.py +280 -0
  743. scipy/optimize/_dual_annealing.py +732 -0
  744. scipy/optimize/_elementwise.py +798 -0
  745. scipy/optimize/_group_columns.cpython-313t-darwin.so +0 -0
  746. scipy/optimize/_hessian_update_strategy.py +479 -0
  747. scipy/optimize/_highspy/__init__.py +0 -0
  748. scipy/optimize/_highspy/_core.cpython-313t-darwin.so +0 -0
  749. scipy/optimize/_highspy/_highs_options.cpython-313t-darwin.so +0 -0
  750. scipy/optimize/_highspy/_highs_wrapper.py +338 -0
  751. scipy/optimize/_isotonic.py +157 -0
  752. scipy/optimize/_lbfgsb.cpython-313t-darwin.so +0 -0
  753. scipy/optimize/_lbfgsb_py.py +634 -0
  754. scipy/optimize/_linesearch.py +896 -0
  755. scipy/optimize/_linprog.py +733 -0
  756. scipy/optimize/_linprog_doc.py +1434 -0
  757. scipy/optimize/_linprog_highs.py +422 -0
  758. scipy/optimize/_linprog_ip.py +1141 -0
  759. scipy/optimize/_linprog_rs.py +572 -0
  760. scipy/optimize/_linprog_simplex.py +663 -0
  761. scipy/optimize/_linprog_util.py +1521 -0
  762. scipy/optimize/_lsap.cpython-313t-darwin.so +0 -0
  763. scipy/optimize/_lsq/__init__.py +5 -0
  764. scipy/optimize/_lsq/bvls.py +183 -0
  765. scipy/optimize/_lsq/common.py +731 -0
  766. scipy/optimize/_lsq/dogbox.py +345 -0
  767. scipy/optimize/_lsq/givens_elimination.cpython-313t-darwin.so +0 -0
  768. scipy/optimize/_lsq/least_squares.py +1044 -0
  769. scipy/optimize/_lsq/lsq_linear.py +361 -0
  770. scipy/optimize/_lsq/trf.py +587 -0
  771. scipy/optimize/_lsq/trf_linear.py +249 -0
  772. scipy/optimize/_milp.py +394 -0
  773. scipy/optimize/_minimize.py +1200 -0
  774. scipy/optimize/_minpack.cpython-313t-darwin.so +0 -0
  775. scipy/optimize/_minpack_py.py +1178 -0
  776. scipy/optimize/_moduleTNC.cpython-313t-darwin.so +0 -0
  777. scipy/optimize/_nnls.py +96 -0
  778. scipy/optimize/_nonlin.py +1634 -0
  779. scipy/optimize/_numdiff.py +963 -0
  780. scipy/optimize/_optimize.py +4169 -0
  781. scipy/optimize/_pava_pybind.cpython-313t-darwin.so +0 -0
  782. scipy/optimize/_qap.py +760 -0
  783. scipy/optimize/_remove_redundancy.py +522 -0
  784. scipy/optimize/_root.py +732 -0
  785. scipy/optimize/_root_scalar.py +538 -0
  786. scipy/optimize/_shgo.py +1606 -0
  787. scipy/optimize/_shgo_lib/__init__.py +0 -0
  788. scipy/optimize/_shgo_lib/_complex.py +1225 -0
  789. scipy/optimize/_shgo_lib/_vertex.py +460 -0
  790. scipy/optimize/_slsqp_py.py +603 -0
  791. scipy/optimize/_slsqplib.cpython-313t-darwin.so +0 -0
  792. scipy/optimize/_spectral.py +260 -0
  793. scipy/optimize/_tnc.py +438 -0
  794. scipy/optimize/_trlib/__init__.py +12 -0
  795. scipy/optimize/_trlib/_trlib.cpython-313t-darwin.so +0 -0
  796. scipy/optimize/_trustregion.py +318 -0
  797. scipy/optimize/_trustregion_constr/__init__.py +6 -0
  798. scipy/optimize/_trustregion_constr/canonical_constraint.py +390 -0
  799. scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +231 -0
  800. scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +584 -0
  801. scipy/optimize/_trustregion_constr/projections.py +411 -0
  802. scipy/optimize/_trustregion_constr/qp_subproblem.py +637 -0
  803. scipy/optimize/_trustregion_constr/report.py +49 -0
  804. scipy/optimize/_trustregion_constr/tests/__init__.py +0 -0
  805. scipy/optimize/_trustregion_constr/tests/test_canonical_constraint.py +296 -0
  806. scipy/optimize/_trustregion_constr/tests/test_nested_minimize.py +39 -0
  807. scipy/optimize/_trustregion_constr/tests/test_projections.py +214 -0
  808. scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +645 -0
  809. scipy/optimize/_trustregion_constr/tests/test_report.py +34 -0
  810. scipy/optimize/_trustregion_constr/tr_interior_point.py +361 -0
  811. scipy/optimize/_trustregion_dogleg.py +122 -0
  812. scipy/optimize/_trustregion_exact.py +437 -0
  813. scipy/optimize/_trustregion_krylov.py +65 -0
  814. scipy/optimize/_trustregion_ncg.py +126 -0
  815. scipy/optimize/_tstutils.py +972 -0
  816. scipy/optimize/_zeros.cpython-313t-darwin.so +0 -0
  817. scipy/optimize/_zeros_py.py +1475 -0
  818. scipy/optimize/cobyla.py +19 -0
  819. scipy/optimize/cython_optimize/__init__.py +133 -0
  820. scipy/optimize/cython_optimize/_zeros.cpython-313t-darwin.so +0 -0
  821. scipy/optimize/cython_optimize/_zeros.pxd +33 -0
  822. scipy/optimize/cython_optimize/c_zeros.pxd +26 -0
  823. scipy/optimize/cython_optimize.pxd +11 -0
  824. scipy/optimize/elementwise.py +38 -0
  825. scipy/optimize/lbfgsb.py +23 -0
  826. scipy/optimize/linesearch.py +18 -0
  827. scipy/optimize/minpack.py +27 -0
  828. scipy/optimize/minpack2.py +17 -0
  829. scipy/optimize/moduleTNC.py +19 -0
  830. scipy/optimize/nonlin.py +29 -0
  831. scipy/optimize/optimize.py +40 -0
  832. scipy/optimize/slsqp.py +22 -0
  833. scipy/optimize/tests/__init__.py +0 -0
  834. scipy/optimize/tests/_cython_examples/extending.pyx +43 -0
  835. scipy/optimize/tests/_cython_examples/meson.build +32 -0
  836. scipy/optimize/tests/test__basinhopping.py +535 -0
  837. scipy/optimize/tests/test__differential_evolution.py +1703 -0
  838. scipy/optimize/tests/test__dual_annealing.py +416 -0
  839. scipy/optimize/tests/test__linprog_clean_inputs.py +312 -0
  840. scipy/optimize/tests/test__numdiff.py +885 -0
  841. scipy/optimize/tests/test__remove_redundancy.py +228 -0
  842. scipy/optimize/tests/test__root.py +124 -0
  843. scipy/optimize/tests/test__shgo.py +1164 -0
  844. scipy/optimize/tests/test__spectral.py +226 -0
  845. scipy/optimize/tests/test_bracket.py +896 -0
  846. scipy/optimize/tests/test_chandrupatla.py +982 -0
  847. scipy/optimize/tests/test_cobyla.py +195 -0
  848. scipy/optimize/tests/test_cobyqa.py +252 -0
  849. scipy/optimize/tests/test_constraint_conversion.py +286 -0
  850. scipy/optimize/tests/test_constraints.py +255 -0
  851. scipy/optimize/tests/test_cython_optimize.py +92 -0
  852. scipy/optimize/tests/test_differentiable_functions.py +1025 -0
  853. scipy/optimize/tests/test_direct.py +321 -0
  854. scipy/optimize/tests/test_extending.py +28 -0
  855. scipy/optimize/tests/test_hessian_update_strategy.py +300 -0
  856. scipy/optimize/tests/test_isotonic_regression.py +167 -0
  857. scipy/optimize/tests/test_lbfgsb_hessinv.py +65 -0
  858. scipy/optimize/tests/test_lbfgsb_setulb.py +122 -0
  859. scipy/optimize/tests/test_least_squares.py +986 -0
  860. scipy/optimize/tests/test_linear_assignment.py +116 -0
  861. scipy/optimize/tests/test_linesearch.py +328 -0
  862. scipy/optimize/tests/test_linprog.py +2577 -0
  863. scipy/optimize/tests/test_lsq_common.py +297 -0
  864. scipy/optimize/tests/test_lsq_linear.py +287 -0
  865. scipy/optimize/tests/test_milp.py +459 -0
  866. scipy/optimize/tests/test_minimize_constrained.py +845 -0
  867. scipy/optimize/tests/test_minpack.py +1194 -0
  868. scipy/optimize/tests/test_nnls.py +469 -0
  869. scipy/optimize/tests/test_nonlin.py +572 -0
  870. scipy/optimize/tests/test_optimize.py +3335 -0
  871. scipy/optimize/tests/test_quadratic_assignment.py +455 -0
  872. scipy/optimize/tests/test_regression.py +40 -0
  873. scipy/optimize/tests/test_slsqp.py +645 -0
  874. scipy/optimize/tests/test_tnc.py +345 -0
  875. scipy/optimize/tests/test_trustregion.py +110 -0
  876. scipy/optimize/tests/test_trustregion_exact.py +351 -0
  877. scipy/optimize/tests/test_trustregion_krylov.py +170 -0
  878. scipy/optimize/tests/test_zeros.py +998 -0
  879. scipy/optimize/tnc.py +22 -0
  880. scipy/optimize/zeros.py +26 -0
  881. scipy/signal/__init__.py +316 -0
  882. scipy/signal/_arraytools.py +264 -0
  883. scipy/signal/_czt.py +575 -0
  884. scipy/signal/_delegators.py +568 -0
  885. scipy/signal/_filter_design.py +5881 -0
  886. scipy/signal/_fir_filter_design.py +1458 -0
  887. scipy/signal/_lti_conversion.py +534 -0
  888. scipy/signal/_ltisys.py +3546 -0
  889. scipy/signal/_max_len_seq.py +139 -0
  890. scipy/signal/_max_len_seq_inner.cpython-313t-darwin.so +0 -0
  891. scipy/signal/_peak_finding.py +1310 -0
  892. scipy/signal/_peak_finding_utils.cpython-313t-darwin.so +0 -0
  893. scipy/signal/_polyutils.py +172 -0
  894. scipy/signal/_savitzky_golay.py +357 -0
  895. scipy/signal/_short_time_fft.py +2187 -0
  896. scipy/signal/_signal_api.py +30 -0
  897. scipy/signal/_signaltools.py +5309 -0
  898. scipy/signal/_sigtools.cpython-313t-darwin.so +0 -0
  899. scipy/signal/_sosfilt.cpython-313t-darwin.so +0 -0
  900. scipy/signal/_spectral_py.py +2471 -0
  901. scipy/signal/_spline.cpython-313t-darwin.so +0 -0
  902. scipy/signal/_spline.pyi +34 -0
  903. scipy/signal/_spline_filters.py +848 -0
  904. scipy/signal/_support_alternative_backends.py +73 -0
  905. scipy/signal/_upfirdn.py +219 -0
  906. scipy/signal/_upfirdn_apply.cpython-313t-darwin.so +0 -0
  907. scipy/signal/_waveforms.py +687 -0
  908. scipy/signal/_wavelets.py +29 -0
  909. scipy/signal/bsplines.py +21 -0
  910. scipy/signal/filter_design.py +28 -0
  911. scipy/signal/fir_filter_design.py +21 -0
  912. scipy/signal/lti_conversion.py +20 -0
  913. scipy/signal/ltisys.py +25 -0
  914. scipy/signal/signaltools.py +27 -0
  915. scipy/signal/spectral.py +21 -0
  916. scipy/signal/spline.py +18 -0
  917. scipy/signal/tests/__init__.py +0 -0
  918. scipy/signal/tests/_scipy_spectral_test_shim.py +311 -0
  919. scipy/signal/tests/mpsig.py +122 -0
  920. scipy/signal/tests/test_array_tools.py +111 -0
  921. scipy/signal/tests/test_bsplines.py +365 -0
  922. scipy/signal/tests/test_cont2discrete.py +424 -0
  923. scipy/signal/tests/test_czt.py +221 -0
  924. scipy/signal/tests/test_dltisys.py +599 -0
  925. scipy/signal/tests/test_filter_design.py +4725 -0
  926. scipy/signal/tests/test_fir_filter_design.py +846 -0
  927. scipy/signal/tests/test_ltisys.py +1225 -0
  928. scipy/signal/tests/test_max_len_seq.py +71 -0
  929. scipy/signal/tests/test_peak_finding.py +915 -0
  930. scipy/signal/tests/test_result_type.py +51 -0
  931. scipy/signal/tests/test_savitzky_golay.py +363 -0
  932. scipy/signal/tests/test_short_time_fft.py +1098 -0
  933. scipy/signal/tests/test_signaltools.py +4729 -0
  934. scipy/signal/tests/test_spectral.py +2103 -0
  935. scipy/signal/tests/test_splines.py +427 -0
  936. scipy/signal/tests/test_upfirdn.py +322 -0
  937. scipy/signal/tests/test_waveforms.py +400 -0
  938. scipy/signal/tests/test_wavelets.py +59 -0
  939. scipy/signal/tests/test_windows.py +987 -0
  940. scipy/signal/waveforms.py +20 -0
  941. scipy/signal/wavelets.py +17 -0
  942. scipy/signal/windows/__init__.py +52 -0
  943. scipy/signal/windows/_windows.py +2513 -0
  944. scipy/signal/windows/windows.py +23 -0
  945. scipy/sparse/__init__.py +350 -0
  946. scipy/sparse/_base.py +1610 -0
  947. scipy/sparse/_bsr.py +880 -0
  948. scipy/sparse/_compressed.py +1328 -0
  949. scipy/sparse/_construct.py +1454 -0
  950. scipy/sparse/_coo.py +1581 -0
  951. scipy/sparse/_csc.py +367 -0
  952. scipy/sparse/_csparsetools.cpython-313t-darwin.so +0 -0
  953. scipy/sparse/_csr.py +558 -0
  954. scipy/sparse/_data.py +569 -0
  955. scipy/sparse/_dia.py +677 -0
  956. scipy/sparse/_dok.py +669 -0
  957. scipy/sparse/_extract.py +178 -0
  958. scipy/sparse/_index.py +444 -0
  959. scipy/sparse/_lil.py +632 -0
  960. scipy/sparse/_matrix.py +169 -0
  961. scipy/sparse/_matrix_io.py +167 -0
  962. scipy/sparse/_sparsetools.cpython-313t-darwin.so +0 -0
  963. scipy/sparse/_spfuncs.py +76 -0
  964. scipy/sparse/_sputils.py +632 -0
  965. scipy/sparse/base.py +24 -0
  966. scipy/sparse/bsr.py +22 -0
  967. scipy/sparse/compressed.py +20 -0
  968. scipy/sparse/construct.py +38 -0
  969. scipy/sparse/coo.py +23 -0
  970. scipy/sparse/csc.py +22 -0
  971. scipy/sparse/csgraph/__init__.py +210 -0
  972. scipy/sparse/csgraph/_flow.cpython-313t-darwin.so +0 -0
  973. scipy/sparse/csgraph/_laplacian.py +563 -0
  974. scipy/sparse/csgraph/_matching.cpython-313t-darwin.so +0 -0
  975. scipy/sparse/csgraph/_min_spanning_tree.cpython-313t-darwin.so +0 -0
  976. scipy/sparse/csgraph/_reordering.cpython-313t-darwin.so +0 -0
  977. scipy/sparse/csgraph/_shortest_path.cpython-313t-darwin.so +0 -0
  978. scipy/sparse/csgraph/_tools.cpython-313t-darwin.so +0 -0
  979. scipy/sparse/csgraph/_traversal.cpython-313t-darwin.so +0 -0
  980. scipy/sparse/csgraph/_validation.py +66 -0
  981. scipy/sparse/csgraph/tests/__init__.py +0 -0
  982. scipy/sparse/csgraph/tests/test_connected_components.py +119 -0
  983. scipy/sparse/csgraph/tests/test_conversions.py +61 -0
  984. scipy/sparse/csgraph/tests/test_flow.py +209 -0
  985. scipy/sparse/csgraph/tests/test_graph_laplacian.py +368 -0
  986. scipy/sparse/csgraph/tests/test_matching.py +307 -0
  987. scipy/sparse/csgraph/tests/test_pydata_sparse.py +197 -0
  988. scipy/sparse/csgraph/tests/test_reordering.py +70 -0
  989. scipy/sparse/csgraph/tests/test_shortest_path.py +540 -0
  990. scipy/sparse/csgraph/tests/test_spanning_tree.py +66 -0
  991. scipy/sparse/csgraph/tests/test_traversal.py +148 -0
  992. scipy/sparse/csr.py +22 -0
  993. scipy/sparse/data.py +18 -0
  994. scipy/sparse/dia.py +22 -0
  995. scipy/sparse/dok.py +22 -0
  996. scipy/sparse/extract.py +23 -0
  997. scipy/sparse/lil.py +22 -0
  998. scipy/sparse/linalg/__init__.py +148 -0
  999. scipy/sparse/linalg/_dsolve/__init__.py +71 -0
  1000. scipy/sparse/linalg/_dsolve/_add_newdocs.py +147 -0
  1001. scipy/sparse/linalg/_dsolve/_superlu.cpython-313t-darwin.so +0 -0
  1002. scipy/sparse/linalg/_dsolve/linsolve.py +882 -0
  1003. scipy/sparse/linalg/_dsolve/tests/__init__.py +0 -0
  1004. scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +928 -0
  1005. scipy/sparse/linalg/_eigen/__init__.py +22 -0
  1006. scipy/sparse/linalg/_eigen/_svds.py +540 -0
  1007. scipy/sparse/linalg/_eigen/_svds_doc.py +382 -0
  1008. scipy/sparse/linalg/_eigen/arpack/COPYING +45 -0
  1009. scipy/sparse/linalg/_eigen/arpack/__init__.py +20 -0
  1010. scipy/sparse/linalg/_eigen/arpack/_arpack.cpython-313t-darwin.so +0 -0
  1011. scipy/sparse/linalg/_eigen/arpack/arpack.py +1706 -0
  1012. scipy/sparse/linalg/_eigen/arpack/tests/__init__.py +0 -0
  1013. scipy/sparse/linalg/_eigen/arpack/tests/test_arpack.py +717 -0
  1014. scipy/sparse/linalg/_eigen/lobpcg/__init__.py +16 -0
  1015. scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +1110 -0
  1016. scipy/sparse/linalg/_eigen/lobpcg/tests/__init__.py +0 -0
  1017. scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py +725 -0
  1018. scipy/sparse/linalg/_eigen/tests/__init__.py +0 -0
  1019. scipy/sparse/linalg/_eigen/tests/test_svds.py +886 -0
  1020. scipy/sparse/linalg/_expm_multiply.py +816 -0
  1021. scipy/sparse/linalg/_interface.py +920 -0
  1022. scipy/sparse/linalg/_isolve/__init__.py +20 -0
  1023. scipy/sparse/linalg/_isolve/_gcrotmk.py +503 -0
  1024. scipy/sparse/linalg/_isolve/iterative.py +1051 -0
  1025. scipy/sparse/linalg/_isolve/lgmres.py +230 -0
  1026. scipy/sparse/linalg/_isolve/lsmr.py +486 -0
  1027. scipy/sparse/linalg/_isolve/lsqr.py +589 -0
  1028. scipy/sparse/linalg/_isolve/minres.py +372 -0
  1029. scipy/sparse/linalg/_isolve/tests/__init__.py +0 -0
  1030. scipy/sparse/linalg/_isolve/tests/test_gcrotmk.py +183 -0
  1031. scipy/sparse/linalg/_isolve/tests/test_iterative.py +809 -0
  1032. scipy/sparse/linalg/_isolve/tests/test_lgmres.py +225 -0
  1033. scipy/sparse/linalg/_isolve/tests/test_lsmr.py +185 -0
  1034. scipy/sparse/linalg/_isolve/tests/test_lsqr.py +120 -0
  1035. scipy/sparse/linalg/_isolve/tests/test_minres.py +97 -0
  1036. scipy/sparse/linalg/_isolve/tests/test_utils.py +9 -0
  1037. scipy/sparse/linalg/_isolve/tfqmr.py +179 -0
  1038. scipy/sparse/linalg/_isolve/utils.py +121 -0
  1039. scipy/sparse/linalg/_matfuncs.py +940 -0
  1040. scipy/sparse/linalg/_norm.py +195 -0
  1041. scipy/sparse/linalg/_onenormest.py +467 -0
  1042. scipy/sparse/linalg/_propack/_cpropack.cpython-313t-darwin.so +0 -0
  1043. scipy/sparse/linalg/_propack/_dpropack.cpython-313t-darwin.so +0 -0
  1044. scipy/sparse/linalg/_propack/_spropack.cpython-313t-darwin.so +0 -0
  1045. scipy/sparse/linalg/_propack/_zpropack.cpython-313t-darwin.so +0 -0
  1046. scipy/sparse/linalg/_special_sparse_arrays.py +949 -0
  1047. scipy/sparse/linalg/_svdp.py +309 -0
  1048. scipy/sparse/linalg/dsolve.py +22 -0
  1049. scipy/sparse/linalg/eigen.py +21 -0
  1050. scipy/sparse/linalg/interface.py +20 -0
  1051. scipy/sparse/linalg/isolve.py +22 -0
  1052. scipy/sparse/linalg/matfuncs.py +18 -0
  1053. scipy/sparse/linalg/tests/__init__.py +0 -0
  1054. scipy/sparse/linalg/tests/propack_test_data.npz +0 -0
  1055. scipy/sparse/linalg/tests/test_expm_multiply.py +367 -0
  1056. scipy/sparse/linalg/tests/test_interface.py +561 -0
  1057. scipy/sparse/linalg/tests/test_matfuncs.py +592 -0
  1058. scipy/sparse/linalg/tests/test_norm.py +154 -0
  1059. scipy/sparse/linalg/tests/test_onenormest.py +252 -0
  1060. scipy/sparse/linalg/tests/test_propack.py +165 -0
  1061. scipy/sparse/linalg/tests/test_pydata_sparse.py +272 -0
  1062. scipy/sparse/linalg/tests/test_special_sparse_arrays.py +337 -0
  1063. scipy/sparse/sparsetools.py +17 -0
  1064. scipy/sparse/spfuncs.py +17 -0
  1065. scipy/sparse/sputils.py +17 -0
  1066. scipy/sparse/tests/__init__.py +0 -0
  1067. scipy/sparse/tests/data/csc_py2.npz +0 -0
  1068. scipy/sparse/tests/data/csc_py3.npz +0 -0
  1069. scipy/sparse/tests/test_arithmetic1d.py +341 -0
  1070. scipy/sparse/tests/test_array_api.py +561 -0
  1071. scipy/sparse/tests/test_base.py +5867 -0
  1072. scipy/sparse/tests/test_common1d.py +447 -0
  1073. scipy/sparse/tests/test_construct.py +872 -0
  1074. scipy/sparse/tests/test_coo.py +1119 -0
  1075. scipy/sparse/tests/test_csc.py +98 -0
  1076. scipy/sparse/tests/test_csr.py +214 -0
  1077. scipy/sparse/tests/test_dok.py +209 -0
  1078. scipy/sparse/tests/test_extract.py +51 -0
  1079. scipy/sparse/tests/test_indexing1d.py +603 -0
  1080. scipy/sparse/tests/test_matrix_io.py +109 -0
  1081. scipy/sparse/tests/test_minmax1d.py +128 -0
  1082. scipy/sparse/tests/test_sparsetools.py +344 -0
  1083. scipy/sparse/tests/test_spfuncs.py +97 -0
  1084. scipy/sparse/tests/test_sputils.py +424 -0
  1085. scipy/spatial/__init__.py +129 -0
  1086. scipy/spatial/_ckdtree.cpython-313t-darwin.so +0 -0
  1087. scipy/spatial/_distance_pybind.cpython-313t-darwin.so +0 -0
  1088. scipy/spatial/_distance_wrap.cpython-313t-darwin.so +0 -0
  1089. scipy/spatial/_geometric_slerp.py +238 -0
  1090. scipy/spatial/_hausdorff.cpython-313t-darwin.so +0 -0
  1091. scipy/spatial/_kdtree.py +920 -0
  1092. scipy/spatial/_plotutils.py +274 -0
  1093. scipy/spatial/_procrustes.py +132 -0
  1094. scipy/spatial/_qhull.cpython-313t-darwin.so +0 -0
  1095. scipy/spatial/_qhull.pyi +213 -0
  1096. scipy/spatial/_spherical_voronoi.py +341 -0
  1097. scipy/spatial/_voronoi.cpython-313t-darwin.so +0 -0
  1098. scipy/spatial/_voronoi.pyi +4 -0
  1099. scipy/spatial/ckdtree.py +18 -0
  1100. scipy/spatial/distance.py +3147 -0
  1101. scipy/spatial/distance.pyi +210 -0
  1102. scipy/spatial/kdtree.py +25 -0
  1103. scipy/spatial/qhull.py +25 -0
  1104. scipy/spatial/tests/__init__.py +0 -0
  1105. scipy/spatial/tests/data/cdist-X1.txt +10 -0
  1106. scipy/spatial/tests/data/cdist-X2.txt +20 -0
  1107. scipy/spatial/tests/data/degenerate_pointset.npz +0 -0
  1108. scipy/spatial/tests/data/iris.txt +150 -0
  1109. scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
  1110. scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +1 -0
  1111. scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
  1112. scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +1 -0
  1113. scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
  1114. scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +1 -0
  1115. scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
  1116. scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +1 -0
  1117. scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
  1118. scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
  1119. scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +1 -0
  1120. scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
  1121. scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
  1122. scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
  1123. scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +1 -0
  1124. scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
  1125. scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +1 -0
  1126. scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
  1127. scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +1 -0
  1128. scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +1 -0
  1129. scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
  1130. scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
  1131. scipy/spatial/tests/data/random-bool-data.txt +100 -0
  1132. scipy/spatial/tests/data/random-double-data.txt +100 -0
  1133. scipy/spatial/tests/data/random-int-data.txt +100 -0
  1134. scipy/spatial/tests/data/random-uint-data.txt +100 -0
  1135. scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
  1136. scipy/spatial/tests/test__plotutils.py +91 -0
  1137. scipy/spatial/tests/test__procrustes.py +116 -0
  1138. scipy/spatial/tests/test_distance.py +2388 -0
  1139. scipy/spatial/tests/test_hausdorff.py +199 -0
  1140. scipy/spatial/tests/test_kdtree.py +1536 -0
  1141. scipy/spatial/tests/test_qhull.py +1313 -0
  1142. scipy/spatial/tests/test_slerp.py +417 -0
  1143. scipy/spatial/tests/test_spherical_voronoi.py +358 -0
  1144. scipy/spatial/transform/__init__.py +31 -0
  1145. scipy/spatial/transform/_rigid_transform.cpython-313t-darwin.so +0 -0
  1146. scipy/spatial/transform/_rotation.cpython-313t-darwin.so +0 -0
  1147. scipy/spatial/transform/_rotation_groups.py +140 -0
  1148. scipy/spatial/transform/_rotation_spline.py +460 -0
  1149. scipy/spatial/transform/rotation.py +21 -0
  1150. scipy/spatial/transform/tests/__init__.py +0 -0
  1151. scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
  1152. scipy/spatial/transform/tests/test_rotation.py +2569 -0
  1153. scipy/spatial/transform/tests/test_rotation_groups.py +169 -0
  1154. scipy/spatial/transform/tests/test_rotation_spline.py +183 -0
  1155. scipy/special/__init__.pxd +1 -0
  1156. scipy/special/__init__.py +841 -0
  1157. scipy/special/_add_newdocs.py +9961 -0
  1158. scipy/special/_basic.py +3576 -0
  1159. scipy/special/_comb.cpython-313t-darwin.so +0 -0
  1160. scipy/special/_ellip_harm.py +214 -0
  1161. scipy/special/_ellip_harm_2.cpython-313t-darwin.so +0 -0
  1162. scipy/special/_gufuncs.cpython-313t-darwin.so +0 -0
  1163. scipy/special/_input_validation.py +17 -0
  1164. scipy/special/_lambertw.py +149 -0
  1165. scipy/special/_logsumexp.py +426 -0
  1166. scipy/special/_mptestutils.py +453 -0
  1167. scipy/special/_multiufuncs.py +610 -0
  1168. scipy/special/_orthogonal.py +2592 -0
  1169. scipy/special/_orthogonal.pyi +330 -0
  1170. scipy/special/_precompute/__init__.py +0 -0
  1171. scipy/special/_precompute/cosine_cdf.py +17 -0
  1172. scipy/special/_precompute/expn_asy.py +54 -0
  1173. scipy/special/_precompute/gammainc_asy.py +116 -0
  1174. scipy/special/_precompute/gammainc_data.py +124 -0
  1175. scipy/special/_precompute/hyp2f1_data.py +484 -0
  1176. scipy/special/_precompute/lambertw.py +68 -0
  1177. scipy/special/_precompute/loggamma.py +43 -0
  1178. scipy/special/_precompute/struve_convergence.py +131 -0
  1179. scipy/special/_precompute/utils.py +38 -0
  1180. scipy/special/_precompute/wright_bessel.py +342 -0
  1181. scipy/special/_precompute/wright_bessel_data.py +152 -0
  1182. scipy/special/_precompute/wrightomega.py +41 -0
  1183. scipy/special/_precompute/zetac.py +27 -0
  1184. scipy/special/_sf_error.py +15 -0
  1185. scipy/special/_specfun.cpython-313t-darwin.so +0 -0
  1186. scipy/special/_special_ufuncs.cpython-313t-darwin.so +0 -0
  1187. scipy/special/_spfun_stats.py +106 -0
  1188. scipy/special/_spherical_bessel.py +397 -0
  1189. scipy/special/_support_alternative_backends.py +295 -0
  1190. scipy/special/_test_internal.cpython-313t-darwin.so +0 -0
  1191. scipy/special/_test_internal.pyi +9 -0
  1192. scipy/special/_testutils.py +321 -0
  1193. scipy/special/_ufuncs.cpython-313t-darwin.so +0 -0
  1194. scipy/special/_ufuncs.pyi +522 -0
  1195. scipy/special/_ufuncs.pyx +13173 -0
  1196. scipy/special/_ufuncs_cxx.cpython-313t-darwin.so +0 -0
  1197. scipy/special/_ufuncs_cxx.pxd +142 -0
  1198. scipy/special/_ufuncs_cxx.pyx +427 -0
  1199. scipy/special/_ufuncs_cxx_defs.h +147 -0
  1200. scipy/special/_ufuncs_defs.h +57 -0
  1201. scipy/special/add_newdocs.py +15 -0
  1202. scipy/special/basic.py +87 -0
  1203. scipy/special/cython_special.cpython-313t-darwin.so +0 -0
  1204. scipy/special/cython_special.pxd +259 -0
  1205. scipy/special/cython_special.pyi +3 -0
  1206. scipy/special/orthogonal.py +45 -0
  1207. scipy/special/sf_error.py +20 -0
  1208. scipy/special/specfun.py +24 -0
  1209. scipy/special/spfun_stats.py +17 -0
  1210. scipy/special/tests/__init__.py +0 -0
  1211. scipy/special/tests/_cython_examples/extending.pyx +12 -0
  1212. scipy/special/tests/_cython_examples/meson.build +34 -0
  1213. scipy/special/tests/data/__init__.py +0 -0
  1214. scipy/special/tests/data/boost.npz +0 -0
  1215. scipy/special/tests/data/gsl.npz +0 -0
  1216. scipy/special/tests/data/local.npz +0 -0
  1217. scipy/special/tests/test_basic.py +4815 -0
  1218. scipy/special/tests/test_bdtr.py +112 -0
  1219. scipy/special/tests/test_boost_ufuncs.py +64 -0
  1220. scipy/special/tests/test_boxcox.py +125 -0
  1221. scipy/special/tests/test_cdflib.py +712 -0
  1222. scipy/special/tests/test_cdft_asymptotic.py +49 -0
  1223. scipy/special/tests/test_cephes_intp_cast.py +29 -0
  1224. scipy/special/tests/test_cosine_distr.py +83 -0
  1225. scipy/special/tests/test_cython_special.py +363 -0
  1226. scipy/special/tests/test_data.py +719 -0
  1227. scipy/special/tests/test_dd.py +42 -0
  1228. scipy/special/tests/test_digamma.py +45 -0
  1229. scipy/special/tests/test_ellip_harm.py +278 -0
  1230. scipy/special/tests/test_erfinv.py +89 -0
  1231. scipy/special/tests/test_exponential_integrals.py +118 -0
  1232. scipy/special/tests/test_extending.py +28 -0
  1233. scipy/special/tests/test_faddeeva.py +85 -0
  1234. scipy/special/tests/test_gamma.py +12 -0
  1235. scipy/special/tests/test_gammainc.py +152 -0
  1236. scipy/special/tests/test_hyp2f1.py +2566 -0
  1237. scipy/special/tests/test_hypergeometric.py +234 -0
  1238. scipy/special/tests/test_iv_ratio.py +249 -0
  1239. scipy/special/tests/test_kolmogorov.py +491 -0
  1240. scipy/special/tests/test_lambertw.py +109 -0
  1241. scipy/special/tests/test_legendre.py +1518 -0
  1242. scipy/special/tests/test_log1mexp.py +85 -0
  1243. scipy/special/tests/test_loggamma.py +70 -0
  1244. scipy/special/tests/test_logit.py +162 -0
  1245. scipy/special/tests/test_logsumexp.py +469 -0
  1246. scipy/special/tests/test_mpmath.py +2293 -0
  1247. scipy/special/tests/test_nan_inputs.py +65 -0
  1248. scipy/special/tests/test_ndtr.py +77 -0
  1249. scipy/special/tests/test_ndtri_exp.py +94 -0
  1250. scipy/special/tests/test_orthogonal.py +821 -0
  1251. scipy/special/tests/test_orthogonal_eval.py +275 -0
  1252. scipy/special/tests/test_owens_t.py +53 -0
  1253. scipy/special/tests/test_pcf.py +24 -0
  1254. scipy/special/tests/test_pdtr.py +48 -0
  1255. scipy/special/tests/test_powm1.py +65 -0
  1256. scipy/special/tests/test_precompute_expn_asy.py +24 -0
  1257. scipy/special/tests/test_precompute_gammainc.py +108 -0
  1258. scipy/special/tests/test_precompute_utils.py +36 -0
  1259. scipy/special/tests/test_round.py +18 -0
  1260. scipy/special/tests/test_sf_error.py +146 -0
  1261. scipy/special/tests/test_sici.py +36 -0
  1262. scipy/special/tests/test_specfun.py +48 -0
  1263. scipy/special/tests/test_spence.py +32 -0
  1264. scipy/special/tests/test_spfun_stats.py +61 -0
  1265. scipy/special/tests/test_sph_harm.py +85 -0
  1266. scipy/special/tests/test_spherical_bessel.py +400 -0
  1267. scipy/special/tests/test_support_alternative_backends.py +248 -0
  1268. scipy/special/tests/test_trig.py +72 -0
  1269. scipy/special/tests/test_ufunc_signatures.py +46 -0
  1270. scipy/special/tests/test_wright_bessel.py +205 -0
  1271. scipy/special/tests/test_wrightomega.py +117 -0
  1272. scipy/special/tests/test_zeta.py +301 -0
  1273. scipy/stats/__init__.py +670 -0
  1274. scipy/stats/_ansari_swilk_statistics.cpython-313t-darwin.so +0 -0
  1275. scipy/stats/_axis_nan_policy.py +692 -0
  1276. scipy/stats/_biasedurn.cpython-313t-darwin.so +0 -0
  1277. scipy/stats/_biasedurn.pxd +27 -0
  1278. scipy/stats/_binned_statistic.py +795 -0
  1279. scipy/stats/_binomtest.py +375 -0
  1280. scipy/stats/_bws_test.py +177 -0
  1281. scipy/stats/_censored_data.py +459 -0
  1282. scipy/stats/_common.py +5 -0
  1283. scipy/stats/_constants.py +42 -0
  1284. scipy/stats/_continued_fraction.py +387 -0
  1285. scipy/stats/_continuous_distns.py +12483 -0
  1286. scipy/stats/_correlation.py +210 -0
  1287. scipy/stats/_covariance.py +636 -0
  1288. scipy/stats/_crosstab.py +204 -0
  1289. scipy/stats/_discrete_distns.py +2098 -0
  1290. scipy/stats/_distn_infrastructure.py +4201 -0
  1291. scipy/stats/_distr_params.py +299 -0
  1292. scipy/stats/_distribution_infrastructure.py +5750 -0
  1293. scipy/stats/_entropy.py +428 -0
  1294. scipy/stats/_finite_differences.py +145 -0
  1295. scipy/stats/_fit.py +1351 -0
  1296. scipy/stats/_hypotests.py +2060 -0
  1297. scipy/stats/_kde.py +732 -0
  1298. scipy/stats/_ksstats.py +600 -0
  1299. scipy/stats/_levy_stable/__init__.py +1231 -0
  1300. scipy/stats/_levy_stable/levyst.cpython-313t-darwin.so +0 -0
  1301. scipy/stats/_mannwhitneyu.py +492 -0
  1302. scipy/stats/_mgc.py +550 -0
  1303. scipy/stats/_morestats.py +4626 -0
  1304. scipy/stats/_mstats_basic.py +3658 -0
  1305. scipy/stats/_mstats_extras.py +521 -0
  1306. scipy/stats/_multicomp.py +449 -0
  1307. scipy/stats/_multivariate.py +7281 -0
  1308. scipy/stats/_new_distributions.py +452 -0
  1309. scipy/stats/_odds_ratio.py +466 -0
  1310. scipy/stats/_page_trend_test.py +486 -0
  1311. scipy/stats/_probability_distribution.py +1964 -0
  1312. scipy/stats/_qmc.py +2956 -0
  1313. scipy/stats/_qmc_cy.cpython-313t-darwin.so +0 -0
  1314. scipy/stats/_qmc_cy.pyi +54 -0
  1315. scipy/stats/_qmvnt.py +454 -0
  1316. scipy/stats/_qmvnt_cy.cpython-313t-darwin.so +0 -0
  1317. scipy/stats/_quantile.py +335 -0
  1318. scipy/stats/_rcont/__init__.py +4 -0
  1319. scipy/stats/_rcont/rcont.cpython-313t-darwin.so +0 -0
  1320. scipy/stats/_relative_risk.py +263 -0
  1321. scipy/stats/_resampling.py +2352 -0
  1322. scipy/stats/_result_classes.py +40 -0
  1323. scipy/stats/_sampling.py +1314 -0
  1324. scipy/stats/_sensitivity_analysis.py +713 -0
  1325. scipy/stats/_sobol.cpython-313t-darwin.so +0 -0
  1326. scipy/stats/_sobol.pyi +54 -0
  1327. scipy/stats/_sobol_direction_numbers.npz +0 -0
  1328. scipy/stats/_stats.cpython-313t-darwin.so +0 -0
  1329. scipy/stats/_stats.pxd +10 -0
  1330. scipy/stats/_stats_mstats_common.py +322 -0
  1331. scipy/stats/_stats_py.py +11089 -0
  1332. scipy/stats/_stats_pythran.cpython-313t-darwin.so +0 -0
  1333. scipy/stats/_survival.py +683 -0
  1334. scipy/stats/_tukeylambda_stats.py +199 -0
  1335. scipy/stats/_unuran/__init__.py +0 -0
  1336. scipy/stats/_unuran/unuran_wrapper.cpython-313t-darwin.so +0 -0
  1337. scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
  1338. scipy/stats/_variation.py +126 -0
  1339. scipy/stats/_warnings_errors.py +38 -0
  1340. scipy/stats/_wilcoxon.py +265 -0
  1341. scipy/stats/biasedurn.py +16 -0
  1342. scipy/stats/contingency.py +521 -0
  1343. scipy/stats/distributions.py +24 -0
  1344. scipy/stats/kde.py +18 -0
  1345. scipy/stats/morestats.py +27 -0
  1346. scipy/stats/mstats.py +140 -0
  1347. scipy/stats/mstats_basic.py +42 -0
  1348. scipy/stats/mstats_extras.py +25 -0
  1349. scipy/stats/mvn.py +17 -0
  1350. scipy/stats/qmc.py +236 -0
  1351. scipy/stats/sampling.py +73 -0
  1352. scipy/stats/stats.py +41 -0
  1353. scipy/stats/tests/__init__.py +0 -0
  1354. scipy/stats/tests/common_tests.py +356 -0
  1355. scipy/stats/tests/data/_mvt.py +171 -0
  1356. scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
  1357. scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
  1358. scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
  1359. scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
  1360. scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
  1361. scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
  1362. scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
  1363. scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
  1364. scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
  1365. scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
  1366. scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
  1367. scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
  1368. scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
  1369. scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
  1370. scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
  1371. scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
  1372. scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
  1373. scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
  1374. scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
  1375. scipy/stats/tests/test_axis_nan_policy.py +1388 -0
  1376. scipy/stats/tests/test_binned_statistic.py +568 -0
  1377. scipy/stats/tests/test_censored_data.py +152 -0
  1378. scipy/stats/tests/test_contingency.py +294 -0
  1379. scipy/stats/tests/test_continued_fraction.py +173 -0
  1380. scipy/stats/tests/test_continuous.py +2198 -0
  1381. scipy/stats/tests/test_continuous_basic.py +1053 -0
  1382. scipy/stats/tests/test_continuous_fit_censored.py +683 -0
  1383. scipy/stats/tests/test_correlation.py +80 -0
  1384. scipy/stats/tests/test_crosstab.py +115 -0
  1385. scipy/stats/tests/test_discrete_basic.py +580 -0
  1386. scipy/stats/tests/test_discrete_distns.py +700 -0
  1387. scipy/stats/tests/test_distributions.py +10400 -0
  1388. scipy/stats/tests/test_entropy.py +322 -0
  1389. scipy/stats/tests/test_fast_gen_inversion.py +433 -0
  1390. scipy/stats/tests/test_fit.py +1090 -0
  1391. scipy/stats/tests/test_hypotests.py +1991 -0
  1392. scipy/stats/tests/test_kdeoth.py +676 -0
  1393. scipy/stats/tests/test_marray.py +289 -0
  1394. scipy/stats/tests/test_mgc.py +217 -0
  1395. scipy/stats/tests/test_morestats.py +3259 -0
  1396. scipy/stats/tests/test_mstats_basic.py +2071 -0
  1397. scipy/stats/tests/test_mstats_extras.py +172 -0
  1398. scipy/stats/tests/test_multicomp.py +405 -0
  1399. scipy/stats/tests/test_multivariate.py +4381 -0
  1400. scipy/stats/tests/test_odds_ratio.py +148 -0
  1401. scipy/stats/tests/test_qmc.py +1492 -0
  1402. scipy/stats/tests/test_quantile.py +199 -0
  1403. scipy/stats/tests/test_rank.py +345 -0
  1404. scipy/stats/tests/test_relative_risk.py +95 -0
  1405. scipy/stats/tests/test_resampling.py +2000 -0
  1406. scipy/stats/tests/test_sampling.py +1450 -0
  1407. scipy/stats/tests/test_sensitivity_analysis.py +310 -0
  1408. scipy/stats/tests/test_stats.py +9707 -0
  1409. scipy/stats/tests/test_survival.py +466 -0
  1410. scipy/stats/tests/test_tukeylambda_stats.py +85 -0
  1411. scipy/stats/tests/test_variation.py +216 -0
  1412. scipy/version.py +12 -0
  1413. scipy-1.16.0.dist-info/LICENSE.txt +934 -0
  1414. scipy-1.16.0.dist-info/METADATA +1082 -0
  1415. scipy-1.16.0.dist-info/RECORD +1416 -0
  1416. scipy-1.16.0.dist-info/WHEEL +6 -0
@@ -0,0 +1,2413 @@
1
+ # Copyright (C) 2003-2005 Peter J. Verveer
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions
5
+ # are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above
11
+ # copyright notice, this list of conditions and the following
12
+ # disclaimer in the documentation and/or other materials provided
13
+ # with the distribution.
14
+ #
15
+ # 3. The name of the author may not be used to endorse or promote
16
+ # products derived from this software without specific prior
17
+ # written permission.
18
+ #
19
+ # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20
+ # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23
+ # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25
+ # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ from collections.abc import Iterable
32
+ import numbers
33
+ import warnings
34
+ import numpy as np
35
+ import operator
36
+ import math
37
+
38
+ from scipy._lib._util import normalize_axis_index
39
+ from scipy._lib._array_api import array_namespace, is_cupy, xp_size
40
+ from . import _ni_support
41
+ from . import _nd_image
42
+ from . import _ni_docstrings
43
+ from . import _rank_filter_1d
44
+
45
+ __all__ = ['correlate1d', 'convolve1d', 'gaussian_filter1d', 'gaussian_filter',
46
+ 'prewitt', 'sobel', 'generic_laplace', 'laplace',
47
+ 'gaussian_laplace', 'generic_gradient_magnitude',
48
+ 'gaussian_gradient_magnitude', 'correlate', 'convolve',
49
+ 'uniform_filter1d', 'uniform_filter', 'minimum_filter1d',
50
+ 'maximum_filter1d', 'minimum_filter', 'maximum_filter',
51
+ 'rank_filter', 'median_filter', 'percentile_filter',
52
+ 'generic_filter1d', 'generic_filter', 'vectorized_filter']
53
+
54
+
55
+ def _vectorized_filter_iv(input, function, size, footprint, output, mode, cval, origin,
56
+ axes, batch_memory):
57
+ xp = array_namespace(input, footprint, output)
58
+
59
+ # vectorized_filter input validation and standardization
60
+ input = xp.asarray(input)
61
+
62
+ if not callable(function):
63
+ raise ValueError("`function` must be a callable.")
64
+
65
+ if size is None and footprint is None:
66
+ raise ValueError("Either `size` or `footprint` must be provided.")
67
+
68
+ if size is not None and footprint is not None:
69
+ raise ValueError("Either `size` or `footprint` may be provided, not both.")
70
+
71
+ if axes is None:
72
+ axes = tuple(range(-input.ndim, 0))
73
+ elif np.isscalar(axes):
74
+ axes = (axes,)
75
+ n_axes = len(axes)
76
+ n_batch = input.ndim - n_axes
77
+
78
+ if n_axes > input.ndim:
79
+ message = ("The length of `axes` may not exceed the dimensionality of `input`"
80
+ "(`input.ndim`).")
81
+ raise ValueError(message)
82
+
83
+ # Either footprint or size must be provided
84
+ footprinted_function = function
85
+ if size is not None:
86
+ # If provided, size must be an integer or tuple of integers.
87
+ size = (size,)*n_axes if np.isscalar(size) else tuple(size)
88
+ valid = [xp.isdtype(xp.asarray(i).dtype, 'integral') and i > 0 for i in size]
89
+ if not all(valid):
90
+ raise ValueError("All elements of `size` must be positive integers.")
91
+ else:
92
+ # If provided, `footprint` must be array-like
93
+ footprint = xp.asarray(footprint, dtype=xp.bool)
94
+ size = footprint.shape
95
+ def footprinted_function(input, *args, axis=-1, **kwargs):
96
+ return function(input[..., footprint], *args, axis=-1, **kwargs)
97
+
98
+ # And by now, the dimensionality of the footprint must equal the number of axes
99
+ if n_axes != len(size):
100
+ message = ("`axes` must be compatible with the dimensionality "
101
+ "of the window specified by `size` or `footprint`.")
102
+ raise ValueError(message)
103
+
104
+ # If this is not *equal* to the dimensionality of `input`, then `axes`
105
+ # must be a provided tuple, and its length must equal the core dimensionality.
106
+ elif n_axes < input.ndim:
107
+ if axes is None:
108
+ message = ("`axes` must be provided if the dimensionality of the window "
109
+ "(`len(size)` or `footprint.ndim`) does not equal the number "
110
+ "of axes of `input` (`input.ndim`).")
111
+ raise ValueError(message)
112
+ else:
113
+ axes = tuple(range(-n_axes, 0)) if axes is None else axes
114
+
115
+ axes = (axes,) if np.isscalar(axes) else axes
116
+
117
+ # If `origin` is provided, then it must be "broadcastable" to a tuple with length
118
+ # equal to the core dimensionality.
119
+ if origin is None:
120
+ origin = (0,) * n_axes
121
+ else:
122
+ origin = (origin,)*n_axes if np.isscalar(origin) else tuple(origin)
123
+ integral = [xp.isdtype(xp.asarray(i).dtype, 'integral') for i in origin]
124
+ if not all(integral):
125
+ raise ValueError("All elements of `origin` must be integers.")
126
+ if not len(origin) == n_axes:
127
+ message = ("`origin` must be an integer or tuple of integers with length "
128
+ "equal to the number of axes.")
129
+ raise ValueError(message)
130
+
131
+ # mode must be one of the allowed strings, and we should convert it to the
132
+ # value required by `np.pad`/`cp.pad` here.
133
+ valid_modes = {'reflect', 'constant', 'nearest', 'mirror', 'wrap',
134
+ 'grid-mirror', 'grid-constant', 'grid-wrap', 'valid'}
135
+ if mode not in valid_modes:
136
+ raise ValueError(f"`mode` must be one of {valid_modes}.")
137
+ mode_map = {'nearest': 'edge', 'reflect': 'symmetric', 'mirror': 'reflect',
138
+ 'grid-mirror': 'reflect', 'grid-constant': 'constant',
139
+ 'grid-wrap': 'wrap'}
140
+ mode = mode_map.get(mode, mode)
141
+
142
+ if mode == 'valid' and any(origin):
143
+ raise ValueError("`mode='valid'` is incompatible with use of `origin`.")
144
+
145
+ if cval is None:
146
+ cval = 0.0
147
+ elif mode != 'constant':
148
+ raise ValueError("Use of `cval` is compatible only with `mode='constant'`.")
149
+
150
+ # `cval` must be a scalar or "broadcastable" to a tuple with the same
151
+ # dimensionality of `input`. (Full input validation done by `np.pad`/`cp.pad`.)
152
+ if not xp.isdtype(xp.asarray(cval).dtype, 'numeric'):
153
+ raise ValueError("`cval` must include only numbers.")
154
+
155
+ # `batch_memory` must be a positive number.
156
+ temp = xp.asarray(batch_memory)
157
+ if temp.ndim != 0 or (not xp.isdtype(temp.dtype, 'numeric')) or temp <= 0:
158
+ raise ValueError("`batch_memory` must be positive number.")
159
+
160
+ # For simplicity, work with `axes` at the end.
161
+ working_axes = tuple(range(-n_axes, 0))
162
+ input = xp.moveaxis(input, axes, working_axes)
163
+ output = (xp.moveaxis(output, axes, working_axes)
164
+ if output is not None else output)
165
+
166
+ # Wrap the function to limit maximum memory usage, deal with `footprint`,
167
+ # and populate `output`. The latter requires some verbosity because we
168
+ # don't know the output dtype.
169
+ def wrapped_function(view, output=output):
170
+ kwargs = {'axis': working_axes}
171
+
172
+ if working_axes == ():
173
+ return footprinted_function(xp.asarray(view), **kwargs)
174
+
175
+ # for now, assume we only have to iterate over zeroth axis
176
+ chunk_size = math.prod(view.shape[1:]) * view.dtype.itemsize
177
+ slices_per_batch = min(view.shape[0], batch_memory // chunk_size)
178
+ if slices_per_batch < 1:
179
+ raise ValueError("`batch_memory` is insufficient for minimum chunk size.")
180
+
181
+ elif slices_per_batch == view.shape[0]:
182
+ if output is None:
183
+ return footprinted_function(xp.asarray(view), **kwargs)
184
+ else:
185
+ output[...] = footprinted_function(xp.asarray(view), **kwargs)
186
+ return output
187
+
188
+ for i in range(0, view.shape[0], slices_per_batch):
189
+ i2 = min(i + slices_per_batch, view.shape[0])
190
+ if output is None:
191
+ # Look at the dtype before allocating the array. (In a follow-up, we
192
+ # can also look at the shape to support non-scalar elements.)
193
+ temp = footprinted_function(xp.asarray(view[i:i2]), **kwargs)
194
+ output = xp.empty(view.shape[:-n_axes], dtype=temp.dtype)
195
+ output[i:i2, ...] = temp
196
+ else:
197
+ output[i:i2, ...] = footprinted_function(xp.asarray(view[i:i2]),
198
+ **kwargs)
199
+ return output
200
+
201
+ return (input, wrapped_function, size, mode, cval, origin,
202
+ working_axes, axes, n_axes, n_batch, xp)
203
+
204
+
205
+ @_ni_docstrings.docfiller
206
+ def vectorized_filter(input, function, *, size=None, footprint=None, output=None,
207
+ mode='reflect', cval=None, origin=None, axes=None,
208
+ batch_memory=2**30):
209
+ """Filter an array with a vectorized Python callable as the kernel
210
+
211
+ Parameters
212
+ ----------
213
+ %(input)s
214
+ function : callable
215
+ Kernel to apply over a window centered at each element of `input`.
216
+ Callable must have signature::
217
+
218
+ function(window: ndarray, *, axis: int | tuple) -> scalar
219
+
220
+ where ``axis`` specifies the axis (or axes) of ``window`` along which
221
+ the filter function is evaluated.
222
+ size : scalar or tuple, optional
223
+ See `footprint` below. Ignored if `footprint` is given.
224
+ footprint : array, optional
225
+ Either `size` or `footprint` must be defined. `size` gives
226
+ the shape that is taken from the input array, at every element
227
+ position, to define the input to the filter function.
228
+ `footprint` is a boolean array that specifies (implicitly) a
229
+ shape, but also which of the elements within this shape will get
230
+ passed to the filter function. Thus ``size=(n, m)`` is equivalent
231
+ to ``footprint=np.ones((n, m))``.
232
+ We adjust `size` to the number of dimensions indicated by `axes`.
233
+ For instance, if `axes` is ``(0, 2, 1)`` and ``n`` is passed for ``size``,
234
+ then the effective `size` is ``(n, n, n)``.
235
+ %(output)s
236
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
237
+ The `mode` parameter determines how the input array is extended
238
+ beyond its boundaries. Default is 'reflect'. Behavior for each valid
239
+ value is as follows:
240
+
241
+ 'reflect' (`d c b a | a b c d | d c b a`)
242
+ The input is extended by reflecting about the edge of the last
243
+ pixel. This mode is also sometimes referred to as half-sample
244
+ symmetric.
245
+
246
+ 'constant' (`k k k k | a b c d | k k k k`)
247
+ The input is extended by filling all values beyond the edge with
248
+ the same constant value, defined by the `cval` parameter.
249
+
250
+ 'nearest' (`a a a a | a b c d | d d d d`)
251
+ The input is extended by replicating the last pixel.
252
+
253
+ 'mirror' (`d c b | a b c d | c b a`)
254
+ The input is extended by reflecting about the center of the last
255
+ pixel. This mode is also sometimes referred to as whole-sample
256
+ symmetric.
257
+
258
+ 'wrap' (`a b c d | a b c d | a b c d`)
259
+ The input is extended by wrapping around to the opposite edge.
260
+
261
+ 'valid' (`| a b c d |`)
262
+ The input is not extended; rather, the output shape is reduced depending
263
+ on the window size according to the following calculation::
264
+
265
+ window_size = np.asarray(size if size is not None else footprint.shape)
266
+ output_shape = np.asarray(input.shape)
267
+ output_shape[np.asarray(axes)] -= (window_size - 1)
268
+
269
+ %(cval)s
270
+ %(origin_multiple)s
271
+ axes : tuple of int, optional
272
+ If None, `input` is filtered along all axes. Otherwise, `input` is filtered
273
+ along the specified axes. When `axes` is specified, the dimensionality of
274
+ `footprint` and the length of any tuples used for `size` or `origin` must
275
+ match the length of `axes`. The ith axis of `footprint` and the ith element
276
+ in these tuples corresponds to the ith element of `axes`.
277
+ batch_memory : int, default: 2**30
278
+ The maximum number of bytes occupied by data in the ``window``
279
+ array passed to ``function``.
280
+
281
+ Returns
282
+ -------
283
+ output : ndarray
284
+ Filtered array. The dtype is the output dtype of `function`. If `function` is
285
+ scalar-valued when applied to a single window, the shape of the output is that
286
+ of `input` (unless ``mode=='valid'``; see `mode` documentation). If `function`
287
+ is multi-valued when applied to a single window, the placement of the
288
+ corresponding dimensions within the output shape depends entirely on the
289
+ behavior of `function`; see Examples.
290
+
291
+ See Also
292
+ --------
293
+ scipy.ndimage.generic_filter
294
+
295
+ Notes
296
+ -----
297
+ This function works by padding `input` according to `mode`, then calling the
298
+ provided `function` on chunks of a sliding window view over the padded array.
299
+ This approach is very simple and flexible, and so the function has many features
300
+ not offered by some other filter functions (e.g. memory control, ``float16``
301
+ and complex dtype support, and any NaN-handling features provided by the
302
+ `function` argument).
303
+
304
+ However, this brute-force approach may perform considerable redundant work.
305
+ Use a specialized filter (e.g. `minimum_filter` instead of this function with
306
+ `numpy.min` as the callable; `uniform_filter` instead of this function with
307
+ `numpy.mean` as the callable) when possible, as it may use a more efficient
308
+ algorithm.
309
+
310
+ When a specialized filter is not available, this function is ideal when `function`
311
+ is a vectorized, pure-Python callable. Even better performance may be possible
312
+ by passing a `scipy.LowLevelCallable` to `generic_filter`. `generic_filter` may
313
+ also be preferred for expensive callables with large filter footprints and
314
+ callables that are not vectorized (i.e. those without ``axis`` support).
315
+
316
+ This function does not provide the ``extra_arguments`` or ``extra_keywords``
317
+ arguments provided by some `ndimage` functions. There are two reasons:
318
+
319
+ - The passthrough functionality can be achieved by the user: simply wrap the
320
+ original callable in another function that provides the required arguments;
321
+ e.g., ``function=lambda input, axis: function(input, *extra_arguments, axis=axis, **extra_keywords)``.
322
+ - There are use cases for `function` to be passed additional *sliding-window data*
323
+ to `function` besides `input`. This is not yet implemented, but we reserve
324
+ these argument names for such a feature, which would add capability rather than
325
+ providing a duplicate interface to existing capability.
326
+
327
+ Examples
328
+ --------
329
+ Suppose we wish to perform a median filter with even window size on a ``float16``
330
+ image. Furthermore, the image has NaNs that we wish to be ignored (and effectively
331
+ removed by the filter). `median_filter` does not support ``float16`` data, its
332
+ behavior when NaNs are present is not defined, and for even window sizes, it does
333
+ not return the usual sample median - the average of the two middle elements. This
334
+ would be an excellent use case for `vectorized_filter` with
335
+ ``function=np.nanmedian``, which supports the required interface: it accepts a
336
+ data array of any shape as the first positional argument, and tuple of axes as
337
+ keyword argument ``axis``.
338
+
339
+ >>> import numpy as np
340
+ >>> from scipy import datasets, ndimage
341
+ >>> from scipy.ndimage import vectorized_filter
342
+ >>> import matplotlib.pyplot as plt
343
+ >>> ascent = ndimage.zoom(datasets.ascent(), 0.5).astype(np.float16)
344
+ >>> ascent[::16, ::16] = np.nan
345
+ >>> result = vectorized_filter(ascent, function=np.nanmedian, size=4)
346
+
347
+ Plot the original and filtered images.
348
+
349
+ >>> fig = plt.figure()
350
+ >>> plt.gray() # show the filtered result in grayscale
351
+ >>> ax1 = fig.add_subplot(121) # left side
352
+ >>> ax2 = fig.add_subplot(122) # right side
353
+ >>> ax1.imshow(ascent)
354
+ >>> ax2.imshow(result)
355
+ >>> fig.tight_layout()
356
+ >>> plt.show()
357
+
358
+ Another need satisfied by `vectorized_filter` is to perform multi-output
359
+ filters. For instance, suppose we wish to filter an image according to the 25th
360
+ and 75th percentiles in addition to the median. We could perform the three
361
+ filters separately.
362
+
363
+ >>> ascent = ndimage.zoom(datasets.ascent(), 0.5)
364
+ >>> def get_quantile_fun(p):
365
+ ... return lambda x, axis: np.quantile(x, p, axis=axis)
366
+ >>> ref1 = vectorized_filter(ascent, get_quantile_fun(0.25), size=4)
367
+ >>> ref2 = vectorized_filter(ascent, get_quantile_fun(0.50), size=4)
368
+ >>> ref3 = vectorized_filter(ascent, get_quantile_fun(0.75), size=4)
369
+ >>> ref = np.stack([ref1, ref2, ref3])
370
+
371
+ However, `vectorized_filter` also supports filters that return multiple outputs
372
+ as long as `output` is unspecified and `batch_memory` is sufficiently high to
373
+ perform the calculation in a single chunk.
374
+
375
+ >>> def quartiles(x, axis):
376
+ ... return np.quantile(x, [0.25, 0.50, 0.75], axis=axis)
377
+ >>> res = vectorized_filter(ascent, quartiles, size=4, batch_memory=np.inf)
378
+ >>> np.all(np.isclose(res, ref))
379
+ np.True_
380
+
381
+ The placement of the additional dimension(s) corresponding with multiple outputs
382
+ is at the discretion of `function`. `quartiles` happens to prepend one dimension
383
+ corresponding with the three outputs simply because that is the behavior of
384
+ `np.quantile`:
385
+
386
+ >>> res.shape == (3,) + ascent.shape
387
+ True
388
+
389
+ If we wished for this dimension to be appended:
390
+
391
+ >>> def quartiles(x, axis):
392
+ ... return np.moveaxis(np.quantile(x, [0.25, 0.50, 0.75], axis=axis), 0, -1)
393
+ >>> res = vectorized_filter(ascent, quartiles, size=4, batch_memory=np.inf)
394
+ >>> res.shape == ascent.shape + (3,)
395
+ True
396
+
397
+ Suppose we wish to implment a "mode" filter - a filter that selects the most
398
+ frequently occuring value within the window. A simple (but rather slow)
399
+ approach is to use `generic_filter` with `scipy.stats.mode`.
400
+
401
+ >>> from scipy import stats
402
+ >>> rng = np.random.default_rng(3195824598724609246)
403
+ >>> input = rng.integers(255, size=(50, 50)).astype(np.uint8)
404
+ >>> def simple_mode(input):
405
+ ... return stats.mode(input, axis=None).mode
406
+ >>> ref = ndimage.generic_filter(input, simple_mode, size=5)
407
+
408
+ If speed is important, `vectorized_filter` can take advantage of the performance
409
+ benefit of a vectorized callable.
410
+
411
+ >>> def vectorized_mode(x, axis=(-1,)):
412
+ ... n_axes = 1 if np.isscalar(axis) else len(axis)
413
+ ... x = np.moveaxis(x, axis, tuple(range(-n_axes, 0)))
414
+ ... x = np.reshape(x, x.shape[:-n_axes] + (-1,))
415
+ ... y = np.sort(x, axis=-1)
416
+ ... i = np.concatenate([np.ones(y.shape[:-1] + (1,), dtype=bool),
417
+ ... y[..., :-1] != y[..., 1:]], axis=-1)
418
+ ... indices = np.arange(y.size)[i.ravel()]
419
+ ... counts = np.diff(indices, append=y.size)
420
+ ... counts = np.reshape(np.repeat(counts, counts), y.shape)
421
+ ... k = np.argmax(counts, axis=-1, keepdims=True)
422
+ ... return np.take_along_axis(y, k, axis=-1)[..., 0]
423
+ >>> res = vectorized_filter(input, vectorized_mode, size=5)
424
+ >>> np.all(res == ref)
425
+ np.True_
426
+
427
+ Depending on the machine, the `vectorized_filter` version may be as much as
428
+ 100x faster.
429
+
430
+ """ # noqa: E501
431
+
432
+ (input, function, size, mode, cval, origin, working_axes, axes, n_axes, n_batch, xp
433
+ ) = _vectorized_filter_iv(input, function, size, footprint, output, mode, cval,
434
+ origin, axes, batch_memory)
435
+
436
+ # `np.pad`/`cp.pad` raises with these sorts of cases, but the best result is
437
+ # probably to return the original array. It could be argued that we should call
438
+ # the function on the empty array with `axis=None` just to determine the output
439
+ # dtype, but I can also see rationale against that.
440
+ if xp_size(input) == 0:
441
+ return xp.asarray(input)
442
+
443
+ # This seems to be defined.
444
+ if input.ndim == 0 and size == ():
445
+ return xp.asarray(function(input) if footprint is None
446
+ else function(input[footprint]))
447
+
448
+ if is_cupy(xp):
449
+ # CuPy is the only GPU backend that has `pad` (with all modes)
450
+ # and `sliding_window_view`. An enhancement would be to use
451
+ # no-copy conversion to CuPy whenever the data is on the GPU.
452
+ cp = xp # let there be no ambiguity!
453
+ swv = cp.lib.stride_tricks.sliding_window_view
454
+ pad = cp.pad
455
+ else:
456
+ # Try to perform no-copy conversion to NumPy for padding and
457
+ # `sliding_window_view`. (If that fails, fine - for now, the only
458
+ # GPU backend we support is CuPy.)
459
+ swv = np.lib.stride_tricks.sliding_window_view
460
+ pad = np.pad
461
+ input = np.asarray(input)
462
+ cval = np.asarray(cval)[()] if mode == 'constant' else None
463
+
464
+ # Border the image according to `mode` and `offset`.
465
+ if mode != 'valid':
466
+ kwargs = {'constant_values': cval} if mode == 'constant' else {}
467
+ borders = tuple((i//2 + j, (i-1)//2 - j) for i, j in zip(size, origin))
468
+ bordered_input = pad(input, ((0, 0),)*n_batch + borders, mode=mode, **kwargs)
469
+ else:
470
+ bordered_input = input
471
+
472
+ # Evaluate function with sliding window view. Function is already wrapped to
473
+ # manage memory, deal with `footprint`, populate `output`, etc.
474
+ view = swv(bordered_input, size, working_axes)
475
+ res = function(view)
476
+
477
+ # move working_axes back to original positions
478
+ return xp.moveaxis(res, working_axes, axes)
479
+
480
+
481
+ def _invalid_origin(origin, lenw):
482
+ return (origin < -(lenw // 2)) or (origin > (lenw - 1) // 2)
483
+
484
+
485
+ def _complex_via_real_components(func, input, weights, output, cval, **kwargs):
486
+ """Complex convolution via a linear combination of real convolutions."""
487
+ complex_input = input.dtype.kind == 'c'
488
+ complex_weights = weights.dtype.kind == 'c'
489
+ if complex_input and complex_weights:
490
+ # real component of the output
491
+ func(input.real, weights.real, output=output.real,
492
+ cval=np.real(cval), **kwargs)
493
+ output.real -= func(input.imag, weights.imag, output=None,
494
+ cval=np.imag(cval), **kwargs)
495
+ # imaginary component of the output
496
+ func(input.real, weights.imag, output=output.imag,
497
+ cval=np.real(cval), **kwargs)
498
+ output.imag += func(input.imag, weights.real, output=None,
499
+ cval=np.imag(cval), **kwargs)
500
+ elif complex_input:
501
+ func(input.real, weights, output=output.real, cval=np.real(cval),
502
+ **kwargs)
503
+ func(input.imag, weights, output=output.imag, cval=np.imag(cval),
504
+ **kwargs)
505
+ else:
506
+ if np.iscomplexobj(cval):
507
+ raise ValueError("Cannot provide a complex-valued cval when the "
508
+ "input is real.")
509
+ func(input, weights.real, output=output.real, cval=cval, **kwargs)
510
+ func(input, weights.imag, output=output.imag, cval=cval, **kwargs)
511
+ return output
512
+
513
+
514
+ def _expand_origin(ndim_image, axes, origin):
515
+ num_axes = len(axes)
516
+ origins = _ni_support._normalize_sequence(origin, num_axes)
517
+ if num_axes < ndim_image:
518
+ # set origin = 0 for any axes not being filtered
519
+ origins_temp = [0,] * ndim_image
520
+ for o, ax in zip(origins, axes):
521
+ origins_temp[ax] = o
522
+ origins = origins_temp
523
+ return origins
524
+
525
+
526
+ def _expand_footprint(ndim_image, axes, footprint,
527
+ footprint_name="footprint"):
528
+ num_axes = len(axes)
529
+ if num_axes < ndim_image:
530
+ if footprint.ndim != num_axes:
531
+ raise RuntimeError(f"{footprint_name}.ndim ({footprint.ndim}) "
532
+ f"must match len(axes) ({num_axes})")
533
+
534
+ footprint = np.expand_dims(
535
+ footprint,
536
+ tuple(ax for ax in range(ndim_image) if ax not in axes)
537
+ )
538
+ return footprint
539
+
540
+
541
+ def _expand_mode(ndim_image, axes, mode):
542
+ num_axes = len(axes)
543
+ if not isinstance(mode, str) and isinstance(mode, Iterable):
544
+ # set mode = 'constant' for any axes not being filtered
545
+ modes = _ni_support._normalize_sequence(mode, num_axes)
546
+ modes_temp = ['constant'] * ndim_image
547
+ for m, ax in zip(modes, axes):
548
+ modes_temp[ax] = m
549
+ mode = modes_temp
550
+ return mode
551
+
552
+
553
+ @_ni_docstrings.docfiller
554
+ def correlate1d(input, weights, axis=-1, output=None, mode="reflect",
555
+ cval=0.0, origin=0):
556
+ """Calculate a 1-D correlation along the given axis.
557
+
558
+ The lines of the array along the given axis are correlated with the
559
+ given weights.
560
+
561
+ Parameters
562
+ ----------
563
+ %(input)s
564
+ weights : array
565
+ 1-D sequence of numbers.
566
+ %(axis)s
567
+ %(output)s
568
+ %(mode_reflect)s
569
+ %(cval)s
570
+ %(origin)s
571
+
572
+ Returns
573
+ -------
574
+ result : ndarray
575
+ Correlation result. Has the same shape as `input`.
576
+
577
+ Examples
578
+ --------
579
+ >>> from scipy.ndimage import correlate1d
580
+ >>> correlate1d([2, 8, 0, 4, 1, 9, 9, 0], weights=[1, 3])
581
+ array([ 8, 26, 8, 12, 7, 28, 36, 9])
582
+ """
583
+ input = np.asarray(input)
584
+ weights = np.asarray(weights)
585
+ complex_input = input.dtype.kind == 'c'
586
+ complex_weights = weights.dtype.kind == 'c'
587
+ if complex_input or complex_weights:
588
+ if complex_weights:
589
+ weights = weights.conj()
590
+ weights = weights.astype(np.complex128, copy=False)
591
+ kwargs = dict(axis=axis, mode=mode, origin=origin)
592
+ output = _ni_support._get_output(output, input, complex_output=True)
593
+ return _complex_via_real_components(correlate1d, input, weights,
594
+ output, cval, **kwargs)
595
+
596
+ output = _ni_support._get_output(output, input)
597
+ weights = np.asarray(weights, dtype=np.float64)
598
+ if weights.ndim != 1 or weights.shape[0] < 1:
599
+ raise RuntimeError('no filter weights given')
600
+ if not weights.flags.contiguous:
601
+ weights = weights.copy()
602
+ axis = normalize_axis_index(axis, input.ndim)
603
+ if _invalid_origin(origin, len(weights)):
604
+ raise ValueError('Invalid origin; origin must satisfy '
605
+ '-(len(weights) // 2) <= origin <= '
606
+ '(len(weights)-1) // 2')
607
+ mode = _ni_support._extend_mode_to_code(mode)
608
+ _nd_image.correlate1d(input, weights, axis, output, mode, cval,
609
+ origin)
610
+ return output
611
+
612
+
613
+ @_ni_docstrings.docfiller
614
+ def convolve1d(input, weights, axis=-1, output=None, mode="reflect",
615
+ cval=0.0, origin=0):
616
+ """Calculate a 1-D convolution along the given axis.
617
+
618
+ The lines of the array along the given axis are convolved with the
619
+ given weights.
620
+
621
+ Parameters
622
+ ----------
623
+ %(input)s
624
+ weights : ndarray
625
+ 1-D sequence of numbers.
626
+ %(axis)s
627
+ %(output)s
628
+ %(mode_reflect)s
629
+ %(cval)s
630
+ %(origin)s
631
+
632
+ Returns
633
+ -------
634
+ convolve1d : ndarray
635
+ Convolved array with same shape as input
636
+
637
+ Examples
638
+ --------
639
+ >>> from scipy.ndimage import convolve1d
640
+ >>> convolve1d([2, 8, 0, 4, 1, 9, 9, 0], weights=[1, 3])
641
+ array([14, 24, 4, 13, 12, 36, 27, 0])
642
+ """
643
+ weights = np.asarray(weights)
644
+ weights = weights[::-1]
645
+ origin = -origin
646
+ if not weights.shape[0] & 1:
647
+ origin -= 1
648
+ if weights.dtype.kind == 'c':
649
+ # pre-conjugate here to counteract the conjugation in correlate1d
650
+ weights = weights.conj()
651
+ return correlate1d(input, weights, axis, output, mode, cval, origin)
652
+
653
+
654
+ def _gaussian_kernel1d(sigma, order, radius):
655
+ """
656
+ Computes a 1-D Gaussian convolution kernel.
657
+ """
658
+ if order < 0:
659
+ raise ValueError('order must be non-negative')
660
+ exponent_range = np.arange(order + 1)
661
+ sigma2 = sigma * sigma
662
+ x = np.arange(-radius, radius+1)
663
+ phi_x = np.exp(-0.5 / sigma2 * x ** 2)
664
+ phi_x = phi_x / phi_x.sum()
665
+
666
+ if order == 0:
667
+ return phi_x
668
+ else:
669
+ # f(x) = q(x) * phi(x) = q(x) * exp(p(x))
670
+ # f'(x) = (q'(x) + q(x) * p'(x)) * phi(x)
671
+ # p'(x) = -1 / sigma ** 2
672
+ # Implement q'(x) + q(x) * p'(x) as a matrix operator and apply to the
673
+ # coefficients of q(x)
674
+ q = np.zeros(order + 1)
675
+ q[0] = 1
676
+ D = np.diag(exponent_range[1:], 1) # D @ q(x) = q'(x)
677
+ P = np.diag(np.ones(order)/-sigma2, -1) # P @ q(x) = q(x) * p'(x)
678
+ Q_deriv = D + P
679
+ for _ in range(order):
680
+ q = Q_deriv.dot(q)
681
+ q = (x[:, None] ** exponent_range).dot(q)
682
+ return q * phi_x
683
+
684
+
685
+ @_ni_docstrings.docfiller
686
+ def gaussian_filter1d(input, sigma, axis=-1, order=0, output=None,
687
+ mode="reflect", cval=0.0, truncate=4.0, *, radius=None):
688
+ """1-D Gaussian filter.
689
+
690
+ Parameters
691
+ ----------
692
+ %(input)s
693
+ sigma : scalar
694
+ standard deviation for Gaussian kernel
695
+ %(axis)s
696
+ order : int, optional
697
+ An order of 0 corresponds to convolution with a Gaussian
698
+ kernel. A positive order corresponds to convolution with
699
+ that derivative of a Gaussian.
700
+ %(output)s
701
+ %(mode_reflect)s
702
+ %(cval)s
703
+ truncate : float, optional
704
+ Truncate the filter at this many standard deviations.
705
+ Default is 4.0.
706
+ radius : None or int, optional
707
+ Radius of the Gaussian kernel. If specified, the size of
708
+ the kernel will be ``2*radius + 1``, and `truncate` is ignored.
709
+ Default is None.
710
+
711
+ Returns
712
+ -------
713
+ gaussian_filter1d : ndarray
714
+
715
+ Notes
716
+ -----
717
+ The Gaussian kernel will have size ``2*radius + 1`` along each axis. If
718
+ `radius` is None, a default ``radius = round(truncate * sigma)`` will be
719
+ used.
720
+
721
+ Examples
722
+ --------
723
+ >>> from scipy.ndimage import gaussian_filter1d
724
+ >>> import numpy as np
725
+ >>> gaussian_filter1d([1.0, 2.0, 3.0, 4.0, 5.0], 1)
726
+ array([ 1.42704095, 2.06782203, 3. , 3.93217797, 4.57295905])
727
+ >>> gaussian_filter1d([1.0, 2.0, 3.0, 4.0, 5.0], 4)
728
+ array([ 2.91948343, 2.95023502, 3. , 3.04976498, 3.08051657])
729
+ >>> import matplotlib.pyplot as plt
730
+ >>> rng = np.random.default_rng()
731
+ >>> x = rng.standard_normal(101).cumsum()
732
+ >>> y3 = gaussian_filter1d(x, 3)
733
+ >>> y6 = gaussian_filter1d(x, 6)
734
+ >>> plt.plot(x, 'k', label='original data')
735
+ >>> plt.plot(y3, '--', label='filtered, sigma=3')
736
+ >>> plt.plot(y6, ':', label='filtered, sigma=6')
737
+ >>> plt.legend()
738
+ >>> plt.grid()
739
+ >>> plt.show()
740
+
741
+ """
742
+ sd = float(sigma)
743
+ # make the radius of the filter equal to truncate standard deviations
744
+ lw = int(truncate * sd + 0.5)
745
+ if radius is not None:
746
+ lw = radius
747
+ if not isinstance(lw, numbers.Integral) or lw < 0:
748
+ raise ValueError('Radius must be a nonnegative integer.')
749
+ # Since we are calling correlate, not convolve, revert the kernel
750
+ weights = _gaussian_kernel1d(sigma, order, lw)[::-1]
751
+ return correlate1d(input, weights, axis, output, mode, cval, 0)
752
+
753
+
754
+ @_ni_docstrings.docfiller
755
+ def gaussian_filter(input, sigma, order=0, output=None,
756
+ mode="reflect", cval=0.0, truncate=4.0, *, radius=None,
757
+ axes=None):
758
+ """Multidimensional Gaussian filter.
759
+
760
+ Parameters
761
+ ----------
762
+ %(input)s
763
+ sigma : scalar or sequence of scalars
764
+ Standard deviation for Gaussian kernel. The standard
765
+ deviations of the Gaussian filter are given for each axis as a
766
+ sequence, or as a single number, in which case it is equal for
767
+ all axes.
768
+ order : int or sequence of ints, optional
769
+ The order of the filter along each axis is given as a sequence
770
+ of integers, or as a single number. An order of 0 corresponds
771
+ to convolution with a Gaussian kernel. A positive order
772
+ corresponds to convolution with that derivative of a Gaussian.
773
+ %(output)s
774
+ %(mode_multiple)s
775
+ %(cval)s
776
+ truncate : float, optional
777
+ Truncate the filter at this many standard deviations.
778
+ Default is 4.0.
779
+ radius : None or int or sequence of ints, optional
780
+ Radius of the Gaussian kernel. The radius are given for each axis
781
+ as a sequence, or as a single number, in which case it is equal
782
+ for all axes. If specified, the size of the kernel along each axis
783
+ will be ``2*radius + 1``, and `truncate` is ignored.
784
+ Default is None.
785
+ axes : tuple of int or None, optional
786
+ If None, `input` is filtered along all axes. Otherwise,
787
+ `input` is filtered along the specified axes. When `axes` is
788
+ specified, any tuples used for `sigma`, `order`, `mode` and/or `radius`
789
+ must match the length of `axes`. The ith entry in any of these tuples
790
+ corresponds to the ith entry in `axes`.
791
+
792
+ Returns
793
+ -------
794
+ gaussian_filter : ndarray
795
+ Returned array of same shape as `input`.
796
+
797
+ Notes
798
+ -----
799
+ The multidimensional filter is implemented as a sequence of
800
+ 1-D convolution filters. The intermediate arrays are
801
+ stored in the same data type as the output. Therefore, for output
802
+ types with a limited precision, the results may be imprecise
803
+ because intermediate results may be stored with insufficient
804
+ precision.
805
+
806
+ The Gaussian kernel will have size ``2*radius + 1`` along each axis. If
807
+ `radius` is None, the default ``radius = round(truncate * sigma)`` will be
808
+ used.
809
+
810
+ Examples
811
+ --------
812
+ >>> from scipy.ndimage import gaussian_filter
813
+ >>> import numpy as np
814
+ >>> a = np.arange(50, step=2).reshape((5,5))
815
+ >>> a
816
+ array([[ 0, 2, 4, 6, 8],
817
+ [10, 12, 14, 16, 18],
818
+ [20, 22, 24, 26, 28],
819
+ [30, 32, 34, 36, 38],
820
+ [40, 42, 44, 46, 48]])
821
+ >>> gaussian_filter(a, sigma=1)
822
+ array([[ 4, 6, 8, 9, 11],
823
+ [10, 12, 14, 15, 17],
824
+ [20, 22, 24, 25, 27],
825
+ [29, 31, 33, 34, 36],
826
+ [35, 37, 39, 40, 42]])
827
+
828
+ >>> from scipy import datasets
829
+ >>> import matplotlib.pyplot as plt
830
+ >>> fig = plt.figure()
831
+ >>> plt.gray() # show the filtered result in grayscale
832
+ >>> ax1 = fig.add_subplot(121) # left side
833
+ >>> ax2 = fig.add_subplot(122) # right side
834
+ >>> ascent = datasets.ascent()
835
+ >>> result = gaussian_filter(ascent, sigma=5)
836
+ >>> ax1.imshow(ascent)
837
+ >>> ax2.imshow(result)
838
+ >>> plt.show()
839
+ """
840
+ input = np.asarray(input)
841
+ output = _ni_support._get_output(output, input)
842
+
843
+ axes = _ni_support._check_axes(axes, input.ndim)
844
+ num_axes = len(axes)
845
+ orders = _ni_support._normalize_sequence(order, num_axes)
846
+ sigmas = _ni_support._normalize_sequence(sigma, num_axes)
847
+ modes = _ni_support._normalize_sequence(mode, num_axes)
848
+ radiuses = _ni_support._normalize_sequence(radius, num_axes)
849
+ axes = [(axes[ii], sigmas[ii], orders[ii], modes[ii], radiuses[ii])
850
+ for ii in range(num_axes) if sigmas[ii] > 1e-15]
851
+ if len(axes) > 0:
852
+ for axis, sigma, order, mode, radius in axes:
853
+ gaussian_filter1d(input, sigma, axis, order, output,
854
+ mode, cval, truncate, radius=radius)
855
+ input = output
856
+ else:
857
+ output[...] = input[...]
858
+ return output
859
+
860
+
861
+ @_ni_docstrings.docfiller
862
+ def prewitt(input, axis=-1, output=None, mode="reflect", cval=0.0):
863
+ """Calculate a Prewitt filter.
864
+
865
+ Parameters
866
+ ----------
867
+ %(input)s
868
+ %(axis)s
869
+ %(output)s
870
+ %(mode_multiple)s
871
+ %(cval)s
872
+
873
+ Returns
874
+ -------
875
+ prewitt : ndarray
876
+ Filtered array. Has the same shape as `input`.
877
+
878
+ See Also
879
+ --------
880
+ sobel: Sobel filter
881
+
882
+ Notes
883
+ -----
884
+ This function computes the one-dimensional Prewitt filter.
885
+ Horizontal edges are emphasised with the horizontal transform (axis=0),
886
+ vertical edges with the vertical transform (axis=1), and so on for higher
887
+ dimensions. These can be combined to give the magnitude.
888
+
889
+ Examples
890
+ --------
891
+ >>> from scipy import ndimage, datasets
892
+ >>> import matplotlib.pyplot as plt
893
+ >>> import numpy as np
894
+ >>> ascent = datasets.ascent()
895
+ >>> prewitt_h = ndimage.prewitt(ascent, axis=0)
896
+ >>> prewitt_v = ndimage.prewitt(ascent, axis=1)
897
+ >>> magnitude = np.sqrt(prewitt_h ** 2 + prewitt_v ** 2)
898
+ >>> magnitude *= 255 / np.max(magnitude) # Normalization
899
+ >>> fig, axes = plt.subplots(2, 2, figsize = (8, 8))
900
+ >>> plt.gray()
901
+ >>> axes[0, 0].imshow(ascent)
902
+ >>> axes[0, 1].imshow(prewitt_h)
903
+ >>> axes[1, 0].imshow(prewitt_v)
904
+ >>> axes[1, 1].imshow(magnitude)
905
+ >>> titles = ["original", "horizontal", "vertical", "magnitude"]
906
+ >>> for i, ax in enumerate(axes.ravel()):
907
+ ... ax.set_title(titles[i])
908
+ ... ax.axis("off")
909
+ >>> plt.show()
910
+
911
+ """
912
+ input = np.asarray(input)
913
+ axis = normalize_axis_index(axis, input.ndim)
914
+ output = _ni_support._get_output(output, input)
915
+ modes = _ni_support._normalize_sequence(mode, input.ndim)
916
+ correlate1d(input, [-1, 0, 1], axis, output, modes[axis], cval, 0)
917
+ axes = [ii for ii in range(input.ndim) if ii != axis]
918
+ for ii in axes:
919
+ correlate1d(output, [1, 1, 1], ii, output, modes[ii], cval, 0,)
920
+ return output
921
+
922
+
923
+ @_ni_docstrings.docfiller
924
+ def sobel(input, axis=-1, output=None, mode="reflect", cval=0.0):
925
+ """Calculate a Sobel filter.
926
+
927
+ Parameters
928
+ ----------
929
+ %(input)s
930
+ %(axis)s
931
+ %(output)s
932
+ %(mode_multiple)s
933
+ %(cval)s
934
+
935
+ Returns
936
+ -------
937
+ sobel : ndarray
938
+ Filtered array. Has the same shape as `input`.
939
+
940
+ Notes
941
+ -----
942
+ This function computes the axis-specific Sobel gradient.
943
+ The horizontal edges can be emphasised with the horizontal transform (axis=0),
944
+ the vertical edges with the vertical transform (axis=1) and so on for higher
945
+ dimensions. These can be combined to give the magnitude.
946
+
947
+ Examples
948
+ --------
949
+ >>> from scipy import ndimage, datasets
950
+ >>> import matplotlib.pyplot as plt
951
+ >>> import numpy as np
952
+ >>> ascent = datasets.ascent().astype('int32')
953
+ >>> sobel_h = ndimage.sobel(ascent, 0) # horizontal gradient
954
+ >>> sobel_v = ndimage.sobel(ascent, 1) # vertical gradient
955
+ >>> magnitude = np.sqrt(sobel_h**2 + sobel_v**2)
956
+ >>> magnitude *= 255.0 / np.max(magnitude) # normalization
957
+ >>> fig, axs = plt.subplots(2, 2, figsize=(8, 8))
958
+ >>> plt.gray() # show the filtered result in grayscale
959
+ >>> axs[0, 0].imshow(ascent)
960
+ >>> axs[0, 1].imshow(sobel_h)
961
+ >>> axs[1, 0].imshow(sobel_v)
962
+ >>> axs[1, 1].imshow(magnitude)
963
+ >>> titles = ["original", "horizontal", "vertical", "magnitude"]
964
+ >>> for i, ax in enumerate(axs.ravel()):
965
+ ... ax.set_title(titles[i])
966
+ ... ax.axis("off")
967
+ >>> plt.show()
968
+
969
+ """
970
+ input = np.asarray(input)
971
+ axis = normalize_axis_index(axis, input.ndim)
972
+ output = _ni_support._get_output(output, input)
973
+ modes = _ni_support._normalize_sequence(mode, input.ndim)
974
+ correlate1d(input, [-1, 0, 1], axis, output, modes[axis], cval, 0)
975
+ axes = [ii for ii in range(input.ndim) if ii != axis]
976
+ for ii in axes:
977
+ correlate1d(output, [1, 2, 1], ii, output, modes[ii], cval, 0)
978
+ return output
979
+
980
+
981
+ @_ni_docstrings.docfiller
982
+ def generic_laplace(input, derivative2, output=None, mode="reflect",
983
+ cval=0.0,
984
+ extra_arguments=(),
985
+ extra_keywords=None,
986
+ *, axes=None):
987
+ """
988
+ N-D Laplace filter using a provided second derivative function.
989
+
990
+ Parameters
991
+ ----------
992
+ %(input)s
993
+ derivative2 : callable
994
+ Callable with the following signature::
995
+
996
+ derivative2(input, axis, output, mode, cval,
997
+ *extra_arguments, **extra_keywords)
998
+
999
+ See `extra_arguments`, `extra_keywords` below.
1000
+ %(output)s
1001
+ %(mode_multiple)s
1002
+ %(cval)s
1003
+ %(extra_keywords)s
1004
+ %(extra_arguments)s
1005
+ axes : tuple of int or None
1006
+ The axes over which to apply the filter. If a `mode` tuple is
1007
+ provided, its length must match the number of axes.
1008
+
1009
+ Returns
1010
+ -------
1011
+ generic_laplace : ndarray
1012
+ Filtered array. Has the same shape as `input`.
1013
+
1014
+ """
1015
+ if extra_keywords is None:
1016
+ extra_keywords = {}
1017
+ input = np.asarray(input)
1018
+ output = _ni_support._get_output(output, input)
1019
+ axes = _ni_support._check_axes(axes, input.ndim)
1020
+ if len(axes) > 0:
1021
+ modes = _ni_support._normalize_sequence(mode, len(axes))
1022
+ derivative2(input, axes[0], output, modes[0], cval,
1023
+ *extra_arguments, **extra_keywords)
1024
+ for ii in range(1, len(axes)):
1025
+ tmp = derivative2(input, axes[ii], output.dtype, modes[ii], cval,
1026
+ *extra_arguments, **extra_keywords)
1027
+ output += tmp
1028
+ else:
1029
+ output[...] = input[...]
1030
+ return output
1031
+
1032
+
1033
+ @_ni_docstrings.docfiller
1034
+ def laplace(input, output=None, mode="reflect", cval=0.0, *, axes=None):
1035
+ """N-D Laplace filter based on approximate second derivatives.
1036
+
1037
+ Parameters
1038
+ ----------
1039
+ %(input)s
1040
+ %(output)s
1041
+ %(mode_multiple)s
1042
+ %(cval)s
1043
+ axes : tuple of int or None
1044
+ The axes over which to apply the filter. If a `mode` tuple is
1045
+ provided, its length must match the number of axes.
1046
+
1047
+ Returns
1048
+ -------
1049
+ laplace : ndarray
1050
+ Filtered array. Has the same shape as `input`.
1051
+
1052
+ Examples
1053
+ --------
1054
+ >>> from scipy import ndimage, datasets
1055
+ >>> import matplotlib.pyplot as plt
1056
+ >>> fig = plt.figure()
1057
+ >>> plt.gray() # show the filtered result in grayscale
1058
+ >>> ax1 = fig.add_subplot(121) # left side
1059
+ >>> ax2 = fig.add_subplot(122) # right side
1060
+ >>> ascent = datasets.ascent()
1061
+ >>> result = ndimage.laplace(ascent)
1062
+ >>> ax1.imshow(ascent)
1063
+ >>> ax2.imshow(result)
1064
+ >>> plt.show()
1065
+ """
1066
+ def derivative2(input, axis, output, mode, cval):
1067
+ return correlate1d(input, [1, -2, 1], axis, output, mode, cval, 0)
1068
+ return generic_laplace(input, derivative2, output, mode, cval, axes=axes)
1069
+
1070
+
1071
+ @_ni_docstrings.docfiller
1072
+ def gaussian_laplace(input, sigma, output=None, mode="reflect",
1073
+ cval=0.0, *, axes=None, **kwargs):
1074
+ """Multidimensional Laplace filter using Gaussian second derivatives.
1075
+
1076
+ Parameters
1077
+ ----------
1078
+ %(input)s
1079
+ sigma : scalar or sequence of scalars
1080
+ The standard deviations of the Gaussian filter are given for
1081
+ each axis as a sequence, or as a single number, in which case
1082
+ it is equal for all axes.
1083
+ %(output)s
1084
+ %(mode_multiple)s
1085
+ %(cval)s
1086
+ axes : tuple of int or None
1087
+ The axes over which to apply the filter. If `sigma` or `mode` tuples
1088
+ are provided, their length must match the number of axes.
1089
+ Extra keyword arguments will be passed to gaussian_filter().
1090
+
1091
+ Returns
1092
+ -------
1093
+ gaussian_laplace : ndarray
1094
+ Filtered array. Has the same shape as `input`.
1095
+
1096
+ Examples
1097
+ --------
1098
+ >>> from scipy import ndimage, datasets
1099
+ >>> import matplotlib.pyplot as plt
1100
+ >>> ascent = datasets.ascent()
1101
+
1102
+ >>> fig = plt.figure()
1103
+ >>> plt.gray() # show the filtered result in grayscale
1104
+ >>> ax1 = fig.add_subplot(121) # left side
1105
+ >>> ax2 = fig.add_subplot(122) # right side
1106
+
1107
+ >>> result = ndimage.gaussian_laplace(ascent, sigma=1)
1108
+ >>> ax1.imshow(result)
1109
+
1110
+ >>> result = ndimage.gaussian_laplace(ascent, sigma=3)
1111
+ >>> ax2.imshow(result)
1112
+ >>> plt.show()
1113
+ """
1114
+ input = np.asarray(input)
1115
+
1116
+ def derivative2(input, axis, output, mode, cval, sigma, **kwargs):
1117
+ order = [0] * input.ndim
1118
+ order[axis] = 2
1119
+ return gaussian_filter(input, sigma, order, output, mode, cval,
1120
+ **kwargs)
1121
+
1122
+ axes = _ni_support._check_axes(axes, input.ndim)
1123
+ num_axes = len(axes)
1124
+ sigma = _ni_support._normalize_sequence(sigma, num_axes)
1125
+ if num_axes < input.ndim:
1126
+ # set sigma = 0 for any axes not being filtered
1127
+ sigma_temp = [0,] * input.ndim
1128
+ for s, ax in zip(sigma, axes):
1129
+ sigma_temp[ax] = s
1130
+ sigma = sigma_temp
1131
+
1132
+ return generic_laplace(input, derivative2, output, mode, cval,
1133
+ extra_arguments=(sigma,),
1134
+ extra_keywords=kwargs,
1135
+ axes=axes)
1136
+
1137
+
1138
+ @_ni_docstrings.docfiller
1139
+ def generic_gradient_magnitude(input, derivative, output=None,
1140
+ mode="reflect", cval=0.0,
1141
+ extra_arguments=(), extra_keywords=None,
1142
+ *, axes=None):
1143
+ """Gradient magnitude using a provided gradient function.
1144
+
1145
+ Parameters
1146
+ ----------
1147
+ %(input)s
1148
+ derivative : callable
1149
+ Callable with the following signature::
1150
+
1151
+ derivative(input, axis, output, mode, cval,
1152
+ *extra_arguments, **extra_keywords)
1153
+
1154
+ See `extra_arguments`, `extra_keywords` below.
1155
+ `derivative` can assume that `input` and `output` are ndarrays.
1156
+ Note that the output from `derivative` is modified inplace;
1157
+ be careful to copy important inputs before returning them.
1158
+ %(output)s
1159
+ %(mode_multiple)s
1160
+ %(cval)s
1161
+ %(extra_keywords)s
1162
+ %(extra_arguments)s
1163
+ axes : tuple of int or None
1164
+ The axes over which to apply the filter. If a `mode` tuple is
1165
+ provided, its length must match the number of axes.
1166
+
1167
+ Returns
1168
+ -------
1169
+ generic_gradient_magnitude : ndarray
1170
+ Filtered array. Has the same shape as `input`.
1171
+
1172
+ """
1173
+ if extra_keywords is None:
1174
+ extra_keywords = {}
1175
+ input = np.asarray(input)
1176
+ output = _ni_support._get_output(output, input)
1177
+ axes = _ni_support._check_axes(axes, input.ndim)
1178
+ if len(axes) > 0:
1179
+ modes = _ni_support._normalize_sequence(mode, len(axes))
1180
+ derivative(input, axes[0], output, modes[0], cval,
1181
+ *extra_arguments, **extra_keywords)
1182
+ np.multiply(output, output, output)
1183
+ for ii in range(1, len(axes)):
1184
+ tmp = derivative(input, axes[ii], output.dtype, modes[ii], cval,
1185
+ *extra_arguments, **extra_keywords)
1186
+ np.multiply(tmp, tmp, tmp)
1187
+ output += tmp
1188
+ # This allows the sqrt to work with a different default casting
1189
+ np.sqrt(output, output, casting='unsafe')
1190
+ else:
1191
+ output[...] = input[...]
1192
+ return output
1193
+
1194
+
1195
+ @_ni_docstrings.docfiller
1196
+ def gaussian_gradient_magnitude(input, sigma, output=None,
1197
+ mode="reflect", cval=0.0, *, axes=None,
1198
+ **kwargs):
1199
+ """Multidimensional gradient magnitude using Gaussian derivatives.
1200
+
1201
+ Parameters
1202
+ ----------
1203
+ %(input)s
1204
+ sigma : scalar or sequence of scalars
1205
+ The standard deviations of the Gaussian filter are given for
1206
+ each axis as a sequence, or as a single number, in which case
1207
+ it is equal for all axes.
1208
+ %(output)s
1209
+ %(mode_multiple)s
1210
+ %(cval)s
1211
+ axes : tuple of int or None
1212
+ The axes over which to apply the filter. If `sigma` or `mode` tuples
1213
+ are provided, their length must match the number of axes.
1214
+ Extra keyword arguments will be passed to gaussian_filter().
1215
+
1216
+ Returns
1217
+ -------
1218
+ gaussian_gradient_magnitude : ndarray
1219
+ Filtered array. Has the same shape as `input`.
1220
+
1221
+ Examples
1222
+ --------
1223
+ >>> from scipy import ndimage, datasets
1224
+ >>> import matplotlib.pyplot as plt
1225
+ >>> fig = plt.figure()
1226
+ >>> plt.gray() # show the filtered result in grayscale
1227
+ >>> ax1 = fig.add_subplot(121) # left side
1228
+ >>> ax2 = fig.add_subplot(122) # right side
1229
+ >>> ascent = datasets.ascent()
1230
+ >>> result = ndimage.gaussian_gradient_magnitude(ascent, sigma=5)
1231
+ >>> ax1.imshow(ascent)
1232
+ >>> ax2.imshow(result)
1233
+ >>> plt.show()
1234
+ """
1235
+ input = np.asarray(input)
1236
+
1237
+ def derivative(input, axis, output, mode, cval, sigma, **kwargs):
1238
+ order = [0] * input.ndim
1239
+ order[axis] = 1
1240
+ return gaussian_filter(input, sigma, order, output, mode,
1241
+ cval, **kwargs)
1242
+
1243
+ return generic_gradient_magnitude(input, derivative, output, mode,
1244
+ cval, extra_arguments=(sigma,),
1245
+ extra_keywords=kwargs, axes=axes)
1246
+
1247
+
1248
+ def _correlate_or_convolve(input, weights, output, mode, cval, origin,
1249
+ convolution, axes):
1250
+ input = np.asarray(input)
1251
+ weights = np.asarray(weights)
1252
+ complex_input = input.dtype.kind == 'c'
1253
+ complex_weights = weights.dtype.kind == 'c'
1254
+ if complex_input or complex_weights:
1255
+ if complex_weights and not convolution:
1256
+ # As for np.correlate, conjugate weights rather than input.
1257
+ weights = weights.conj()
1258
+ kwargs = dict(
1259
+ mode=mode, origin=origin, convolution=convolution, axes=axes
1260
+ )
1261
+ output = _ni_support._get_output(output, input, complex_output=True)
1262
+
1263
+ return _complex_via_real_components(_correlate_or_convolve, input,
1264
+ weights, output, cval, **kwargs)
1265
+
1266
+ axes = _ni_support._check_axes(axes, input.ndim)
1267
+ weights = np.asarray(weights, dtype=np.float64)
1268
+
1269
+ # expand weights and origins if num_axes < input.ndim
1270
+ weights = _expand_footprint(input.ndim, axes, weights, "weights")
1271
+ origins = _expand_origin(input.ndim, axes, origin)
1272
+
1273
+ wshape = [ii for ii in weights.shape if ii > 0]
1274
+ if len(wshape) != input.ndim:
1275
+ raise RuntimeError(f"weights.ndim ({len(wshape)}) must match "
1276
+ f"len(axes) ({len(axes)})")
1277
+ if convolution:
1278
+ weights = weights[tuple([slice(None, None, -1)] * weights.ndim)]
1279
+ for ii in range(len(origins)):
1280
+ origins[ii] = -origins[ii]
1281
+ if not weights.shape[ii] & 1:
1282
+ origins[ii] -= 1
1283
+ for origin, lenw in zip(origins, wshape):
1284
+ if _invalid_origin(origin, lenw):
1285
+ raise ValueError('Invalid origin; origin must satisfy '
1286
+ '-(weights.shape[k] // 2) <= origin[k] <= '
1287
+ '(weights.shape[k]-1) // 2')
1288
+
1289
+ if not weights.flags.contiguous:
1290
+ weights = weights.copy()
1291
+ output = _ni_support._get_output(output, input)
1292
+ temp_needed = np.may_share_memory(input, output)
1293
+ if temp_needed:
1294
+ # input and output arrays cannot share memory
1295
+ temp = output
1296
+ output = _ni_support._get_output(output.dtype, input)
1297
+ if not isinstance(mode, str) and isinstance(mode, Iterable):
1298
+ raise RuntimeError("A sequence of modes is not supported")
1299
+ mode = _ni_support._extend_mode_to_code(mode)
1300
+ _nd_image.correlate(input, weights, output, mode, cval, origins)
1301
+ if temp_needed:
1302
+ temp[...] = output
1303
+ output = temp
1304
+ return output
1305
+
1306
+
1307
+ @_ni_docstrings.docfiller
1308
+ def correlate(input, weights, output=None, mode='reflect', cval=0.0,
1309
+ origin=0, *, axes=None):
1310
+ """
1311
+ Multidimensional correlation.
1312
+
1313
+ The array is correlated with the given kernel.
1314
+
1315
+ Parameters
1316
+ ----------
1317
+ %(input)s
1318
+ weights : ndarray
1319
+ array of weights, same number of dimensions as input
1320
+ %(output)s
1321
+ %(mode_reflect)s
1322
+ %(cval)s
1323
+ %(origin_multiple)s
1324
+ axes : tuple of int or None, optional
1325
+ If None, `input` is filtered along all axes. Otherwise,
1326
+ `input` is filtered along the specified axes. When `axes` is
1327
+ specified, any tuples used for `mode` or `origin` must match the length
1328
+ of `axes`. The ith entry in any of these tuples corresponds to the ith
1329
+ entry in `axes`.
1330
+
1331
+ Returns
1332
+ -------
1333
+ result : ndarray
1334
+ The result of correlation of `input` with `weights`.
1335
+
1336
+ See Also
1337
+ --------
1338
+ convolve : Convolve an image with a kernel.
1339
+
1340
+ Examples
1341
+ --------
1342
+ Correlation is the process of moving a filter mask often referred to
1343
+ as kernel over the image and computing the sum of products at each location.
1344
+
1345
+ >>> from scipy.ndimage import correlate
1346
+ >>> import numpy as np
1347
+ >>> input_img = np.arange(25).reshape(5,5)
1348
+ >>> print(input_img)
1349
+ [[ 0 1 2 3 4]
1350
+ [ 5 6 7 8 9]
1351
+ [10 11 12 13 14]
1352
+ [15 16 17 18 19]
1353
+ [20 21 22 23 24]]
1354
+
1355
+ Define a kernel (weights) for correlation. In this example, it is for sum of
1356
+ center and up, down, left and right next elements.
1357
+
1358
+ >>> weights = [[0, 1, 0],
1359
+ ... [1, 1, 1],
1360
+ ... [0, 1, 0]]
1361
+
1362
+ We can calculate a correlation result:
1363
+ For example, element ``[2,2]`` is ``7 + 11 + 12 + 13 + 17 = 60``.
1364
+
1365
+ >>> correlate(input_img, weights)
1366
+ array([[ 6, 10, 15, 20, 24],
1367
+ [ 26, 30, 35, 40, 44],
1368
+ [ 51, 55, 60, 65, 69],
1369
+ [ 76, 80, 85, 90, 94],
1370
+ [ 96, 100, 105, 110, 114]])
1371
+
1372
+ """
1373
+ return _correlate_or_convolve(input, weights, output, mode, cval,
1374
+ origin, False, axes)
1375
+
1376
+
1377
+ @_ni_docstrings.docfiller
1378
+ def convolve(input, weights, output=None, mode='reflect', cval=0.0,
1379
+ origin=0, *, axes=None):
1380
+ """
1381
+ Multidimensional convolution.
1382
+
1383
+ The array is convolved with the given kernel.
1384
+
1385
+ Parameters
1386
+ ----------
1387
+ %(input)s
1388
+ weights : array_like
1389
+ Array of weights, same number of dimensions as input
1390
+ %(output)s
1391
+ %(mode_reflect)s
1392
+ cval : scalar, optional
1393
+ Value to fill past edges of input if `mode` is 'constant'. Default
1394
+ is 0.0
1395
+ origin : int or sequence, optional
1396
+ Controls the placement of the filter on the input array's pixels.
1397
+ A value of 0 (the default) centers the filter over the pixel, with
1398
+ positive values shifting the filter to the right, and negative ones
1399
+ to the left. By passing a sequence of origins with length equal to
1400
+ the number of dimensions of the input array, different shifts can
1401
+ be specified along each axis.
1402
+ axes : tuple of int or None, optional
1403
+ If None, `input` is filtered along all axes. Otherwise,
1404
+ `input` is filtered along the specified axes. When `axes` is
1405
+ specified, any tuples used for `mode` or `origin` must match the length
1406
+ of `axes`. The ith entry in any of these tuples corresponds to the ith
1407
+ entry in `axes`.
1408
+
1409
+ Returns
1410
+ -------
1411
+ result : ndarray
1412
+ The result of convolution of `input` with `weights`.
1413
+
1414
+ See Also
1415
+ --------
1416
+ correlate : Correlate an image with a kernel.
1417
+
1418
+ Notes
1419
+ -----
1420
+ Each value in result is :math:`C_i = \\sum_j{I_{i+k-j} W_j}`, where
1421
+ W is the `weights` kernel,
1422
+ j is the N-D spatial index over :math:`W`,
1423
+ I is the `input` and k is the coordinate of the center of
1424
+ W, specified by `origin` in the input parameters.
1425
+
1426
+ Examples
1427
+ --------
1428
+ Perhaps the simplest case to understand is ``mode='constant', cval=0.0``,
1429
+ because in this case borders (i.e., where the `weights` kernel, centered
1430
+ on any one value, extends beyond an edge of `input`) are treated as zeros.
1431
+
1432
+ >>> import numpy as np
1433
+ >>> a = np.array([[1, 2, 0, 0],
1434
+ ... [5, 3, 0, 4],
1435
+ ... [0, 0, 0, 7],
1436
+ ... [9, 3, 0, 0]])
1437
+ >>> k = np.array([[1,1,1],[1,1,0],[1,0,0]])
1438
+ >>> from scipy import ndimage
1439
+ >>> ndimage.convolve(a, k, mode='constant', cval=0.0)
1440
+ array([[11, 10, 7, 4],
1441
+ [10, 3, 11, 11],
1442
+ [15, 12, 14, 7],
1443
+ [12, 3, 7, 0]])
1444
+
1445
+ Setting ``cval=1.0`` is equivalent to padding the outer edge of `input`
1446
+ with 1.0's (and then extracting only the original region of the result).
1447
+
1448
+ >>> ndimage.convolve(a, k, mode='constant', cval=1.0)
1449
+ array([[13, 11, 8, 7],
1450
+ [11, 3, 11, 14],
1451
+ [16, 12, 14, 10],
1452
+ [15, 6, 10, 5]])
1453
+
1454
+ With ``mode='reflect'`` (the default), outer values are reflected at the
1455
+ edge of `input` to fill in missing values.
1456
+
1457
+ >>> b = np.array([[2, 0, 0],
1458
+ ... [1, 0, 0],
1459
+ ... [0, 0, 0]])
1460
+ >>> k = np.array([[0,1,0], [0,1,0], [0,1,0]])
1461
+ >>> ndimage.convolve(b, k, mode='reflect')
1462
+ array([[5, 0, 0],
1463
+ [3, 0, 0],
1464
+ [1, 0, 0]])
1465
+
1466
+ This includes diagonally at the corners.
1467
+
1468
+ >>> k = np.array([[1,0,0],[0,1,0],[0,0,1]])
1469
+ >>> ndimage.convolve(b, k)
1470
+ array([[4, 2, 0],
1471
+ [3, 2, 0],
1472
+ [1, 1, 0]])
1473
+
1474
+ With ``mode='nearest'``, the single nearest value in to an edge in
1475
+ `input` is repeated as many times as needed to match the overlapping
1476
+ `weights`.
1477
+
1478
+ >>> c = np.array([[2, 0, 1],
1479
+ ... [1, 0, 0],
1480
+ ... [0, 0, 0]])
1481
+ >>> k = np.array([[0, 1, 0],
1482
+ ... [0, 1, 0],
1483
+ ... [0, 1, 0],
1484
+ ... [0, 1, 0],
1485
+ ... [0, 1, 0]])
1486
+ >>> ndimage.convolve(c, k, mode='nearest')
1487
+ array([[7, 0, 3],
1488
+ [5, 0, 2],
1489
+ [3, 0, 1]])
1490
+
1491
+ """
1492
+ return _correlate_or_convolve(input, weights, output, mode, cval,
1493
+ origin, True, axes)
1494
+
1495
+
1496
+ @_ni_docstrings.docfiller
1497
+ def uniform_filter1d(input, size, axis=-1, output=None,
1498
+ mode="reflect", cval=0.0, origin=0):
1499
+ """Calculate a 1-D uniform filter along the given axis.
1500
+
1501
+ The lines of the array along the given axis are filtered with a
1502
+ uniform filter of given size.
1503
+
1504
+ Parameters
1505
+ ----------
1506
+ %(input)s
1507
+ size : int
1508
+ length of uniform filter
1509
+ %(axis)s
1510
+ %(output)s
1511
+ %(mode_reflect)s
1512
+ %(cval)s
1513
+ %(origin)s
1514
+
1515
+ Returns
1516
+ -------
1517
+ result : ndarray
1518
+ Filtered array. Has same shape as `input`.
1519
+
1520
+ Examples
1521
+ --------
1522
+ >>> from scipy.ndimage import uniform_filter1d
1523
+ >>> uniform_filter1d([2, 8, 0, 4, 1, 9, 9, 0], size=3)
1524
+ array([4, 3, 4, 1, 4, 6, 6, 3])
1525
+ """
1526
+ input = np.asarray(input)
1527
+ axis = normalize_axis_index(axis, input.ndim)
1528
+ if size < 1:
1529
+ raise RuntimeError('incorrect filter size')
1530
+ complex_output = input.dtype.kind == 'c'
1531
+ output = _ni_support._get_output(output, input,
1532
+ complex_output=complex_output)
1533
+ if (size // 2 + origin < 0) or (size // 2 + origin >= size):
1534
+ raise ValueError('invalid origin')
1535
+ mode = _ni_support._extend_mode_to_code(mode)
1536
+ if not complex_output:
1537
+ _nd_image.uniform_filter1d(input, size, axis, output, mode, cval,
1538
+ origin)
1539
+ else:
1540
+ _nd_image.uniform_filter1d(input.real, size, axis, output.real, mode,
1541
+ np.real(cval), origin)
1542
+ _nd_image.uniform_filter1d(input.imag, size, axis, output.imag, mode,
1543
+ np.imag(cval), origin)
1544
+ return output
1545
+
1546
+
1547
+ @_ni_docstrings.docfiller
1548
+ def uniform_filter(input, size=3, output=None, mode="reflect",
1549
+ cval=0.0, origin=0, *, axes=None):
1550
+ """Multidimensional uniform filter.
1551
+
1552
+ Parameters
1553
+ ----------
1554
+ %(input)s
1555
+ size : int or sequence of ints, optional
1556
+ The sizes of the uniform filter are given for each axis as a
1557
+ sequence, or as a single number, in which case the size is
1558
+ equal for all axes.
1559
+ %(output)s
1560
+ %(mode_multiple)s
1561
+ %(cval)s
1562
+ %(origin_multiple)s
1563
+ axes : tuple of int or None, optional
1564
+ If None, `input` is filtered along all axes. Otherwise,
1565
+ `input` is filtered along the specified axes. When `axes` is
1566
+ specified, any tuples used for `size`, `origin`, and/or `mode`
1567
+ must match the length of `axes`. The ith entry in any of these tuples
1568
+ corresponds to the ith entry in `axes`.
1569
+
1570
+ Returns
1571
+ -------
1572
+ uniform_filter : ndarray
1573
+ Filtered array. Has the same shape as `input`.
1574
+
1575
+ Notes
1576
+ -----
1577
+ The multidimensional filter is implemented as a sequence of
1578
+ 1-D uniform filters. The intermediate arrays are stored
1579
+ in the same data type as the output. Therefore, for output types
1580
+ with a limited precision, the results may be imprecise because
1581
+ intermediate results may be stored with insufficient precision.
1582
+
1583
+ %(nan)s
1584
+
1585
+ Examples
1586
+ --------
1587
+ >>> from scipy import ndimage, datasets
1588
+ >>> import matplotlib.pyplot as plt
1589
+ >>> fig = plt.figure()
1590
+ >>> plt.gray() # show the filtered result in grayscale
1591
+ >>> ax1 = fig.add_subplot(121) # left side
1592
+ >>> ax2 = fig.add_subplot(122) # right side
1593
+ >>> ascent = datasets.ascent()
1594
+ >>> result = ndimage.uniform_filter(ascent, size=20)
1595
+ >>> ax1.imshow(ascent)
1596
+ >>> ax2.imshow(result)
1597
+ >>> plt.show()
1598
+ """
1599
+ input = np.asarray(input)
1600
+ output = _ni_support._get_output(output, input,
1601
+ complex_output=input.dtype.kind == 'c')
1602
+ axes = _ni_support._check_axes(axes, input.ndim)
1603
+ num_axes = len(axes)
1604
+ sizes = _ni_support._normalize_sequence(size, num_axes)
1605
+ origins = _ni_support._normalize_sequence(origin, num_axes)
1606
+ modes = _ni_support._normalize_sequence(mode, num_axes)
1607
+ axes = [(axes[ii], sizes[ii], origins[ii], modes[ii])
1608
+ for ii in range(num_axes) if sizes[ii] > 1]
1609
+ if len(axes) > 0:
1610
+ for axis, size, origin, mode in axes:
1611
+ uniform_filter1d(input, int(size), axis, output, mode,
1612
+ cval, origin)
1613
+ input = output
1614
+ else:
1615
+ output[...] = input[...]
1616
+ return output
1617
+
1618
+
1619
+ @_ni_docstrings.docfiller
1620
+ def minimum_filter1d(input, size, axis=-1, output=None,
1621
+ mode="reflect", cval=0.0, origin=0):
1622
+ """Calculate a 1-D minimum filter along the given axis.
1623
+
1624
+ The lines of the array along the given axis are filtered with a
1625
+ minimum filter of given size.
1626
+
1627
+ Parameters
1628
+ ----------
1629
+ %(input)s
1630
+ size : int
1631
+ length along which to calculate 1D minimum
1632
+ %(axis)s
1633
+ %(output)s
1634
+ %(mode_reflect)s
1635
+ %(cval)s
1636
+ %(origin)s
1637
+
1638
+ Returns
1639
+ -------
1640
+ result : ndarray.
1641
+ Filtered image. Has the same shape as `input`.
1642
+
1643
+ Notes
1644
+ -----
1645
+ This function implements the MINLIST algorithm [1]_, as described by
1646
+ Richard Harter [2]_, and has a guaranteed O(n) performance, `n` being
1647
+ the `input` length, regardless of filter size.
1648
+
1649
+ References
1650
+ ----------
1651
+ .. [1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.2777
1652
+ .. [2] http://www.richardhartersworld.com/cri/2001/slidingmin.html
1653
+
1654
+
1655
+ Examples
1656
+ --------
1657
+ >>> from scipy.ndimage import minimum_filter1d
1658
+ >>> minimum_filter1d([2, 8, 0, 4, 1, 9, 9, 0], size=3)
1659
+ array([2, 0, 0, 0, 1, 1, 0, 0])
1660
+ """
1661
+ input = np.asarray(input)
1662
+ if np.iscomplexobj(input):
1663
+ raise TypeError('Complex type not supported')
1664
+ axis = normalize_axis_index(axis, input.ndim)
1665
+ if size < 1:
1666
+ raise RuntimeError('incorrect filter size')
1667
+ output = _ni_support._get_output(output, input)
1668
+ if (size // 2 + origin < 0) or (size // 2 + origin >= size):
1669
+ raise ValueError('invalid origin')
1670
+ mode = _ni_support._extend_mode_to_code(mode)
1671
+ _nd_image.min_or_max_filter1d(input, size, axis, output, mode, cval,
1672
+ origin, 1)
1673
+ return output
1674
+
1675
+
1676
+ @_ni_docstrings.docfiller
1677
+ def maximum_filter1d(input, size, axis=-1, output=None,
1678
+ mode="reflect", cval=0.0, origin=0):
1679
+ """Calculate a 1-D maximum filter along the given axis.
1680
+
1681
+ The lines of the array along the given axis are filtered with a
1682
+ maximum filter of given size.
1683
+
1684
+ Parameters
1685
+ ----------
1686
+ %(input)s
1687
+ size : int
1688
+ Length along which to calculate the 1-D maximum.
1689
+ %(axis)s
1690
+ %(output)s
1691
+ %(mode_reflect)s
1692
+ %(cval)s
1693
+ %(origin)s
1694
+
1695
+ Returns
1696
+ -------
1697
+ maximum1d : ndarray, None
1698
+ Maximum-filtered array with same shape as input.
1699
+ None if `output` is not None
1700
+
1701
+ Notes
1702
+ -----
1703
+ This function implements the MAXLIST algorithm [1]_, as described by
1704
+ Richard Harter [2]_, and has a guaranteed O(n) performance, `n` being
1705
+ the `input` length, regardless of filter size.
1706
+
1707
+ References
1708
+ ----------
1709
+ .. [1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.42.2777
1710
+ .. [2] http://www.richardhartersworld.com/cri/2001/slidingmin.html
1711
+
1712
+ Examples
1713
+ --------
1714
+ >>> from scipy.ndimage import maximum_filter1d
1715
+ >>> maximum_filter1d([2, 8, 0, 4, 1, 9, 9, 0], size=3)
1716
+ array([8, 8, 8, 4, 9, 9, 9, 9])
1717
+ """
1718
+ input = np.asarray(input)
1719
+ if np.iscomplexobj(input):
1720
+ raise TypeError('Complex type not supported')
1721
+ axis = normalize_axis_index(axis, input.ndim)
1722
+ if size < 1:
1723
+ raise RuntimeError('incorrect filter size')
1724
+ output = _ni_support._get_output(output, input)
1725
+ if (size // 2 + origin < 0) or (size // 2 + origin >= size):
1726
+ raise ValueError('invalid origin')
1727
+ mode = _ni_support._extend_mode_to_code(mode)
1728
+ _nd_image.min_or_max_filter1d(input, size, axis, output, mode, cval,
1729
+ origin, 0)
1730
+ return output
1731
+
1732
+
1733
+ def _min_or_max_filter(input, size, footprint, structure, output, mode,
1734
+ cval, origin, minimum, axes=None):
1735
+ if (size is not None) and (footprint is not None):
1736
+ warnings.warn("ignoring size because footprint is set",
1737
+ UserWarning, stacklevel=3)
1738
+ if structure is None:
1739
+ if footprint is None:
1740
+ if size is None:
1741
+ raise RuntimeError("no footprint provided")
1742
+ separable = True
1743
+ else:
1744
+ footprint = np.asarray(footprint, dtype=bool)
1745
+ if not footprint.any():
1746
+ raise ValueError("All-zero footprint is not supported.")
1747
+ if footprint.all():
1748
+ size = footprint.shape
1749
+ footprint = None
1750
+ separable = True
1751
+ else:
1752
+ separable = False
1753
+ else:
1754
+ structure = np.asarray(structure, dtype=np.float64)
1755
+ separable = False
1756
+ if footprint is None:
1757
+ footprint = np.ones(structure.shape, bool)
1758
+ else:
1759
+ footprint = np.asarray(footprint, dtype=bool)
1760
+ input = np.asarray(input)
1761
+ if np.iscomplexobj(input):
1762
+ raise TypeError("Complex type not supported")
1763
+ output = _ni_support._get_output(output, input)
1764
+ temp_needed = np.may_share_memory(input, output)
1765
+ if temp_needed:
1766
+ # input and output arrays cannot share memory
1767
+ temp = output
1768
+ output = _ni_support._get_output(output.dtype, input)
1769
+ axes = _ni_support._check_axes(axes, input.ndim)
1770
+ num_axes = len(axes)
1771
+ if separable:
1772
+ origins = _ni_support._normalize_sequence(origin, num_axes)
1773
+ sizes = _ni_support._normalize_sequence(size, num_axes)
1774
+ modes = _ni_support._normalize_sequence(mode, num_axes)
1775
+ axes = [(axes[ii], sizes[ii], origins[ii], modes[ii])
1776
+ for ii in range(len(axes)) if sizes[ii] > 1]
1777
+ if minimum:
1778
+ filter_ = minimum_filter1d
1779
+ else:
1780
+ filter_ = maximum_filter1d
1781
+ if len(axes) > 0:
1782
+ for axis, size, origin, mode in axes:
1783
+ filter_(input, int(size), axis, output, mode, cval, origin)
1784
+ input = output
1785
+ else:
1786
+ output[...] = input[...]
1787
+ else:
1788
+ # expand origins and footprint if num_axes < input.ndim
1789
+ footprint = _expand_footprint(input.ndim, axes, footprint)
1790
+ origins = _expand_origin(input.ndim, axes, origin)
1791
+
1792
+ fshape = [ii for ii in footprint.shape if ii > 0]
1793
+ if len(fshape) != input.ndim:
1794
+ raise RuntimeError(f"footprint.ndim ({footprint.ndim}) must match "
1795
+ f"len(axes) ({len(axes)})")
1796
+ for origin, lenf in zip(origins, fshape):
1797
+ if (lenf // 2 + origin < 0) or (lenf // 2 + origin >= lenf):
1798
+ raise ValueError("invalid origin")
1799
+ if not footprint.flags.contiguous:
1800
+ footprint = footprint.copy()
1801
+ if structure is not None:
1802
+ if len(structure.shape) != num_axes:
1803
+ raise RuntimeError("structure array has incorrect shape")
1804
+ if num_axes != structure.ndim:
1805
+ structure = np.expand_dims(
1806
+ structure,
1807
+ tuple(ax for ax in range(structure.ndim) if ax not in axes)
1808
+ )
1809
+ if not structure.flags.contiguous:
1810
+ structure = structure.copy()
1811
+ if not isinstance(mode, str) and isinstance(mode, Iterable):
1812
+ raise RuntimeError(
1813
+ "A sequence of modes is not supported for non-separable "
1814
+ "footprints")
1815
+ mode = _ni_support._extend_mode_to_code(mode)
1816
+ _nd_image.min_or_max_filter(input, footprint, structure, output,
1817
+ mode, cval, origins, minimum)
1818
+ if temp_needed:
1819
+ temp[...] = output
1820
+ output = temp
1821
+ return output
1822
+
1823
+
1824
+ @_ni_docstrings.docfiller
1825
+ def minimum_filter(input, size=None, footprint=None, output=None,
1826
+ mode="reflect", cval=0.0, origin=0, *, axes=None):
1827
+ """Calculate a multidimensional minimum filter.
1828
+
1829
+ Parameters
1830
+ ----------
1831
+ %(input)s
1832
+ %(size_foot)s
1833
+ %(output)s
1834
+ %(mode_multiple)s
1835
+ %(cval)s
1836
+ %(origin_multiple)s
1837
+ axes : tuple of int or None, optional
1838
+ If None, `input` is filtered along all axes. Otherwise,
1839
+ `input` is filtered along the specified axes. When `axes` is
1840
+ specified, any tuples used for `size`, `origin`, and/or `mode`
1841
+ must match the length of `axes`. The ith entry in any of these tuples
1842
+ corresponds to the ith entry in `axes`.
1843
+
1844
+ Returns
1845
+ -------
1846
+ minimum_filter : ndarray
1847
+ Filtered array. Has the same shape as `input`.
1848
+
1849
+ Notes
1850
+ -----
1851
+ A sequence of modes (one per axis) is only supported when the footprint is
1852
+ separable. Otherwise, a single mode string must be provided.
1853
+
1854
+ Examples
1855
+ --------
1856
+ >>> from scipy import ndimage, datasets
1857
+ >>> import matplotlib.pyplot as plt
1858
+ >>> fig = plt.figure()
1859
+ >>> plt.gray() # show the filtered result in grayscale
1860
+ >>> ax1 = fig.add_subplot(121) # left side
1861
+ >>> ax2 = fig.add_subplot(122) # right side
1862
+ >>> ascent = datasets.ascent()
1863
+ >>> result = ndimage.minimum_filter(ascent, size=20)
1864
+ >>> ax1.imshow(ascent)
1865
+ >>> ax2.imshow(result)
1866
+ >>> plt.show()
1867
+ """
1868
+ return _min_or_max_filter(input, size, footprint, None, output, mode,
1869
+ cval, origin, 1, axes)
1870
+
1871
+
1872
+ @_ni_docstrings.docfiller
1873
+ def maximum_filter(input, size=None, footprint=None, output=None,
1874
+ mode="reflect", cval=0.0, origin=0, *, axes=None):
1875
+ """Calculate a multidimensional maximum filter.
1876
+
1877
+ Parameters
1878
+ ----------
1879
+ %(input)s
1880
+ %(size_foot)s
1881
+ %(output)s
1882
+ %(mode_multiple)s
1883
+ %(cval)s
1884
+ %(origin_multiple)s
1885
+ axes : tuple of int or None, optional
1886
+ If None, `input` is filtered along all axes. Otherwise,
1887
+ `input` is filtered along the specified axes. When `axes` is
1888
+ specified, any tuples used for `size`, `origin`, and/or `mode`
1889
+ must match the length of `axes`. The ith entry in any of these tuples
1890
+ corresponds to the ith entry in `axes`.
1891
+
1892
+ Returns
1893
+ -------
1894
+ maximum_filter : ndarray
1895
+ Filtered array. Has the same shape as `input`.
1896
+
1897
+ Notes
1898
+ -----
1899
+ A sequence of modes (one per axis) is only supported when the footprint is
1900
+ separable. Otherwise, a single mode string must be provided.
1901
+
1902
+ %(nan)s
1903
+
1904
+ Examples
1905
+ --------
1906
+ >>> from scipy import ndimage, datasets
1907
+ >>> import matplotlib.pyplot as plt
1908
+ >>> fig = plt.figure()
1909
+ >>> plt.gray() # show the filtered result in grayscale
1910
+ >>> ax1 = fig.add_subplot(121) # left side
1911
+ >>> ax2 = fig.add_subplot(122) # right side
1912
+ >>> ascent = datasets.ascent()
1913
+ >>> result = ndimage.maximum_filter(ascent, size=20)
1914
+ >>> ax1.imshow(ascent)
1915
+ >>> ax2.imshow(result)
1916
+ >>> plt.show()
1917
+ """
1918
+ return _min_or_max_filter(input, size, footprint, None, output, mode,
1919
+ cval, origin, 0, axes)
1920
+
1921
+
1922
+ @_ni_docstrings.docfiller
1923
+ def _rank_filter(input, rank, size=None, footprint=None, output=None,
1924
+ mode="reflect", cval=0.0, origin=0, operation='rank',
1925
+ axes=None):
1926
+ if (size is not None) and (footprint is not None):
1927
+ warnings.warn("ignoring size because footprint is set",
1928
+ UserWarning, stacklevel=3)
1929
+ input = np.asarray(input)
1930
+ if np.iscomplexobj(input):
1931
+ raise TypeError('Complex type not supported')
1932
+ axes = _ni_support._check_axes(axes, input.ndim)
1933
+ num_axes = len(axes)
1934
+ if footprint is None:
1935
+ if size is None:
1936
+ raise RuntimeError("no footprint or filter size provided")
1937
+ sizes = _ni_support._normalize_sequence(size, num_axes)
1938
+ footprint = np.ones(sizes, dtype=bool)
1939
+ else:
1940
+ footprint = np.asarray(footprint, dtype=bool)
1941
+ # expand origins, footprint and modes if num_axes < input.ndim
1942
+ footprint = _expand_footprint(input.ndim, axes, footprint)
1943
+ origins = _expand_origin(input.ndim, axes, origin)
1944
+ mode = _expand_mode(input.ndim, axes, mode)
1945
+
1946
+ fshape = [ii for ii in footprint.shape if ii > 0]
1947
+ if len(fshape) != input.ndim:
1948
+ raise RuntimeError(f"footprint.ndim ({footprint.ndim}) must match "
1949
+ f"len(axes) ({len(axes)})")
1950
+ for origin, lenf in zip(origins, fshape):
1951
+ if (lenf // 2 + origin < 0) or (lenf // 2 + origin >= lenf):
1952
+ raise ValueError('invalid origin')
1953
+ if not footprint.flags.contiguous:
1954
+ footprint = footprint.copy()
1955
+ filter_size = np.where(footprint, 1, 0).sum()
1956
+ if operation == 'median':
1957
+ rank = filter_size // 2
1958
+ elif operation == 'percentile':
1959
+ percentile = rank
1960
+ if percentile < 0.0:
1961
+ percentile += 100.0
1962
+ if percentile < 0 or percentile > 100:
1963
+ raise RuntimeError('invalid percentile')
1964
+ if percentile == 100.0:
1965
+ rank = filter_size - 1
1966
+ else:
1967
+ rank = int(float(filter_size) * percentile / 100.0)
1968
+ if rank < 0:
1969
+ rank += filter_size
1970
+ if rank < 0 or rank >= filter_size:
1971
+ raise RuntimeError('rank not within filter footprint size')
1972
+ if rank == 0:
1973
+ return minimum_filter(input, None, footprint, output, mode, cval,
1974
+ origins, axes=None)
1975
+ elif rank == filter_size - 1:
1976
+ return maximum_filter(input, None, footprint, output, mode, cval,
1977
+ origins, axes=None)
1978
+ else:
1979
+ output = _ni_support._get_output(output, input)
1980
+ temp_needed = np.may_share_memory(input, output)
1981
+ if temp_needed:
1982
+ # input and output arrays cannot share memory
1983
+ temp = output
1984
+ output = _ni_support._get_output(output.dtype, input)
1985
+ if not isinstance(mode, str) and isinstance(mode, Iterable):
1986
+ raise RuntimeError(
1987
+ "A sequence of modes is not supported by non-separable rank "
1988
+ "filters")
1989
+ mode = _ni_support._extend_mode_to_code(mode, is_filter=True)
1990
+ if input.ndim == 1:
1991
+ if input.dtype in (np.int64, np.float64, np.float32):
1992
+ x = input
1993
+ x_out = output
1994
+ elif input.dtype == np.float16:
1995
+ x = input.astype('float32')
1996
+ x_out = np.empty(x.shape, dtype='float32')
1997
+ elif np.result_type(input, np.int64) == np.int64:
1998
+ x = input.astype('int64')
1999
+ x_out = np.empty(x.shape, dtype='int64')
2000
+ elif input.dtype.kind in 'biu':
2001
+ # cast any other boolean, integer or unsigned type to int64
2002
+ x = input.astype('int64')
2003
+ x_out = np.empty(x.shape, dtype='int64')
2004
+ else:
2005
+ raise RuntimeError('Unsupported array type')
2006
+ cval = x.dtype.type(cval)
2007
+ _rank_filter_1d.rank_filter(x, rank, footprint.size, x_out, mode, cval,
2008
+ origin)
2009
+ if input.dtype not in (np.int64, np.float64, np.float32):
2010
+ np.copyto(output, x_out, casting='unsafe')
2011
+ else:
2012
+ _nd_image.rank_filter(input, rank, footprint, output, mode, cval, origins)
2013
+ if temp_needed:
2014
+ temp[...] = output
2015
+ output = temp
2016
+ return output
2017
+
2018
+
2019
+ @_ni_docstrings.docfiller
2020
+ def rank_filter(input, rank, size=None, footprint=None, output=None,
2021
+ mode="reflect", cval=0.0, origin=0, *, axes=None):
2022
+ """Calculate a multidimensional rank filter.
2023
+
2024
+ Parameters
2025
+ ----------
2026
+ %(input)s
2027
+ rank : int
2028
+ The rank parameter may be less than zero, i.e., rank = -1
2029
+ indicates the largest element.
2030
+ %(size_foot)s
2031
+ %(output)s
2032
+ %(mode_reflect)s
2033
+ %(cval)s
2034
+ %(origin_multiple)s
2035
+ axes : tuple of int or None, optional
2036
+ If None, `input` is filtered along all axes. Otherwise,
2037
+ `input` is filtered along the specified axes. When `axes` is
2038
+ specified, any tuples used for `size`, `origin`, and/or `mode`
2039
+ must match the length of `axes`. The ith entry in any of these tuples
2040
+ corresponds to the ith entry in `axes`.
2041
+
2042
+ Returns
2043
+ -------
2044
+ rank_filter : ndarray
2045
+ Filtered array. Has the same shape as `input`.
2046
+
2047
+ Examples
2048
+ --------
2049
+ >>> from scipy import ndimage, datasets
2050
+ >>> import matplotlib.pyplot as plt
2051
+ >>> fig = plt.figure()
2052
+ >>> plt.gray() # show the filtered result in grayscale
2053
+ >>> ax1 = fig.add_subplot(121) # left side
2054
+ >>> ax2 = fig.add_subplot(122) # right side
2055
+ >>> ascent = datasets.ascent()
2056
+ >>> result = ndimage.rank_filter(ascent, rank=42, size=20)
2057
+ >>> ax1.imshow(ascent)
2058
+ >>> ax2.imshow(result)
2059
+ >>> plt.show()
2060
+ """
2061
+ rank = operator.index(rank)
2062
+ return _rank_filter(input, rank, size, footprint, output, mode, cval,
2063
+ origin, 'rank', axes=axes)
2064
+
2065
+
2066
+ @_ni_docstrings.docfiller
2067
+ def median_filter(input, size=None, footprint=None, output=None,
2068
+ mode="reflect", cval=0.0, origin=0, *, axes=None):
2069
+ """
2070
+ Calculate a multidimensional median filter.
2071
+
2072
+ Parameters
2073
+ ----------
2074
+ %(input)s
2075
+ %(size_foot)s
2076
+ %(output)s
2077
+ %(mode_reflect)s
2078
+ %(cval)s
2079
+ %(origin_multiple)s
2080
+ axes : tuple of int or None, optional
2081
+ If None, `input` is filtered along all axes. Otherwise,
2082
+ `input` is filtered along the specified axes. When `axes` is
2083
+ specified, any tuples used for `size`, `origin`, and/or `mode`
2084
+ must match the length of `axes`. The ith entry in any of these tuples
2085
+ corresponds to the ith entry in `axes`.
2086
+
2087
+ Returns
2088
+ -------
2089
+ median_filter : ndarray
2090
+ Filtered array. Has the same shape as `input`.
2091
+
2092
+ See Also
2093
+ --------
2094
+ scipy.signal.medfilt2d
2095
+
2096
+ Notes
2097
+ -----
2098
+ For 2-dimensional images with ``uint8``, ``float32`` or ``float64`` dtypes
2099
+ the specialised function `scipy.signal.medfilt2d` may be faster. It is
2100
+ however limited to constant mode with ``cval=0``.
2101
+
2102
+ The filter always returns the argument that would appear at index ``n // 2`` in
2103
+ a sorted array, where ``n`` is the number of elements in the footprint of the
2104
+ filter. Note that this differs from the conventional definition of the median
2105
+ when ``n`` is even. Also, this function does not support the ``float16`` dtype,
2106
+ behavior in the presence of NaNs is undefined, and memory consumption scales with
2107
+ ``n**4``. For ``float16`` support, greater control over the definition of the
2108
+ filter, and to limit memory usage, consider using `vectorized_filter` with
2109
+ NumPy functions `np.median` or `np.nanmedian`.
2110
+
2111
+ Examples
2112
+ --------
2113
+ >>> from scipy import ndimage, datasets
2114
+ >>> import matplotlib.pyplot as plt
2115
+ >>> fig = plt.figure()
2116
+ >>> plt.gray() # show the filtered result in grayscale
2117
+ >>> ax1 = fig.add_subplot(121) # left side
2118
+ >>> ax2 = fig.add_subplot(122) # right side
2119
+ >>> ascent = datasets.ascent()
2120
+ >>> result = ndimage.median_filter(ascent, size=20)
2121
+ >>> ax1.imshow(ascent)
2122
+ >>> ax2.imshow(result)
2123
+ >>> plt.show()
2124
+ """
2125
+ return _rank_filter(input, 0, size, footprint, output, mode, cval,
2126
+ origin, 'median', axes=axes)
2127
+
2128
+
2129
+ @_ni_docstrings.docfiller
2130
+ def percentile_filter(input, percentile, size=None, footprint=None,
2131
+ output=None, mode="reflect", cval=0.0, origin=0, *,
2132
+ axes=None):
2133
+ """Calculate a multidimensional percentile filter.
2134
+
2135
+ Parameters
2136
+ ----------
2137
+ %(input)s
2138
+ percentile : scalar
2139
+ The percentile parameter may be less than zero, i.e.,
2140
+ percentile = -20 equals percentile = 80
2141
+ %(size_foot)s
2142
+ %(output)s
2143
+ %(mode_reflect)s
2144
+ %(cval)s
2145
+ %(origin_multiple)s
2146
+ axes : tuple of int or None, optional
2147
+ If None, `input` is filtered along all axes. Otherwise,
2148
+ `input` is filtered along the specified axes. When `axes` is
2149
+ specified, any tuples used for `size`, `origin`, and/or `mode`
2150
+ must match the length of `axes`. The ith entry in any of these tuples
2151
+ corresponds to the ith entry in `axes`.
2152
+
2153
+ Returns
2154
+ -------
2155
+ percentile_filter : ndarray
2156
+ Filtered array. Has the same shape as `input`.
2157
+
2158
+ Examples
2159
+ --------
2160
+ >>> from scipy import ndimage, datasets
2161
+ >>> import matplotlib.pyplot as plt
2162
+ >>> fig = plt.figure()
2163
+ >>> plt.gray() # show the filtered result in grayscale
2164
+ >>> ax1 = fig.add_subplot(121) # left side
2165
+ >>> ax2 = fig.add_subplot(122) # right side
2166
+ >>> ascent = datasets.ascent()
2167
+ >>> result = ndimage.percentile_filter(ascent, percentile=20, size=20)
2168
+ >>> ax1.imshow(ascent)
2169
+ >>> ax2.imshow(result)
2170
+ >>> plt.show()
2171
+ """
2172
+ return _rank_filter(input, percentile, size, footprint, output, mode,
2173
+ cval, origin, 'percentile', axes=axes)
2174
+
2175
+
2176
+ @_ni_docstrings.docfiller
2177
+ def generic_filter1d(input, function, filter_size, axis=-1,
2178
+ output=None, mode="reflect", cval=0.0, origin=0,
2179
+ extra_arguments=(), extra_keywords=None):
2180
+ """Calculate a 1-D filter along the given axis.
2181
+
2182
+ `generic_filter1d` iterates over the lines of the array, calling the
2183
+ given function at each line. The arguments of the line are the
2184
+ input line, and the output line. The input and output lines are 1-D
2185
+ double arrays. The input line is extended appropriately according
2186
+ to the filter size and origin. The output line must be modified
2187
+ in-place with the result.
2188
+
2189
+ Parameters
2190
+ ----------
2191
+ %(input)s
2192
+ function : {callable, scipy.LowLevelCallable}
2193
+ Function to apply along given axis.
2194
+ filter_size : scalar
2195
+ Length of the filter.
2196
+ %(axis)s
2197
+ %(output)s
2198
+ %(mode_reflect)s
2199
+ %(cval)s
2200
+ %(origin)s
2201
+ %(extra_arguments)s
2202
+ %(extra_keywords)s
2203
+
2204
+ Returns
2205
+ -------
2206
+ generic_filter1d : ndarray
2207
+ Filtered array. Has the same shape as `input`.
2208
+
2209
+ Notes
2210
+ -----
2211
+ This function also accepts low-level callback functions with one of
2212
+ the following signatures and wrapped in `scipy.LowLevelCallable`:
2213
+
2214
+ .. code:: c
2215
+
2216
+ int function(double *input_line, npy_intp input_length,
2217
+ double *output_line, npy_intp output_length,
2218
+ void *user_data)
2219
+ int function(double *input_line, intptr_t input_length,
2220
+ double *output_line, intptr_t output_length,
2221
+ void *user_data)
2222
+
2223
+ The calling function iterates over the lines of the input and output
2224
+ arrays, calling the callback function at each line. The current line
2225
+ is extended according to the border conditions set by the calling
2226
+ function, and the result is copied into the array that is passed
2227
+ through ``input_line``. The length of the input line (after extension)
2228
+ is passed through ``input_length``. The callback function should apply
2229
+ the filter and store the result in the array passed through
2230
+ ``output_line``. The length of the output line is passed through
2231
+ ``output_length``. ``user_data`` is the data pointer provided
2232
+ to `scipy.LowLevelCallable` as-is.
2233
+
2234
+ The callback function must return an integer error status that is zero
2235
+ if something went wrong and one otherwise. If an error occurs, you should
2236
+ normally set the python error status with an informative message
2237
+ before returning, otherwise a default error message is set by the
2238
+ calling function.
2239
+
2240
+ In addition, some other low-level function pointer specifications
2241
+ are accepted, but these are for backward compatibility only and should
2242
+ not be used in new code.
2243
+
2244
+ """
2245
+ if extra_keywords is None:
2246
+ extra_keywords = {}
2247
+ input = np.asarray(input)
2248
+ if np.iscomplexobj(input):
2249
+ raise TypeError('Complex type not supported')
2250
+ output = _ni_support._get_output(output, input)
2251
+ if filter_size < 1:
2252
+ raise RuntimeError('invalid filter size')
2253
+ axis = normalize_axis_index(axis, input.ndim)
2254
+ if (filter_size // 2 + origin < 0) or (filter_size // 2 + origin >=
2255
+ filter_size):
2256
+ raise ValueError('invalid origin')
2257
+ mode = _ni_support._extend_mode_to_code(mode)
2258
+ _nd_image.generic_filter1d(input, function, filter_size, axis, output,
2259
+ mode, cval, origin, extra_arguments,
2260
+ extra_keywords)
2261
+ return output
2262
+
2263
+
2264
+ @_ni_docstrings.docfiller
2265
+ def generic_filter(input, function, size=None, footprint=None,
2266
+ output=None, mode="reflect", cval=0.0, origin=0,
2267
+ extra_arguments=(), extra_keywords=None, *, axes=None):
2268
+ """Calculate a multidimensional filter using the given function.
2269
+
2270
+ At each element the provided function is called. The input values
2271
+ within the filter footprint at that element are passed to the function
2272
+ as a 1-D array of double values.
2273
+
2274
+ Parameters
2275
+ ----------
2276
+ %(input)s
2277
+ function : {callable, scipy.LowLevelCallable}
2278
+ Function to apply at each element.
2279
+ %(size_foot)s
2280
+ %(output)s
2281
+ %(mode_reflect)s
2282
+ %(cval)s
2283
+ %(origin_multiple)s
2284
+ %(extra_arguments)s
2285
+ %(extra_keywords)s
2286
+ axes : tuple of int or None, optional
2287
+ If None, `input` is filtered along all axes. Otherwise,
2288
+ `input` is filtered along the specified axes. When `axes` is
2289
+ specified, any tuples used for `size` or `origin` must match the length
2290
+ of `axes`. The ith entry in any of these tuples corresponds to the ith
2291
+ entry in `axes`.
2292
+
2293
+ Returns
2294
+ -------
2295
+ output : ndarray
2296
+ Filtered array. Has the same shape as `input`.
2297
+
2298
+ See Also
2299
+ --------
2300
+ vectorized_filter : similar functionality, but optimized for vectorized callables
2301
+
2302
+ Notes
2303
+ -----
2304
+ This function is ideal for use with instances of `scipy.LowLevelCallable`;
2305
+ for vectorized, pure-Python callables, consider `vectorized_filter` for improved
2306
+ performance.
2307
+
2308
+ Low-level callback functions must have one of the following signatures:
2309
+
2310
+ .. code:: c
2311
+
2312
+ int callback(double *buffer, npy_intp filter_size,
2313
+ double *return_value, void *user_data)
2314
+ int callback(double *buffer, intptr_t filter_size,
2315
+ double *return_value, void *user_data)
2316
+
2317
+ The calling function iterates over the elements of the input and
2318
+ output arrays, calling the callback function at each element. The
2319
+ elements within the footprint of the filter at the current element are
2320
+ passed through the ``buffer`` parameter, and the number of elements
2321
+ within the footprint through ``filter_size``. The calculated value is
2322
+ returned in ``return_value``. ``user_data`` is the data pointer provided
2323
+ to `scipy.LowLevelCallable` as-is.
2324
+
2325
+ The callback function must return an integer error status that is zero
2326
+ if something went wrong and one otherwise. If an error occurs, you should
2327
+ normally set the python error status with an informative message
2328
+ before returning, otherwise a default error message is set by the
2329
+ calling function.
2330
+
2331
+ In addition, some other low-level function pointer specifications
2332
+ are accepted, but these are for backward compatibility only and should
2333
+ not be used in new code.
2334
+
2335
+ Examples
2336
+ --------
2337
+ Import the necessary modules and load the example image used for
2338
+ filtering.
2339
+
2340
+ >>> import numpy as np
2341
+ >>> from scipy import datasets
2342
+ >>> from scipy.ndimage import zoom, generic_filter
2343
+ >>> import matplotlib.pyplot as plt
2344
+ >>> ascent = zoom(datasets.ascent(), 0.5)
2345
+
2346
+ Compute a maximum filter with kernel size 5 by passing a simple NumPy
2347
+ aggregation function as argument to `function`.
2348
+
2349
+ >>> maximum_filter_result = generic_filter(ascent, np.amax, [5, 5])
2350
+
2351
+ While a maximum filter could also directly be obtained using
2352
+ `maximum_filter`, `generic_filter` allows generic Python function or
2353
+ `scipy.LowLevelCallable` to be used as a filter. Here, we compute the
2354
+ range between maximum and minimum value as an example for a kernel size
2355
+ of 5.
2356
+
2357
+ >>> def custom_filter(image):
2358
+ ... return np.amax(image) - np.amin(image)
2359
+ >>> custom_filter_result = generic_filter(ascent, custom_filter, [5, 5])
2360
+
2361
+ Plot the original and filtered images.
2362
+
2363
+ >>> fig, axes = plt.subplots(3, 1, figsize=(3, 9))
2364
+ >>> plt.gray() # show the filtered result in grayscale
2365
+ >>> top, middle, bottom = axes
2366
+ >>> for ax in axes:
2367
+ ... ax.set_axis_off() # remove coordinate system
2368
+ >>> top.imshow(ascent)
2369
+ >>> top.set_title("Original image")
2370
+ >>> middle.imshow(maximum_filter_result)
2371
+ >>> middle.set_title("Maximum filter, Kernel: 5x5")
2372
+ >>> bottom.imshow(custom_filter_result)
2373
+ >>> bottom.set_title("Custom filter, Kernel: 5x5")
2374
+ >>> fig.tight_layout()
2375
+
2376
+ """
2377
+ if (size is not None) and (footprint is not None):
2378
+ warnings.warn("ignoring size because footprint is set",
2379
+ UserWarning, stacklevel=2)
2380
+ if extra_keywords is None:
2381
+ extra_keywords = {}
2382
+ input = np.asarray(input)
2383
+ if np.iscomplexobj(input):
2384
+ raise TypeError('Complex type not supported')
2385
+ axes = _ni_support._check_axes(axes, input.ndim)
2386
+ num_axes = len(axes)
2387
+ if footprint is None:
2388
+ if size is None:
2389
+ raise RuntimeError("no footprint or filter size provided")
2390
+ sizes = _ni_support._normalize_sequence(size, num_axes)
2391
+ footprint = np.ones(sizes, dtype=bool)
2392
+ else:
2393
+ footprint = np.asarray(footprint, dtype=bool)
2394
+
2395
+ # expand origins, footprint if num_axes < input.ndim
2396
+ footprint = _expand_footprint(input.ndim, axes, footprint)
2397
+ origins = _expand_origin(input.ndim, axes, origin)
2398
+
2399
+ fshape = [ii for ii in footprint.shape if ii > 0]
2400
+ if len(fshape) != input.ndim:
2401
+ raise RuntimeError(f"footprint.ndim ({footprint.ndim}) "
2402
+ f"must match len(axes) ({num_axes})")
2403
+ for origin, lenf in zip(origins, fshape):
2404
+ if (lenf // 2 + origin < 0) or (lenf // 2 + origin >= lenf):
2405
+ raise ValueError('invalid origin')
2406
+ if not footprint.flags.contiguous:
2407
+ footprint = footprint.copy()
2408
+ output = _ni_support._get_output(output, input)
2409
+
2410
+ mode = _ni_support._extend_mode_to_code(mode)
2411
+ _nd_image.generic_filter(input, function, footprint, output, mode,
2412
+ cval, origins, extra_arguments, extra_keywords)
2413
+ return output