scipy 1.16.2__cp314-cp314-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1530) hide show
  1. scipy/__config__.py +161 -0
  2. scipy/__init__.py +150 -0
  3. scipy/_cyutility.cp314-win_arm64.lib +0 -0
  4. scipy/_cyutility.cp314-win_arm64.pyd +0 -0
  5. scipy/_distributor_init.py +18 -0
  6. scipy/_lib/__init__.py +14 -0
  7. scipy/_lib/_array_api.py +931 -0
  8. scipy/_lib/_array_api_compat_vendor.py +9 -0
  9. scipy/_lib/_array_api_no_0d.py +103 -0
  10. scipy/_lib/_bunch.py +229 -0
  11. scipy/_lib/_ccallback.py +251 -0
  12. scipy/_lib/_ccallback_c.cp314-win_arm64.lib +0 -0
  13. scipy/_lib/_ccallback_c.cp314-win_arm64.pyd +0 -0
  14. scipy/_lib/_disjoint_set.py +254 -0
  15. scipy/_lib/_docscrape.py +761 -0
  16. scipy/_lib/_elementwise_iterative_method.py +346 -0
  17. scipy/_lib/_fpumode.cp314-win_arm64.lib +0 -0
  18. scipy/_lib/_fpumode.cp314-win_arm64.pyd +0 -0
  19. scipy/_lib/_gcutils.py +105 -0
  20. scipy/_lib/_pep440.py +487 -0
  21. scipy/_lib/_sparse.py +41 -0
  22. scipy/_lib/_test_ccallback.cp314-win_arm64.lib +0 -0
  23. scipy/_lib/_test_ccallback.cp314-win_arm64.pyd +0 -0
  24. scipy/_lib/_test_deprecation_call.cp314-win_arm64.lib +0 -0
  25. scipy/_lib/_test_deprecation_call.cp314-win_arm64.pyd +0 -0
  26. scipy/_lib/_test_deprecation_def.cp314-win_arm64.lib +0 -0
  27. scipy/_lib/_test_deprecation_def.cp314-win_arm64.pyd +0 -0
  28. scipy/_lib/_testutils.py +373 -0
  29. scipy/_lib/_threadsafety.py +58 -0
  30. scipy/_lib/_tmpdirs.py +86 -0
  31. scipy/_lib/_uarray/LICENSE +29 -0
  32. scipy/_lib/_uarray/__init__.py +116 -0
  33. scipy/_lib/_uarray/_backend.py +707 -0
  34. scipy/_lib/_uarray/_uarray.cp314-win_arm64.lib +0 -0
  35. scipy/_lib/_uarray/_uarray.cp314-win_arm64.pyd +0 -0
  36. scipy/_lib/_util.py +1283 -0
  37. scipy/_lib/array_api_compat/__init__.py +22 -0
  38. scipy/_lib/array_api_compat/_internal.py +59 -0
  39. scipy/_lib/array_api_compat/common/__init__.py +1 -0
  40. scipy/_lib/array_api_compat/common/_aliases.py +727 -0
  41. scipy/_lib/array_api_compat/common/_fft.py +213 -0
  42. scipy/_lib/array_api_compat/common/_helpers.py +1058 -0
  43. scipy/_lib/array_api_compat/common/_linalg.py +232 -0
  44. scipy/_lib/array_api_compat/common/_typing.py +192 -0
  45. scipy/_lib/array_api_compat/cupy/__init__.py +13 -0
  46. scipy/_lib/array_api_compat/cupy/_aliases.py +156 -0
  47. scipy/_lib/array_api_compat/cupy/_info.py +336 -0
  48. scipy/_lib/array_api_compat/cupy/_typing.py +31 -0
  49. scipy/_lib/array_api_compat/cupy/fft.py +36 -0
  50. scipy/_lib/array_api_compat/cupy/linalg.py +49 -0
  51. scipy/_lib/array_api_compat/dask/__init__.py +0 -0
  52. scipy/_lib/array_api_compat/dask/array/__init__.py +12 -0
  53. scipy/_lib/array_api_compat/dask/array/_aliases.py +376 -0
  54. scipy/_lib/array_api_compat/dask/array/_info.py +416 -0
  55. scipy/_lib/array_api_compat/dask/array/fft.py +21 -0
  56. scipy/_lib/array_api_compat/dask/array/linalg.py +72 -0
  57. scipy/_lib/array_api_compat/numpy/__init__.py +28 -0
  58. scipy/_lib/array_api_compat/numpy/_aliases.py +190 -0
  59. scipy/_lib/array_api_compat/numpy/_info.py +366 -0
  60. scipy/_lib/array_api_compat/numpy/_typing.py +30 -0
  61. scipy/_lib/array_api_compat/numpy/fft.py +35 -0
  62. scipy/_lib/array_api_compat/numpy/linalg.py +143 -0
  63. scipy/_lib/array_api_compat/torch/__init__.py +22 -0
  64. scipy/_lib/array_api_compat/torch/_aliases.py +855 -0
  65. scipy/_lib/array_api_compat/torch/_info.py +369 -0
  66. scipy/_lib/array_api_compat/torch/_typing.py +3 -0
  67. scipy/_lib/array_api_compat/torch/fft.py +85 -0
  68. scipy/_lib/array_api_compat/torch/linalg.py +121 -0
  69. scipy/_lib/array_api_extra/__init__.py +38 -0
  70. scipy/_lib/array_api_extra/_delegation.py +171 -0
  71. scipy/_lib/array_api_extra/_lib/__init__.py +1 -0
  72. scipy/_lib/array_api_extra/_lib/_at.py +463 -0
  73. scipy/_lib/array_api_extra/_lib/_backends.py +46 -0
  74. scipy/_lib/array_api_extra/_lib/_funcs.py +937 -0
  75. scipy/_lib/array_api_extra/_lib/_lazy.py +357 -0
  76. scipy/_lib/array_api_extra/_lib/_testing.py +278 -0
  77. scipy/_lib/array_api_extra/_lib/_utils/__init__.py +1 -0
  78. scipy/_lib/array_api_extra/_lib/_utils/_compat.py +74 -0
  79. scipy/_lib/array_api_extra/_lib/_utils/_compat.pyi +45 -0
  80. scipy/_lib/array_api_extra/_lib/_utils/_helpers.py +559 -0
  81. scipy/_lib/array_api_extra/_lib/_utils/_typing.py +10 -0
  82. scipy/_lib/array_api_extra/_lib/_utils/_typing.pyi +105 -0
  83. scipy/_lib/array_api_extra/testing.py +359 -0
  84. scipy/_lib/cobyqa/__init__.py +20 -0
  85. scipy/_lib/cobyqa/framework.py +1240 -0
  86. scipy/_lib/cobyqa/main.py +1506 -0
  87. scipy/_lib/cobyqa/models.py +1529 -0
  88. scipy/_lib/cobyqa/problem.py +1296 -0
  89. scipy/_lib/cobyqa/settings.py +132 -0
  90. scipy/_lib/cobyqa/subsolvers/__init__.py +14 -0
  91. scipy/_lib/cobyqa/subsolvers/geometry.py +387 -0
  92. scipy/_lib/cobyqa/subsolvers/optim.py +1203 -0
  93. scipy/_lib/cobyqa/utils/__init__.py +18 -0
  94. scipy/_lib/cobyqa/utils/exceptions.py +22 -0
  95. scipy/_lib/cobyqa/utils/math.py +77 -0
  96. scipy/_lib/cobyqa/utils/versions.py +67 -0
  97. scipy/_lib/decorator.py +399 -0
  98. scipy/_lib/deprecation.py +274 -0
  99. scipy/_lib/doccer.py +366 -0
  100. scipy/_lib/messagestream.cp314-win_arm64.lib +0 -0
  101. scipy/_lib/messagestream.cp314-win_arm64.pyd +0 -0
  102. scipy/_lib/pyprima/__init__.py +212 -0
  103. scipy/_lib/pyprima/cobyla/__init__.py +0 -0
  104. scipy/_lib/pyprima/cobyla/cobyla.py +559 -0
  105. scipy/_lib/pyprima/cobyla/cobylb.py +714 -0
  106. scipy/_lib/pyprima/cobyla/geometry.py +226 -0
  107. scipy/_lib/pyprima/cobyla/initialize.py +215 -0
  108. scipy/_lib/pyprima/cobyla/trustregion.py +492 -0
  109. scipy/_lib/pyprima/cobyla/update.py +289 -0
  110. scipy/_lib/pyprima/common/__init__.py +0 -0
  111. scipy/_lib/pyprima/common/_bounds.py +34 -0
  112. scipy/_lib/pyprima/common/_linear_constraints.py +46 -0
  113. scipy/_lib/pyprima/common/_nonlinear_constraints.py +54 -0
  114. scipy/_lib/pyprima/common/_project.py +173 -0
  115. scipy/_lib/pyprima/common/checkbreak.py +93 -0
  116. scipy/_lib/pyprima/common/consts.py +47 -0
  117. scipy/_lib/pyprima/common/evaluate.py +99 -0
  118. scipy/_lib/pyprima/common/history.py +38 -0
  119. scipy/_lib/pyprima/common/infos.py +30 -0
  120. scipy/_lib/pyprima/common/linalg.py +435 -0
  121. scipy/_lib/pyprima/common/message.py +290 -0
  122. scipy/_lib/pyprima/common/powalg.py +131 -0
  123. scipy/_lib/pyprima/common/preproc.py +277 -0
  124. scipy/_lib/pyprima/common/present.py +5 -0
  125. scipy/_lib/pyprima/common/ratio.py +54 -0
  126. scipy/_lib/pyprima/common/redrho.py +47 -0
  127. scipy/_lib/pyprima/common/selectx.py +296 -0
  128. scipy/_lib/tests/__init__.py +0 -0
  129. scipy/_lib/tests/test__gcutils.py +110 -0
  130. scipy/_lib/tests/test__pep440.py +67 -0
  131. scipy/_lib/tests/test__testutils.py +32 -0
  132. scipy/_lib/tests/test__threadsafety.py +51 -0
  133. scipy/_lib/tests/test__util.py +641 -0
  134. scipy/_lib/tests/test_array_api.py +322 -0
  135. scipy/_lib/tests/test_bunch.py +169 -0
  136. scipy/_lib/tests/test_ccallback.py +196 -0
  137. scipy/_lib/tests/test_config.py +45 -0
  138. scipy/_lib/tests/test_deprecation.py +10 -0
  139. scipy/_lib/tests/test_doccer.py +143 -0
  140. scipy/_lib/tests/test_import_cycles.py +18 -0
  141. scipy/_lib/tests/test_public_api.py +482 -0
  142. scipy/_lib/tests/test_scipy_version.py +28 -0
  143. scipy/_lib/tests/test_tmpdirs.py +48 -0
  144. scipy/_lib/tests/test_warnings.py +137 -0
  145. scipy/_lib/uarray.py +31 -0
  146. scipy/cluster/__init__.py +31 -0
  147. scipy/cluster/_hierarchy.cp314-win_arm64.lib +0 -0
  148. scipy/cluster/_hierarchy.cp314-win_arm64.pyd +0 -0
  149. scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.lib +0 -0
  150. scipy/cluster/_optimal_leaf_ordering.cp314-win_arm64.pyd +0 -0
  151. scipy/cluster/_vq.cp314-win_arm64.lib +0 -0
  152. scipy/cluster/_vq.cp314-win_arm64.pyd +0 -0
  153. scipy/cluster/hierarchy.py +4348 -0
  154. scipy/cluster/tests/__init__.py +0 -0
  155. scipy/cluster/tests/hierarchy_test_data.py +145 -0
  156. scipy/cluster/tests/test_disjoint_set.py +202 -0
  157. scipy/cluster/tests/test_hierarchy.py +1238 -0
  158. scipy/cluster/tests/test_vq.py +434 -0
  159. scipy/cluster/vq.py +832 -0
  160. scipy/conftest.py +683 -0
  161. scipy/constants/__init__.py +358 -0
  162. scipy/constants/_codata.py +2266 -0
  163. scipy/constants/_constants.py +369 -0
  164. scipy/constants/codata.py +21 -0
  165. scipy/constants/constants.py +53 -0
  166. scipy/constants/tests/__init__.py +0 -0
  167. scipy/constants/tests/test_codata.py +78 -0
  168. scipy/constants/tests/test_constants.py +83 -0
  169. scipy/datasets/__init__.py +90 -0
  170. scipy/datasets/_download_all.py +71 -0
  171. scipy/datasets/_fetchers.py +225 -0
  172. scipy/datasets/_registry.py +26 -0
  173. scipy/datasets/_utils.py +81 -0
  174. scipy/datasets/tests/__init__.py +0 -0
  175. scipy/datasets/tests/test_data.py +128 -0
  176. scipy/differentiate/__init__.py +27 -0
  177. scipy/differentiate/_differentiate.py +1129 -0
  178. scipy/differentiate/tests/__init__.py +0 -0
  179. scipy/differentiate/tests/test_differentiate.py +694 -0
  180. scipy/fft/__init__.py +114 -0
  181. scipy/fft/_backend.py +196 -0
  182. scipy/fft/_basic.py +1650 -0
  183. scipy/fft/_basic_backend.py +197 -0
  184. scipy/fft/_debug_backends.py +22 -0
  185. scipy/fft/_fftlog.py +223 -0
  186. scipy/fft/_fftlog_backend.py +200 -0
  187. scipy/fft/_helper.py +348 -0
  188. scipy/fft/_pocketfft/LICENSE.md +25 -0
  189. scipy/fft/_pocketfft/__init__.py +9 -0
  190. scipy/fft/_pocketfft/basic.py +251 -0
  191. scipy/fft/_pocketfft/helper.py +249 -0
  192. scipy/fft/_pocketfft/pypocketfft.cp314-win_arm64.lib +0 -0
  193. scipy/fft/_pocketfft/pypocketfft.cp314-win_arm64.pyd +0 -0
  194. scipy/fft/_pocketfft/realtransforms.py +109 -0
  195. scipy/fft/_pocketfft/tests/__init__.py +0 -0
  196. scipy/fft/_pocketfft/tests/test_basic.py +1011 -0
  197. scipy/fft/_pocketfft/tests/test_real_transforms.py +505 -0
  198. scipy/fft/_realtransforms.py +706 -0
  199. scipy/fft/_realtransforms_backend.py +63 -0
  200. scipy/fft/tests/__init__.py +0 -0
  201. scipy/fft/tests/mock_backend.py +96 -0
  202. scipy/fft/tests/test_backend.py +98 -0
  203. scipy/fft/tests/test_basic.py +504 -0
  204. scipy/fft/tests/test_fftlog.py +215 -0
  205. scipy/fft/tests/test_helper.py +558 -0
  206. scipy/fft/tests/test_multithreading.py +84 -0
  207. scipy/fft/tests/test_real_transforms.py +247 -0
  208. scipy/fftpack/__init__.py +103 -0
  209. scipy/fftpack/_basic.py +428 -0
  210. scipy/fftpack/_helper.py +115 -0
  211. scipy/fftpack/_pseudo_diffs.py +554 -0
  212. scipy/fftpack/_realtransforms.py +598 -0
  213. scipy/fftpack/basic.py +20 -0
  214. scipy/fftpack/convolve.cp314-win_arm64.lib +0 -0
  215. scipy/fftpack/convolve.cp314-win_arm64.pyd +0 -0
  216. scipy/fftpack/helper.py +19 -0
  217. scipy/fftpack/pseudo_diffs.py +22 -0
  218. scipy/fftpack/realtransforms.py +19 -0
  219. scipy/fftpack/tests/__init__.py +0 -0
  220. scipy/fftpack/tests/fftw_double_ref.npz +0 -0
  221. scipy/fftpack/tests/fftw_longdouble_ref.npz +0 -0
  222. scipy/fftpack/tests/fftw_single_ref.npz +0 -0
  223. scipy/fftpack/tests/test.npz +0 -0
  224. scipy/fftpack/tests/test_basic.py +877 -0
  225. scipy/fftpack/tests/test_helper.py +54 -0
  226. scipy/fftpack/tests/test_import.py +33 -0
  227. scipy/fftpack/tests/test_pseudo_diffs.py +388 -0
  228. scipy/fftpack/tests/test_real_transforms.py +836 -0
  229. scipy/integrate/__init__.py +122 -0
  230. scipy/integrate/_bvp.py +1160 -0
  231. scipy/integrate/_cubature.py +729 -0
  232. scipy/integrate/_dop.cp314-win_arm64.lib +0 -0
  233. scipy/integrate/_dop.cp314-win_arm64.pyd +0 -0
  234. scipy/integrate/_ivp/__init__.py +8 -0
  235. scipy/integrate/_ivp/base.py +290 -0
  236. scipy/integrate/_ivp/bdf.py +478 -0
  237. scipy/integrate/_ivp/common.py +451 -0
  238. scipy/integrate/_ivp/dop853_coefficients.py +193 -0
  239. scipy/integrate/_ivp/ivp.py +755 -0
  240. scipy/integrate/_ivp/lsoda.py +224 -0
  241. scipy/integrate/_ivp/radau.py +572 -0
  242. scipy/integrate/_ivp/rk.py +601 -0
  243. scipy/integrate/_ivp/tests/__init__.py +0 -0
  244. scipy/integrate/_ivp/tests/test_ivp.py +1287 -0
  245. scipy/integrate/_ivp/tests/test_rk.py +37 -0
  246. scipy/integrate/_lebedev.py +5450 -0
  247. scipy/integrate/_lsoda.cp314-win_arm64.lib +0 -0
  248. scipy/integrate/_lsoda.cp314-win_arm64.pyd +0 -0
  249. scipy/integrate/_ode.py +1395 -0
  250. scipy/integrate/_odepack.cp314-win_arm64.lib +0 -0
  251. scipy/integrate/_odepack.cp314-win_arm64.pyd +0 -0
  252. scipy/integrate/_odepack_py.py +273 -0
  253. scipy/integrate/_quad_vec.py +674 -0
  254. scipy/integrate/_quadpack.cp314-win_arm64.lib +0 -0
  255. scipy/integrate/_quadpack.cp314-win_arm64.pyd +0 -0
  256. scipy/integrate/_quadpack_py.py +1283 -0
  257. scipy/integrate/_quadrature.py +1336 -0
  258. scipy/integrate/_rules/__init__.py +12 -0
  259. scipy/integrate/_rules/_base.py +518 -0
  260. scipy/integrate/_rules/_gauss_kronrod.py +202 -0
  261. scipy/integrate/_rules/_gauss_legendre.py +62 -0
  262. scipy/integrate/_rules/_genz_malik.py +210 -0
  263. scipy/integrate/_tanhsinh.py +1385 -0
  264. scipy/integrate/_test_multivariate.cp314-win_arm64.lib +0 -0
  265. scipy/integrate/_test_multivariate.cp314-win_arm64.pyd +0 -0
  266. scipy/integrate/_test_odeint_banded.cp314-win_arm64.lib +0 -0
  267. scipy/integrate/_test_odeint_banded.cp314-win_arm64.pyd +0 -0
  268. scipy/integrate/_vode.cp314-win_arm64.lib +0 -0
  269. scipy/integrate/_vode.cp314-win_arm64.pyd +0 -0
  270. scipy/integrate/dop.py +15 -0
  271. scipy/integrate/lsoda.py +15 -0
  272. scipy/integrate/odepack.py +17 -0
  273. scipy/integrate/quadpack.py +23 -0
  274. scipy/integrate/tests/__init__.py +0 -0
  275. scipy/integrate/tests/test__quad_vec.py +211 -0
  276. scipy/integrate/tests/test_banded_ode_solvers.py +305 -0
  277. scipy/integrate/tests/test_bvp.py +714 -0
  278. scipy/integrate/tests/test_cubature.py +1375 -0
  279. scipy/integrate/tests/test_integrate.py +840 -0
  280. scipy/integrate/tests/test_odeint_jac.py +74 -0
  281. scipy/integrate/tests/test_quadpack.py +680 -0
  282. scipy/integrate/tests/test_quadrature.py +730 -0
  283. scipy/integrate/tests/test_tanhsinh.py +1171 -0
  284. scipy/integrate/vode.py +15 -0
  285. scipy/interpolate/__init__.py +228 -0
  286. scipy/interpolate/_bary_rational.py +715 -0
  287. scipy/interpolate/_bsplines.py +2469 -0
  288. scipy/interpolate/_cubic.py +973 -0
  289. scipy/interpolate/_dfitpack.cp314-win_arm64.lib +0 -0
  290. scipy/interpolate/_dfitpack.cp314-win_arm64.pyd +0 -0
  291. scipy/interpolate/_dierckx.cp314-win_arm64.lib +0 -0
  292. scipy/interpolate/_dierckx.cp314-win_arm64.pyd +0 -0
  293. scipy/interpolate/_fitpack.cp314-win_arm64.lib +0 -0
  294. scipy/interpolate/_fitpack.cp314-win_arm64.pyd +0 -0
  295. scipy/interpolate/_fitpack2.py +2397 -0
  296. scipy/interpolate/_fitpack_impl.py +811 -0
  297. scipy/interpolate/_fitpack_py.py +898 -0
  298. scipy/interpolate/_fitpack_repro.py +996 -0
  299. scipy/interpolate/_interpnd.cp314-win_arm64.lib +0 -0
  300. scipy/interpolate/_interpnd.cp314-win_arm64.pyd +0 -0
  301. scipy/interpolate/_interpolate.py +2266 -0
  302. scipy/interpolate/_ndbspline.py +415 -0
  303. scipy/interpolate/_ndgriddata.py +329 -0
  304. scipy/interpolate/_pade.py +67 -0
  305. scipy/interpolate/_polyint.py +1025 -0
  306. scipy/interpolate/_ppoly.cp314-win_arm64.lib +0 -0
  307. scipy/interpolate/_ppoly.cp314-win_arm64.pyd +0 -0
  308. scipy/interpolate/_rbf.py +290 -0
  309. scipy/interpolate/_rbfinterp.py +550 -0
  310. scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.lib +0 -0
  311. scipy/interpolate/_rbfinterp_pythran.cp314-win_arm64.pyd +0 -0
  312. scipy/interpolate/_rgi.py +764 -0
  313. scipy/interpolate/_rgi_cython.cp314-win_arm64.lib +0 -0
  314. scipy/interpolate/_rgi_cython.cp314-win_arm64.pyd +0 -0
  315. scipy/interpolate/dfitpack.py +24 -0
  316. scipy/interpolate/fitpack.py +31 -0
  317. scipy/interpolate/fitpack2.py +29 -0
  318. scipy/interpolate/interpnd.py +24 -0
  319. scipy/interpolate/interpolate.py +30 -0
  320. scipy/interpolate/ndgriddata.py +23 -0
  321. scipy/interpolate/polyint.py +24 -0
  322. scipy/interpolate/rbf.py +18 -0
  323. scipy/interpolate/tests/__init__.py +0 -0
  324. scipy/interpolate/tests/data/bug-1310.npz +0 -0
  325. scipy/interpolate/tests/data/estimate_gradients_hang.npy +0 -0
  326. scipy/interpolate/tests/data/gcvspl.npz +0 -0
  327. scipy/interpolate/tests/test_bary_rational.py +368 -0
  328. scipy/interpolate/tests/test_bsplines.py +3754 -0
  329. scipy/interpolate/tests/test_fitpack.py +519 -0
  330. scipy/interpolate/tests/test_fitpack2.py +1431 -0
  331. scipy/interpolate/tests/test_gil.py +64 -0
  332. scipy/interpolate/tests/test_interpnd.py +452 -0
  333. scipy/interpolate/tests/test_interpolate.py +2630 -0
  334. scipy/interpolate/tests/test_ndgriddata.py +308 -0
  335. scipy/interpolate/tests/test_pade.py +107 -0
  336. scipy/interpolate/tests/test_polyint.py +972 -0
  337. scipy/interpolate/tests/test_rbf.py +246 -0
  338. scipy/interpolate/tests/test_rbfinterp.py +534 -0
  339. scipy/interpolate/tests/test_rgi.py +1151 -0
  340. scipy/io/__init__.py +116 -0
  341. scipy/io/_fast_matrix_market/__init__.py +600 -0
  342. scipy/io/_fast_matrix_market/_fmm_core.cp314-win_arm64.lib +0 -0
  343. scipy/io/_fast_matrix_market/_fmm_core.cp314-win_arm64.pyd +0 -0
  344. scipy/io/_fortran.py +354 -0
  345. scipy/io/_harwell_boeing/__init__.py +7 -0
  346. scipy/io/_harwell_boeing/_fortran_format_parser.py +316 -0
  347. scipy/io/_harwell_boeing/hb.py +571 -0
  348. scipy/io/_harwell_boeing/tests/__init__.py +0 -0
  349. scipy/io/_harwell_boeing/tests/test_fortran_format.py +74 -0
  350. scipy/io/_harwell_boeing/tests/test_hb.py +70 -0
  351. scipy/io/_idl.py +917 -0
  352. scipy/io/_mmio.py +968 -0
  353. scipy/io/_netcdf.py +1104 -0
  354. scipy/io/_test_fortran.cp314-win_arm64.lib +0 -0
  355. scipy/io/_test_fortran.cp314-win_arm64.pyd +0 -0
  356. scipy/io/arff/__init__.py +28 -0
  357. scipy/io/arff/_arffread.py +873 -0
  358. scipy/io/arff/arffread.py +19 -0
  359. scipy/io/arff/tests/__init__.py +0 -0
  360. scipy/io/arff/tests/data/iris.arff +225 -0
  361. scipy/io/arff/tests/data/missing.arff +8 -0
  362. scipy/io/arff/tests/data/nodata.arff +11 -0
  363. scipy/io/arff/tests/data/quoted_nominal.arff +13 -0
  364. scipy/io/arff/tests/data/quoted_nominal_spaces.arff +13 -0
  365. scipy/io/arff/tests/data/test1.arff +10 -0
  366. scipy/io/arff/tests/data/test10.arff +8 -0
  367. scipy/io/arff/tests/data/test11.arff +11 -0
  368. scipy/io/arff/tests/data/test2.arff +15 -0
  369. scipy/io/arff/tests/data/test3.arff +6 -0
  370. scipy/io/arff/tests/data/test4.arff +11 -0
  371. scipy/io/arff/tests/data/test5.arff +26 -0
  372. scipy/io/arff/tests/data/test6.arff +12 -0
  373. scipy/io/arff/tests/data/test7.arff +15 -0
  374. scipy/io/arff/tests/data/test8.arff +12 -0
  375. scipy/io/arff/tests/data/test9.arff +14 -0
  376. scipy/io/arff/tests/test_arffread.py +421 -0
  377. scipy/io/harwell_boeing.py +17 -0
  378. scipy/io/idl.py +17 -0
  379. scipy/io/matlab/__init__.py +66 -0
  380. scipy/io/matlab/_byteordercodes.py +75 -0
  381. scipy/io/matlab/_mio.py +375 -0
  382. scipy/io/matlab/_mio4.py +632 -0
  383. scipy/io/matlab/_mio5.py +901 -0
  384. scipy/io/matlab/_mio5_params.py +281 -0
  385. scipy/io/matlab/_mio5_utils.cp314-win_arm64.lib +0 -0
  386. scipy/io/matlab/_mio5_utils.cp314-win_arm64.pyd +0 -0
  387. scipy/io/matlab/_mio_utils.cp314-win_arm64.lib +0 -0
  388. scipy/io/matlab/_mio_utils.cp314-win_arm64.pyd +0 -0
  389. scipy/io/matlab/_miobase.py +435 -0
  390. scipy/io/matlab/_streams.cp314-win_arm64.lib +0 -0
  391. scipy/io/matlab/_streams.cp314-win_arm64.pyd +0 -0
  392. scipy/io/matlab/byteordercodes.py +17 -0
  393. scipy/io/matlab/mio.py +16 -0
  394. scipy/io/matlab/mio4.py +17 -0
  395. scipy/io/matlab/mio5.py +19 -0
  396. scipy/io/matlab/mio5_params.py +18 -0
  397. scipy/io/matlab/mio5_utils.py +17 -0
  398. scipy/io/matlab/mio_utils.py +17 -0
  399. scipy/io/matlab/miobase.py +16 -0
  400. scipy/io/matlab/streams.py +16 -0
  401. scipy/io/matlab/tests/__init__.py +0 -0
  402. scipy/io/matlab/tests/data/bad_miuint32.mat +0 -0
  403. scipy/io/matlab/tests/data/bad_miutf8_array_name.mat +0 -0
  404. scipy/io/matlab/tests/data/big_endian.mat +0 -0
  405. scipy/io/matlab/tests/data/broken_utf8.mat +0 -0
  406. scipy/io/matlab/tests/data/corrupted_zlib_checksum.mat +0 -0
  407. scipy/io/matlab/tests/data/corrupted_zlib_data.mat +0 -0
  408. scipy/io/matlab/tests/data/debigged_m4.mat +0 -0
  409. scipy/io/matlab/tests/data/japanese_utf8.txt +5 -0
  410. scipy/io/matlab/tests/data/little_endian.mat +0 -0
  411. scipy/io/matlab/tests/data/logical_sparse.mat +0 -0
  412. scipy/io/matlab/tests/data/malformed1.mat +0 -0
  413. scipy/io/matlab/tests/data/miuint32_for_miint32.mat +0 -0
  414. scipy/io/matlab/tests/data/miutf8_array_name.mat +0 -0
  415. scipy/io/matlab/tests/data/nasty_duplicate_fieldnames.mat +0 -0
  416. scipy/io/matlab/tests/data/one_by_zero_char.mat +0 -0
  417. scipy/io/matlab/tests/data/parabola.mat +0 -0
  418. scipy/io/matlab/tests/data/single_empty_string.mat +0 -0
  419. scipy/io/matlab/tests/data/some_functions.mat +0 -0
  420. scipy/io/matlab/tests/data/sqr.mat +0 -0
  421. scipy/io/matlab/tests/data/test3dmatrix_6.1_SOL2.mat +0 -0
  422. scipy/io/matlab/tests/data/test3dmatrix_6.5.1_GLNX86.mat +0 -0
  423. scipy/io/matlab/tests/data/test3dmatrix_7.1_GLNX86.mat +0 -0
  424. scipy/io/matlab/tests/data/test3dmatrix_7.4_GLNX86.mat +0 -0
  425. scipy/io/matlab/tests/data/test_empty_struct.mat +0 -0
  426. scipy/io/matlab/tests/data/test_mat4_le_floats.mat +0 -0
  427. scipy/io/matlab/tests/data/test_skip_variable.mat +0 -0
  428. scipy/io/matlab/tests/data/testbool_8_WIN64.mat +0 -0
  429. scipy/io/matlab/tests/data/testcell_6.1_SOL2.mat +0 -0
  430. scipy/io/matlab/tests/data/testcell_6.5.1_GLNX86.mat +0 -0
  431. scipy/io/matlab/tests/data/testcell_7.1_GLNX86.mat +0 -0
  432. scipy/io/matlab/tests/data/testcell_7.4_GLNX86.mat +0 -0
  433. scipy/io/matlab/tests/data/testcellnest_6.1_SOL2.mat +0 -0
  434. scipy/io/matlab/tests/data/testcellnest_6.5.1_GLNX86.mat +0 -0
  435. scipy/io/matlab/tests/data/testcellnest_7.1_GLNX86.mat +0 -0
  436. scipy/io/matlab/tests/data/testcellnest_7.4_GLNX86.mat +0 -0
  437. scipy/io/matlab/tests/data/testcomplex_4.2c_SOL2.mat +0 -0
  438. scipy/io/matlab/tests/data/testcomplex_6.1_SOL2.mat +0 -0
  439. scipy/io/matlab/tests/data/testcomplex_6.5.1_GLNX86.mat +0 -0
  440. scipy/io/matlab/tests/data/testcomplex_7.1_GLNX86.mat +0 -0
  441. scipy/io/matlab/tests/data/testcomplex_7.4_GLNX86.mat +0 -0
  442. scipy/io/matlab/tests/data/testdouble_4.2c_SOL2.mat +0 -0
  443. scipy/io/matlab/tests/data/testdouble_6.1_SOL2.mat +0 -0
  444. scipy/io/matlab/tests/data/testdouble_6.5.1_GLNX86.mat +0 -0
  445. scipy/io/matlab/tests/data/testdouble_7.1_GLNX86.mat +0 -0
  446. scipy/io/matlab/tests/data/testdouble_7.4_GLNX86.mat +0 -0
  447. scipy/io/matlab/tests/data/testemptycell_5.3_SOL2.mat +0 -0
  448. scipy/io/matlab/tests/data/testemptycell_6.5.1_GLNX86.mat +0 -0
  449. scipy/io/matlab/tests/data/testemptycell_7.1_GLNX86.mat +0 -0
  450. scipy/io/matlab/tests/data/testemptycell_7.4_GLNX86.mat +0 -0
  451. scipy/io/matlab/tests/data/testfunc_7.4_GLNX86.mat +0 -0
  452. scipy/io/matlab/tests/data/testhdf5_7.4_GLNX86.mat +0 -0
  453. scipy/io/matlab/tests/data/testmatrix_4.2c_SOL2.mat +0 -0
  454. scipy/io/matlab/tests/data/testmatrix_6.1_SOL2.mat +0 -0
  455. scipy/io/matlab/tests/data/testmatrix_6.5.1_GLNX86.mat +0 -0
  456. scipy/io/matlab/tests/data/testmatrix_7.1_GLNX86.mat +0 -0
  457. scipy/io/matlab/tests/data/testmatrix_7.4_GLNX86.mat +0 -0
  458. scipy/io/matlab/tests/data/testminus_4.2c_SOL2.mat +0 -0
  459. scipy/io/matlab/tests/data/testminus_6.1_SOL2.mat +0 -0
  460. scipy/io/matlab/tests/data/testminus_6.5.1_GLNX86.mat +0 -0
  461. scipy/io/matlab/tests/data/testminus_7.1_GLNX86.mat +0 -0
  462. scipy/io/matlab/tests/data/testminus_7.4_GLNX86.mat +0 -0
  463. scipy/io/matlab/tests/data/testmulti_4.2c_SOL2.mat +0 -0
  464. scipy/io/matlab/tests/data/testmulti_7.1_GLNX86.mat +0 -0
  465. scipy/io/matlab/tests/data/testmulti_7.4_GLNX86.mat +0 -0
  466. scipy/io/matlab/tests/data/testobject_6.1_SOL2.mat +0 -0
  467. scipy/io/matlab/tests/data/testobject_6.5.1_GLNX86.mat +0 -0
  468. scipy/io/matlab/tests/data/testobject_7.1_GLNX86.mat +0 -0
  469. scipy/io/matlab/tests/data/testobject_7.4_GLNX86.mat +0 -0
  470. scipy/io/matlab/tests/data/testonechar_4.2c_SOL2.mat +0 -0
  471. scipy/io/matlab/tests/data/testonechar_6.1_SOL2.mat +0 -0
  472. scipy/io/matlab/tests/data/testonechar_6.5.1_GLNX86.mat +0 -0
  473. scipy/io/matlab/tests/data/testonechar_7.1_GLNX86.mat +0 -0
  474. scipy/io/matlab/tests/data/testonechar_7.4_GLNX86.mat +0 -0
  475. scipy/io/matlab/tests/data/testscalarcell_7.4_GLNX86.mat +0 -0
  476. scipy/io/matlab/tests/data/testsimplecell.mat +0 -0
  477. scipy/io/matlab/tests/data/testsparse_4.2c_SOL2.mat +0 -0
  478. scipy/io/matlab/tests/data/testsparse_6.1_SOL2.mat +0 -0
  479. scipy/io/matlab/tests/data/testsparse_6.5.1_GLNX86.mat +0 -0
  480. scipy/io/matlab/tests/data/testsparse_7.1_GLNX86.mat +0 -0
  481. scipy/io/matlab/tests/data/testsparse_7.4_GLNX86.mat +0 -0
  482. scipy/io/matlab/tests/data/testsparsecomplex_4.2c_SOL2.mat +0 -0
  483. scipy/io/matlab/tests/data/testsparsecomplex_6.1_SOL2.mat +0 -0
  484. scipy/io/matlab/tests/data/testsparsecomplex_6.5.1_GLNX86.mat +0 -0
  485. scipy/io/matlab/tests/data/testsparsecomplex_7.1_GLNX86.mat +0 -0
  486. scipy/io/matlab/tests/data/testsparsecomplex_7.4_GLNX86.mat +0 -0
  487. scipy/io/matlab/tests/data/testsparsefloat_7.4_GLNX86.mat +0 -0
  488. scipy/io/matlab/tests/data/teststring_4.2c_SOL2.mat +0 -0
  489. scipy/io/matlab/tests/data/teststring_6.1_SOL2.mat +0 -0
  490. scipy/io/matlab/tests/data/teststring_6.5.1_GLNX86.mat +0 -0
  491. scipy/io/matlab/tests/data/teststring_7.1_GLNX86.mat +0 -0
  492. scipy/io/matlab/tests/data/teststring_7.4_GLNX86.mat +0 -0
  493. scipy/io/matlab/tests/data/teststringarray_4.2c_SOL2.mat +0 -0
  494. scipy/io/matlab/tests/data/teststringarray_6.1_SOL2.mat +0 -0
  495. scipy/io/matlab/tests/data/teststringarray_6.5.1_GLNX86.mat +0 -0
  496. scipy/io/matlab/tests/data/teststringarray_7.1_GLNX86.mat +0 -0
  497. scipy/io/matlab/tests/data/teststringarray_7.4_GLNX86.mat +0 -0
  498. scipy/io/matlab/tests/data/teststruct_6.1_SOL2.mat +0 -0
  499. scipy/io/matlab/tests/data/teststruct_6.5.1_GLNX86.mat +0 -0
  500. scipy/io/matlab/tests/data/teststruct_7.1_GLNX86.mat +0 -0
  501. scipy/io/matlab/tests/data/teststruct_7.4_GLNX86.mat +0 -0
  502. scipy/io/matlab/tests/data/teststructarr_6.1_SOL2.mat +0 -0
  503. scipy/io/matlab/tests/data/teststructarr_6.5.1_GLNX86.mat +0 -0
  504. scipy/io/matlab/tests/data/teststructarr_7.1_GLNX86.mat +0 -0
  505. scipy/io/matlab/tests/data/teststructarr_7.4_GLNX86.mat +0 -0
  506. scipy/io/matlab/tests/data/teststructnest_6.1_SOL2.mat +0 -0
  507. scipy/io/matlab/tests/data/teststructnest_6.5.1_GLNX86.mat +0 -0
  508. scipy/io/matlab/tests/data/teststructnest_7.1_GLNX86.mat +0 -0
  509. scipy/io/matlab/tests/data/teststructnest_7.4_GLNX86.mat +0 -0
  510. scipy/io/matlab/tests/data/testunicode_7.1_GLNX86.mat +0 -0
  511. scipy/io/matlab/tests/data/testunicode_7.4_GLNX86.mat +0 -0
  512. scipy/io/matlab/tests/data/testvec_4_GLNX86.mat +0 -0
  513. scipy/io/matlab/tests/test_byteordercodes.py +29 -0
  514. scipy/io/matlab/tests/test_mio.py +1399 -0
  515. scipy/io/matlab/tests/test_mio5_utils.py +179 -0
  516. scipy/io/matlab/tests/test_mio_funcs.py +51 -0
  517. scipy/io/matlab/tests/test_mio_utils.py +45 -0
  518. scipy/io/matlab/tests/test_miobase.py +32 -0
  519. scipy/io/matlab/tests/test_pathological.py +33 -0
  520. scipy/io/matlab/tests/test_streams.py +241 -0
  521. scipy/io/mmio.py +17 -0
  522. scipy/io/netcdf.py +17 -0
  523. scipy/io/tests/__init__.py +0 -0
  524. scipy/io/tests/data/Transparent Busy.ani +0 -0
  525. scipy/io/tests/data/array_float32_1d.sav +0 -0
  526. scipy/io/tests/data/array_float32_2d.sav +0 -0
  527. scipy/io/tests/data/array_float32_3d.sav +0 -0
  528. scipy/io/tests/data/array_float32_4d.sav +0 -0
  529. scipy/io/tests/data/array_float32_5d.sav +0 -0
  530. scipy/io/tests/data/array_float32_6d.sav +0 -0
  531. scipy/io/tests/data/array_float32_7d.sav +0 -0
  532. scipy/io/tests/data/array_float32_8d.sav +0 -0
  533. scipy/io/tests/data/array_float32_pointer_1d.sav +0 -0
  534. scipy/io/tests/data/array_float32_pointer_2d.sav +0 -0
  535. scipy/io/tests/data/array_float32_pointer_3d.sav +0 -0
  536. scipy/io/tests/data/array_float32_pointer_4d.sav +0 -0
  537. scipy/io/tests/data/array_float32_pointer_5d.sav +0 -0
  538. scipy/io/tests/data/array_float32_pointer_6d.sav +0 -0
  539. scipy/io/tests/data/array_float32_pointer_7d.sav +0 -0
  540. scipy/io/tests/data/array_float32_pointer_8d.sav +0 -0
  541. scipy/io/tests/data/example_1.nc +0 -0
  542. scipy/io/tests/data/example_2.nc +0 -0
  543. scipy/io/tests/data/example_3_maskedvals.nc +0 -0
  544. scipy/io/tests/data/fortran-3x3d-2i.dat +0 -0
  545. scipy/io/tests/data/fortran-mixed.dat +0 -0
  546. scipy/io/tests/data/fortran-sf8-11x1x10.dat +0 -0
  547. scipy/io/tests/data/fortran-sf8-15x10x22.dat +0 -0
  548. scipy/io/tests/data/fortran-sf8-1x1x1.dat +0 -0
  549. scipy/io/tests/data/fortran-sf8-1x1x5.dat +0 -0
  550. scipy/io/tests/data/fortran-sf8-1x1x7.dat +0 -0
  551. scipy/io/tests/data/fortran-sf8-1x3x5.dat +0 -0
  552. scipy/io/tests/data/fortran-si4-11x1x10.dat +0 -0
  553. scipy/io/tests/data/fortran-si4-15x10x22.dat +0 -0
  554. scipy/io/tests/data/fortran-si4-1x1x1.dat +0 -0
  555. scipy/io/tests/data/fortran-si4-1x1x5.dat +0 -0
  556. scipy/io/tests/data/fortran-si4-1x1x7.dat +0 -0
  557. scipy/io/tests/data/fortran-si4-1x3x5.dat +0 -0
  558. scipy/io/tests/data/invalid_pointer.sav +0 -0
  559. scipy/io/tests/data/null_pointer.sav +0 -0
  560. scipy/io/tests/data/scalar_byte.sav +0 -0
  561. scipy/io/tests/data/scalar_byte_descr.sav +0 -0
  562. scipy/io/tests/data/scalar_complex32.sav +0 -0
  563. scipy/io/tests/data/scalar_complex64.sav +0 -0
  564. scipy/io/tests/data/scalar_float32.sav +0 -0
  565. scipy/io/tests/data/scalar_float64.sav +0 -0
  566. scipy/io/tests/data/scalar_heap_pointer.sav +0 -0
  567. scipy/io/tests/data/scalar_int16.sav +0 -0
  568. scipy/io/tests/data/scalar_int32.sav +0 -0
  569. scipy/io/tests/data/scalar_int64.sav +0 -0
  570. scipy/io/tests/data/scalar_string.sav +0 -0
  571. scipy/io/tests/data/scalar_uint16.sav +0 -0
  572. scipy/io/tests/data/scalar_uint32.sav +0 -0
  573. scipy/io/tests/data/scalar_uint64.sav +0 -0
  574. scipy/io/tests/data/struct_arrays.sav +0 -0
  575. scipy/io/tests/data/struct_arrays_byte_idl80.sav +0 -0
  576. scipy/io/tests/data/struct_arrays_replicated.sav +0 -0
  577. scipy/io/tests/data/struct_arrays_replicated_3d.sav +0 -0
  578. scipy/io/tests/data/struct_inherit.sav +0 -0
  579. scipy/io/tests/data/struct_pointer_arrays.sav +0 -0
  580. scipy/io/tests/data/struct_pointer_arrays_replicated.sav +0 -0
  581. scipy/io/tests/data/struct_pointer_arrays_replicated_3d.sav +0 -0
  582. scipy/io/tests/data/struct_pointers.sav +0 -0
  583. scipy/io/tests/data/struct_pointers_replicated.sav +0 -0
  584. scipy/io/tests/data/struct_pointers_replicated_3d.sav +0 -0
  585. scipy/io/tests/data/struct_scalars.sav +0 -0
  586. scipy/io/tests/data/struct_scalars_replicated.sav +0 -0
  587. scipy/io/tests/data/struct_scalars_replicated_3d.sav +0 -0
  588. scipy/io/tests/data/test-1234Hz-le-1ch-10S-20bit-extra.wav +0 -0
  589. scipy/io/tests/data/test-44100Hz-2ch-32bit-float-be.wav +0 -0
  590. scipy/io/tests/data/test-44100Hz-2ch-32bit-float-le.wav +0 -0
  591. scipy/io/tests/data/test-44100Hz-be-1ch-4bytes.wav +0 -0
  592. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof-no-data.wav +0 -0
  593. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-early-eof.wav +0 -0
  594. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-incomplete-chunk.wav +0 -0
  595. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes-rf64.wav +0 -0
  596. scipy/io/tests/data/test-44100Hz-le-1ch-4bytes.wav +0 -0
  597. scipy/io/tests/data/test-48000Hz-2ch-64bit-float-le-wavex.wav +0 -0
  598. scipy/io/tests/data/test-8000Hz-be-3ch-5S-24bit.wav +0 -0
  599. scipy/io/tests/data/test-8000Hz-le-1ch-1byte-ulaw.wav +0 -0
  600. scipy/io/tests/data/test-8000Hz-le-2ch-1byteu.wav +0 -0
  601. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-inconsistent.wav +0 -0
  602. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit-rf64.wav +0 -0
  603. scipy/io/tests/data/test-8000Hz-le-3ch-5S-24bit.wav +0 -0
  604. scipy/io/tests/data/test-8000Hz-le-3ch-5S-36bit.wav +0 -0
  605. scipy/io/tests/data/test-8000Hz-le-3ch-5S-45bit.wav +0 -0
  606. scipy/io/tests/data/test-8000Hz-le-3ch-5S-53bit.wav +0 -0
  607. scipy/io/tests/data/test-8000Hz-le-3ch-5S-64bit.wav +0 -0
  608. scipy/io/tests/data/test-8000Hz-le-4ch-9S-12bit.wav +0 -0
  609. scipy/io/tests/data/test-8000Hz-le-5ch-9S-5bit.wav +0 -0
  610. scipy/io/tests/data/various_compressed.sav +0 -0
  611. scipy/io/tests/test_fortran.py +264 -0
  612. scipy/io/tests/test_idl.py +483 -0
  613. scipy/io/tests/test_mmio.py +831 -0
  614. scipy/io/tests/test_netcdf.py +550 -0
  615. scipy/io/tests/test_paths.py +93 -0
  616. scipy/io/tests/test_wavfile.py +501 -0
  617. scipy/io/wavfile.py +938 -0
  618. scipy/linalg/__init__.pxd +1 -0
  619. scipy/linalg/__init__.py +236 -0
  620. scipy/linalg/_basic.py +2146 -0
  621. scipy/linalg/_blas_subroutines.h +164 -0
  622. scipy/linalg/_cythonized_array_utils.cp314-win_arm64.lib +0 -0
  623. scipy/linalg/_cythonized_array_utils.cp314-win_arm64.pyd +0 -0
  624. scipy/linalg/_cythonized_array_utils.pxd +40 -0
  625. scipy/linalg/_cythonized_array_utils.pyi +16 -0
  626. scipy/linalg/_decomp.py +1645 -0
  627. scipy/linalg/_decomp_cholesky.py +413 -0
  628. scipy/linalg/_decomp_cossin.py +236 -0
  629. scipy/linalg/_decomp_interpolative.cp314-win_arm64.lib +0 -0
  630. scipy/linalg/_decomp_interpolative.cp314-win_arm64.pyd +0 -0
  631. scipy/linalg/_decomp_ldl.py +356 -0
  632. scipy/linalg/_decomp_lu.py +401 -0
  633. scipy/linalg/_decomp_lu_cython.cp314-win_arm64.lib +0 -0
  634. scipy/linalg/_decomp_lu_cython.cp314-win_arm64.pyd +0 -0
  635. scipy/linalg/_decomp_lu_cython.pyi +6 -0
  636. scipy/linalg/_decomp_polar.py +113 -0
  637. scipy/linalg/_decomp_qr.py +494 -0
  638. scipy/linalg/_decomp_qz.py +452 -0
  639. scipy/linalg/_decomp_schur.py +336 -0
  640. scipy/linalg/_decomp_svd.py +545 -0
  641. scipy/linalg/_decomp_update.cp314-win_arm64.lib +0 -0
  642. scipy/linalg/_decomp_update.cp314-win_arm64.pyd +0 -0
  643. scipy/linalg/_expm_frechet.py +417 -0
  644. scipy/linalg/_fblas.cp314-win_arm64.lib +0 -0
  645. scipy/linalg/_fblas.cp314-win_arm64.pyd +0 -0
  646. scipy/linalg/_flapack.cp314-win_arm64.lib +0 -0
  647. scipy/linalg/_flapack.cp314-win_arm64.pyd +0 -0
  648. scipy/linalg/_lapack_subroutines.h +1521 -0
  649. scipy/linalg/_linalg_pythran.cp314-win_arm64.lib +0 -0
  650. scipy/linalg/_linalg_pythran.cp314-win_arm64.pyd +0 -0
  651. scipy/linalg/_matfuncs.py +1050 -0
  652. scipy/linalg/_matfuncs_expm.cp314-win_arm64.lib +0 -0
  653. scipy/linalg/_matfuncs_expm.cp314-win_arm64.pyd +0 -0
  654. scipy/linalg/_matfuncs_expm.pyi +6 -0
  655. scipy/linalg/_matfuncs_inv_ssq.py +886 -0
  656. scipy/linalg/_matfuncs_schur_sqrtm.cp314-win_arm64.lib +0 -0
  657. scipy/linalg/_matfuncs_schur_sqrtm.cp314-win_arm64.pyd +0 -0
  658. scipy/linalg/_matfuncs_sqrtm.py +107 -0
  659. scipy/linalg/_matfuncs_sqrtm_triu.cp314-win_arm64.lib +0 -0
  660. scipy/linalg/_matfuncs_sqrtm_triu.cp314-win_arm64.pyd +0 -0
  661. scipy/linalg/_misc.py +191 -0
  662. scipy/linalg/_procrustes.py +113 -0
  663. scipy/linalg/_sketches.py +189 -0
  664. scipy/linalg/_solve_toeplitz.cp314-win_arm64.lib +0 -0
  665. scipy/linalg/_solve_toeplitz.cp314-win_arm64.pyd +0 -0
  666. scipy/linalg/_solvers.py +862 -0
  667. scipy/linalg/_special_matrices.py +1322 -0
  668. scipy/linalg/_testutils.py +65 -0
  669. scipy/linalg/basic.py +23 -0
  670. scipy/linalg/blas.py +495 -0
  671. scipy/linalg/cython_blas.cp314-win_arm64.lib +0 -0
  672. scipy/linalg/cython_blas.cp314-win_arm64.pyd +0 -0
  673. scipy/linalg/cython_blas.pxd +169 -0
  674. scipy/linalg/cython_blas.pyx +1432 -0
  675. scipy/linalg/cython_lapack.cp314-win_arm64.lib +0 -0
  676. scipy/linalg/cython_lapack.cp314-win_arm64.pyd +0 -0
  677. scipy/linalg/cython_lapack.pxd +1528 -0
  678. scipy/linalg/cython_lapack.pyx +12045 -0
  679. scipy/linalg/decomp.py +23 -0
  680. scipy/linalg/decomp_cholesky.py +21 -0
  681. scipy/linalg/decomp_lu.py +21 -0
  682. scipy/linalg/decomp_qr.py +20 -0
  683. scipy/linalg/decomp_schur.py +21 -0
  684. scipy/linalg/decomp_svd.py +21 -0
  685. scipy/linalg/interpolative.py +989 -0
  686. scipy/linalg/lapack.py +1081 -0
  687. scipy/linalg/matfuncs.py +23 -0
  688. scipy/linalg/misc.py +21 -0
  689. scipy/linalg/special_matrices.py +22 -0
  690. scipy/linalg/tests/__init__.py +0 -0
  691. scipy/linalg/tests/_cython_examples/extending.pyx +23 -0
  692. scipy/linalg/tests/_cython_examples/meson.build +34 -0
  693. scipy/linalg/tests/data/carex_15_data.npz +0 -0
  694. scipy/linalg/tests/data/carex_18_data.npz +0 -0
  695. scipy/linalg/tests/data/carex_19_data.npz +0 -0
  696. scipy/linalg/tests/data/carex_20_data.npz +0 -0
  697. scipy/linalg/tests/data/carex_6_data.npz +0 -0
  698. scipy/linalg/tests/data/gendare_20170120_data.npz +0 -0
  699. scipy/linalg/tests/test_basic.py +2074 -0
  700. scipy/linalg/tests/test_batch.py +588 -0
  701. scipy/linalg/tests/test_blas.py +1127 -0
  702. scipy/linalg/tests/test_cython_blas.py +118 -0
  703. scipy/linalg/tests/test_cython_lapack.py +22 -0
  704. scipy/linalg/tests/test_cythonized_array_utils.py +130 -0
  705. scipy/linalg/tests/test_decomp.py +3189 -0
  706. scipy/linalg/tests/test_decomp_cholesky.py +268 -0
  707. scipy/linalg/tests/test_decomp_cossin.py +314 -0
  708. scipy/linalg/tests/test_decomp_ldl.py +137 -0
  709. scipy/linalg/tests/test_decomp_lu.py +308 -0
  710. scipy/linalg/tests/test_decomp_polar.py +110 -0
  711. scipy/linalg/tests/test_decomp_update.py +1701 -0
  712. scipy/linalg/tests/test_extending.py +46 -0
  713. scipy/linalg/tests/test_fblas.py +607 -0
  714. scipy/linalg/tests/test_interpolative.py +232 -0
  715. scipy/linalg/tests/test_lapack.py +3620 -0
  716. scipy/linalg/tests/test_matfuncs.py +1125 -0
  717. scipy/linalg/tests/test_matmul_toeplitz.py +136 -0
  718. scipy/linalg/tests/test_procrustes.py +214 -0
  719. scipy/linalg/tests/test_sketches.py +118 -0
  720. scipy/linalg/tests/test_solve_toeplitz.py +150 -0
  721. scipy/linalg/tests/test_solvers.py +844 -0
  722. scipy/linalg/tests/test_special_matrices.py +636 -0
  723. scipy/misc/__init__.py +6 -0
  724. scipy/misc/common.py +6 -0
  725. scipy/misc/doccer.py +6 -0
  726. scipy/ndimage/__init__.py +174 -0
  727. scipy/ndimage/_ctest.cp314-win_arm64.lib +0 -0
  728. scipy/ndimage/_ctest.cp314-win_arm64.pyd +0 -0
  729. scipy/ndimage/_cytest.cp314-win_arm64.lib +0 -0
  730. scipy/ndimage/_cytest.cp314-win_arm64.pyd +0 -0
  731. scipy/ndimage/_delegators.py +303 -0
  732. scipy/ndimage/_filters.py +2422 -0
  733. scipy/ndimage/_fourier.py +306 -0
  734. scipy/ndimage/_interpolation.py +1033 -0
  735. scipy/ndimage/_measurements.py +1689 -0
  736. scipy/ndimage/_morphology.py +2634 -0
  737. scipy/ndimage/_nd_image.cp314-win_arm64.lib +0 -0
  738. scipy/ndimage/_nd_image.cp314-win_arm64.pyd +0 -0
  739. scipy/ndimage/_ndimage_api.py +16 -0
  740. scipy/ndimage/_ni_docstrings.py +214 -0
  741. scipy/ndimage/_ni_label.cp314-win_arm64.lib +0 -0
  742. scipy/ndimage/_ni_label.cp314-win_arm64.pyd +0 -0
  743. scipy/ndimage/_ni_support.py +139 -0
  744. scipy/ndimage/_rank_filter_1d.cp314-win_arm64.lib +0 -0
  745. scipy/ndimage/_rank_filter_1d.cp314-win_arm64.pyd +0 -0
  746. scipy/ndimage/_support_alternative_backends.py +84 -0
  747. scipy/ndimage/filters.py +27 -0
  748. scipy/ndimage/fourier.py +21 -0
  749. scipy/ndimage/interpolation.py +22 -0
  750. scipy/ndimage/measurements.py +24 -0
  751. scipy/ndimage/morphology.py +27 -0
  752. scipy/ndimage/tests/__init__.py +12 -0
  753. scipy/ndimage/tests/data/label_inputs.txt +21 -0
  754. scipy/ndimage/tests/data/label_results.txt +294 -0
  755. scipy/ndimage/tests/data/label_strels.txt +42 -0
  756. scipy/ndimage/tests/dots.png +0 -0
  757. scipy/ndimage/tests/test_c_api.py +102 -0
  758. scipy/ndimage/tests/test_datatypes.py +67 -0
  759. scipy/ndimage/tests/test_filters.py +3083 -0
  760. scipy/ndimage/tests/test_fourier.py +187 -0
  761. scipy/ndimage/tests/test_interpolation.py +1491 -0
  762. scipy/ndimage/tests/test_measurements.py +1592 -0
  763. scipy/ndimage/tests/test_morphology.py +2950 -0
  764. scipy/ndimage/tests/test_ni_support.py +78 -0
  765. scipy/ndimage/tests/test_splines.py +70 -0
  766. scipy/odr/__init__.py +131 -0
  767. scipy/odr/__odrpack.cp314-win_arm64.lib +0 -0
  768. scipy/odr/__odrpack.cp314-win_arm64.pyd +0 -0
  769. scipy/odr/_add_newdocs.py +34 -0
  770. scipy/odr/_models.py +315 -0
  771. scipy/odr/_odrpack.py +1154 -0
  772. scipy/odr/models.py +20 -0
  773. scipy/odr/odrpack.py +21 -0
  774. scipy/odr/tests/__init__.py +0 -0
  775. scipy/odr/tests/test_odr.py +607 -0
  776. scipy/optimize/__init__.pxd +1 -0
  777. scipy/optimize/__init__.py +460 -0
  778. scipy/optimize/_basinhopping.py +741 -0
  779. scipy/optimize/_bglu_dense.cp314-win_arm64.lib +0 -0
  780. scipy/optimize/_bglu_dense.cp314-win_arm64.pyd +0 -0
  781. scipy/optimize/_bracket.py +706 -0
  782. scipy/optimize/_chandrupatla.py +551 -0
  783. scipy/optimize/_cobyla_py.py +297 -0
  784. scipy/optimize/_cobyqa_py.py +72 -0
  785. scipy/optimize/_constraints.py +598 -0
  786. scipy/optimize/_dcsrch.py +728 -0
  787. scipy/optimize/_differentiable_functions.py +835 -0
  788. scipy/optimize/_differentialevolution.py +1970 -0
  789. scipy/optimize/_direct.cp314-win_arm64.lib +0 -0
  790. scipy/optimize/_direct.cp314-win_arm64.pyd +0 -0
  791. scipy/optimize/_direct_py.py +280 -0
  792. scipy/optimize/_dual_annealing.py +732 -0
  793. scipy/optimize/_elementwise.py +798 -0
  794. scipy/optimize/_group_columns.cp314-win_arm64.lib +0 -0
  795. scipy/optimize/_group_columns.cp314-win_arm64.pyd +0 -0
  796. scipy/optimize/_hessian_update_strategy.py +479 -0
  797. scipy/optimize/_highspy/__init__.py +0 -0
  798. scipy/optimize/_highspy/_core.cp314-win_arm64.lib +0 -0
  799. scipy/optimize/_highspy/_core.cp314-win_arm64.pyd +0 -0
  800. scipy/optimize/_highspy/_highs_options.cp314-win_arm64.lib +0 -0
  801. scipy/optimize/_highspy/_highs_options.cp314-win_arm64.pyd +0 -0
  802. scipy/optimize/_highspy/_highs_wrapper.py +338 -0
  803. scipy/optimize/_isotonic.py +157 -0
  804. scipy/optimize/_lbfgsb.cp314-win_arm64.lib +0 -0
  805. scipy/optimize/_lbfgsb.cp314-win_arm64.pyd +0 -0
  806. scipy/optimize/_lbfgsb_py.py +634 -0
  807. scipy/optimize/_linesearch.py +896 -0
  808. scipy/optimize/_linprog.py +733 -0
  809. scipy/optimize/_linprog_doc.py +1434 -0
  810. scipy/optimize/_linprog_highs.py +422 -0
  811. scipy/optimize/_linprog_ip.py +1141 -0
  812. scipy/optimize/_linprog_rs.py +572 -0
  813. scipy/optimize/_linprog_simplex.py +663 -0
  814. scipy/optimize/_linprog_util.py +1521 -0
  815. scipy/optimize/_lsap.cp314-win_arm64.lib +0 -0
  816. scipy/optimize/_lsap.cp314-win_arm64.pyd +0 -0
  817. scipy/optimize/_lsq/__init__.py +5 -0
  818. scipy/optimize/_lsq/bvls.py +183 -0
  819. scipy/optimize/_lsq/common.py +731 -0
  820. scipy/optimize/_lsq/dogbox.py +345 -0
  821. scipy/optimize/_lsq/givens_elimination.cp314-win_arm64.lib +0 -0
  822. scipy/optimize/_lsq/givens_elimination.cp314-win_arm64.pyd +0 -0
  823. scipy/optimize/_lsq/least_squares.py +1044 -0
  824. scipy/optimize/_lsq/lsq_linear.py +361 -0
  825. scipy/optimize/_lsq/trf.py +587 -0
  826. scipy/optimize/_lsq/trf_linear.py +249 -0
  827. scipy/optimize/_milp.py +394 -0
  828. scipy/optimize/_minimize.py +1199 -0
  829. scipy/optimize/_minpack.cp314-win_arm64.lib +0 -0
  830. scipy/optimize/_minpack.cp314-win_arm64.pyd +0 -0
  831. scipy/optimize/_minpack_py.py +1178 -0
  832. scipy/optimize/_moduleTNC.cp314-win_arm64.lib +0 -0
  833. scipy/optimize/_moduleTNC.cp314-win_arm64.pyd +0 -0
  834. scipy/optimize/_nnls.py +96 -0
  835. scipy/optimize/_nonlin.py +1634 -0
  836. scipy/optimize/_numdiff.py +963 -0
  837. scipy/optimize/_optimize.py +4169 -0
  838. scipy/optimize/_pava_pybind.cp314-win_arm64.lib +0 -0
  839. scipy/optimize/_pava_pybind.cp314-win_arm64.pyd +0 -0
  840. scipy/optimize/_qap.py +760 -0
  841. scipy/optimize/_remove_redundancy.py +522 -0
  842. scipy/optimize/_root.py +732 -0
  843. scipy/optimize/_root_scalar.py +538 -0
  844. scipy/optimize/_shgo.py +1606 -0
  845. scipy/optimize/_shgo_lib/__init__.py +0 -0
  846. scipy/optimize/_shgo_lib/_complex.py +1225 -0
  847. scipy/optimize/_shgo_lib/_vertex.py +460 -0
  848. scipy/optimize/_slsqp_py.py +603 -0
  849. scipy/optimize/_slsqplib.cp314-win_arm64.lib +0 -0
  850. scipy/optimize/_slsqplib.cp314-win_arm64.pyd +0 -0
  851. scipy/optimize/_spectral.py +260 -0
  852. scipy/optimize/_tnc.py +438 -0
  853. scipy/optimize/_trlib/__init__.py +12 -0
  854. scipy/optimize/_trlib/_trlib.cp314-win_arm64.lib +0 -0
  855. scipy/optimize/_trlib/_trlib.cp314-win_arm64.pyd +0 -0
  856. scipy/optimize/_trustregion.py +318 -0
  857. scipy/optimize/_trustregion_constr/__init__.py +6 -0
  858. scipy/optimize/_trustregion_constr/canonical_constraint.py +390 -0
  859. scipy/optimize/_trustregion_constr/equality_constrained_sqp.py +231 -0
  860. scipy/optimize/_trustregion_constr/minimize_trustregion_constr.py +584 -0
  861. scipy/optimize/_trustregion_constr/projections.py +411 -0
  862. scipy/optimize/_trustregion_constr/qp_subproblem.py +637 -0
  863. scipy/optimize/_trustregion_constr/report.py +49 -0
  864. scipy/optimize/_trustregion_constr/tests/__init__.py +0 -0
  865. scipy/optimize/_trustregion_constr/tests/test_canonical_constraint.py +296 -0
  866. scipy/optimize/_trustregion_constr/tests/test_nested_minimize.py +39 -0
  867. scipy/optimize/_trustregion_constr/tests/test_projections.py +214 -0
  868. scipy/optimize/_trustregion_constr/tests/test_qp_subproblem.py +645 -0
  869. scipy/optimize/_trustregion_constr/tests/test_report.py +34 -0
  870. scipy/optimize/_trustregion_constr/tr_interior_point.py +361 -0
  871. scipy/optimize/_trustregion_dogleg.py +122 -0
  872. scipy/optimize/_trustregion_exact.py +437 -0
  873. scipy/optimize/_trustregion_krylov.py +65 -0
  874. scipy/optimize/_trustregion_ncg.py +126 -0
  875. scipy/optimize/_tstutils.py +972 -0
  876. scipy/optimize/_zeros.cp314-win_arm64.lib +0 -0
  877. scipy/optimize/_zeros.cp314-win_arm64.pyd +0 -0
  878. scipy/optimize/_zeros_py.py +1475 -0
  879. scipy/optimize/cobyla.py +19 -0
  880. scipy/optimize/cython_optimize/__init__.py +133 -0
  881. scipy/optimize/cython_optimize/_zeros.cp314-win_arm64.lib +0 -0
  882. scipy/optimize/cython_optimize/_zeros.cp314-win_arm64.pyd +0 -0
  883. scipy/optimize/cython_optimize/_zeros.pxd +33 -0
  884. scipy/optimize/cython_optimize/c_zeros.pxd +26 -0
  885. scipy/optimize/cython_optimize.pxd +11 -0
  886. scipy/optimize/elementwise.py +38 -0
  887. scipy/optimize/lbfgsb.py +23 -0
  888. scipy/optimize/linesearch.py +18 -0
  889. scipy/optimize/minpack.py +27 -0
  890. scipy/optimize/minpack2.py +17 -0
  891. scipy/optimize/moduleTNC.py +19 -0
  892. scipy/optimize/nonlin.py +29 -0
  893. scipy/optimize/optimize.py +40 -0
  894. scipy/optimize/slsqp.py +22 -0
  895. scipy/optimize/tests/__init__.py +0 -0
  896. scipy/optimize/tests/_cython_examples/extending.pyx +43 -0
  897. scipy/optimize/tests/_cython_examples/meson.build +32 -0
  898. scipy/optimize/tests/test__basinhopping.py +535 -0
  899. scipy/optimize/tests/test__differential_evolution.py +1703 -0
  900. scipy/optimize/tests/test__dual_annealing.py +416 -0
  901. scipy/optimize/tests/test__linprog_clean_inputs.py +312 -0
  902. scipy/optimize/tests/test__numdiff.py +885 -0
  903. scipy/optimize/tests/test__remove_redundancy.py +228 -0
  904. scipy/optimize/tests/test__root.py +124 -0
  905. scipy/optimize/tests/test__shgo.py +1164 -0
  906. scipy/optimize/tests/test__spectral.py +226 -0
  907. scipy/optimize/tests/test_bracket.py +896 -0
  908. scipy/optimize/tests/test_chandrupatla.py +982 -0
  909. scipy/optimize/tests/test_cobyla.py +195 -0
  910. scipy/optimize/tests/test_cobyqa.py +252 -0
  911. scipy/optimize/tests/test_constraint_conversion.py +286 -0
  912. scipy/optimize/tests/test_constraints.py +255 -0
  913. scipy/optimize/tests/test_cython_optimize.py +92 -0
  914. scipy/optimize/tests/test_differentiable_functions.py +1025 -0
  915. scipy/optimize/tests/test_direct.py +321 -0
  916. scipy/optimize/tests/test_extending.py +28 -0
  917. scipy/optimize/tests/test_hessian_update_strategy.py +300 -0
  918. scipy/optimize/tests/test_isotonic_regression.py +167 -0
  919. scipy/optimize/tests/test_lbfgsb_hessinv.py +65 -0
  920. scipy/optimize/tests/test_lbfgsb_setulb.py +122 -0
  921. scipy/optimize/tests/test_least_squares.py +986 -0
  922. scipy/optimize/tests/test_linear_assignment.py +116 -0
  923. scipy/optimize/tests/test_linesearch.py +328 -0
  924. scipy/optimize/tests/test_linprog.py +2577 -0
  925. scipy/optimize/tests/test_lsq_common.py +297 -0
  926. scipy/optimize/tests/test_lsq_linear.py +287 -0
  927. scipy/optimize/tests/test_milp.py +459 -0
  928. scipy/optimize/tests/test_minimize_constrained.py +845 -0
  929. scipy/optimize/tests/test_minpack.py +1194 -0
  930. scipy/optimize/tests/test_nnls.py +469 -0
  931. scipy/optimize/tests/test_nonlin.py +572 -0
  932. scipy/optimize/tests/test_optimize.py +3344 -0
  933. scipy/optimize/tests/test_quadratic_assignment.py +455 -0
  934. scipy/optimize/tests/test_regression.py +40 -0
  935. scipy/optimize/tests/test_slsqp.py +645 -0
  936. scipy/optimize/tests/test_tnc.py +345 -0
  937. scipy/optimize/tests/test_trustregion.py +110 -0
  938. scipy/optimize/tests/test_trustregion_exact.py +351 -0
  939. scipy/optimize/tests/test_trustregion_krylov.py +170 -0
  940. scipy/optimize/tests/test_zeros.py +998 -0
  941. scipy/optimize/tnc.py +22 -0
  942. scipy/optimize/zeros.py +26 -0
  943. scipy/signal/__init__.py +316 -0
  944. scipy/signal/_arraytools.py +264 -0
  945. scipy/signal/_czt.py +575 -0
  946. scipy/signal/_delegators.py +568 -0
  947. scipy/signal/_filter_design.py +5893 -0
  948. scipy/signal/_fir_filter_design.py +1458 -0
  949. scipy/signal/_lti_conversion.py +534 -0
  950. scipy/signal/_ltisys.py +3546 -0
  951. scipy/signal/_max_len_seq.py +139 -0
  952. scipy/signal/_max_len_seq_inner.cp314-win_arm64.lib +0 -0
  953. scipy/signal/_max_len_seq_inner.cp314-win_arm64.pyd +0 -0
  954. scipy/signal/_peak_finding.py +1310 -0
  955. scipy/signal/_peak_finding_utils.cp314-win_arm64.lib +0 -0
  956. scipy/signal/_peak_finding_utils.cp314-win_arm64.pyd +0 -0
  957. scipy/signal/_polyutils.py +172 -0
  958. scipy/signal/_savitzky_golay.py +357 -0
  959. scipy/signal/_short_time_fft.py +2228 -0
  960. scipy/signal/_signal_api.py +30 -0
  961. scipy/signal/_signaltools.py +5309 -0
  962. scipy/signal/_sigtools.cp314-win_arm64.lib +0 -0
  963. scipy/signal/_sigtools.cp314-win_arm64.pyd +0 -0
  964. scipy/signal/_sosfilt.cp314-win_arm64.lib +0 -0
  965. scipy/signal/_sosfilt.cp314-win_arm64.pyd +0 -0
  966. scipy/signal/_spectral_py.py +2471 -0
  967. scipy/signal/_spline.cp314-win_arm64.lib +0 -0
  968. scipy/signal/_spline.cp314-win_arm64.pyd +0 -0
  969. scipy/signal/_spline.pyi +34 -0
  970. scipy/signal/_spline_filters.py +848 -0
  971. scipy/signal/_support_alternative_backends.py +73 -0
  972. scipy/signal/_upfirdn.py +219 -0
  973. scipy/signal/_upfirdn_apply.cp314-win_arm64.lib +0 -0
  974. scipy/signal/_upfirdn_apply.cp314-win_arm64.pyd +0 -0
  975. scipy/signal/_waveforms.py +687 -0
  976. scipy/signal/_wavelets.py +29 -0
  977. scipy/signal/bsplines.py +21 -0
  978. scipy/signal/filter_design.py +28 -0
  979. scipy/signal/fir_filter_design.py +21 -0
  980. scipy/signal/lti_conversion.py +20 -0
  981. scipy/signal/ltisys.py +25 -0
  982. scipy/signal/signaltools.py +27 -0
  983. scipy/signal/spectral.py +21 -0
  984. scipy/signal/spline.py +18 -0
  985. scipy/signal/tests/__init__.py +0 -0
  986. scipy/signal/tests/_scipy_spectral_test_shim.py +311 -0
  987. scipy/signal/tests/mpsig.py +122 -0
  988. scipy/signal/tests/test_array_tools.py +111 -0
  989. scipy/signal/tests/test_bsplines.py +365 -0
  990. scipy/signal/tests/test_cont2discrete.py +424 -0
  991. scipy/signal/tests/test_czt.py +221 -0
  992. scipy/signal/tests/test_dltisys.py +599 -0
  993. scipy/signal/tests/test_filter_design.py +4744 -0
  994. scipy/signal/tests/test_fir_filter_design.py +851 -0
  995. scipy/signal/tests/test_ltisys.py +1225 -0
  996. scipy/signal/tests/test_max_len_seq.py +71 -0
  997. scipy/signal/tests/test_peak_finding.py +915 -0
  998. scipy/signal/tests/test_result_type.py +51 -0
  999. scipy/signal/tests/test_savitzky_golay.py +363 -0
  1000. scipy/signal/tests/test_short_time_fft.py +1107 -0
  1001. scipy/signal/tests/test_signaltools.py +4735 -0
  1002. scipy/signal/tests/test_spectral.py +2141 -0
  1003. scipy/signal/tests/test_splines.py +427 -0
  1004. scipy/signal/tests/test_upfirdn.py +322 -0
  1005. scipy/signal/tests/test_waveforms.py +400 -0
  1006. scipy/signal/tests/test_wavelets.py +59 -0
  1007. scipy/signal/tests/test_windows.py +987 -0
  1008. scipy/signal/waveforms.py +20 -0
  1009. scipy/signal/wavelets.py +17 -0
  1010. scipy/signal/windows/__init__.py +52 -0
  1011. scipy/signal/windows/_windows.py +2513 -0
  1012. scipy/signal/windows/windows.py +23 -0
  1013. scipy/sparse/__init__.py +350 -0
  1014. scipy/sparse/_base.py +1613 -0
  1015. scipy/sparse/_bsr.py +880 -0
  1016. scipy/sparse/_compressed.py +1328 -0
  1017. scipy/sparse/_construct.py +1454 -0
  1018. scipy/sparse/_coo.py +1581 -0
  1019. scipy/sparse/_csc.py +367 -0
  1020. scipy/sparse/_csparsetools.cp314-win_arm64.lib +0 -0
  1021. scipy/sparse/_csparsetools.cp314-win_arm64.pyd +0 -0
  1022. scipy/sparse/_csr.py +558 -0
  1023. scipy/sparse/_data.py +569 -0
  1024. scipy/sparse/_dia.py +677 -0
  1025. scipy/sparse/_dok.py +669 -0
  1026. scipy/sparse/_extract.py +178 -0
  1027. scipy/sparse/_index.py +444 -0
  1028. scipy/sparse/_lil.py +632 -0
  1029. scipy/sparse/_matrix.py +169 -0
  1030. scipy/sparse/_matrix_io.py +167 -0
  1031. scipy/sparse/_sparsetools.cp314-win_arm64.lib +0 -0
  1032. scipy/sparse/_sparsetools.cp314-win_arm64.pyd +0 -0
  1033. scipy/sparse/_spfuncs.py +76 -0
  1034. scipy/sparse/_sputils.py +632 -0
  1035. scipy/sparse/base.py +24 -0
  1036. scipy/sparse/bsr.py +22 -0
  1037. scipy/sparse/compressed.py +20 -0
  1038. scipy/sparse/construct.py +38 -0
  1039. scipy/sparse/coo.py +23 -0
  1040. scipy/sparse/csc.py +22 -0
  1041. scipy/sparse/csgraph/__init__.py +210 -0
  1042. scipy/sparse/csgraph/_flow.cp314-win_arm64.lib +0 -0
  1043. scipy/sparse/csgraph/_flow.cp314-win_arm64.pyd +0 -0
  1044. scipy/sparse/csgraph/_laplacian.py +563 -0
  1045. scipy/sparse/csgraph/_matching.cp314-win_arm64.lib +0 -0
  1046. scipy/sparse/csgraph/_matching.cp314-win_arm64.pyd +0 -0
  1047. scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.lib +0 -0
  1048. scipy/sparse/csgraph/_min_spanning_tree.cp314-win_arm64.pyd +0 -0
  1049. scipy/sparse/csgraph/_reordering.cp314-win_arm64.lib +0 -0
  1050. scipy/sparse/csgraph/_reordering.cp314-win_arm64.pyd +0 -0
  1051. scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.lib +0 -0
  1052. scipy/sparse/csgraph/_shortest_path.cp314-win_arm64.pyd +0 -0
  1053. scipy/sparse/csgraph/_tools.cp314-win_arm64.lib +0 -0
  1054. scipy/sparse/csgraph/_tools.cp314-win_arm64.pyd +0 -0
  1055. scipy/sparse/csgraph/_traversal.cp314-win_arm64.lib +0 -0
  1056. scipy/sparse/csgraph/_traversal.cp314-win_arm64.pyd +0 -0
  1057. scipy/sparse/csgraph/_validation.py +66 -0
  1058. scipy/sparse/csgraph/tests/__init__.py +0 -0
  1059. scipy/sparse/csgraph/tests/test_connected_components.py +119 -0
  1060. scipy/sparse/csgraph/tests/test_conversions.py +61 -0
  1061. scipy/sparse/csgraph/tests/test_flow.py +209 -0
  1062. scipy/sparse/csgraph/tests/test_graph_laplacian.py +368 -0
  1063. scipy/sparse/csgraph/tests/test_matching.py +307 -0
  1064. scipy/sparse/csgraph/tests/test_pydata_sparse.py +197 -0
  1065. scipy/sparse/csgraph/tests/test_reordering.py +70 -0
  1066. scipy/sparse/csgraph/tests/test_shortest_path.py +540 -0
  1067. scipy/sparse/csgraph/tests/test_spanning_tree.py +66 -0
  1068. scipy/sparse/csgraph/tests/test_traversal.py +148 -0
  1069. scipy/sparse/csr.py +22 -0
  1070. scipy/sparse/data.py +18 -0
  1071. scipy/sparse/dia.py +22 -0
  1072. scipy/sparse/dok.py +22 -0
  1073. scipy/sparse/extract.py +23 -0
  1074. scipy/sparse/lil.py +22 -0
  1075. scipy/sparse/linalg/__init__.py +148 -0
  1076. scipy/sparse/linalg/_dsolve/__init__.py +71 -0
  1077. scipy/sparse/linalg/_dsolve/_add_newdocs.py +147 -0
  1078. scipy/sparse/linalg/_dsolve/_superlu.cp314-win_arm64.lib +0 -0
  1079. scipy/sparse/linalg/_dsolve/_superlu.cp314-win_arm64.pyd +0 -0
  1080. scipy/sparse/linalg/_dsolve/linsolve.py +882 -0
  1081. scipy/sparse/linalg/_dsolve/tests/__init__.py +0 -0
  1082. scipy/sparse/linalg/_dsolve/tests/test_linsolve.py +928 -0
  1083. scipy/sparse/linalg/_eigen/__init__.py +22 -0
  1084. scipy/sparse/linalg/_eigen/_svds.py +540 -0
  1085. scipy/sparse/linalg/_eigen/_svds_doc.py +382 -0
  1086. scipy/sparse/linalg/_eigen/arpack/COPYING +45 -0
  1087. scipy/sparse/linalg/_eigen/arpack/__init__.py +20 -0
  1088. scipy/sparse/linalg/_eigen/arpack/_arpack.cp314-win_arm64.lib +0 -0
  1089. scipy/sparse/linalg/_eigen/arpack/_arpack.cp314-win_arm64.pyd +0 -0
  1090. scipy/sparse/linalg/_eigen/arpack/arpack.py +1706 -0
  1091. scipy/sparse/linalg/_eigen/arpack/tests/__init__.py +0 -0
  1092. scipy/sparse/linalg/_eigen/arpack/tests/test_arpack.py +717 -0
  1093. scipy/sparse/linalg/_eigen/lobpcg/__init__.py +16 -0
  1094. scipy/sparse/linalg/_eigen/lobpcg/lobpcg.py +1110 -0
  1095. scipy/sparse/linalg/_eigen/lobpcg/tests/__init__.py +0 -0
  1096. scipy/sparse/linalg/_eigen/lobpcg/tests/test_lobpcg.py +725 -0
  1097. scipy/sparse/linalg/_eigen/tests/__init__.py +0 -0
  1098. scipy/sparse/linalg/_eigen/tests/test_svds.py +886 -0
  1099. scipy/sparse/linalg/_expm_multiply.py +816 -0
  1100. scipy/sparse/linalg/_interface.py +920 -0
  1101. scipy/sparse/linalg/_isolve/__init__.py +20 -0
  1102. scipy/sparse/linalg/_isolve/_gcrotmk.py +503 -0
  1103. scipy/sparse/linalg/_isolve/iterative.py +1051 -0
  1104. scipy/sparse/linalg/_isolve/lgmres.py +230 -0
  1105. scipy/sparse/linalg/_isolve/lsmr.py +486 -0
  1106. scipy/sparse/linalg/_isolve/lsqr.py +589 -0
  1107. scipy/sparse/linalg/_isolve/minres.py +372 -0
  1108. scipy/sparse/linalg/_isolve/tests/__init__.py +0 -0
  1109. scipy/sparse/linalg/_isolve/tests/test_gcrotmk.py +183 -0
  1110. scipy/sparse/linalg/_isolve/tests/test_iterative.py +809 -0
  1111. scipy/sparse/linalg/_isolve/tests/test_lgmres.py +225 -0
  1112. scipy/sparse/linalg/_isolve/tests/test_lsmr.py +185 -0
  1113. scipy/sparse/linalg/_isolve/tests/test_lsqr.py +120 -0
  1114. scipy/sparse/linalg/_isolve/tests/test_minres.py +97 -0
  1115. scipy/sparse/linalg/_isolve/tests/test_utils.py +9 -0
  1116. scipy/sparse/linalg/_isolve/tfqmr.py +179 -0
  1117. scipy/sparse/linalg/_isolve/utils.py +121 -0
  1118. scipy/sparse/linalg/_matfuncs.py +940 -0
  1119. scipy/sparse/linalg/_norm.py +195 -0
  1120. scipy/sparse/linalg/_onenormest.py +467 -0
  1121. scipy/sparse/linalg/_propack/_cpropack.cp314-win_arm64.lib +0 -0
  1122. scipy/sparse/linalg/_propack/_cpropack.cp314-win_arm64.pyd +0 -0
  1123. scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.lib +0 -0
  1124. scipy/sparse/linalg/_propack/_dpropack.cp314-win_arm64.pyd +0 -0
  1125. scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.lib +0 -0
  1126. scipy/sparse/linalg/_propack/_spropack.cp314-win_arm64.pyd +0 -0
  1127. scipy/sparse/linalg/_propack/_zpropack.cp314-win_arm64.lib +0 -0
  1128. scipy/sparse/linalg/_propack/_zpropack.cp314-win_arm64.pyd +0 -0
  1129. scipy/sparse/linalg/_special_sparse_arrays.py +949 -0
  1130. scipy/sparse/linalg/_svdp.py +309 -0
  1131. scipy/sparse/linalg/dsolve.py +22 -0
  1132. scipy/sparse/linalg/eigen.py +21 -0
  1133. scipy/sparse/linalg/interface.py +20 -0
  1134. scipy/sparse/linalg/isolve.py +22 -0
  1135. scipy/sparse/linalg/matfuncs.py +18 -0
  1136. scipy/sparse/linalg/tests/__init__.py +0 -0
  1137. scipy/sparse/linalg/tests/propack_test_data.npz +0 -0
  1138. scipy/sparse/linalg/tests/test_expm_multiply.py +367 -0
  1139. scipy/sparse/linalg/tests/test_interface.py +561 -0
  1140. scipy/sparse/linalg/tests/test_matfuncs.py +592 -0
  1141. scipy/sparse/linalg/tests/test_norm.py +154 -0
  1142. scipy/sparse/linalg/tests/test_onenormest.py +252 -0
  1143. scipy/sparse/linalg/tests/test_propack.py +165 -0
  1144. scipy/sparse/linalg/tests/test_pydata_sparse.py +272 -0
  1145. scipy/sparse/linalg/tests/test_special_sparse_arrays.py +337 -0
  1146. scipy/sparse/sparsetools.py +17 -0
  1147. scipy/sparse/spfuncs.py +17 -0
  1148. scipy/sparse/sputils.py +17 -0
  1149. scipy/sparse/tests/__init__.py +0 -0
  1150. scipy/sparse/tests/data/csc_py2.npz +0 -0
  1151. scipy/sparse/tests/data/csc_py3.npz +0 -0
  1152. scipy/sparse/tests/test_arithmetic1d.py +341 -0
  1153. scipy/sparse/tests/test_array_api.py +561 -0
  1154. scipy/sparse/tests/test_base.py +5870 -0
  1155. scipy/sparse/tests/test_common1d.py +447 -0
  1156. scipy/sparse/tests/test_construct.py +872 -0
  1157. scipy/sparse/tests/test_coo.py +1119 -0
  1158. scipy/sparse/tests/test_csc.py +98 -0
  1159. scipy/sparse/tests/test_csr.py +214 -0
  1160. scipy/sparse/tests/test_dok.py +209 -0
  1161. scipy/sparse/tests/test_extract.py +51 -0
  1162. scipy/sparse/tests/test_indexing1d.py +603 -0
  1163. scipy/sparse/tests/test_matrix_io.py +109 -0
  1164. scipy/sparse/tests/test_minmax1d.py +128 -0
  1165. scipy/sparse/tests/test_sparsetools.py +344 -0
  1166. scipy/sparse/tests/test_spfuncs.py +97 -0
  1167. scipy/sparse/tests/test_sputils.py +424 -0
  1168. scipy/spatial/__init__.py +129 -0
  1169. scipy/spatial/_ckdtree.cp314-win_arm64.lib +0 -0
  1170. scipy/spatial/_ckdtree.cp314-win_arm64.pyd +0 -0
  1171. scipy/spatial/_distance_pybind.cp314-win_arm64.lib +0 -0
  1172. scipy/spatial/_distance_pybind.cp314-win_arm64.pyd +0 -0
  1173. scipy/spatial/_distance_wrap.cp314-win_arm64.lib +0 -0
  1174. scipy/spatial/_distance_wrap.cp314-win_arm64.pyd +0 -0
  1175. scipy/spatial/_geometric_slerp.py +238 -0
  1176. scipy/spatial/_hausdorff.cp314-win_arm64.lib +0 -0
  1177. scipy/spatial/_hausdorff.cp314-win_arm64.pyd +0 -0
  1178. scipy/spatial/_kdtree.py +920 -0
  1179. scipy/spatial/_plotutils.py +274 -0
  1180. scipy/spatial/_procrustes.py +132 -0
  1181. scipy/spatial/_qhull.cp314-win_arm64.lib +0 -0
  1182. scipy/spatial/_qhull.cp314-win_arm64.pyd +0 -0
  1183. scipy/spatial/_qhull.pyi +213 -0
  1184. scipy/spatial/_spherical_voronoi.py +341 -0
  1185. scipy/spatial/_voronoi.cp314-win_arm64.lib +0 -0
  1186. scipy/spatial/_voronoi.cp314-win_arm64.pyd +0 -0
  1187. scipy/spatial/_voronoi.pyi +4 -0
  1188. scipy/spatial/ckdtree.py +18 -0
  1189. scipy/spatial/distance.py +3147 -0
  1190. scipy/spatial/distance.pyi +210 -0
  1191. scipy/spatial/kdtree.py +25 -0
  1192. scipy/spatial/qhull.py +25 -0
  1193. scipy/spatial/qhull_src/COPYING_QHULL.txt +39 -0
  1194. scipy/spatial/tests/__init__.py +0 -0
  1195. scipy/spatial/tests/data/cdist-X1.txt +10 -0
  1196. scipy/spatial/tests/data/cdist-X2.txt +20 -0
  1197. scipy/spatial/tests/data/degenerate_pointset.npz +0 -0
  1198. scipy/spatial/tests/data/iris.txt +150 -0
  1199. scipy/spatial/tests/data/pdist-boolean-inp.txt +20 -0
  1200. scipy/spatial/tests/data/pdist-chebyshev-ml-iris.txt +1 -0
  1201. scipy/spatial/tests/data/pdist-chebyshev-ml.txt +1 -0
  1202. scipy/spatial/tests/data/pdist-cityblock-ml-iris.txt +1 -0
  1203. scipy/spatial/tests/data/pdist-cityblock-ml.txt +1 -0
  1204. scipy/spatial/tests/data/pdist-correlation-ml-iris.txt +1 -0
  1205. scipy/spatial/tests/data/pdist-correlation-ml.txt +1 -0
  1206. scipy/spatial/tests/data/pdist-cosine-ml-iris.txt +1 -0
  1207. scipy/spatial/tests/data/pdist-cosine-ml.txt +1 -0
  1208. scipy/spatial/tests/data/pdist-double-inp.txt +20 -0
  1209. scipy/spatial/tests/data/pdist-euclidean-ml-iris.txt +1 -0
  1210. scipy/spatial/tests/data/pdist-euclidean-ml.txt +1 -0
  1211. scipy/spatial/tests/data/pdist-hamming-ml.txt +1 -0
  1212. scipy/spatial/tests/data/pdist-jaccard-ml.txt +1 -0
  1213. scipy/spatial/tests/data/pdist-jensenshannon-ml-iris.txt +1 -0
  1214. scipy/spatial/tests/data/pdist-jensenshannon-ml.txt +1 -0
  1215. scipy/spatial/tests/data/pdist-minkowski-3.2-ml-iris.txt +1 -0
  1216. scipy/spatial/tests/data/pdist-minkowski-3.2-ml.txt +1 -0
  1217. scipy/spatial/tests/data/pdist-minkowski-5.8-ml-iris.txt +1 -0
  1218. scipy/spatial/tests/data/pdist-seuclidean-ml-iris.txt +1 -0
  1219. scipy/spatial/tests/data/pdist-seuclidean-ml.txt +1 -0
  1220. scipy/spatial/tests/data/pdist-spearman-ml.txt +1 -0
  1221. scipy/spatial/tests/data/random-bool-data.txt +100 -0
  1222. scipy/spatial/tests/data/random-double-data.txt +100 -0
  1223. scipy/spatial/tests/data/random-int-data.txt +100 -0
  1224. scipy/spatial/tests/data/random-uint-data.txt +100 -0
  1225. scipy/spatial/tests/data/selfdual-4d-polytope.txt +27 -0
  1226. scipy/spatial/tests/test__plotutils.py +91 -0
  1227. scipy/spatial/tests/test__procrustes.py +116 -0
  1228. scipy/spatial/tests/test_distance.py +2389 -0
  1229. scipy/spatial/tests/test_hausdorff.py +199 -0
  1230. scipy/spatial/tests/test_kdtree.py +1536 -0
  1231. scipy/spatial/tests/test_qhull.py +1313 -0
  1232. scipy/spatial/tests/test_slerp.py +417 -0
  1233. scipy/spatial/tests/test_spherical_voronoi.py +358 -0
  1234. scipy/spatial/transform/__init__.py +31 -0
  1235. scipy/spatial/transform/_rigid_transform.cp314-win_arm64.lib +0 -0
  1236. scipy/spatial/transform/_rigid_transform.cp314-win_arm64.pyd +0 -0
  1237. scipy/spatial/transform/_rotation.cp314-win_arm64.lib +0 -0
  1238. scipy/spatial/transform/_rotation.cp314-win_arm64.pyd +0 -0
  1239. scipy/spatial/transform/_rotation_groups.py +140 -0
  1240. scipy/spatial/transform/_rotation_spline.py +460 -0
  1241. scipy/spatial/transform/rotation.py +21 -0
  1242. scipy/spatial/transform/tests/__init__.py +0 -0
  1243. scipy/spatial/transform/tests/test_rigid_transform.py +1221 -0
  1244. scipy/spatial/transform/tests/test_rotation.py +2569 -0
  1245. scipy/spatial/transform/tests/test_rotation_groups.py +169 -0
  1246. scipy/spatial/transform/tests/test_rotation_spline.py +183 -0
  1247. scipy/special/__init__.pxd +1 -0
  1248. scipy/special/__init__.py +841 -0
  1249. scipy/special/_add_newdocs.py +9961 -0
  1250. scipy/special/_basic.py +3576 -0
  1251. scipy/special/_comb.cp314-win_arm64.lib +0 -0
  1252. scipy/special/_comb.cp314-win_arm64.pyd +0 -0
  1253. scipy/special/_ellip_harm.py +214 -0
  1254. scipy/special/_ellip_harm_2.cp314-win_arm64.lib +0 -0
  1255. scipy/special/_ellip_harm_2.cp314-win_arm64.pyd +0 -0
  1256. scipy/special/_gufuncs.cp314-win_arm64.lib +0 -0
  1257. scipy/special/_gufuncs.cp314-win_arm64.pyd +0 -0
  1258. scipy/special/_input_validation.py +17 -0
  1259. scipy/special/_lambertw.py +149 -0
  1260. scipy/special/_logsumexp.py +426 -0
  1261. scipy/special/_mptestutils.py +453 -0
  1262. scipy/special/_multiufuncs.py +610 -0
  1263. scipy/special/_orthogonal.py +2592 -0
  1264. scipy/special/_orthogonal.pyi +330 -0
  1265. scipy/special/_precompute/__init__.py +0 -0
  1266. scipy/special/_precompute/cosine_cdf.py +17 -0
  1267. scipy/special/_precompute/expn_asy.py +54 -0
  1268. scipy/special/_precompute/gammainc_asy.py +116 -0
  1269. scipy/special/_precompute/gammainc_data.py +124 -0
  1270. scipy/special/_precompute/hyp2f1_data.py +484 -0
  1271. scipy/special/_precompute/lambertw.py +68 -0
  1272. scipy/special/_precompute/loggamma.py +43 -0
  1273. scipy/special/_precompute/struve_convergence.py +131 -0
  1274. scipy/special/_precompute/utils.py +38 -0
  1275. scipy/special/_precompute/wright_bessel.py +342 -0
  1276. scipy/special/_precompute/wright_bessel_data.py +152 -0
  1277. scipy/special/_precompute/wrightomega.py +41 -0
  1278. scipy/special/_precompute/zetac.py +27 -0
  1279. scipy/special/_sf_error.py +15 -0
  1280. scipy/special/_specfun.cp314-win_arm64.lib +0 -0
  1281. scipy/special/_specfun.cp314-win_arm64.pyd +0 -0
  1282. scipy/special/_special_ufuncs.cp314-win_arm64.lib +0 -0
  1283. scipy/special/_special_ufuncs.cp314-win_arm64.pyd +0 -0
  1284. scipy/special/_spfun_stats.py +106 -0
  1285. scipy/special/_spherical_bessel.py +397 -0
  1286. scipy/special/_support_alternative_backends.py +295 -0
  1287. scipy/special/_test_internal.cp314-win_arm64.lib +0 -0
  1288. scipy/special/_test_internal.cp314-win_arm64.pyd +0 -0
  1289. scipy/special/_test_internal.pyi +9 -0
  1290. scipy/special/_testutils.py +321 -0
  1291. scipy/special/_ufuncs.cp314-win_arm64.lib +0 -0
  1292. scipy/special/_ufuncs.cp314-win_arm64.pyd +0 -0
  1293. scipy/special/_ufuncs.pyi +522 -0
  1294. scipy/special/_ufuncs.pyx +13173 -0
  1295. scipy/special/_ufuncs_cxx.cp314-win_arm64.lib +0 -0
  1296. scipy/special/_ufuncs_cxx.cp314-win_arm64.pyd +0 -0
  1297. scipy/special/_ufuncs_cxx.pxd +142 -0
  1298. scipy/special/_ufuncs_cxx.pyx +427 -0
  1299. scipy/special/_ufuncs_cxx_defs.h +147 -0
  1300. scipy/special/_ufuncs_defs.h +57 -0
  1301. scipy/special/add_newdocs.py +15 -0
  1302. scipy/special/basic.py +87 -0
  1303. scipy/special/cython_special.cp314-win_arm64.lib +0 -0
  1304. scipy/special/cython_special.cp314-win_arm64.pyd +0 -0
  1305. scipy/special/cython_special.pxd +259 -0
  1306. scipy/special/cython_special.pyi +3 -0
  1307. scipy/special/orthogonal.py +45 -0
  1308. scipy/special/sf_error.py +20 -0
  1309. scipy/special/specfun.py +24 -0
  1310. scipy/special/spfun_stats.py +17 -0
  1311. scipy/special/tests/__init__.py +0 -0
  1312. scipy/special/tests/_cython_examples/extending.pyx +12 -0
  1313. scipy/special/tests/_cython_examples/meson.build +34 -0
  1314. scipy/special/tests/data/__init__.py +0 -0
  1315. scipy/special/tests/data/boost.npz +0 -0
  1316. scipy/special/tests/data/gsl.npz +0 -0
  1317. scipy/special/tests/data/local.npz +0 -0
  1318. scipy/special/tests/test_basic.py +4815 -0
  1319. scipy/special/tests/test_bdtr.py +112 -0
  1320. scipy/special/tests/test_boost_ufuncs.py +64 -0
  1321. scipy/special/tests/test_boxcox.py +125 -0
  1322. scipy/special/tests/test_cdflib.py +712 -0
  1323. scipy/special/tests/test_cdft_asymptotic.py +49 -0
  1324. scipy/special/tests/test_cephes_intp_cast.py +29 -0
  1325. scipy/special/tests/test_cosine_distr.py +83 -0
  1326. scipy/special/tests/test_cython_special.py +363 -0
  1327. scipy/special/tests/test_data.py +719 -0
  1328. scipy/special/tests/test_dd.py +42 -0
  1329. scipy/special/tests/test_digamma.py +45 -0
  1330. scipy/special/tests/test_ellip_harm.py +278 -0
  1331. scipy/special/tests/test_erfinv.py +89 -0
  1332. scipy/special/tests/test_exponential_integrals.py +118 -0
  1333. scipy/special/tests/test_extending.py +28 -0
  1334. scipy/special/tests/test_faddeeva.py +85 -0
  1335. scipy/special/tests/test_gamma.py +12 -0
  1336. scipy/special/tests/test_gammainc.py +152 -0
  1337. scipy/special/tests/test_hyp2f1.py +2566 -0
  1338. scipy/special/tests/test_hypergeometric.py +234 -0
  1339. scipy/special/tests/test_iv_ratio.py +249 -0
  1340. scipy/special/tests/test_kolmogorov.py +491 -0
  1341. scipy/special/tests/test_lambertw.py +109 -0
  1342. scipy/special/tests/test_legendre.py +1518 -0
  1343. scipy/special/tests/test_log1mexp.py +85 -0
  1344. scipy/special/tests/test_loggamma.py +70 -0
  1345. scipy/special/tests/test_logit.py +162 -0
  1346. scipy/special/tests/test_logsumexp.py +469 -0
  1347. scipy/special/tests/test_mpmath.py +2293 -0
  1348. scipy/special/tests/test_nan_inputs.py +65 -0
  1349. scipy/special/tests/test_ndtr.py +77 -0
  1350. scipy/special/tests/test_ndtri_exp.py +94 -0
  1351. scipy/special/tests/test_orthogonal.py +821 -0
  1352. scipy/special/tests/test_orthogonal_eval.py +275 -0
  1353. scipy/special/tests/test_owens_t.py +53 -0
  1354. scipy/special/tests/test_pcf.py +24 -0
  1355. scipy/special/tests/test_pdtr.py +48 -0
  1356. scipy/special/tests/test_powm1.py +65 -0
  1357. scipy/special/tests/test_precompute_expn_asy.py +24 -0
  1358. scipy/special/tests/test_precompute_gammainc.py +108 -0
  1359. scipy/special/tests/test_precompute_utils.py +36 -0
  1360. scipy/special/tests/test_round.py +18 -0
  1361. scipy/special/tests/test_sf_error.py +146 -0
  1362. scipy/special/tests/test_sici.py +36 -0
  1363. scipy/special/tests/test_specfun.py +48 -0
  1364. scipy/special/tests/test_spence.py +32 -0
  1365. scipy/special/tests/test_spfun_stats.py +61 -0
  1366. scipy/special/tests/test_sph_harm.py +85 -0
  1367. scipy/special/tests/test_spherical_bessel.py +400 -0
  1368. scipy/special/tests/test_support_alternative_backends.py +248 -0
  1369. scipy/special/tests/test_trig.py +72 -0
  1370. scipy/special/tests/test_ufunc_signatures.py +46 -0
  1371. scipy/special/tests/test_wright_bessel.py +205 -0
  1372. scipy/special/tests/test_wrightomega.py +117 -0
  1373. scipy/special/tests/test_zeta.py +301 -0
  1374. scipy/stats/__init__.py +670 -0
  1375. scipy/stats/_ansari_swilk_statistics.cp314-win_arm64.lib +0 -0
  1376. scipy/stats/_ansari_swilk_statistics.cp314-win_arm64.pyd +0 -0
  1377. scipy/stats/_axis_nan_policy.py +692 -0
  1378. scipy/stats/_biasedurn.cp314-win_arm64.lib +0 -0
  1379. scipy/stats/_biasedurn.cp314-win_arm64.pyd +0 -0
  1380. scipy/stats/_biasedurn.pxd +27 -0
  1381. scipy/stats/_binned_statistic.py +795 -0
  1382. scipy/stats/_binomtest.py +375 -0
  1383. scipy/stats/_bws_test.py +177 -0
  1384. scipy/stats/_censored_data.py +459 -0
  1385. scipy/stats/_common.py +5 -0
  1386. scipy/stats/_constants.py +42 -0
  1387. scipy/stats/_continued_fraction.py +387 -0
  1388. scipy/stats/_continuous_distns.py +12486 -0
  1389. scipy/stats/_correlation.py +210 -0
  1390. scipy/stats/_covariance.py +636 -0
  1391. scipy/stats/_crosstab.py +204 -0
  1392. scipy/stats/_discrete_distns.py +2098 -0
  1393. scipy/stats/_distn_infrastructure.py +4201 -0
  1394. scipy/stats/_distr_params.py +299 -0
  1395. scipy/stats/_distribution_infrastructure.py +5750 -0
  1396. scipy/stats/_entropy.py +428 -0
  1397. scipy/stats/_finite_differences.py +145 -0
  1398. scipy/stats/_fit.py +1351 -0
  1399. scipy/stats/_hypotests.py +2060 -0
  1400. scipy/stats/_kde.py +732 -0
  1401. scipy/stats/_ksstats.py +600 -0
  1402. scipy/stats/_levy_stable/__init__.py +1231 -0
  1403. scipy/stats/_levy_stable/levyst.cp314-win_arm64.lib +0 -0
  1404. scipy/stats/_levy_stable/levyst.cp314-win_arm64.pyd +0 -0
  1405. scipy/stats/_mannwhitneyu.py +492 -0
  1406. scipy/stats/_mgc.py +550 -0
  1407. scipy/stats/_morestats.py +4626 -0
  1408. scipy/stats/_mstats_basic.py +3658 -0
  1409. scipy/stats/_mstats_extras.py +521 -0
  1410. scipy/stats/_multicomp.py +449 -0
  1411. scipy/stats/_multivariate.py +7281 -0
  1412. scipy/stats/_new_distributions.py +452 -0
  1413. scipy/stats/_odds_ratio.py +466 -0
  1414. scipy/stats/_page_trend_test.py +486 -0
  1415. scipy/stats/_probability_distribution.py +1964 -0
  1416. scipy/stats/_qmc.py +2956 -0
  1417. scipy/stats/_qmc_cy.cp314-win_arm64.lib +0 -0
  1418. scipy/stats/_qmc_cy.cp314-win_arm64.pyd +0 -0
  1419. scipy/stats/_qmc_cy.pyi +54 -0
  1420. scipy/stats/_qmvnt.py +454 -0
  1421. scipy/stats/_qmvnt_cy.cp314-win_arm64.lib +0 -0
  1422. scipy/stats/_qmvnt_cy.cp314-win_arm64.pyd +0 -0
  1423. scipy/stats/_quantile.py +335 -0
  1424. scipy/stats/_rcont/__init__.py +4 -0
  1425. scipy/stats/_rcont/rcont.cp314-win_arm64.lib +0 -0
  1426. scipy/stats/_rcont/rcont.cp314-win_arm64.pyd +0 -0
  1427. scipy/stats/_relative_risk.py +263 -0
  1428. scipy/stats/_resampling.py +2352 -0
  1429. scipy/stats/_result_classes.py +40 -0
  1430. scipy/stats/_sampling.py +1314 -0
  1431. scipy/stats/_sensitivity_analysis.py +713 -0
  1432. scipy/stats/_sobol.cp314-win_arm64.lib +0 -0
  1433. scipy/stats/_sobol.cp314-win_arm64.pyd +0 -0
  1434. scipy/stats/_sobol.pyi +54 -0
  1435. scipy/stats/_sobol_direction_numbers.npz +0 -0
  1436. scipy/stats/_stats.cp314-win_arm64.lib +0 -0
  1437. scipy/stats/_stats.cp314-win_arm64.pyd +0 -0
  1438. scipy/stats/_stats.pxd +10 -0
  1439. scipy/stats/_stats_mstats_common.py +322 -0
  1440. scipy/stats/_stats_py.py +11089 -0
  1441. scipy/stats/_stats_pythran.cp314-win_arm64.lib +0 -0
  1442. scipy/stats/_stats_pythran.cp314-win_arm64.pyd +0 -0
  1443. scipy/stats/_survival.py +683 -0
  1444. scipy/stats/_tukeylambda_stats.py +199 -0
  1445. scipy/stats/_unuran/__init__.py +0 -0
  1446. scipy/stats/_unuran/unuran_wrapper.cp314-win_arm64.lib +0 -0
  1447. scipy/stats/_unuran/unuran_wrapper.cp314-win_arm64.pyd +0 -0
  1448. scipy/stats/_unuran/unuran_wrapper.pyi +179 -0
  1449. scipy/stats/_variation.py +126 -0
  1450. scipy/stats/_warnings_errors.py +38 -0
  1451. scipy/stats/_wilcoxon.py +265 -0
  1452. scipy/stats/biasedurn.py +16 -0
  1453. scipy/stats/contingency.py +521 -0
  1454. scipy/stats/distributions.py +24 -0
  1455. scipy/stats/kde.py +18 -0
  1456. scipy/stats/morestats.py +27 -0
  1457. scipy/stats/mstats.py +140 -0
  1458. scipy/stats/mstats_basic.py +42 -0
  1459. scipy/stats/mstats_extras.py +25 -0
  1460. scipy/stats/mvn.py +17 -0
  1461. scipy/stats/qmc.py +236 -0
  1462. scipy/stats/sampling.py +73 -0
  1463. scipy/stats/stats.py +41 -0
  1464. scipy/stats/tests/__init__.py +0 -0
  1465. scipy/stats/tests/common_tests.py +356 -0
  1466. scipy/stats/tests/data/_mvt.py +171 -0
  1467. scipy/stats/tests/data/fisher_exact_results_from_r.py +607 -0
  1468. scipy/stats/tests/data/jf_skew_t_gamlss_pdf_data.npy +0 -0
  1469. scipy/stats/tests/data/levy_stable/stable-Z1-cdf-sample-data.npy +0 -0
  1470. scipy/stats/tests/data/levy_stable/stable-Z1-pdf-sample-data.npy +0 -0
  1471. scipy/stats/tests/data/levy_stable/stable-loc-scale-sample-data.npy +0 -0
  1472. scipy/stats/tests/data/nist_anova/AtmWtAg.dat +108 -0
  1473. scipy/stats/tests/data/nist_anova/SiRstv.dat +85 -0
  1474. scipy/stats/tests/data/nist_anova/SmLs01.dat +249 -0
  1475. scipy/stats/tests/data/nist_anova/SmLs02.dat +1869 -0
  1476. scipy/stats/tests/data/nist_anova/SmLs03.dat +18069 -0
  1477. scipy/stats/tests/data/nist_anova/SmLs04.dat +249 -0
  1478. scipy/stats/tests/data/nist_anova/SmLs05.dat +1869 -0
  1479. scipy/stats/tests/data/nist_anova/SmLs06.dat +18069 -0
  1480. scipy/stats/tests/data/nist_anova/SmLs07.dat +249 -0
  1481. scipy/stats/tests/data/nist_anova/SmLs08.dat +1869 -0
  1482. scipy/stats/tests/data/nist_anova/SmLs09.dat +18069 -0
  1483. scipy/stats/tests/data/nist_linregress/Norris.dat +97 -0
  1484. scipy/stats/tests/data/rel_breitwigner_pdf_sample_data_ROOT.npy +0 -0
  1485. scipy/stats/tests/data/studentized_range_mpmath_ref.json +1499 -0
  1486. scipy/stats/tests/test_axis_nan_policy.py +1388 -0
  1487. scipy/stats/tests/test_binned_statistic.py +568 -0
  1488. scipy/stats/tests/test_censored_data.py +152 -0
  1489. scipy/stats/tests/test_contingency.py +294 -0
  1490. scipy/stats/tests/test_continued_fraction.py +173 -0
  1491. scipy/stats/tests/test_continuous.py +2198 -0
  1492. scipy/stats/tests/test_continuous_basic.py +1053 -0
  1493. scipy/stats/tests/test_continuous_fit_censored.py +683 -0
  1494. scipy/stats/tests/test_correlation.py +80 -0
  1495. scipy/stats/tests/test_crosstab.py +115 -0
  1496. scipy/stats/tests/test_discrete_basic.py +580 -0
  1497. scipy/stats/tests/test_discrete_distns.py +700 -0
  1498. scipy/stats/tests/test_distributions.py +10413 -0
  1499. scipy/stats/tests/test_entropy.py +322 -0
  1500. scipy/stats/tests/test_fast_gen_inversion.py +435 -0
  1501. scipy/stats/tests/test_fit.py +1090 -0
  1502. scipy/stats/tests/test_hypotests.py +1991 -0
  1503. scipy/stats/tests/test_kdeoth.py +676 -0
  1504. scipy/stats/tests/test_marray.py +289 -0
  1505. scipy/stats/tests/test_mgc.py +217 -0
  1506. scipy/stats/tests/test_morestats.py +3259 -0
  1507. scipy/stats/tests/test_mstats_basic.py +2071 -0
  1508. scipy/stats/tests/test_mstats_extras.py +172 -0
  1509. scipy/stats/tests/test_multicomp.py +405 -0
  1510. scipy/stats/tests/test_multivariate.py +4381 -0
  1511. scipy/stats/tests/test_odds_ratio.py +148 -0
  1512. scipy/stats/tests/test_qmc.py +1492 -0
  1513. scipy/stats/tests/test_quantile.py +199 -0
  1514. scipy/stats/tests/test_rank.py +345 -0
  1515. scipy/stats/tests/test_relative_risk.py +95 -0
  1516. scipy/stats/tests/test_resampling.py +2000 -0
  1517. scipy/stats/tests/test_sampling.py +1450 -0
  1518. scipy/stats/tests/test_sensitivity_analysis.py +310 -0
  1519. scipy/stats/tests/test_stats.py +9707 -0
  1520. scipy/stats/tests/test_survival.py +466 -0
  1521. scipy/stats/tests/test_tukeylambda_stats.py +85 -0
  1522. scipy/stats/tests/test_variation.py +216 -0
  1523. scipy/version.py +12 -0
  1524. scipy-1.16.2.dist-info/DELVEWHEEL +2 -0
  1525. scipy-1.16.2.dist-info/LICENSE.txt +912 -0
  1526. scipy-1.16.2.dist-info/METADATA +1061 -0
  1527. scipy-1.16.2.dist-info/RECORD +1530 -0
  1528. scipy-1.16.2.dist-info/WHEEL +4 -0
  1529. scipy.libs/msvcp140-5f1c5dd31916990d94181e07bc3afb32.dll +0 -0
  1530. scipy.libs/scipy_openblas-f3ac85b1f412f7e86514c923dc4058d1.dll +0 -0
@@ -0,0 +1,2634 @@
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
+ import warnings
32
+ import operator
33
+
34
+ import numpy as np
35
+ from . import _ni_support
36
+ from . import _nd_image
37
+ from . import _filters
38
+
39
+ __all__ = ['iterate_structure', 'generate_binary_structure', 'binary_erosion',
40
+ 'binary_dilation', 'binary_opening', 'binary_closing',
41
+ 'binary_hit_or_miss', 'binary_propagation', 'binary_fill_holes',
42
+ 'grey_erosion', 'grey_dilation', 'grey_opening', 'grey_closing',
43
+ 'morphological_gradient', 'morphological_laplace', 'white_tophat',
44
+ 'black_tophat', 'distance_transform_bf', 'distance_transform_cdt',
45
+ 'distance_transform_edt']
46
+
47
+
48
+ def _center_is_true(structure, origin):
49
+ structure = np.asarray(structure)
50
+ coor = tuple([oo + ss // 2 for ss, oo in zip(structure.shape,
51
+ origin)])
52
+ return bool(structure[coor])
53
+
54
+
55
+ def iterate_structure(structure, iterations, origin=None):
56
+ """
57
+ Iterate a structure by dilating it with itself.
58
+
59
+ Parameters
60
+ ----------
61
+ structure : array_like
62
+ Structuring element (an array of bools, for example), to be dilated with
63
+ itself.
64
+ iterations : int
65
+ number of dilations performed on the structure with itself
66
+ origin : optional
67
+ If origin is None, only the iterated structure is returned. If
68
+ not, a tuple of the iterated structure and the modified origin is
69
+ returned.
70
+
71
+ Returns
72
+ -------
73
+ iterate_structure : ndarray of bools
74
+ A new structuring element obtained by dilating `structure`
75
+ (`iterations` - 1) times with itself.
76
+
77
+ See Also
78
+ --------
79
+ generate_binary_structure
80
+
81
+ Examples
82
+ --------
83
+ >>> from scipy import ndimage
84
+ >>> struct = ndimage.generate_binary_structure(2, 1)
85
+ >>> struct.astype(int)
86
+ array([[0, 1, 0],
87
+ [1, 1, 1],
88
+ [0, 1, 0]])
89
+ >>> ndimage.iterate_structure(struct, 2).astype(int)
90
+ array([[0, 0, 1, 0, 0],
91
+ [0, 1, 1, 1, 0],
92
+ [1, 1, 1, 1, 1],
93
+ [0, 1, 1, 1, 0],
94
+ [0, 0, 1, 0, 0]])
95
+ >>> ndimage.iterate_structure(struct, 3).astype(int)
96
+ array([[0, 0, 0, 1, 0, 0, 0],
97
+ [0, 0, 1, 1, 1, 0, 0],
98
+ [0, 1, 1, 1, 1, 1, 0],
99
+ [1, 1, 1, 1, 1, 1, 1],
100
+ [0, 1, 1, 1, 1, 1, 0],
101
+ [0, 0, 1, 1, 1, 0, 0],
102
+ [0, 0, 0, 1, 0, 0, 0]])
103
+
104
+ """
105
+ structure = np.asarray(structure)
106
+ if iterations < 2:
107
+ return structure.copy()
108
+ ni = iterations - 1
109
+ shape = [ii + ni * (ii - 1) for ii in structure.shape]
110
+ pos = [ni * (structure.shape[ii] // 2) for ii in range(len(shape))]
111
+ slc = tuple(slice(pos[ii], pos[ii] + structure.shape[ii], None)
112
+ for ii in range(len(shape)))
113
+ out = np.zeros(shape, bool)
114
+ out[slc] = structure != 0
115
+ out = binary_dilation(out, structure, iterations=ni)
116
+ if origin is None:
117
+ return out
118
+ else:
119
+ origin = _ni_support._normalize_sequence(origin, structure.ndim)
120
+ origin = [iterations * o for o in origin]
121
+ return out, origin
122
+
123
+
124
+ def generate_binary_structure(rank, connectivity):
125
+ """
126
+ Generate a binary structure for binary morphological operations.
127
+
128
+ Parameters
129
+ ----------
130
+ rank : int
131
+ Number of dimensions of the array to which the structuring element
132
+ will be applied, as returned by `np.ndim`.
133
+ connectivity : int
134
+ `connectivity` determines which elements of the output array belong
135
+ to the structure, i.e., are considered as neighbors of the central
136
+ element. Elements up to a squared distance of `connectivity` from
137
+ the center are considered neighbors. `connectivity` may range from 1
138
+ (no diagonal elements are neighbors) to `rank` (all elements are
139
+ neighbors).
140
+
141
+ Returns
142
+ -------
143
+ output : ndarray of bools
144
+ Structuring element which may be used for binary morphological
145
+ operations, with `rank` dimensions and all dimensions equal to 3.
146
+
147
+ See Also
148
+ --------
149
+ iterate_structure, binary_dilation, binary_erosion
150
+
151
+ Notes
152
+ -----
153
+ `generate_binary_structure` can only create structuring elements with
154
+ dimensions equal to 3, i.e., minimal dimensions. For larger structuring
155
+ elements, that are useful e.g., for eroding large objects, one may either
156
+ use `iterate_structure`, or create directly custom arrays with
157
+ numpy functions such as `numpy.ones`.
158
+
159
+ Examples
160
+ --------
161
+ >>> from scipy import ndimage
162
+ >>> import numpy as np
163
+ >>> struct = ndimage.generate_binary_structure(2, 1)
164
+ >>> struct
165
+ array([[False, True, False],
166
+ [ True, True, True],
167
+ [False, True, False]], dtype=bool)
168
+ >>> a = np.zeros((5,5))
169
+ >>> a[2, 2] = 1
170
+ >>> a
171
+ array([[ 0., 0., 0., 0., 0.],
172
+ [ 0., 0., 0., 0., 0.],
173
+ [ 0., 0., 1., 0., 0.],
174
+ [ 0., 0., 0., 0., 0.],
175
+ [ 0., 0., 0., 0., 0.]])
176
+ >>> b = ndimage.binary_dilation(a, structure=struct).astype(a.dtype)
177
+ >>> b
178
+ array([[ 0., 0., 0., 0., 0.],
179
+ [ 0., 0., 1., 0., 0.],
180
+ [ 0., 1., 1., 1., 0.],
181
+ [ 0., 0., 1., 0., 0.],
182
+ [ 0., 0., 0., 0., 0.]])
183
+ >>> ndimage.binary_dilation(b, structure=struct).astype(a.dtype)
184
+ array([[ 0., 0., 1., 0., 0.],
185
+ [ 0., 1., 1., 1., 0.],
186
+ [ 1., 1., 1., 1., 1.],
187
+ [ 0., 1., 1., 1., 0.],
188
+ [ 0., 0., 1., 0., 0.]])
189
+ >>> struct = ndimage.generate_binary_structure(2, 2)
190
+ >>> struct
191
+ array([[ True, True, True],
192
+ [ True, True, True],
193
+ [ True, True, True]], dtype=bool)
194
+ >>> struct = ndimage.generate_binary_structure(3, 1)
195
+ >>> struct # no diagonal elements
196
+ array([[[False, False, False],
197
+ [False, True, False],
198
+ [False, False, False]],
199
+ [[False, True, False],
200
+ [ True, True, True],
201
+ [False, True, False]],
202
+ [[False, False, False],
203
+ [False, True, False],
204
+ [False, False, False]]], dtype=bool)
205
+
206
+ """
207
+ if connectivity < 1:
208
+ connectivity = 1
209
+ if rank < 1:
210
+ return np.array(True, dtype=bool)
211
+ output = np.fabs(np.indices([3] * rank) - 1)
212
+ output = np.add.reduce(output, 0)
213
+ return output <= connectivity
214
+
215
+
216
+ def _binary_erosion(input, structure, iterations, mask, output,
217
+ border_value, origin, invert, brute_force, axes):
218
+ try:
219
+ iterations = operator.index(iterations)
220
+ except TypeError as e:
221
+ raise TypeError('iterations parameter should be an integer') from e
222
+
223
+ input = np.asarray(input)
224
+ # The Cython code can't cope with broadcasted inputs
225
+ if not input.flags.c_contiguous and not input.flags.f_contiguous:
226
+ input = np.ascontiguousarray(input)
227
+
228
+ ndim = input.ndim
229
+ if np.iscomplexobj(input):
230
+ raise TypeError('Complex type not supported')
231
+ axes = _ni_support._check_axes(axes, input.ndim)
232
+ num_axes = len(axes)
233
+ if structure is None:
234
+ structure = generate_binary_structure(num_axes, 1)
235
+ else:
236
+ structure = np.asarray(structure, dtype=bool)
237
+ if ndim > num_axes:
238
+ structure = _filters._expand_footprint(ndim, axes, structure,
239
+ footprint_name="structure")
240
+
241
+ if structure.ndim != input.ndim:
242
+ raise RuntimeError('structure and input must have same dimensionality')
243
+ if not structure.flags.contiguous:
244
+ structure = structure.copy()
245
+ if structure.size < 1:
246
+ raise RuntimeError('structure must not be empty')
247
+ if mask is not None:
248
+ mask = np.asarray(mask)
249
+ if mask.shape != input.shape:
250
+ raise RuntimeError('mask and input must have equal sizes')
251
+ origin = _ni_support._normalize_sequence(origin, num_axes)
252
+ origin = _filters._expand_origin(ndim, axes, origin)
253
+ cit = _center_is_true(structure, origin)
254
+ if isinstance(output, np.ndarray):
255
+ if np.iscomplexobj(output):
256
+ raise TypeError('Complex output type not supported')
257
+ else:
258
+ output = bool
259
+ output = _ni_support._get_output(output, input)
260
+ temp_needed = np.may_share_memory(input, output)
261
+ if temp_needed:
262
+ # input and output arrays cannot share memory
263
+ temp = output
264
+ output = _ni_support._get_output(output.dtype, input)
265
+ if iterations == 1:
266
+ _nd_image.binary_erosion(input, structure, mask, output,
267
+ border_value, origin, invert, cit, 0)
268
+ elif cit and not brute_force:
269
+ changed, coordinate_list = _nd_image.binary_erosion(
270
+ input, structure, mask, output,
271
+ border_value, origin, invert, cit, 1)
272
+ structure = structure[tuple([slice(None, None, -1)] *
273
+ structure.ndim)]
274
+ for ii in range(len(origin)):
275
+ origin[ii] = -origin[ii]
276
+ if not structure.shape[ii] & 1:
277
+ origin[ii] -= 1
278
+ if mask is not None:
279
+ mask = np.asarray(mask, dtype=np.int8)
280
+ if not structure.flags.contiguous:
281
+ structure = structure.copy()
282
+ _nd_image.binary_erosion2(output, structure, mask, iterations - 1,
283
+ origin, invert, coordinate_list)
284
+ else:
285
+ tmp_in = np.empty_like(input, dtype=bool)
286
+ tmp_out = output
287
+ if iterations >= 1 and not iterations & 1:
288
+ tmp_in, tmp_out = tmp_out, tmp_in
289
+ changed = _nd_image.binary_erosion(
290
+ input, structure, mask, tmp_out,
291
+ border_value, origin, invert, cit, 0)
292
+ ii = 1
293
+ while ii < iterations or (iterations < 1 and changed):
294
+ tmp_in, tmp_out = tmp_out, tmp_in
295
+ changed = _nd_image.binary_erosion(
296
+ tmp_in, structure, mask, tmp_out,
297
+ border_value, origin, invert, cit, 0)
298
+ ii += 1
299
+ if temp_needed:
300
+ temp[...] = output
301
+ output = temp
302
+ return output
303
+
304
+
305
+ def binary_erosion(input, structure=None, iterations=1, mask=None, output=None,
306
+ border_value=0, origin=0, brute_force=False, *, axes=None):
307
+ """
308
+ Multidimensional binary erosion with a given structuring element.
309
+
310
+ Binary erosion is a mathematical morphology operation used for image
311
+ processing.
312
+
313
+ Parameters
314
+ ----------
315
+ input : array_like
316
+ Binary image to be eroded. Non-zero (True) elements form
317
+ the subset to be eroded.
318
+ structure : array_like, optional
319
+ Structuring element used for the erosion. Non-zero elements are
320
+ considered True. If no structuring element is provided, an element
321
+ is generated with a square connectivity equal to one.
322
+ iterations : int, optional
323
+ The erosion is repeated `iterations` times (one, by default).
324
+ If iterations is less than 1, the erosion is repeated until the
325
+ result does not change anymore.
326
+ mask : array_like, optional
327
+ If a mask is given, only those elements with a True value at
328
+ the corresponding mask element are modified at each iteration.
329
+ output : ndarray, optional
330
+ Array of the same shape as input, into which the output is placed.
331
+ By default, a new array is created.
332
+ border_value : int (cast to 0 or 1), optional
333
+ Value at the border in the output array.
334
+ origin : int or tuple of ints, optional
335
+ Placement of the filter, by default 0.
336
+ brute_force : boolean, optional
337
+ Memory condition: if False, only the pixels whose value was changed in
338
+ the last iteration are tracked as candidates to be updated (eroded) in
339
+ the current iteration; if True all pixels are considered as candidates
340
+ for erosion, regardless of what happened in the previous iteration.
341
+ False by default.
342
+ axes : tuple of int or None
343
+ The axes over which to apply the filter. If None, `input` is filtered
344
+ along all axes. If an `origin` tuple is provided, its length must match
345
+ the number of axes.
346
+
347
+ Returns
348
+ -------
349
+ binary_erosion : ndarray of bools
350
+ Erosion of the input by the structuring element.
351
+
352
+ See Also
353
+ --------
354
+ grey_erosion, binary_dilation, binary_closing, binary_opening,
355
+ generate_binary_structure
356
+
357
+ Notes
358
+ -----
359
+ Erosion [1]_ is a mathematical morphology operation [2]_ that uses a
360
+ structuring element for shrinking the shapes in an image. The binary
361
+ erosion of an image by a structuring element is the locus of the points
362
+ where a superimposition of the structuring element centered on the point
363
+ is entirely contained in the set of non-zero elements of the image.
364
+
365
+ References
366
+ ----------
367
+ .. [1] https://en.wikipedia.org/wiki/Erosion_%28morphology%29
368
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
369
+
370
+ Examples
371
+ --------
372
+ >>> from scipy import ndimage
373
+ >>> import numpy as np
374
+ >>> a = np.zeros((7,7), dtype=int)
375
+ >>> a[1:6, 2:5] = 1
376
+ >>> a
377
+ array([[0, 0, 0, 0, 0, 0, 0],
378
+ [0, 0, 1, 1, 1, 0, 0],
379
+ [0, 0, 1, 1, 1, 0, 0],
380
+ [0, 0, 1, 1, 1, 0, 0],
381
+ [0, 0, 1, 1, 1, 0, 0],
382
+ [0, 0, 1, 1, 1, 0, 0],
383
+ [0, 0, 0, 0, 0, 0, 0]])
384
+ >>> ndimage.binary_erosion(a).astype(a.dtype)
385
+ array([[0, 0, 0, 0, 0, 0, 0],
386
+ [0, 0, 0, 0, 0, 0, 0],
387
+ [0, 0, 0, 1, 0, 0, 0],
388
+ [0, 0, 0, 1, 0, 0, 0],
389
+ [0, 0, 0, 1, 0, 0, 0],
390
+ [0, 0, 0, 0, 0, 0, 0],
391
+ [0, 0, 0, 0, 0, 0, 0]])
392
+ >>> #Erosion removes objects smaller than the structure
393
+ >>> ndimage.binary_erosion(a, structure=np.ones((5,5))).astype(a.dtype)
394
+ array([[0, 0, 0, 0, 0, 0, 0],
395
+ [0, 0, 0, 0, 0, 0, 0],
396
+ [0, 0, 0, 0, 0, 0, 0],
397
+ [0, 0, 0, 0, 0, 0, 0],
398
+ [0, 0, 0, 0, 0, 0, 0],
399
+ [0, 0, 0, 0, 0, 0, 0],
400
+ [0, 0, 0, 0, 0, 0, 0]])
401
+
402
+ """
403
+ return _binary_erosion(input, structure, iterations, mask,
404
+ output, border_value, origin, 0, brute_force, axes)
405
+
406
+
407
+ def binary_dilation(input, structure=None, iterations=1, mask=None,
408
+ output=None, border_value=0, origin=0,
409
+ brute_force=False, *, axes=None):
410
+ """
411
+ Multidimensional binary dilation with the given structuring element.
412
+
413
+ Parameters
414
+ ----------
415
+ input : array_like
416
+ Binary array_like to be dilated. Non-zero (True) elements form
417
+ the subset to be dilated.
418
+ structure : array_like, optional
419
+ Structuring element used for the dilation. Non-zero elements are
420
+ considered True. If no structuring element is provided an element
421
+ is generated with a square connectivity equal to one.
422
+ iterations : int, optional
423
+ The dilation is repeated `iterations` times (one, by default).
424
+ If iterations is less than 1, the dilation is repeated until the
425
+ result does not change anymore. Only an integer of iterations is
426
+ accepted.
427
+ mask : array_like, optional
428
+ If a mask is given, only those elements with a True value at
429
+ the corresponding mask element are modified at each iteration.
430
+ output : ndarray, optional
431
+ Array of the same shape as input, into which the output is placed.
432
+ By default, a new array is created.
433
+ border_value : int (cast to 0 or 1), optional
434
+ Value at the border in the output array.
435
+ origin : int or tuple of ints, optional
436
+ Placement of the filter, by default 0.
437
+ brute_force : boolean, optional
438
+ Memory condition: if False, only the pixels whose value was changed in
439
+ the last iteration are tracked as candidates to be updated (dilated)
440
+ in the current iteration; if True all pixels are considered as
441
+ candidates for dilation, regardless of what happened in the previous
442
+ iteration. False by default.
443
+ axes : tuple of int or None
444
+ The axes over which to apply the filter. If None, `input` is filtered
445
+ along all axes. If an `origin` tuple is provided, its length must match
446
+ the number of axes.
447
+
448
+ Returns
449
+ -------
450
+ binary_dilation : ndarray of bools
451
+ Dilation of the input by the structuring element.
452
+
453
+ See Also
454
+ --------
455
+ grey_dilation, binary_erosion, binary_closing, binary_opening,
456
+ generate_binary_structure
457
+
458
+ Notes
459
+ -----
460
+ Dilation [1]_ is a mathematical morphology operation [2]_ that uses a
461
+ structuring element for expanding the shapes in an image. The binary
462
+ dilation of an image by a structuring element is the locus of the points
463
+ covered by the structuring element, when its center lies within the
464
+ non-zero points of the image.
465
+
466
+ References
467
+ ----------
468
+ .. [1] https://en.wikipedia.org/wiki/Dilation_%28morphology%29
469
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
470
+
471
+ Examples
472
+ --------
473
+ >>> from scipy import ndimage
474
+ >>> import numpy as np
475
+ >>> a = np.zeros((5, 5))
476
+ >>> a[2, 2] = 1
477
+ >>> a
478
+ array([[ 0., 0., 0., 0., 0.],
479
+ [ 0., 0., 0., 0., 0.],
480
+ [ 0., 0., 1., 0., 0.],
481
+ [ 0., 0., 0., 0., 0.],
482
+ [ 0., 0., 0., 0., 0.]])
483
+ >>> ndimage.binary_dilation(a)
484
+ array([[False, False, False, False, False],
485
+ [False, False, True, False, False],
486
+ [False, True, True, True, False],
487
+ [False, False, True, False, False],
488
+ [False, False, False, False, False]], dtype=bool)
489
+ >>> ndimage.binary_dilation(a).astype(a.dtype)
490
+ array([[ 0., 0., 0., 0., 0.],
491
+ [ 0., 0., 1., 0., 0.],
492
+ [ 0., 1., 1., 1., 0.],
493
+ [ 0., 0., 1., 0., 0.],
494
+ [ 0., 0., 0., 0., 0.]])
495
+ >>> # 3x3 structuring element with connectivity 1, used by default
496
+ >>> struct1 = ndimage.generate_binary_structure(2, 1)
497
+ >>> struct1
498
+ array([[False, True, False],
499
+ [ True, True, True],
500
+ [False, True, False]], dtype=bool)
501
+ >>> # 3x3 structuring element with connectivity 2
502
+ >>> struct2 = ndimage.generate_binary_structure(2, 2)
503
+ >>> struct2
504
+ array([[ True, True, True],
505
+ [ True, True, True],
506
+ [ True, True, True]], dtype=bool)
507
+ >>> ndimage.binary_dilation(a, structure=struct1).astype(a.dtype)
508
+ array([[ 0., 0., 0., 0., 0.],
509
+ [ 0., 0., 1., 0., 0.],
510
+ [ 0., 1., 1., 1., 0.],
511
+ [ 0., 0., 1., 0., 0.],
512
+ [ 0., 0., 0., 0., 0.]])
513
+ >>> ndimage.binary_dilation(a, structure=struct2).astype(a.dtype)
514
+ array([[ 0., 0., 0., 0., 0.],
515
+ [ 0., 1., 1., 1., 0.],
516
+ [ 0., 1., 1., 1., 0.],
517
+ [ 0., 1., 1., 1., 0.],
518
+ [ 0., 0., 0., 0., 0.]])
519
+ >>> ndimage.binary_dilation(a, structure=struct1,\\
520
+ ... iterations=2).astype(a.dtype)
521
+ array([[ 0., 0., 1., 0., 0.],
522
+ [ 0., 1., 1., 1., 0.],
523
+ [ 1., 1., 1., 1., 1.],
524
+ [ 0., 1., 1., 1., 0.],
525
+ [ 0., 0., 1., 0., 0.]])
526
+
527
+ """
528
+ input = np.asarray(input)
529
+ axes = _ni_support._check_axes(axes, input.ndim)
530
+ num_axes = len(axes)
531
+ if structure is None:
532
+ structure = generate_binary_structure(num_axes, 1)
533
+ origin = _ni_support._normalize_sequence(origin, num_axes)
534
+ structure = np.asarray(structure)
535
+ structure = structure[tuple([slice(None, None, -1)] *
536
+ structure.ndim)]
537
+ for ii in range(len(origin)):
538
+ origin[ii] = -origin[ii]
539
+ if not structure.shape[ii] & 1:
540
+ origin[ii] -= 1
541
+
542
+ return _binary_erosion(input, structure, iterations, mask,
543
+ output, border_value, origin, 1, brute_force, axes)
544
+
545
+
546
+ def binary_opening(input, structure=None, iterations=1, output=None,
547
+ origin=0, mask=None, border_value=0, brute_force=False, *,
548
+ axes=None):
549
+ """
550
+ Multidimensional binary opening with the given structuring element.
551
+
552
+ The *opening* of an input image by a structuring element is the
553
+ *dilation* of the *erosion* of the image by the structuring element.
554
+
555
+ Parameters
556
+ ----------
557
+ input : array_like
558
+ Binary array_like to be opened. Non-zero (True) elements form
559
+ the subset to be opened.
560
+ structure : array_like, optional
561
+ Structuring element used for the opening. Non-zero elements are
562
+ considered True. If no structuring element is provided an element
563
+ is generated with a square connectivity equal to one (i.e., only
564
+ nearest neighbors are connected to the center, diagonally-connected
565
+ elements are not considered neighbors).
566
+ iterations : int, optional
567
+ The erosion step of the opening, then the dilation step are each
568
+ repeated `iterations` times (one, by default). If `iterations` is
569
+ less than 1, each operation is repeated until the result does
570
+ not change anymore. Only an integer of iterations is accepted.
571
+ output : ndarray, optional
572
+ Array of the same shape as input, into which the output is placed.
573
+ By default, a new array is created.
574
+ origin : int or tuple of ints, optional
575
+ Placement of the filter, by default 0.
576
+ mask : array_like, optional
577
+ If a mask is given, only those elements with a True value at
578
+ the corresponding mask element are modified at each iteration.
579
+
580
+ .. versionadded:: 1.1.0
581
+ border_value : int (cast to 0 or 1), optional
582
+ Value at the border in the output array.
583
+
584
+ .. versionadded:: 1.1.0
585
+ brute_force : boolean, optional
586
+ Memory condition: if False, only the pixels whose value was changed in
587
+ the last iteration are tracked as candidates to be updated in the
588
+ current iteration; if true all pixels are considered as candidates for
589
+ update, regardless of what happened in the previous iteration.
590
+ False by default.
591
+
592
+ .. versionadded:: 1.1.0
593
+ axes : tuple of int or None
594
+ The axes over which to apply the filter. If None, `input` is filtered
595
+ along all axes. If an `origin` tuple is provided, its length must match
596
+ the number of axes.
597
+
598
+ Returns
599
+ -------
600
+ binary_opening : ndarray of bools
601
+ Opening of the input by the structuring element.
602
+
603
+ See Also
604
+ --------
605
+ grey_opening, binary_closing, binary_erosion, binary_dilation,
606
+ generate_binary_structure
607
+
608
+ Notes
609
+ -----
610
+ *Opening* [1]_ is a mathematical morphology operation [2]_ that
611
+ consists in the succession of an erosion and a dilation of the
612
+ input with the same structuring element. Opening, therefore, removes
613
+ objects smaller than the structuring element.
614
+
615
+ Together with *closing* (`binary_closing`), opening can be used for
616
+ noise removal.
617
+
618
+ References
619
+ ----------
620
+ .. [1] https://en.wikipedia.org/wiki/Opening_%28morphology%29
621
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
622
+
623
+ Examples
624
+ --------
625
+ >>> from scipy import ndimage
626
+ >>> import numpy as np
627
+ >>> a = np.zeros((5,5), dtype=int)
628
+ >>> a[1:4, 1:4] = 1; a[4, 4] = 1
629
+ >>> a
630
+ array([[0, 0, 0, 0, 0],
631
+ [0, 1, 1, 1, 0],
632
+ [0, 1, 1, 1, 0],
633
+ [0, 1, 1, 1, 0],
634
+ [0, 0, 0, 0, 1]])
635
+ >>> # Opening removes small objects
636
+ >>> ndimage.binary_opening(a, structure=np.ones((3,3))).astype(int)
637
+ array([[0, 0, 0, 0, 0],
638
+ [0, 1, 1, 1, 0],
639
+ [0, 1, 1, 1, 0],
640
+ [0, 1, 1, 1, 0],
641
+ [0, 0, 0, 0, 0]])
642
+ >>> # Opening can also smooth corners
643
+ >>> ndimage.binary_opening(a).astype(int)
644
+ array([[0, 0, 0, 0, 0],
645
+ [0, 0, 1, 0, 0],
646
+ [0, 1, 1, 1, 0],
647
+ [0, 0, 1, 0, 0],
648
+ [0, 0, 0, 0, 0]])
649
+ >>> # Opening is the dilation of the erosion of the input
650
+ >>> ndimage.binary_erosion(a).astype(int)
651
+ array([[0, 0, 0, 0, 0],
652
+ [0, 0, 0, 0, 0],
653
+ [0, 0, 1, 0, 0],
654
+ [0, 0, 0, 0, 0],
655
+ [0, 0, 0, 0, 0]])
656
+ >>> ndimage.binary_dilation(ndimage.binary_erosion(a)).astype(int)
657
+ array([[0, 0, 0, 0, 0],
658
+ [0, 0, 1, 0, 0],
659
+ [0, 1, 1, 1, 0],
660
+ [0, 0, 1, 0, 0],
661
+ [0, 0, 0, 0, 0]])
662
+
663
+ """
664
+ input = np.asarray(input)
665
+ axes = _ni_support._check_axes(axes, input.ndim)
666
+ num_axes = len(axes)
667
+ if structure is None:
668
+ structure = generate_binary_structure(num_axes, 1)
669
+
670
+ tmp = binary_erosion(input, structure, iterations, mask, None,
671
+ border_value, origin, brute_force, axes=axes)
672
+ return binary_dilation(tmp, structure, iterations, mask, output,
673
+ border_value, origin, brute_force, axes=axes)
674
+
675
+
676
+ def binary_closing(input, structure=None, iterations=1, output=None,
677
+ origin=0, mask=None, border_value=0, brute_force=False, *,
678
+ axes=None):
679
+ """
680
+ Multidimensional binary closing with the given structuring element.
681
+
682
+ The *closing* of an input image by a structuring element is the
683
+ *erosion* of the *dilation* of the image by the structuring element.
684
+
685
+ Parameters
686
+ ----------
687
+ input : array_like
688
+ Binary array_like to be closed. Non-zero (True) elements form
689
+ the subset to be closed.
690
+ structure : array_like, optional
691
+ Structuring element used for the closing. Non-zero elements are
692
+ considered True. If no structuring element is provided an element
693
+ is generated with a square connectivity equal to one (i.e., only
694
+ nearest neighbors are connected to the center, diagonally-connected
695
+ elements are not considered neighbors).
696
+ iterations : int, optional
697
+ The dilation step of the closing, then the erosion step are each
698
+ repeated `iterations` times (one, by default). If iterations is
699
+ less than 1, each operations is repeated until the result does
700
+ not change anymore. Only an integer of iterations is accepted.
701
+ output : ndarray, optional
702
+ Array of the same shape as input, into which the output is placed.
703
+ By default, a new array is created.
704
+ origin : int or tuple of ints, optional
705
+ Placement of the filter, by default 0.
706
+ mask : array_like, optional
707
+ If a mask is given, only those elements with a True value at
708
+ the corresponding mask element are modified at each iteration.
709
+
710
+ .. versionadded:: 1.1.0
711
+ border_value : int (cast to 0 or 1), optional
712
+ Value at the border in the output array.
713
+
714
+ .. versionadded:: 1.1.0
715
+ brute_force : boolean, optional
716
+ Memory condition: if False, only the pixels whose value was changed in
717
+ the last iteration are tracked as candidates to be updated in the
718
+ current iteration; if true al pixels are considered as candidates for
719
+ update, regardless of what happened in the previous iteration.
720
+ False by default.
721
+
722
+ .. versionadded:: 1.1.0
723
+ axes : tuple of int or None
724
+ The axes over which to apply the filter. If None, `input` is filtered
725
+ along all axes. If an `origin` tuple is provided, its length must match
726
+ the number of axes.
727
+
728
+ Returns
729
+ -------
730
+ binary_closing : ndarray of bools
731
+ Closing of the input by the structuring element.
732
+
733
+ See Also
734
+ --------
735
+ grey_closing, binary_opening, binary_dilation, binary_erosion,
736
+ generate_binary_structure
737
+
738
+ Notes
739
+ -----
740
+ *Closing* [1]_ is a mathematical morphology operation [2]_ that
741
+ consists in the succession of a dilation and an erosion of the
742
+ input with the same structuring element. Closing therefore fills
743
+ holes smaller than the structuring element.
744
+
745
+ Together with *opening* (`binary_opening`), closing can be used for
746
+ noise removal.
747
+
748
+ References
749
+ ----------
750
+ .. [1] https://en.wikipedia.org/wiki/Closing_%28morphology%29
751
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
752
+
753
+ Examples
754
+ --------
755
+ >>> from scipy import ndimage
756
+ >>> import numpy as np
757
+ >>> a = np.zeros((5,5), dtype=int)
758
+ >>> a[1:-1, 1:-1] = 1; a[2,2] = 0
759
+ >>> a
760
+ array([[0, 0, 0, 0, 0],
761
+ [0, 1, 1, 1, 0],
762
+ [0, 1, 0, 1, 0],
763
+ [0, 1, 1, 1, 0],
764
+ [0, 0, 0, 0, 0]])
765
+ >>> # Closing removes small holes
766
+ >>> ndimage.binary_closing(a).astype(int)
767
+ array([[0, 0, 0, 0, 0],
768
+ [0, 1, 1, 1, 0],
769
+ [0, 1, 1, 1, 0],
770
+ [0, 1, 1, 1, 0],
771
+ [0, 0, 0, 0, 0]])
772
+ >>> # Closing is the erosion of the dilation of the input
773
+ >>> ndimage.binary_dilation(a).astype(int)
774
+ array([[0, 1, 1, 1, 0],
775
+ [1, 1, 1, 1, 1],
776
+ [1, 1, 1, 1, 1],
777
+ [1, 1, 1, 1, 1],
778
+ [0, 1, 1, 1, 0]])
779
+ >>> ndimage.binary_erosion(ndimage.binary_dilation(a)).astype(int)
780
+ array([[0, 0, 0, 0, 0],
781
+ [0, 1, 1, 1, 0],
782
+ [0, 1, 1, 1, 0],
783
+ [0, 1, 1, 1, 0],
784
+ [0, 0, 0, 0, 0]])
785
+
786
+
787
+ >>> a = np.zeros((7,7), dtype=int)
788
+ >>> a[1:6, 2:5] = 1; a[1:3,3] = 0
789
+ >>> a
790
+ array([[0, 0, 0, 0, 0, 0, 0],
791
+ [0, 0, 1, 0, 1, 0, 0],
792
+ [0, 0, 1, 0, 1, 0, 0],
793
+ [0, 0, 1, 1, 1, 0, 0],
794
+ [0, 0, 1, 1, 1, 0, 0],
795
+ [0, 0, 1, 1, 1, 0, 0],
796
+ [0, 0, 0, 0, 0, 0, 0]])
797
+ >>> # In addition to removing holes, closing can also
798
+ >>> # coarsen boundaries with fine hollows.
799
+ >>> ndimage.binary_closing(a).astype(int)
800
+ array([[0, 0, 0, 0, 0, 0, 0],
801
+ [0, 0, 1, 0, 1, 0, 0],
802
+ [0, 0, 1, 1, 1, 0, 0],
803
+ [0, 0, 1, 1, 1, 0, 0],
804
+ [0, 0, 1, 1, 1, 0, 0],
805
+ [0, 0, 1, 1, 1, 0, 0],
806
+ [0, 0, 0, 0, 0, 0, 0]])
807
+ >>> ndimage.binary_closing(a, structure=np.ones((2,2))).astype(int)
808
+ array([[0, 0, 0, 0, 0, 0, 0],
809
+ [0, 0, 1, 1, 1, 0, 0],
810
+ [0, 0, 1, 1, 1, 0, 0],
811
+ [0, 0, 1, 1, 1, 0, 0],
812
+ [0, 0, 1, 1, 1, 0, 0],
813
+ [0, 0, 1, 1, 1, 0, 0],
814
+ [0, 0, 0, 0, 0, 0, 0]])
815
+
816
+ """
817
+ input = np.asarray(input)
818
+ axes = _ni_support._check_axes(axes, input.ndim)
819
+ num_axes = len(axes)
820
+ if structure is None:
821
+ structure = generate_binary_structure(num_axes, 1)
822
+
823
+ tmp = binary_dilation(input, structure, iterations, mask, None,
824
+ border_value, origin, brute_force, axes=axes)
825
+ return binary_erosion(tmp, structure, iterations, mask, output,
826
+ border_value, origin, brute_force, axes=axes)
827
+
828
+
829
+ def binary_hit_or_miss(input, structure1=None, structure2=None,
830
+ output=None, origin1=0, origin2=None, *, axes=None):
831
+ """
832
+ Multidimensional binary hit-or-miss transform.
833
+
834
+ The hit-or-miss transform finds the locations of a given pattern
835
+ inside the input image.
836
+
837
+ Parameters
838
+ ----------
839
+ input : array_like (cast to booleans)
840
+ Binary image where a pattern is to be detected.
841
+ structure1 : array_like (cast to booleans), optional
842
+ Part of the structuring element to be fitted to the foreground
843
+ (non-zero elements) of `input`. If no value is provided, a
844
+ structure of square connectivity 1 is chosen.
845
+ structure2 : array_like (cast to booleans), optional
846
+ Second part of the structuring element that has to miss completely
847
+ the foreground. If no value is provided, the complementary of
848
+ `structure1` is taken.
849
+ output : ndarray, optional
850
+ Array of the same shape as input, into which the output is placed.
851
+ By default, a new array is created.
852
+ origin1 : int or tuple of ints, optional
853
+ Placement of the first part of the structuring element `structure1`,
854
+ by default 0 for a centered structure.
855
+ origin2 : int or tuple of ints, optional
856
+ Placement of the second part of the structuring element `structure2`,
857
+ by default 0 for a centered structure. If a value is provided for
858
+ `origin1` and not for `origin2`, then `origin2` is set to `origin1`.
859
+ axes : tuple of int or None
860
+ The axes over which to apply the filter. If None, `input` is filtered
861
+ along all axes. If `origin1` or `origin2` tuples are provided, their
862
+ length must match the number of axes.
863
+
864
+ Returns
865
+ -------
866
+ binary_hit_or_miss : ndarray
867
+ Hit-or-miss transform of `input` with the given structuring
868
+ element (`structure1`, `structure2`).
869
+
870
+ See Also
871
+ --------
872
+ binary_erosion
873
+
874
+ References
875
+ ----------
876
+ .. [1] https://en.wikipedia.org/wiki/Hit-or-miss_transform
877
+
878
+ Examples
879
+ --------
880
+ >>> from scipy import ndimage
881
+ >>> import numpy as np
882
+ >>> a = np.zeros((7,7), dtype=int)
883
+ >>> a[1, 1] = 1; a[2:4, 2:4] = 1; a[4:6, 4:6] = 1
884
+ >>> a
885
+ array([[0, 0, 0, 0, 0, 0, 0],
886
+ [0, 1, 0, 0, 0, 0, 0],
887
+ [0, 0, 1, 1, 0, 0, 0],
888
+ [0, 0, 1, 1, 0, 0, 0],
889
+ [0, 0, 0, 0, 1, 1, 0],
890
+ [0, 0, 0, 0, 1, 1, 0],
891
+ [0, 0, 0, 0, 0, 0, 0]])
892
+ >>> structure1 = np.array([[1, 0, 0], [0, 1, 1], [0, 1, 1]])
893
+ >>> structure1
894
+ array([[1, 0, 0],
895
+ [0, 1, 1],
896
+ [0, 1, 1]])
897
+ >>> # Find the matches of structure1 in the array a
898
+ >>> ndimage.binary_hit_or_miss(a, structure1=structure1).astype(int)
899
+ array([[0, 0, 0, 0, 0, 0, 0],
900
+ [0, 0, 0, 0, 0, 0, 0],
901
+ [0, 0, 1, 0, 0, 0, 0],
902
+ [0, 0, 0, 0, 0, 0, 0],
903
+ [0, 0, 0, 0, 1, 0, 0],
904
+ [0, 0, 0, 0, 0, 0, 0],
905
+ [0, 0, 0, 0, 0, 0, 0]])
906
+ >>> # Change the origin of the filter
907
+ >>> # origin1=1 is equivalent to origin1=(1,1) here
908
+ >>> ndimage.binary_hit_or_miss(a, structure1=structure1,\\
909
+ ... origin1=1).astype(int)
910
+ array([[0, 0, 0, 0, 0, 0, 0],
911
+ [0, 0, 0, 0, 0, 0, 0],
912
+ [0, 0, 0, 0, 0, 0, 0],
913
+ [0, 0, 0, 1, 0, 0, 0],
914
+ [0, 0, 0, 0, 0, 0, 0],
915
+ [0, 0, 0, 0, 0, 1, 0],
916
+ [0, 0, 0, 0, 0, 0, 0]])
917
+
918
+ """
919
+ input = np.asarray(input)
920
+ axes = _ni_support._check_axes(axes, input.ndim)
921
+ num_axes = len(axes)
922
+ if structure1 is None:
923
+ structure1 = generate_binary_structure(num_axes, 1)
924
+ else:
925
+ structure1 = np.asarray(structure1)
926
+ if structure2 is None:
927
+ structure2 = np.logical_not(structure1)
928
+ origin1 = _ni_support._normalize_sequence(origin1, num_axes)
929
+ if origin2 is None:
930
+ origin2 = origin1
931
+ else:
932
+ origin2 = _ni_support._normalize_sequence(origin2, num_axes)
933
+
934
+ tmp1 = _binary_erosion(input, structure1, 1, None, None, 0, origin1,
935
+ 0, False, axes)
936
+ inplace = isinstance(output, np.ndarray)
937
+ result = _binary_erosion(input, structure2, 1, None, output, 0,
938
+ origin2, 1, False, axes)
939
+ if inplace:
940
+ np.logical_not(output, output)
941
+ np.logical_and(tmp1, output, output)
942
+ else:
943
+ np.logical_not(result, result)
944
+ return np.logical_and(tmp1, result)
945
+
946
+
947
+ def binary_propagation(input, structure=None, mask=None,
948
+ output=None, border_value=0, origin=0, *, axes=None):
949
+ """
950
+ Multidimensional binary propagation with the given structuring element.
951
+
952
+ Parameters
953
+ ----------
954
+ input : array_like
955
+ Binary image to be propagated inside `mask`.
956
+ structure : array_like, optional
957
+ Structuring element used in the successive dilations. The output
958
+ may depend on the structuring element, especially if `mask` has
959
+ several connex components. If no structuring element is
960
+ provided, an element is generated with a squared connectivity equal
961
+ to one.
962
+ mask : array_like, optional
963
+ Binary mask defining the region into which `input` is allowed to
964
+ propagate.
965
+ output : ndarray, optional
966
+ Array of the same shape as input, into which the output is placed.
967
+ By default, a new array is created.
968
+ border_value : int (cast to 0 or 1), optional
969
+ Value at the border in the output array.
970
+ origin : int or tuple of ints, optional
971
+ Placement of the filter, by default 0.
972
+ axes : tuple of int or None
973
+ The axes over which to apply the filter. If None, `input` is filtered
974
+ along all axes. If an `origin` tuple is provided, its length must match
975
+ the number of axes.
976
+
977
+ Returns
978
+ -------
979
+ binary_propagation : ndarray
980
+ Binary propagation of `input` inside `mask`.
981
+
982
+ Notes
983
+ -----
984
+ This function is functionally equivalent to calling binary_dilation
985
+ with the number of iterations less than one: iterative dilation until
986
+ the result does not change anymore.
987
+
988
+ The succession of an erosion and propagation inside the original image
989
+ can be used instead of an *opening* for deleting small objects while
990
+ keeping the contours of larger objects untouched.
991
+
992
+ References
993
+ ----------
994
+ .. [1] http://cmm.ensmp.fr/~serra/cours/pdf/en/ch6en.pdf, slide 15.
995
+ .. [2] I.T. Young, J.J. Gerbrands, and L.J. van Vliet, "Fundamentals of
996
+ image processing", 1998
997
+ ftp://qiftp.tudelft.nl/DIPimage/docs/FIP2.3.pdf
998
+
999
+ Examples
1000
+ --------
1001
+ >>> from scipy import ndimage
1002
+ >>> import numpy as np
1003
+ >>> input = np.zeros((8, 8), dtype=int)
1004
+ >>> input[2, 2] = 1
1005
+ >>> mask = np.zeros((8, 8), dtype=int)
1006
+ >>> mask[1:4, 1:4] = mask[4, 4] = mask[6:8, 6:8] = 1
1007
+ >>> input
1008
+ array([[0, 0, 0, 0, 0, 0, 0, 0],
1009
+ [0, 0, 0, 0, 0, 0, 0, 0],
1010
+ [0, 0, 1, 0, 0, 0, 0, 0],
1011
+ [0, 0, 0, 0, 0, 0, 0, 0],
1012
+ [0, 0, 0, 0, 0, 0, 0, 0],
1013
+ [0, 0, 0, 0, 0, 0, 0, 0],
1014
+ [0, 0, 0, 0, 0, 0, 0, 0],
1015
+ [0, 0, 0, 0, 0, 0, 0, 0]])
1016
+ >>> mask
1017
+ array([[0, 0, 0, 0, 0, 0, 0, 0],
1018
+ [0, 1, 1, 1, 0, 0, 0, 0],
1019
+ [0, 1, 1, 1, 0, 0, 0, 0],
1020
+ [0, 1, 1, 1, 0, 0, 0, 0],
1021
+ [0, 0, 0, 0, 1, 0, 0, 0],
1022
+ [0, 0, 0, 0, 0, 0, 0, 0],
1023
+ [0, 0, 0, 0, 0, 0, 1, 1],
1024
+ [0, 0, 0, 0, 0, 0, 1, 1]])
1025
+ >>> ndimage.binary_propagation(input, mask=mask).astype(int)
1026
+ array([[0, 0, 0, 0, 0, 0, 0, 0],
1027
+ [0, 1, 1, 1, 0, 0, 0, 0],
1028
+ [0, 1, 1, 1, 0, 0, 0, 0],
1029
+ [0, 1, 1, 1, 0, 0, 0, 0],
1030
+ [0, 0, 0, 0, 0, 0, 0, 0],
1031
+ [0, 0, 0, 0, 0, 0, 0, 0],
1032
+ [0, 0, 0, 0, 0, 0, 0, 0],
1033
+ [0, 0, 0, 0, 0, 0, 0, 0]])
1034
+ >>> ndimage.binary_propagation(input, mask=mask,\\
1035
+ ... structure=np.ones((3,3))).astype(int)
1036
+ array([[0, 0, 0, 0, 0, 0, 0, 0],
1037
+ [0, 1, 1, 1, 0, 0, 0, 0],
1038
+ [0, 1, 1, 1, 0, 0, 0, 0],
1039
+ [0, 1, 1, 1, 0, 0, 0, 0],
1040
+ [0, 0, 0, 0, 1, 0, 0, 0],
1041
+ [0, 0, 0, 0, 0, 0, 0, 0],
1042
+ [0, 0, 0, 0, 0, 0, 0, 0],
1043
+ [0, 0, 0, 0, 0, 0, 0, 0]])
1044
+
1045
+ >>> # Comparison between opening and erosion+propagation
1046
+ >>> a = np.zeros((6,6), dtype=int)
1047
+ >>> a[2:5, 2:5] = 1; a[0, 0] = 1; a[5, 5] = 1
1048
+ >>> a
1049
+ array([[1, 0, 0, 0, 0, 0],
1050
+ [0, 0, 0, 0, 0, 0],
1051
+ [0, 0, 1, 1, 1, 0],
1052
+ [0, 0, 1, 1, 1, 0],
1053
+ [0, 0, 1, 1, 1, 0],
1054
+ [0, 0, 0, 0, 0, 1]])
1055
+ >>> ndimage.binary_opening(a).astype(int)
1056
+ array([[0, 0, 0, 0, 0, 0],
1057
+ [0, 0, 0, 0, 0, 0],
1058
+ [0, 0, 0, 1, 0, 0],
1059
+ [0, 0, 1, 1, 1, 0],
1060
+ [0, 0, 0, 1, 0, 0],
1061
+ [0, 0, 0, 0, 0, 0]])
1062
+ >>> b = ndimage.binary_erosion(a)
1063
+ >>> b.astype(int)
1064
+ array([[0, 0, 0, 0, 0, 0],
1065
+ [0, 0, 0, 0, 0, 0],
1066
+ [0, 0, 0, 0, 0, 0],
1067
+ [0, 0, 0, 1, 0, 0],
1068
+ [0, 0, 0, 0, 0, 0],
1069
+ [0, 0, 0, 0, 0, 0]])
1070
+ >>> ndimage.binary_propagation(b, mask=a).astype(int)
1071
+ array([[0, 0, 0, 0, 0, 0],
1072
+ [0, 0, 0, 0, 0, 0],
1073
+ [0, 0, 1, 1, 1, 0],
1074
+ [0, 0, 1, 1, 1, 0],
1075
+ [0, 0, 1, 1, 1, 0],
1076
+ [0, 0, 0, 0, 0, 0]])
1077
+
1078
+ """
1079
+ return binary_dilation(input, structure, -1, mask, output,
1080
+ border_value, origin, axes=axes)
1081
+
1082
+
1083
+ def binary_fill_holes(input, structure=None, output=None, origin=0, *,
1084
+ axes=None):
1085
+ """
1086
+ Fill the holes in binary objects.
1087
+
1088
+
1089
+ Parameters
1090
+ ----------
1091
+ input : array_like
1092
+ N-D binary array with holes to be filled
1093
+ structure : array_like, optional
1094
+ Structuring element used in the computation; large-size elements
1095
+ make computations faster but may miss holes separated from the
1096
+ background by thin regions. The default element (with a square
1097
+ connectivity equal to one) yields the intuitive result where all
1098
+ holes in the input have been filled.
1099
+ output : ndarray, optional
1100
+ Array of the same shape as input, into which the output is placed.
1101
+ By default, a new array is created.
1102
+ origin : int, tuple of ints, optional
1103
+ Position of the structuring element.
1104
+ axes : tuple of int or None
1105
+ The axes over which to apply the filter. If None, `input` is filtered
1106
+ along all axes. If an `origin` tuple is provided, its length must match
1107
+ the number of axes.
1108
+
1109
+ Returns
1110
+ -------
1111
+ out : ndarray
1112
+ Transformation of the initial image `input` where holes have been
1113
+ filled.
1114
+
1115
+ See Also
1116
+ --------
1117
+ binary_dilation, binary_propagation, label
1118
+
1119
+ Notes
1120
+ -----
1121
+ The algorithm used in this function consists in invading the complementary
1122
+ of the shapes in `input` from the outer boundary of the image,
1123
+ using binary dilations. Holes are not connected to the boundary and are
1124
+ therefore not invaded. The result is the complementary subset of the
1125
+ invaded region.
1126
+
1127
+ References
1128
+ ----------
1129
+ .. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
1130
+
1131
+
1132
+ Examples
1133
+ --------
1134
+ >>> from scipy import ndimage
1135
+ >>> import numpy as np
1136
+ >>> a = np.zeros((5, 5), dtype=int)
1137
+ >>> a[1:4, 1:4] = 1
1138
+ >>> a[2,2] = 0
1139
+ >>> a
1140
+ array([[0, 0, 0, 0, 0],
1141
+ [0, 1, 1, 1, 0],
1142
+ [0, 1, 0, 1, 0],
1143
+ [0, 1, 1, 1, 0],
1144
+ [0, 0, 0, 0, 0]])
1145
+ >>> ndimage.binary_fill_holes(a).astype(int)
1146
+ array([[0, 0, 0, 0, 0],
1147
+ [0, 1, 1, 1, 0],
1148
+ [0, 1, 1, 1, 0],
1149
+ [0, 1, 1, 1, 0],
1150
+ [0, 0, 0, 0, 0]])
1151
+ >>> # Too big structuring element
1152
+ >>> ndimage.binary_fill_holes(a, structure=np.ones((5,5))).astype(int)
1153
+ array([[0, 0, 0, 0, 0],
1154
+ [0, 1, 1, 1, 0],
1155
+ [0, 1, 0, 1, 0],
1156
+ [0, 1, 1, 1, 0],
1157
+ [0, 0, 0, 0, 0]])
1158
+
1159
+ """
1160
+ input = np.asarray(input)
1161
+ mask = np.logical_not(input)
1162
+ tmp = np.zeros(mask.shape, bool)
1163
+ inplace = isinstance(output, np.ndarray)
1164
+ if inplace:
1165
+ binary_dilation(tmp, structure, -1, mask, output, 1, origin, axes=axes)
1166
+ np.logical_not(output, output)
1167
+ else:
1168
+ output = binary_dilation(tmp, structure, -1, mask, None, 1,
1169
+ origin, axes=axes)
1170
+ np.logical_not(output, output)
1171
+ return output
1172
+
1173
+
1174
+ def grey_erosion(input, size=None, footprint=None, structure=None,
1175
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1176
+ axes=None):
1177
+ """
1178
+ Calculate a greyscale erosion, using either a structuring element,
1179
+ or a footprint corresponding to a flat structuring element.
1180
+
1181
+ Grayscale erosion is a mathematical morphology operation. For the
1182
+ simple case of a full and flat structuring element, it can be viewed
1183
+ as a minimum filter over a sliding window.
1184
+
1185
+ Parameters
1186
+ ----------
1187
+ input : array_like
1188
+ Array over which the grayscale erosion is to be computed.
1189
+ size : tuple of ints
1190
+ Shape of a flat and full structuring element used for the grayscale
1191
+ erosion. Optional if `footprint` or `structure` is provided.
1192
+ footprint : array of ints, optional
1193
+ Positions of non-infinite elements of a flat structuring element
1194
+ used for the grayscale erosion. Non-zero values give the set of
1195
+ neighbors of the center over which the minimum is chosen.
1196
+ structure : array of ints, optional
1197
+ Structuring element used for the grayscale erosion. `structure`
1198
+ may be a non-flat structuring element. The `structure` array applies a
1199
+ subtractive offset for each pixel in the neighborhood.
1200
+ output : array, optional
1201
+ An array used for storing the output of the erosion may be provided.
1202
+ mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
1203
+ The `mode` parameter determines how the array borders are
1204
+ handled, where `cval` is the value when mode is equal to
1205
+ 'constant'. Default is 'reflect'
1206
+ cval : scalar, optional
1207
+ Value to fill past edges of input if `mode` is 'constant'. Default
1208
+ is 0.0.
1209
+ origin : scalar, optional
1210
+ The `origin` parameter controls the placement of the filter.
1211
+ Default 0
1212
+ axes : tuple of int or None
1213
+ The axes over which to apply the filter. If None, `input` is filtered
1214
+ along all axes. If an `origin` tuple is provided, its length must match
1215
+ the number of axes.
1216
+
1217
+ Returns
1218
+ -------
1219
+ output : ndarray
1220
+ Grayscale erosion of `input`.
1221
+
1222
+ See Also
1223
+ --------
1224
+ binary_erosion, grey_dilation, grey_opening, grey_closing
1225
+ generate_binary_structure, minimum_filter
1226
+
1227
+ Notes
1228
+ -----
1229
+ The grayscale erosion of an image input by a structuring element s defined
1230
+ over a domain E is given by:
1231
+
1232
+ (input+s)(x) = min {input(y) - s(x-y), for y in E}
1233
+
1234
+ In particular, for structuring elements defined as
1235
+ s(y) = 0 for y in E, the grayscale erosion computes the minimum of the
1236
+ input image inside a sliding window defined by E.
1237
+
1238
+ Grayscale erosion [1]_ is a *mathematical morphology* operation [2]_.
1239
+
1240
+ References
1241
+ ----------
1242
+ .. [1] https://en.wikipedia.org/wiki/Erosion_%28morphology%29
1243
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
1244
+
1245
+ Examples
1246
+ --------
1247
+ >>> from scipy import ndimage
1248
+ >>> import numpy as np
1249
+ >>> a = np.zeros((7,7), dtype=int)
1250
+ >>> a[1:6, 1:6] = 3
1251
+ >>> a[4,4] = 2; a[2,3] = 1
1252
+ >>> a
1253
+ array([[0, 0, 0, 0, 0, 0, 0],
1254
+ [0, 3, 3, 3, 3, 3, 0],
1255
+ [0, 3, 3, 1, 3, 3, 0],
1256
+ [0, 3, 3, 3, 3, 3, 0],
1257
+ [0, 3, 3, 3, 2, 3, 0],
1258
+ [0, 3, 3, 3, 3, 3, 0],
1259
+ [0, 0, 0, 0, 0, 0, 0]])
1260
+ >>> ndimage.grey_erosion(a, size=(3,3))
1261
+ array([[0, 0, 0, 0, 0, 0, 0],
1262
+ [0, 0, 0, 0, 0, 0, 0],
1263
+ [0, 0, 1, 1, 1, 0, 0],
1264
+ [0, 0, 1, 1, 1, 0, 0],
1265
+ [0, 0, 3, 2, 2, 0, 0],
1266
+ [0, 0, 0, 0, 0, 0, 0],
1267
+ [0, 0, 0, 0, 0, 0, 0]])
1268
+ >>> footprint = ndimage.generate_binary_structure(2, 1)
1269
+ >>> footprint
1270
+ array([[False, True, False],
1271
+ [ True, True, True],
1272
+ [False, True, False]], dtype=bool)
1273
+ >>> # Diagonally-connected elements are not considered neighbors
1274
+ >>> ndimage.grey_erosion(a, footprint=footprint)
1275
+ array([[0, 0, 0, 0, 0, 0, 0],
1276
+ [0, 0, 0, 0, 0, 0, 0],
1277
+ [0, 0, 1, 1, 1, 0, 0],
1278
+ [0, 0, 3, 1, 2, 0, 0],
1279
+ [0, 0, 3, 2, 2, 0, 0],
1280
+ [0, 0, 0, 0, 0, 0, 0],
1281
+ [0, 0, 0, 0, 0, 0, 0]])
1282
+
1283
+ """
1284
+ if size is None and footprint is None and structure is None:
1285
+ raise ValueError("size, footprint, or structure must be specified")
1286
+
1287
+ return _filters._min_or_max_filter(input, size, footprint, structure,
1288
+ output, mode, cval, origin, 1,
1289
+ axes=axes)
1290
+
1291
+
1292
+ def grey_dilation(input, size=None, footprint=None, structure=None,
1293
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1294
+ axes=None):
1295
+ """
1296
+ Calculate a greyscale dilation, using either a structuring element,
1297
+ or a footprint corresponding to a flat structuring element.
1298
+
1299
+ Grayscale dilation is a mathematical morphology operation. For the
1300
+ simple case of a full and flat structuring element, it can be viewed
1301
+ as a maximum filter over a sliding window.
1302
+
1303
+ Parameters
1304
+ ----------
1305
+ input : array_like
1306
+ Array over which the grayscale dilation is to be computed.
1307
+ size : tuple of ints
1308
+ Shape of a flat and full structuring element used for the grayscale
1309
+ dilation. Optional if `footprint` or `structure` is provided.
1310
+ footprint : array of ints, optional
1311
+ Positions of non-infinite elements of a flat structuring element
1312
+ used for the grayscale dilation. Non-zero values give the set of
1313
+ neighbors of the center over which the maximum is chosen.
1314
+ structure : array of ints, optional
1315
+ Structuring element used for the grayscale dilation. `structure`
1316
+ may be a non-flat structuring element. The `structure` array applies an
1317
+ additive offset for each pixel in the neighborhood.
1318
+ output : array, optional
1319
+ An array used for storing the output of the dilation may be provided.
1320
+ mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
1321
+ The `mode` parameter determines how the array borders are
1322
+ handled, where `cval` is the value when mode is equal to
1323
+ 'constant'. Default is 'reflect'
1324
+ cval : scalar, optional
1325
+ Value to fill past edges of input if `mode` is 'constant'. Default
1326
+ is 0.0.
1327
+ origin : scalar, optional
1328
+ The `origin` parameter controls the placement of the filter.
1329
+ Default 0
1330
+ axes : tuple of int or None
1331
+ The axes over which to apply the filter. If None, `input` is filtered
1332
+ along all axes. If an `origin` tuple is provided, its length must match
1333
+ the number of axes.
1334
+
1335
+ Returns
1336
+ -------
1337
+ grey_dilation : ndarray
1338
+ Grayscale dilation of `input`.
1339
+
1340
+ See Also
1341
+ --------
1342
+ binary_dilation, grey_erosion, grey_closing, grey_opening
1343
+ generate_binary_structure, maximum_filter
1344
+
1345
+ Notes
1346
+ -----
1347
+ The grayscale dilation of an image input by a structuring element s defined
1348
+ over a domain E is given by:
1349
+
1350
+ (input+s)(x) = max {input(y) + s(x-y), for y in E}
1351
+
1352
+ In particular, for structuring elements defined as
1353
+ s(y) = 0 for y in E, the grayscale dilation computes the maximum of the
1354
+ input image inside a sliding window defined by E.
1355
+
1356
+ Grayscale dilation [1]_ is a *mathematical morphology* operation [2]_.
1357
+
1358
+ References
1359
+ ----------
1360
+ .. [1] https://en.wikipedia.org/wiki/Dilation_%28morphology%29
1361
+ .. [2] https://en.wikipedia.org/wiki/Mathematical_morphology
1362
+
1363
+ Examples
1364
+ --------
1365
+ >>> from scipy import ndimage
1366
+ >>> import numpy as np
1367
+ >>> a = np.zeros((7,7), dtype=int)
1368
+ >>> a[2:5, 2:5] = 1
1369
+ >>> a[4,4] = 2; a[2,3] = 3
1370
+ >>> a
1371
+ array([[0, 0, 0, 0, 0, 0, 0],
1372
+ [0, 0, 0, 0, 0, 0, 0],
1373
+ [0, 0, 1, 3, 1, 0, 0],
1374
+ [0, 0, 1, 1, 1, 0, 0],
1375
+ [0, 0, 1, 1, 2, 0, 0],
1376
+ [0, 0, 0, 0, 0, 0, 0],
1377
+ [0, 0, 0, 0, 0, 0, 0]])
1378
+ >>> ndimage.grey_dilation(a, size=(3,3))
1379
+ array([[0, 0, 0, 0, 0, 0, 0],
1380
+ [0, 1, 3, 3, 3, 1, 0],
1381
+ [0, 1, 3, 3, 3, 1, 0],
1382
+ [0, 1, 3, 3, 3, 2, 0],
1383
+ [0, 1, 1, 2, 2, 2, 0],
1384
+ [0, 1, 1, 2, 2, 2, 0],
1385
+ [0, 0, 0, 0, 0, 0, 0]])
1386
+ >>> ndimage.grey_dilation(a, footprint=np.ones((3,3)))
1387
+ array([[0, 0, 0, 0, 0, 0, 0],
1388
+ [0, 1, 3, 3, 3, 1, 0],
1389
+ [0, 1, 3, 3, 3, 1, 0],
1390
+ [0, 1, 3, 3, 3, 2, 0],
1391
+ [0, 1, 1, 2, 2, 2, 0],
1392
+ [0, 1, 1, 2, 2, 2, 0],
1393
+ [0, 0, 0, 0, 0, 0, 0]])
1394
+ >>> s = ndimage.generate_binary_structure(2,1)
1395
+ >>> s
1396
+ array([[False, True, False],
1397
+ [ True, True, True],
1398
+ [False, True, False]], dtype=bool)
1399
+ >>> ndimage.grey_dilation(a, footprint=s)
1400
+ array([[0, 0, 0, 0, 0, 0, 0],
1401
+ [0, 0, 1, 3, 1, 0, 0],
1402
+ [0, 1, 3, 3, 3, 1, 0],
1403
+ [0, 1, 1, 3, 2, 1, 0],
1404
+ [0, 1, 1, 2, 2, 2, 0],
1405
+ [0, 0, 1, 1, 2, 0, 0],
1406
+ [0, 0, 0, 0, 0, 0, 0]])
1407
+ >>> ndimage.grey_dilation(a, size=(3,3), structure=np.ones((3,3)))
1408
+ array([[1, 1, 1, 1, 1, 1, 1],
1409
+ [1, 2, 4, 4, 4, 2, 1],
1410
+ [1, 2, 4, 4, 4, 2, 1],
1411
+ [1, 2, 4, 4, 4, 3, 1],
1412
+ [1, 2, 2, 3, 3, 3, 1],
1413
+ [1, 2, 2, 3, 3, 3, 1],
1414
+ [1, 1, 1, 1, 1, 1, 1]])
1415
+
1416
+ """
1417
+ if size is None and footprint is None and structure is None:
1418
+ raise ValueError("size, footprint, or structure must be specified")
1419
+ if structure is not None:
1420
+ structure = np.asarray(structure)
1421
+ structure = structure[tuple([slice(None, None, -1)] *
1422
+ structure.ndim)]
1423
+ if footprint is not None:
1424
+ footprint = np.asarray(footprint)
1425
+ footprint = footprint[tuple([slice(None, None, -1)] *
1426
+ footprint.ndim)]
1427
+
1428
+ input = np.asarray(input)
1429
+ axes = _ni_support._check_axes(axes, input.ndim)
1430
+ origin = _ni_support._normalize_sequence(origin, len(axes))
1431
+ for ii in range(len(origin)):
1432
+ origin[ii] = -origin[ii]
1433
+ if footprint is not None:
1434
+ sz = footprint.shape[ii]
1435
+ elif structure is not None:
1436
+ sz = structure.shape[ii]
1437
+ elif np.isscalar(size):
1438
+ sz = size
1439
+ else:
1440
+ sz = size[ii]
1441
+ if not sz & 1:
1442
+ origin[ii] -= 1
1443
+
1444
+ return _filters._min_or_max_filter(input, size, footprint, structure,
1445
+ output, mode, cval, origin, 0,
1446
+ axes=axes)
1447
+
1448
+
1449
+ def grey_opening(input, size=None, footprint=None, structure=None,
1450
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1451
+ axes=None):
1452
+ """
1453
+ Multidimensional grayscale opening.
1454
+
1455
+ A grayscale opening consists in the succession of a grayscale erosion,
1456
+ and a grayscale dilation.
1457
+
1458
+ Parameters
1459
+ ----------
1460
+ input : array_like
1461
+ Array over which the grayscale opening is to be computed.
1462
+ size : tuple of ints
1463
+ Shape of a flat and full structuring element used for the grayscale
1464
+ opening. Optional if `footprint` or `structure` is provided.
1465
+ footprint : array of ints, optional
1466
+ Positions of non-infinite elements of a flat structuring element
1467
+ used for the grayscale opening.
1468
+ structure : array of ints, optional
1469
+ Structuring element used for the grayscale opening. `structure`
1470
+ may be a non-flat structuring element. The `structure` array applies
1471
+ offsets to the pixels in a neighborhood (the offset is additive during
1472
+ dilation and subtractive during erosion).
1473
+ output : array, optional
1474
+ An array used for storing the output of the opening may be provided.
1475
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
1476
+ The `mode` parameter determines how the array borders are
1477
+ handled, where `cval` is the value when mode is equal to
1478
+ 'constant'. Default is 'reflect'
1479
+ cval : scalar, optional
1480
+ Value to fill past edges of input if `mode` is 'constant'. Default
1481
+ is 0.0.
1482
+ origin : scalar, optional
1483
+ The `origin` parameter controls the placement of the filter.
1484
+ Default 0
1485
+ axes : tuple of int or None
1486
+ The axes over which to apply the filter. If None, `input` is filtered
1487
+ along all axes. If an `origin` tuple is provided, its length must match
1488
+ the number of axes.
1489
+
1490
+ Returns
1491
+ -------
1492
+ grey_opening : ndarray
1493
+ Result of the grayscale opening of `input` with `structure`.
1494
+
1495
+ See Also
1496
+ --------
1497
+ binary_opening, grey_dilation, grey_erosion, grey_closing
1498
+ generate_binary_structure
1499
+
1500
+ Notes
1501
+ -----
1502
+ The action of a grayscale opening with a flat structuring element amounts
1503
+ to smoothen high local maxima, whereas binary opening erases small objects.
1504
+
1505
+ References
1506
+ ----------
1507
+ .. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
1508
+
1509
+ Examples
1510
+ --------
1511
+ >>> from scipy import ndimage
1512
+ >>> import numpy as np
1513
+ >>> a = np.arange(36).reshape((6,6))
1514
+ >>> a[3, 3] = 50
1515
+ >>> a
1516
+ array([[ 0, 1, 2, 3, 4, 5],
1517
+ [ 6, 7, 8, 9, 10, 11],
1518
+ [12, 13, 14, 15, 16, 17],
1519
+ [18, 19, 20, 50, 22, 23],
1520
+ [24, 25, 26, 27, 28, 29],
1521
+ [30, 31, 32, 33, 34, 35]])
1522
+ >>> ndimage.grey_opening(a, size=(3,3))
1523
+ array([[ 0, 1, 2, 3, 4, 4],
1524
+ [ 6, 7, 8, 9, 10, 10],
1525
+ [12, 13, 14, 15, 16, 16],
1526
+ [18, 19, 20, 22, 22, 22],
1527
+ [24, 25, 26, 27, 28, 28],
1528
+ [24, 25, 26, 27, 28, 28]])
1529
+ >>> # Note that the local maximum a[3,3] has disappeared
1530
+
1531
+ """
1532
+ if (size is not None) and (footprint is not None):
1533
+ warnings.warn("ignoring size because footprint is set",
1534
+ UserWarning, stacklevel=2)
1535
+ tmp = grey_erosion(input, size, footprint, structure, None, mode,
1536
+ cval, origin, axes=axes)
1537
+ return grey_dilation(tmp, size, footprint, structure, output, mode,
1538
+ cval, origin, axes=axes)
1539
+
1540
+
1541
+ def grey_closing(input, size=None, footprint=None, structure=None,
1542
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1543
+ axes=None):
1544
+ """
1545
+ Multidimensional grayscale closing.
1546
+
1547
+ A grayscale closing consists in the succession of a grayscale dilation,
1548
+ and a grayscale erosion.
1549
+
1550
+ Parameters
1551
+ ----------
1552
+ input : array_like
1553
+ Array over which the grayscale closing is to be computed.
1554
+ size : tuple of ints
1555
+ Shape of a flat and full structuring element used for the grayscale
1556
+ closing. Optional if `footprint` or `structure` is provided.
1557
+ footprint : array of ints, optional
1558
+ Positions of non-infinite elements of a flat structuring element
1559
+ used for the grayscale closing.
1560
+ structure : array of ints, optional
1561
+ Structuring element used for the grayscale closing. `structure`
1562
+ may be a non-flat structuring element. The `structure` array applies
1563
+ offsets to the pixels in a neighborhood (the offset is additive during
1564
+ dilation and subtractive during erosion)
1565
+ output : array, optional
1566
+ An array used for storing the output of the closing may be provided.
1567
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
1568
+ The `mode` parameter determines how the array borders are
1569
+ handled, where `cval` is the value when mode is equal to
1570
+ 'constant'. Default is 'reflect'
1571
+ cval : scalar, optional
1572
+ Value to fill past edges of input if `mode` is 'constant'. Default
1573
+ is 0.0.
1574
+ origin : scalar, optional
1575
+ The `origin` parameter controls the placement of the filter.
1576
+ Default 0
1577
+ axes : tuple of int or None
1578
+ The axes over which to apply the filter. If None, `input` is filtered
1579
+ along all axes. If an `origin` tuple is provided, its length must match
1580
+ the number of axes.
1581
+
1582
+ Returns
1583
+ -------
1584
+ grey_closing : ndarray
1585
+ Result of the grayscale closing of `input` with `structure`.
1586
+
1587
+ See Also
1588
+ --------
1589
+ binary_closing, grey_dilation, grey_erosion, grey_opening,
1590
+ generate_binary_structure
1591
+
1592
+ Notes
1593
+ -----
1594
+ The action of a grayscale closing with a flat structuring element amounts
1595
+ to smoothen deep local minima, whereas binary closing fills small holes.
1596
+
1597
+ References
1598
+ ----------
1599
+ .. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
1600
+
1601
+ Examples
1602
+ --------
1603
+ >>> from scipy import ndimage
1604
+ >>> import numpy as np
1605
+ >>> a = np.arange(36).reshape((6,6))
1606
+ >>> a[3,3] = 0
1607
+ >>> a
1608
+ array([[ 0, 1, 2, 3, 4, 5],
1609
+ [ 6, 7, 8, 9, 10, 11],
1610
+ [12, 13, 14, 15, 16, 17],
1611
+ [18, 19, 20, 0, 22, 23],
1612
+ [24, 25, 26, 27, 28, 29],
1613
+ [30, 31, 32, 33, 34, 35]])
1614
+ >>> ndimage.grey_closing(a, size=(3,3))
1615
+ array([[ 7, 7, 8, 9, 10, 11],
1616
+ [ 7, 7, 8, 9, 10, 11],
1617
+ [13, 13, 14, 15, 16, 17],
1618
+ [19, 19, 20, 20, 22, 23],
1619
+ [25, 25, 26, 27, 28, 29],
1620
+ [31, 31, 32, 33, 34, 35]])
1621
+ >>> # Note that the local minimum a[3,3] has disappeared
1622
+
1623
+ """
1624
+ if (size is not None) and (footprint is not None):
1625
+ warnings.warn("ignoring size because footprint is set",
1626
+ UserWarning, stacklevel=2)
1627
+ tmp = grey_dilation(input, size, footprint, structure, None, mode,
1628
+ cval, origin, axes=axes)
1629
+ return grey_erosion(tmp, size, footprint, structure, output, mode,
1630
+ cval, origin, axes=axes)
1631
+
1632
+
1633
+ def morphological_gradient(input, size=None, footprint=None, structure=None,
1634
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1635
+ axes=None):
1636
+ """
1637
+ Multidimensional morphological gradient.
1638
+
1639
+ The morphological gradient is calculated as the difference between a
1640
+ dilation and an erosion of the input with a given structuring element.
1641
+
1642
+ Parameters
1643
+ ----------
1644
+ input : array_like
1645
+ Array over which to compute the morphlogical gradient.
1646
+ size : tuple of ints
1647
+ Shape of a flat and full structuring element used for the mathematical
1648
+ morphology operations. Optional if `footprint` or `structure` is
1649
+ provided. A larger `size` yields a more blurred gradient.
1650
+ footprint : array of ints, optional
1651
+ Positions of non-infinite elements of a flat structuring element
1652
+ used for the morphology operations. Larger footprints
1653
+ give a more blurred morphological gradient.
1654
+ structure : array of ints, optional
1655
+ Structuring element used for the morphology operations. `structure` may
1656
+ be a non-flat structuring element. The `structure` array applies
1657
+ offsets to the pixels in a neighborhood (the offset is additive during
1658
+ dilation and subtractive during erosion)
1659
+ output : array, optional
1660
+ An array used for storing the output of the morphological gradient
1661
+ may be provided.
1662
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
1663
+ The `mode` parameter determines how the array borders are
1664
+ handled, where `cval` is the value when mode is equal to
1665
+ 'constant'. Default is 'reflect'
1666
+ cval : scalar, optional
1667
+ Value to fill past edges of input if `mode` is 'constant'. Default
1668
+ is 0.0.
1669
+ origin : scalar, optional
1670
+ The `origin` parameter controls the placement of the filter.
1671
+ Default 0
1672
+ axes : tuple of int or None
1673
+ The axes over which to apply the filter. If None, `input` is filtered
1674
+ along all axes. If an `origin` tuple is provided, its length must match
1675
+ the number of axes.
1676
+
1677
+ Returns
1678
+ -------
1679
+ morphological_gradient : ndarray
1680
+ Morphological gradient of `input`.
1681
+
1682
+ See Also
1683
+ --------
1684
+ grey_dilation, grey_erosion, gaussian_gradient_magnitude
1685
+
1686
+ Notes
1687
+ -----
1688
+ For a flat structuring element, the morphological gradient
1689
+ computed at a given point corresponds to the maximal difference
1690
+ between elements of the input among the elements covered by the
1691
+ structuring element centered on the point.
1692
+
1693
+ References
1694
+ ----------
1695
+ .. [1] https://en.wikipedia.org/wiki/Mathematical_morphology
1696
+
1697
+ Examples
1698
+ --------
1699
+ >>> from scipy import ndimage
1700
+ >>> import numpy as np
1701
+ >>> a = np.zeros((7,7), dtype=int)
1702
+ >>> a[2:5, 2:5] = 1
1703
+ >>> ndimage.morphological_gradient(a, size=(3,3))
1704
+ array([[0, 0, 0, 0, 0, 0, 0],
1705
+ [0, 1, 1, 1, 1, 1, 0],
1706
+ [0, 1, 1, 1, 1, 1, 0],
1707
+ [0, 1, 1, 0, 1, 1, 0],
1708
+ [0, 1, 1, 1, 1, 1, 0],
1709
+ [0, 1, 1, 1, 1, 1, 0],
1710
+ [0, 0, 0, 0, 0, 0, 0]])
1711
+ >>> # The morphological gradient is computed as the difference
1712
+ >>> # between a dilation and an erosion
1713
+ >>> ndimage.grey_dilation(a, size=(3,3)) -\\
1714
+ ... ndimage.grey_erosion(a, size=(3,3))
1715
+ array([[0, 0, 0, 0, 0, 0, 0],
1716
+ [0, 1, 1, 1, 1, 1, 0],
1717
+ [0, 1, 1, 1, 1, 1, 0],
1718
+ [0, 1, 1, 0, 1, 1, 0],
1719
+ [0, 1, 1, 1, 1, 1, 0],
1720
+ [0, 1, 1, 1, 1, 1, 0],
1721
+ [0, 0, 0, 0, 0, 0, 0]])
1722
+ >>> a = np.zeros((7,7), dtype=int)
1723
+ >>> a[2:5, 2:5] = 1
1724
+ >>> a[4,4] = 2; a[2,3] = 3
1725
+ >>> a
1726
+ array([[0, 0, 0, 0, 0, 0, 0],
1727
+ [0, 0, 0, 0, 0, 0, 0],
1728
+ [0, 0, 1, 3, 1, 0, 0],
1729
+ [0, 0, 1, 1, 1, 0, 0],
1730
+ [0, 0, 1, 1, 2, 0, 0],
1731
+ [0, 0, 0, 0, 0, 0, 0],
1732
+ [0, 0, 0, 0, 0, 0, 0]])
1733
+ >>> ndimage.morphological_gradient(a, size=(3,3))
1734
+ array([[0, 0, 0, 0, 0, 0, 0],
1735
+ [0, 1, 3, 3, 3, 1, 0],
1736
+ [0, 1, 3, 3, 3, 1, 0],
1737
+ [0, 1, 3, 2, 3, 2, 0],
1738
+ [0, 1, 1, 2, 2, 2, 0],
1739
+ [0, 1, 1, 2, 2, 2, 0],
1740
+ [0, 0, 0, 0, 0, 0, 0]])
1741
+
1742
+ """
1743
+ tmp = grey_dilation(input, size, footprint, structure, None, mode,
1744
+ cval, origin, axes=axes)
1745
+ if isinstance(output, np.ndarray):
1746
+ grey_erosion(input, size, footprint, structure, output, mode,
1747
+ cval, origin, axes=axes)
1748
+ return np.subtract(tmp, output, output)
1749
+ else:
1750
+ return (tmp - grey_erosion(input, size, footprint, structure,
1751
+ None, mode, cval, origin, axes=axes))
1752
+
1753
+
1754
+ def morphological_laplace(input, size=None, footprint=None, structure=None,
1755
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1756
+ axes=None):
1757
+ """
1758
+ Multidimensional morphological laplace.
1759
+
1760
+ Parameters
1761
+ ----------
1762
+ input : array_like
1763
+ Input.
1764
+ size : tuple of ints
1765
+ Shape of a flat and full structuring element used for the mathematical
1766
+ morphology operations. Optional if `footprint` or `structure` is
1767
+ provided.
1768
+ footprint : array of ints, optional
1769
+ Positions of non-infinite elements of a flat structuring element
1770
+ used for the morphology operations.
1771
+ structure : array of ints, optional
1772
+ Structuring element used for the morphology operations. `structure` may
1773
+ be a non-flat structuring element. The `structure` array applies
1774
+ offsets to the pixels in a neighborhood (the offset is additive during
1775
+ dilation and subtractive during erosion)
1776
+ output : ndarray, optional
1777
+ An output array can optionally be provided.
1778
+ mode : {'reflect','constant','nearest','mirror', 'wrap'}, optional
1779
+ The mode parameter determines how the array borders are handled.
1780
+ For 'constant' mode, values beyond borders are set to be `cval`.
1781
+ Default is 'reflect'.
1782
+ cval : scalar, optional
1783
+ Value to fill past edges of input if mode is 'constant'.
1784
+ Default is 0.0
1785
+ origin : origin, optional
1786
+ The origin parameter controls the placement of the filter.
1787
+ axes : tuple of int or None
1788
+ The axes over which to apply the filter. If None, `input` is filtered
1789
+ along all axes. If an `origin` tuple is provided, its length must match
1790
+ the number of axes.
1791
+
1792
+ Returns
1793
+ -------
1794
+ morphological_laplace : ndarray
1795
+ Output
1796
+
1797
+ """
1798
+ input = np.asarray(input)
1799
+ tmp1 = grey_dilation(input, size, footprint, structure, None, mode,
1800
+ cval, origin, axes=axes)
1801
+ if isinstance(output, np.ndarray):
1802
+ grey_erosion(input, size, footprint, structure, output, mode,
1803
+ cval, origin, axes=axes)
1804
+ np.add(tmp1, output, output)
1805
+ np.subtract(output, input, output)
1806
+ return np.subtract(output, input, output)
1807
+ else:
1808
+ tmp2 = grey_erosion(input, size, footprint, structure, None, mode,
1809
+ cval, origin, axes=axes)
1810
+ np.add(tmp1, tmp2, tmp2)
1811
+ np.subtract(tmp2, input, tmp2)
1812
+ np.subtract(tmp2, input, tmp2)
1813
+ return tmp2
1814
+
1815
+
1816
+ def white_tophat(input, size=None, footprint=None, structure=None,
1817
+ output=None, mode="reflect", cval=0.0, origin=0, *,
1818
+ axes=None):
1819
+ """
1820
+ Multidimensional white tophat filter.
1821
+
1822
+ Parameters
1823
+ ----------
1824
+ input : array_like
1825
+ Input.
1826
+ size : tuple of ints
1827
+ Shape of a flat and full structuring element used for the filter.
1828
+ Optional if `footprint` or `structure` is provided.
1829
+ footprint : array of ints, optional
1830
+ Positions of elements of a flat structuring element
1831
+ used for the white tophat filter.
1832
+ structure : array of ints, optional
1833
+ Structuring element used for the filter. `structure` may be a non-flat
1834
+ structuring element. The `structure` array applies offsets to the
1835
+ pixels in a neighborhood (the offset is additive during dilation and
1836
+ subtractive during erosion)
1837
+ output : array, optional
1838
+ An array used for storing the output of the filter may be provided.
1839
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
1840
+ The `mode` parameter determines how the array borders are
1841
+ handled, where `cval` is the value when mode is equal to
1842
+ 'constant'. Default is 'reflect'
1843
+ cval : scalar, optional
1844
+ Value to fill past edges of input if `mode` is 'constant'.
1845
+ Default is 0.0.
1846
+ origin : scalar, optional
1847
+ The `origin` parameter controls the placement of the filter.
1848
+ Default is 0.
1849
+ axes : tuple of int or None
1850
+ The axes over which to apply the filter. If None, `input` is filtered
1851
+ along all axes. If an `origin` tuple is provided, its length must match
1852
+ the number of axes.
1853
+
1854
+ Returns
1855
+ -------
1856
+ output : ndarray
1857
+ Result of the filter of `input` with `structure`.
1858
+
1859
+ See Also
1860
+ --------
1861
+ black_tophat
1862
+
1863
+ Examples
1864
+ --------
1865
+ Subtract gray background from a bright peak.
1866
+
1867
+ >>> from scipy.ndimage import generate_binary_structure, white_tophat
1868
+ >>> import numpy as np
1869
+ >>> square = generate_binary_structure(rank=2, connectivity=3)
1870
+ >>> bright_on_gray = np.array([[2, 3, 3, 3, 2],
1871
+ ... [3, 4, 5, 4, 3],
1872
+ ... [3, 5, 9, 5, 3],
1873
+ ... [3, 4, 5, 4, 3],
1874
+ ... [2, 3, 3, 3, 2]])
1875
+ >>> white_tophat(input=bright_on_gray, structure=square)
1876
+ array([[0, 0, 0, 0, 0],
1877
+ [0, 0, 1, 0, 0],
1878
+ [0, 1, 5, 1, 0],
1879
+ [0, 0, 1, 0, 0],
1880
+ [0, 0, 0, 0, 0]])
1881
+
1882
+ """
1883
+ input = np.asarray(input)
1884
+
1885
+ if (size is not None) and (footprint is not None):
1886
+ warnings.warn("ignoring size because footprint is set",
1887
+ UserWarning, stacklevel=2)
1888
+ tmp = grey_erosion(input, size, footprint, structure, None, mode,
1889
+ cval, origin, axes=axes)
1890
+ tmp = grey_dilation(tmp, size, footprint, structure, output, mode,
1891
+ cval, origin, axes=axes)
1892
+ if tmp is None:
1893
+ tmp = output
1894
+
1895
+ if input.dtype == np.bool_ and tmp.dtype == np.bool_:
1896
+ np.bitwise_xor(input, tmp, out=tmp)
1897
+ else:
1898
+ np.subtract(input, tmp, out=tmp)
1899
+ return tmp
1900
+
1901
+
1902
+ def black_tophat(input, size=None, footprint=None, structure=None, output=None,
1903
+ mode="reflect", cval=0.0, origin=0, *, axes=None):
1904
+ """
1905
+ Multidimensional black tophat filter.
1906
+
1907
+ Parameters
1908
+ ----------
1909
+ input : array_like
1910
+ Input.
1911
+ size : tuple of ints, optional
1912
+ Shape of a flat and full structuring element used for the filter.
1913
+ Optional if `footprint` or `structure` is provided.
1914
+ footprint : array of ints, optional
1915
+ Positions of non-infinite elements of a flat structuring element
1916
+ used for the black tophat filter.
1917
+ structure : array of ints, optional
1918
+ Structuring element used for the filter. `structure` may be a non-flat
1919
+ structuring element. The `structure` array applies offsets to the
1920
+ pixels in a neighborhood (the offset is additive during dilation and
1921
+ subtractive during erosion)
1922
+ output : array, optional
1923
+ An array used for storing the output of the filter may be provided.
1924
+ mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
1925
+ The `mode` parameter determines how the array borders are
1926
+ handled, where `cval` is the value when mode is equal to
1927
+ 'constant'. Default is 'reflect'
1928
+ cval : scalar, optional
1929
+ Value to fill past edges of input if `mode` is 'constant'. Default
1930
+ is 0.0.
1931
+ origin : scalar, optional
1932
+ The `origin` parameter controls the placement of the filter.
1933
+ Default 0
1934
+ axes : tuple of int or None
1935
+ The axes over which to apply the filter. If None, `input` is filtered
1936
+ along all axes. If an `origin` tuple is provided, its length must match
1937
+ the number of axes.
1938
+
1939
+ Returns
1940
+ -------
1941
+ black_tophat : ndarray
1942
+ Result of the filter of `input` with `structure`.
1943
+
1944
+ See Also
1945
+ --------
1946
+ white_tophat, grey_opening, grey_closing
1947
+
1948
+ Examples
1949
+ --------
1950
+ Change dark peak to bright peak and subtract background.
1951
+
1952
+ >>> from scipy.ndimage import generate_binary_structure, black_tophat
1953
+ >>> import numpy as np
1954
+ >>> square = generate_binary_structure(rank=2, connectivity=3)
1955
+ >>> dark_on_gray = np.array([[7, 6, 6, 6, 7],
1956
+ ... [6, 5, 4, 5, 6],
1957
+ ... [6, 4, 0, 4, 6],
1958
+ ... [6, 5, 4, 5, 6],
1959
+ ... [7, 6, 6, 6, 7]])
1960
+ >>> black_tophat(input=dark_on_gray, structure=square)
1961
+ array([[0, 0, 0, 0, 0],
1962
+ [0, 0, 1, 0, 0],
1963
+ [0, 1, 5, 1, 0],
1964
+ [0, 0, 1, 0, 0],
1965
+ [0, 0, 0, 0, 0]])
1966
+
1967
+ """
1968
+ input = np.asarray(input)
1969
+
1970
+ if (size is not None) and (footprint is not None):
1971
+ warnings.warn("ignoring size because footprint is set",
1972
+ UserWarning, stacklevel=2)
1973
+ tmp = grey_dilation(input, size, footprint, structure, None, mode,
1974
+ cval, origin, axes=axes)
1975
+ tmp = grey_erosion(tmp, size, footprint, structure, output, mode,
1976
+ cval, origin, axes=axes)
1977
+ if tmp is None:
1978
+ tmp = output
1979
+
1980
+ if input.dtype == np.bool_ and tmp.dtype == np.bool_:
1981
+ np.bitwise_xor(tmp, input, out=tmp)
1982
+ else:
1983
+ np.subtract(tmp, input, out=tmp)
1984
+ return tmp
1985
+
1986
+
1987
+ def distance_transform_bf(input, metric="euclidean", sampling=None,
1988
+ return_distances=True, return_indices=False,
1989
+ distances=None, indices=None):
1990
+ """
1991
+ Distance transform function by a brute force algorithm.
1992
+
1993
+ This function calculates the distance transform of the `input`, by
1994
+ replacing each foreground (non-zero) element, with its
1995
+ shortest distance to the background (any zero-valued element).
1996
+
1997
+ In addition to the distance transform, the feature transform can
1998
+ be calculated. In this case the index of the closest background
1999
+ element to each foreground element is returned in a separate array.
2000
+
2001
+ Parameters
2002
+ ----------
2003
+ input : array_like
2004
+ Input
2005
+ metric : {'euclidean', 'taxicab', 'chessboard'}, optional
2006
+ 'cityblock' and 'manhattan' are also valid, and map to 'taxicab'.
2007
+ The default is 'euclidean'.
2008
+ sampling : float, or sequence of float, optional
2009
+ This parameter is only used when `metric` is 'euclidean'.
2010
+ Spacing of elements along each dimension. If a sequence, must be of
2011
+ length equal to the input rank; if a single number, this is used for
2012
+ all axes. If not specified, a grid spacing of unity is implied.
2013
+ return_distances : bool, optional
2014
+ Whether to calculate the distance transform.
2015
+ Default is True.
2016
+ return_indices : bool, optional
2017
+ Whether to calculate the feature transform.
2018
+ Default is False.
2019
+ distances : ndarray, optional
2020
+ An output array to store the calculated distance transform, instead of
2021
+ returning it.
2022
+ `return_distances` must be True.
2023
+ It must be the same shape as `input`, and of type float64 if `metric`
2024
+ is 'euclidean', uint32 otherwise.
2025
+ indices : int32 ndarray, optional
2026
+ An output array to store the calculated feature transform, instead of
2027
+ returning it.
2028
+ `return_indicies` must be True.
2029
+ Its shape must be ``(input.ndim,) + input.shape``.
2030
+
2031
+ Returns
2032
+ -------
2033
+ distances : ndarray, optional
2034
+ The calculated distance transform. Returned only when
2035
+ `return_distances` is True and `distances` is not supplied.
2036
+ It will have the same shape as the input array.
2037
+ indices : int32 ndarray, optional
2038
+ The calculated feature transform. It has an input-shaped array for each
2039
+ dimension of the input. See distance_transform_edt documentation for an
2040
+ example.
2041
+ Returned only when `return_indices` is True and `indices` is not
2042
+ supplied.
2043
+
2044
+ See Also
2045
+ --------
2046
+ distance_transform_cdt : Faster distance transform for taxicab and
2047
+ chessboard metrics
2048
+ distance_transform_edt : Faster distance transform for euclidean metric
2049
+
2050
+ Notes
2051
+ -----
2052
+ This function employs a slow brute force algorithm. See also the
2053
+ function `distance_transform_cdt` for more efficient taxicab [1]_ and
2054
+ chessboard algorithms [2]_.
2055
+
2056
+ References
2057
+ ----------
2058
+ .. [1] Taxicab distance. Wikipedia, 2023.
2059
+ https://en.wikipedia.org/wiki/Taxicab_geometry
2060
+ .. [2] Chessboard distance. Wikipedia, 2023.
2061
+ https://en.wikipedia.org/wiki/Chebyshev_distance
2062
+
2063
+ Examples
2064
+ --------
2065
+ Import the necessary modules.
2066
+
2067
+ >>> import numpy as np
2068
+ >>> from scipy.ndimage import distance_transform_bf
2069
+ >>> import matplotlib.pyplot as plt
2070
+ >>> from mpl_toolkits.axes_grid1 import ImageGrid
2071
+
2072
+ First, we create a toy binary image.
2073
+
2074
+ >>> def add_circle(center_x, center_y, radius, image, fillvalue=1):
2075
+ ... # fill circular area with 1
2076
+ ... xx, yy = np.mgrid[:image.shape[0], :image.shape[1]]
2077
+ ... circle = (xx - center_x) ** 2 + (yy - center_y) ** 2
2078
+ ... circle_shape = np.sqrt(circle) < radius
2079
+ ... image[circle_shape] = fillvalue
2080
+ ... return image
2081
+ >>> image = np.zeros((100, 100), dtype=np.uint8)
2082
+ >>> image[35:65, 20:80] = 1
2083
+ >>> image = add_circle(28, 65, 10, image)
2084
+ >>> image = add_circle(37, 30, 10, image)
2085
+ >>> image = add_circle(70, 45, 20, image)
2086
+ >>> image = add_circle(45, 80, 10, image)
2087
+
2088
+ Next, we set up the figure.
2089
+
2090
+ >>> fig = plt.figure(figsize=(8, 8)) # set up the figure structure
2091
+ >>> grid = ImageGrid(fig, 111, nrows_ncols=(2, 2), axes_pad=(0.4, 0.3),
2092
+ ... label_mode="1", share_all=True,
2093
+ ... cbar_location="right", cbar_mode="each",
2094
+ ... cbar_size="7%", cbar_pad="2%")
2095
+ >>> for ax in grid:
2096
+ ... ax.axis('off') # remove axes from images
2097
+
2098
+ The top left image is the original binary image.
2099
+
2100
+ >>> binary_image = grid[0].imshow(image, cmap='gray')
2101
+ >>> cbar_binary_image = grid.cbar_axes[0].colorbar(binary_image)
2102
+ >>> cbar_binary_image.set_ticks([0, 1])
2103
+ >>> grid[0].set_title("Binary image: foreground in white")
2104
+
2105
+ The distance transform calculates the distance between foreground pixels
2106
+ and the image background according to a distance metric. Available metrics
2107
+ in `distance_transform_bf` are: ``euclidean`` (default), ``taxicab``
2108
+ and ``chessboard``. The top right image contains the distance transform
2109
+ based on the ``euclidean`` metric.
2110
+
2111
+ >>> distance_transform_euclidean = distance_transform_bf(image)
2112
+ >>> euclidean_transform = grid[1].imshow(distance_transform_euclidean,
2113
+ ... cmap='gray')
2114
+ >>> cbar_euclidean = grid.cbar_axes[1].colorbar(euclidean_transform)
2115
+ >>> colorbar_ticks = [0, 10, 20]
2116
+ >>> cbar_euclidean.set_ticks(colorbar_ticks)
2117
+ >>> grid[1].set_title("Euclidean distance")
2118
+
2119
+ The lower left image contains the distance transform using the ``taxicab``
2120
+ metric.
2121
+
2122
+ >>> distance_transform_taxicab = distance_transform_bf(image,
2123
+ ... metric='taxicab')
2124
+ >>> taxicab_transformation = grid[2].imshow(distance_transform_taxicab,
2125
+ ... cmap='gray')
2126
+ >>> cbar_taxicab = grid.cbar_axes[2].colorbar(taxicab_transformation)
2127
+ >>> cbar_taxicab.set_ticks(colorbar_ticks)
2128
+ >>> grid[2].set_title("Taxicab distance")
2129
+
2130
+ Finally, the lower right image contains the distance transform using the
2131
+ ``chessboard`` metric.
2132
+
2133
+ >>> distance_transform_cb = distance_transform_bf(image,
2134
+ ... metric='chessboard')
2135
+ >>> chessboard_transformation = grid[3].imshow(distance_transform_cb,
2136
+ ... cmap='gray')
2137
+ >>> cbar_taxicab = grid.cbar_axes[3].colorbar(chessboard_transformation)
2138
+ >>> cbar_taxicab.set_ticks(colorbar_ticks)
2139
+ >>> grid[3].set_title("Chessboard distance")
2140
+ >>> plt.show()
2141
+
2142
+ """
2143
+ ft_inplace = isinstance(indices, np.ndarray)
2144
+ dt_inplace = isinstance(distances, np.ndarray)
2145
+ _distance_tranform_arg_check(
2146
+ dt_inplace, ft_inplace, return_distances, return_indices
2147
+ )
2148
+
2149
+ tmp1 = np.asarray(input) != 0
2150
+ struct = generate_binary_structure(tmp1.ndim, tmp1.ndim)
2151
+ tmp2 = binary_dilation(tmp1, struct)
2152
+ tmp2 = np.logical_xor(tmp1, tmp2)
2153
+ tmp1 = tmp1.astype(np.int8) - tmp2.astype(np.int8)
2154
+ metric = metric.lower()
2155
+ if metric == 'euclidean':
2156
+ metric = 1
2157
+ elif metric in ['taxicab', 'cityblock', 'manhattan']:
2158
+ metric = 2
2159
+ elif metric == 'chessboard':
2160
+ metric = 3
2161
+ else:
2162
+ raise RuntimeError('distance metric not supported')
2163
+ if sampling is not None:
2164
+ sampling = _ni_support._normalize_sequence(sampling, tmp1.ndim)
2165
+ sampling = np.asarray(sampling, dtype=np.float64)
2166
+ if not sampling.flags.contiguous:
2167
+ sampling = sampling.copy()
2168
+ if return_indices:
2169
+ ft = np.zeros(tmp1.shape, dtype=np.int32)
2170
+ else:
2171
+ ft = None
2172
+ if return_distances:
2173
+ if distances is None:
2174
+ if metric == 1:
2175
+ dt = np.zeros(tmp1.shape, dtype=np.float64)
2176
+ else:
2177
+ dt = np.zeros(tmp1.shape, dtype=np.uint32)
2178
+ else:
2179
+ if distances.shape != tmp1.shape:
2180
+ raise RuntimeError('distances array has wrong shape')
2181
+ if metric == 1:
2182
+ if distances.dtype.type != np.float64:
2183
+ raise RuntimeError('distances array must be float64')
2184
+ else:
2185
+ if distances.dtype.type != np.uint32:
2186
+ raise RuntimeError('distances array must be uint32')
2187
+ dt = distances
2188
+ else:
2189
+ dt = None
2190
+
2191
+ _nd_image.distance_transform_bf(tmp1, metric, sampling, dt, ft)
2192
+ if return_indices:
2193
+ if isinstance(indices, np.ndarray):
2194
+ if indices.dtype.type != np.int32:
2195
+ raise RuntimeError('indices array must be int32')
2196
+ if indices.shape != (tmp1.ndim,) + tmp1.shape:
2197
+ raise RuntimeError('indices array has wrong shape')
2198
+ tmp2 = indices
2199
+ else:
2200
+ tmp2 = np.indices(tmp1.shape, dtype=np.int32)
2201
+ ft = np.ravel(ft)
2202
+ for ii in range(tmp2.shape[0]):
2203
+ rtmp = np.ravel(tmp2[ii, ...])[ft]
2204
+ rtmp.shape = tmp1.shape
2205
+ tmp2[ii, ...] = rtmp
2206
+ ft = tmp2
2207
+
2208
+ # construct and return the result
2209
+ result = []
2210
+ if return_distances and not dt_inplace:
2211
+ result.append(dt)
2212
+ if return_indices and not ft_inplace:
2213
+ result.append(ft)
2214
+
2215
+ if len(result) == 2:
2216
+ return tuple(result)
2217
+ elif len(result) == 1:
2218
+ return result[0]
2219
+ else:
2220
+ return None
2221
+
2222
+
2223
+ def distance_transform_cdt(input, metric='chessboard', return_distances=True,
2224
+ return_indices=False, distances=None, indices=None):
2225
+ """
2226
+ Distance transform for chamfer type of transforms.
2227
+
2228
+ This function calculates the distance transform of the `input`, by
2229
+ replacing each foreground (non-zero) element, with its
2230
+ shortest distance to the background (any zero-valued element).
2231
+
2232
+ In addition to the distance transform, the feature transform can
2233
+ be calculated. In this case the index of the closest background
2234
+ element to each foreground element is returned in a separate array.
2235
+
2236
+ Parameters
2237
+ ----------
2238
+ input : array_like
2239
+ Input. Values of 0 are treated as background.
2240
+ metric : {'chessboard', 'taxicab'} or array_like, optional
2241
+ The `metric` determines the type of chamfering that is done. If the
2242
+ `metric` is equal to 'taxicab' a structure is generated using
2243
+ `generate_binary_structure` with a squared distance equal to 1. If
2244
+ the `metric` is equal to 'chessboard', a `metric` is generated
2245
+ using `generate_binary_structure` with a squared distance equal to
2246
+ the dimensionality of the array. These choices correspond to the
2247
+ common interpretations of the 'taxicab' and the 'chessboard'
2248
+ distance metrics in two dimensions.
2249
+ A custom metric may be provided, in the form of a matrix where
2250
+ each dimension has a length of three.
2251
+ 'cityblock' and 'manhattan' are also valid, and map to 'taxicab'.
2252
+ The default is 'chessboard'.
2253
+ return_distances : bool, optional
2254
+ Whether to calculate the distance transform.
2255
+ Default is True.
2256
+ return_indices : bool, optional
2257
+ Whether to calculate the feature transform.
2258
+ Default is False.
2259
+ distances : int32 ndarray, optional
2260
+ An output array to store the calculated distance transform, instead of
2261
+ returning it.
2262
+ `return_distances` must be True.
2263
+ It must be the same shape as `input`.
2264
+ indices : int32 ndarray, optional
2265
+ An output array to store the calculated feature transform, instead of
2266
+ returning it.
2267
+ `return_indicies` must be True.
2268
+ Its shape must be ``(input.ndim,) + input.shape``.
2269
+
2270
+ Returns
2271
+ -------
2272
+ distances : int32 ndarray, optional
2273
+ The calculated distance transform. Returned only when
2274
+ `return_distances` is True, and `distances` is not supplied.
2275
+ It will have the same shape as the input array.
2276
+ indices : int32 ndarray, optional
2277
+ The calculated feature transform. It has an input-shaped array for each
2278
+ dimension of the input. See distance_transform_edt documentation for an
2279
+ example.
2280
+ Returned only when `return_indices` is True, and `indices` is not
2281
+ supplied.
2282
+
2283
+ See Also
2284
+ --------
2285
+ distance_transform_edt : Fast distance transform for euclidean metric
2286
+ distance_transform_bf : Distance transform for different metrics using
2287
+ a slower brute force algorithm
2288
+
2289
+ Examples
2290
+ --------
2291
+ Import the necessary modules.
2292
+
2293
+ >>> import numpy as np
2294
+ >>> from scipy.ndimage import distance_transform_cdt
2295
+ >>> import matplotlib.pyplot as plt
2296
+ >>> from mpl_toolkits.axes_grid1 import ImageGrid
2297
+
2298
+ First, we create a toy binary image.
2299
+
2300
+ >>> def add_circle(center_x, center_y, radius, image, fillvalue=1):
2301
+ ... # fill circular area with 1
2302
+ ... xx, yy = np.mgrid[:image.shape[0], :image.shape[1]]
2303
+ ... circle = (xx - center_x) ** 2 + (yy - center_y) ** 2
2304
+ ... circle_shape = np.sqrt(circle) < radius
2305
+ ... image[circle_shape] = fillvalue
2306
+ ... return image
2307
+ >>> image = np.zeros((100, 100), dtype=np.uint8)
2308
+ >>> image[35:65, 20:80] = 1
2309
+ >>> image = add_circle(28, 65, 10, image)
2310
+ >>> image = add_circle(37, 30, 10, image)
2311
+ >>> image = add_circle(70, 45, 20, image)
2312
+ >>> image = add_circle(45, 80, 10, image)
2313
+
2314
+ Next, we set up the figure.
2315
+
2316
+ >>> fig = plt.figure(figsize=(5, 15))
2317
+ >>> grid = ImageGrid(fig, 111, nrows_ncols=(3, 1), axes_pad=(0.5, 0.3),
2318
+ ... label_mode="1", share_all=True,
2319
+ ... cbar_location="right", cbar_mode="each",
2320
+ ... cbar_size="7%", cbar_pad="2%")
2321
+ >>> for ax in grid:
2322
+ ... ax.axis('off')
2323
+ >>> top, middle, bottom = grid
2324
+ >>> colorbar_ticks = [0, 10, 20]
2325
+
2326
+ The top image contains the original binary image.
2327
+
2328
+ >>> binary_image = top.imshow(image, cmap='gray')
2329
+ >>> cbar_binary_image = top.cax.colorbar(binary_image)
2330
+ >>> cbar_binary_image.set_ticks([0, 1])
2331
+ >>> top.set_title("Binary image: foreground in white")
2332
+
2333
+ The middle image contains the distance transform using the ``taxicab``
2334
+ metric.
2335
+
2336
+ >>> distance_taxicab = distance_transform_cdt(image, metric="taxicab")
2337
+ >>> taxicab_transform = middle.imshow(distance_taxicab, cmap='gray')
2338
+ >>> cbar_taxicab = middle.cax.colorbar(taxicab_transform)
2339
+ >>> cbar_taxicab.set_ticks(colorbar_ticks)
2340
+ >>> middle.set_title("Taxicab metric")
2341
+
2342
+ The bottom image contains the distance transform using the ``chessboard``
2343
+ metric.
2344
+
2345
+ >>> distance_chessboard = distance_transform_cdt(image,
2346
+ ... metric="chessboard")
2347
+ >>> chessboard_transform = bottom.imshow(distance_chessboard, cmap='gray')
2348
+ >>> cbar_chessboard = bottom.cax.colorbar(chessboard_transform)
2349
+ >>> cbar_chessboard.set_ticks(colorbar_ticks)
2350
+ >>> bottom.set_title("Chessboard metric")
2351
+ >>> plt.tight_layout()
2352
+ >>> plt.show()
2353
+
2354
+ """
2355
+ ft_inplace = isinstance(indices, np.ndarray)
2356
+ dt_inplace = isinstance(distances, np.ndarray)
2357
+ _distance_tranform_arg_check(
2358
+ dt_inplace, ft_inplace, return_distances, return_indices
2359
+ )
2360
+ input = np.asarray(input)
2361
+ if isinstance(metric, str):
2362
+ if metric in ['taxicab', 'cityblock', 'manhattan']:
2363
+ rank = input.ndim
2364
+ metric = generate_binary_structure(rank, 1)
2365
+ elif metric == 'chessboard':
2366
+ rank = input.ndim
2367
+ metric = generate_binary_structure(rank, rank)
2368
+ else:
2369
+ raise ValueError('invalid metric provided')
2370
+ else:
2371
+ try:
2372
+ metric = np.asarray(metric)
2373
+ except Exception as e:
2374
+ raise ValueError('invalid metric provided') from e
2375
+ for s in metric.shape:
2376
+ if s != 3:
2377
+ raise ValueError('metric sizes must be equal to 3')
2378
+
2379
+ if not metric.flags.contiguous:
2380
+ metric = metric.copy()
2381
+ if dt_inplace:
2382
+ if distances.dtype.type != np.int32:
2383
+ raise ValueError('distances must be of int32 type')
2384
+ if distances.shape != input.shape:
2385
+ raise ValueError('distances has wrong shape')
2386
+ dt = distances
2387
+ dt[...] = np.where(input, -1, 0).astype(np.int32)
2388
+ else:
2389
+ dt = np.where(input, -1, 0).astype(np.int32)
2390
+
2391
+ rank = dt.ndim
2392
+ if return_indices:
2393
+ ft = np.arange(dt.size, dtype=np.int32)
2394
+ ft.shape = dt.shape
2395
+ else:
2396
+ ft = None
2397
+
2398
+ _nd_image.distance_transform_op(metric, dt, ft)
2399
+ dt = dt[tuple([slice(None, None, -1)] * rank)]
2400
+ if return_indices:
2401
+ ft = ft[tuple([slice(None, None, -1)] * rank)]
2402
+ _nd_image.distance_transform_op(metric, dt, ft)
2403
+ dt = dt[tuple([slice(None, None, -1)] * rank)]
2404
+ if return_indices:
2405
+ ft = ft[tuple([slice(None, None, -1)] * rank)]
2406
+ ft = np.ravel(ft)
2407
+ if ft_inplace:
2408
+ if indices.dtype.type != np.int32:
2409
+ raise ValueError('indices array must be int32')
2410
+ if indices.shape != (dt.ndim,) + dt.shape:
2411
+ raise ValueError('indices array has wrong shape')
2412
+ tmp = indices
2413
+ else:
2414
+ tmp = np.indices(dt.shape, dtype=np.int32)
2415
+ for ii in range(tmp.shape[0]):
2416
+ rtmp = np.ravel(tmp[ii, ...])[ft]
2417
+ rtmp.shape = dt.shape
2418
+ tmp[ii, ...] = rtmp
2419
+ ft = tmp
2420
+
2421
+ # construct and return the result
2422
+ result = []
2423
+ if return_distances and not dt_inplace:
2424
+ result.append(dt)
2425
+ if return_indices and not ft_inplace:
2426
+ result.append(ft)
2427
+
2428
+ if len(result) == 2:
2429
+ return tuple(result)
2430
+ elif len(result) == 1:
2431
+ return result[0]
2432
+ else:
2433
+ return None
2434
+
2435
+
2436
+ def distance_transform_edt(input, sampling=None, return_distances=True,
2437
+ return_indices=False, distances=None, indices=None):
2438
+ """
2439
+ Exact Euclidean distance transform.
2440
+
2441
+ This function calculates the distance transform of the `input`, by
2442
+ replacing each foreground (non-zero) element, with its
2443
+ shortest distance to the background (any zero-valued element).
2444
+
2445
+ In addition to the distance transform, the feature transform can
2446
+ be calculated. In this case the index of the closest background
2447
+ element to each foreground element is returned in a separate array.
2448
+
2449
+ Parameters
2450
+ ----------
2451
+ input : array_like
2452
+ Input data to transform. Can be any type but will be converted
2453
+ into binary: 1 wherever input equates to True, 0 elsewhere.
2454
+ sampling : float, or sequence of float, optional
2455
+ Spacing of elements along each dimension. If a sequence, must be of
2456
+ length equal to the input rank; if a single number, this is used for
2457
+ all axes. If not specified, a grid spacing of unity is implied.
2458
+ return_distances : bool, optional
2459
+ Whether to calculate the distance transform.
2460
+ Default is True.
2461
+ return_indices : bool, optional
2462
+ Whether to calculate the feature transform.
2463
+ Default is False.
2464
+ distances : float64 ndarray, optional
2465
+ An output array to store the calculated distance transform, instead of
2466
+ returning it.
2467
+ `return_distances` must be True.
2468
+ It must be the same shape as `input`.
2469
+ indices : int32 ndarray, optional
2470
+ An output array to store the calculated feature transform, instead of
2471
+ returning it.
2472
+ `return_indicies` must be True.
2473
+ Its shape must be ``(input.ndim,) + input.shape``.
2474
+
2475
+ Returns
2476
+ -------
2477
+ distances : float64 ndarray, optional
2478
+ The calculated distance transform. Returned only when
2479
+ `return_distances` is True and `distances` is not supplied.
2480
+ It will have the same shape as the input array.
2481
+ indices : int32 ndarray, optional
2482
+ The calculated feature transform. It has an input-shaped array for each
2483
+ dimension of the input. See example below.
2484
+ Returned only when `return_indices` is True and `indices` is not
2485
+ supplied.
2486
+
2487
+ Notes
2488
+ -----
2489
+ The Euclidean distance transform gives values of the Euclidean
2490
+ distance::
2491
+
2492
+ n
2493
+ y_i = sqrt(sum (x[i]-b[i])**2)
2494
+ i
2495
+
2496
+ where b[i] is the background point (value 0) with the smallest
2497
+ Euclidean distance to input points x[i], and n is the
2498
+ number of dimensions.
2499
+
2500
+ Examples
2501
+ --------
2502
+ >>> from scipy import ndimage
2503
+ >>> import numpy as np
2504
+ >>> a = np.array(([0,1,1,1,1],
2505
+ ... [0,0,1,1,1],
2506
+ ... [0,1,1,1,1],
2507
+ ... [0,1,1,1,0],
2508
+ ... [0,1,1,0,0]))
2509
+ >>> ndimage.distance_transform_edt(a)
2510
+ array([[ 0. , 1. , 1.4142, 2.2361, 3. ],
2511
+ [ 0. , 0. , 1. , 2. , 2. ],
2512
+ [ 0. , 1. , 1.4142, 1.4142, 1. ],
2513
+ [ 0. , 1. , 1.4142, 1. , 0. ],
2514
+ [ 0. , 1. , 1. , 0. , 0. ]])
2515
+
2516
+ With a sampling of 2 units along x, 1 along y:
2517
+
2518
+ >>> ndimage.distance_transform_edt(a, sampling=[2,1])
2519
+ array([[ 0. , 1. , 2. , 2.8284, 3.6056],
2520
+ [ 0. , 0. , 1. , 2. , 3. ],
2521
+ [ 0. , 1. , 2. , 2.2361, 2. ],
2522
+ [ 0. , 1. , 2. , 1. , 0. ],
2523
+ [ 0. , 1. , 1. , 0. , 0. ]])
2524
+
2525
+ Asking for indices as well:
2526
+
2527
+ >>> edt, inds = ndimage.distance_transform_edt(a, return_indices=True)
2528
+ >>> inds
2529
+ array([[[0, 0, 1, 1, 3],
2530
+ [1, 1, 1, 1, 3],
2531
+ [2, 2, 1, 3, 3],
2532
+ [3, 3, 4, 4, 3],
2533
+ [4, 4, 4, 4, 4]],
2534
+ [[0, 0, 1, 1, 4],
2535
+ [0, 1, 1, 1, 4],
2536
+ [0, 0, 1, 4, 4],
2537
+ [0, 0, 3, 3, 4],
2538
+ [0, 0, 3, 3, 4]]], dtype=int32)
2539
+
2540
+ With arrays provided for inplace outputs:
2541
+
2542
+ >>> indices = np.zeros(((np.ndim(a),) + a.shape), dtype=np.int32)
2543
+ >>> ndimage.distance_transform_edt(a, return_indices=True, indices=indices)
2544
+ array([[ 0. , 1. , 1.4142, 2.2361, 3. ],
2545
+ [ 0. , 0. , 1. , 2. , 2. ],
2546
+ [ 0. , 1. , 1.4142, 1.4142, 1. ],
2547
+ [ 0. , 1. , 1.4142, 1. , 0. ],
2548
+ [ 0. , 1. , 1. , 0. , 0. ]])
2549
+ >>> indices
2550
+ array([[[0, 0, 1, 1, 3],
2551
+ [1, 1, 1, 1, 3],
2552
+ [2, 2, 1, 3, 3],
2553
+ [3, 3, 4, 4, 3],
2554
+ [4, 4, 4, 4, 4]],
2555
+ [[0, 0, 1, 1, 4],
2556
+ [0, 1, 1, 1, 4],
2557
+ [0, 0, 1, 4, 4],
2558
+ [0, 0, 3, 3, 4],
2559
+ [0, 0, 3, 3, 4]]], dtype=int32)
2560
+
2561
+ """
2562
+ ft_inplace = isinstance(indices, np.ndarray)
2563
+ dt_inplace = isinstance(distances, np.ndarray)
2564
+ _distance_tranform_arg_check(
2565
+ dt_inplace, ft_inplace, return_distances, return_indices
2566
+ )
2567
+
2568
+ # calculate the feature transform
2569
+ input = np.atleast_1d(np.where(input, 1, 0).astype(np.int8))
2570
+ if sampling is not None:
2571
+ sampling = _ni_support._normalize_sequence(sampling, input.ndim)
2572
+ sampling = np.asarray(sampling, dtype=np.float64)
2573
+ if not sampling.flags.contiguous:
2574
+ sampling = sampling.copy()
2575
+
2576
+ if ft_inplace:
2577
+ ft = indices
2578
+ if ft.shape != (input.ndim,) + input.shape:
2579
+ raise RuntimeError('indices array has wrong shape')
2580
+ if ft.dtype.type != np.int32:
2581
+ raise RuntimeError('indices array must be int32')
2582
+ else:
2583
+ ft = np.zeros((input.ndim,) + input.shape, dtype=np.int32)
2584
+
2585
+ _nd_image.euclidean_feature_transform(input, sampling, ft)
2586
+ # if requested, calculate the distance transform
2587
+ if return_distances:
2588
+ dt = ft - np.indices(input.shape, dtype=ft.dtype)
2589
+ dt = dt.astype(np.float64)
2590
+ if sampling is not None:
2591
+ for ii in range(len(sampling)):
2592
+ dt[ii, ...] *= sampling[ii]
2593
+ np.multiply(dt, dt, dt)
2594
+ if dt_inplace:
2595
+ dt = np.add.reduce(dt, axis=0)
2596
+ if distances.shape != dt.shape:
2597
+ raise RuntimeError('distances array has wrong shape')
2598
+ if distances.dtype.type != np.float64:
2599
+ raise RuntimeError('distances array must be float64')
2600
+ np.sqrt(dt, distances)
2601
+ else:
2602
+ dt = np.add.reduce(dt, axis=0)
2603
+ dt = np.sqrt(dt)
2604
+
2605
+ # construct and return the result
2606
+ result = []
2607
+ if return_distances and not dt_inplace:
2608
+ result.append(dt)
2609
+ if return_indices and not ft_inplace:
2610
+ result.append(ft)
2611
+
2612
+ if len(result) == 2:
2613
+ return tuple(result)
2614
+ elif len(result) == 1:
2615
+ return result[0]
2616
+ else:
2617
+ return None
2618
+
2619
+
2620
+ def _distance_tranform_arg_check(distances_out, indices_out,
2621
+ return_distances, return_indices):
2622
+ """Raise a RuntimeError if the arguments are invalid"""
2623
+ error_msgs = []
2624
+ if (not return_distances) and (not return_indices):
2625
+ error_msgs.append(
2626
+ 'at least one of return_distances/return_indices must be True')
2627
+ if distances_out and not return_distances:
2628
+ error_msgs.append(
2629
+ 'return_distances must be True if distances is supplied'
2630
+ )
2631
+ if indices_out and not return_indices:
2632
+ error_msgs.append('return_indices must be True if indices is supplied')
2633
+ if error_msgs:
2634
+ raise RuntimeError(', '.join(error_msgs))