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