matplotlib-rs 0.0.8__cp315-cp315-win_amd64.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 (352) hide show
  1. docs/releases/0.0.1.md +268 -0
  2. docs/releases/0.0.2.md +69 -0
  3. docs/releases/0.0.3.md +80 -0
  4. docs/releases/0.0.4.md +73 -0
  5. docs/releases/0.0.5.md +24 -0
  6. docs/releases/0.0.6.md +24 -0
  7. docs/releases/0.0.7.md +24 -0
  8. docs/releases/0.0.8.md +16 -0
  9. licenses/LICENSE_CONTOURPY +29 -0
  10. licenses/LICENSE_CYCLER +27 -0
  11. licenses/LICENSE_DATEUTIL +54 -0
  12. licenses/LICENSE_KIWISOLVER +71 -0
  13. licenses/LICENSE_LIBWEBP +56 -0
  14. licenses/LICENSE_MATPLOTLIB +1253 -0
  15. licenses/LICENSE_PYPARSING +20 -0
  16. licenses/LICENSE_QHULL +39 -0
  17. licenses/LICENSE_SIX +18 -0
  18. matplotlib_rs/__init__.py +1683 -0
  19. matplotlib_rs/__main__.py +27 -0
  20. matplotlib_rs/_afm.py +500 -0
  21. matplotlib_rs/_animation_data.py +263 -0
  22. matplotlib_rs/_api/__init__.py +495 -0
  23. matplotlib_rs/_api/deprecation.py +534 -0
  24. matplotlib_rs/_axis_py.py +2991 -0
  25. matplotlib_rs/_blocking_input.py +31 -0
  26. matplotlib_rs/_cm.py +1500 -0
  27. matplotlib_rs/_cm_bivar.py +1289 -0
  28. matplotlib_rs/_cm_listed.py +2848 -0
  29. matplotlib_rs/_cm_multivar.py +167 -0
  30. matplotlib_rs/_color_data.py +1142 -0
  31. matplotlib_rs/_colormap.py +132 -0
  32. matplotlib_rs/_constrained_layout.py +825 -0
  33. matplotlib_rs/_contour.py +108 -0
  34. matplotlib_rs/_doc_cache.py +12214 -0
  35. matplotlib_rs/_docstring.py +142 -0
  36. matplotlib_rs/_enums.py +178 -0
  37. matplotlib_rs/_figure_rs.py +294 -0
  38. matplotlib_rs/_fontconfig_pattern.py +129 -0
  39. matplotlib_rs/_foreign.py +220 -0
  40. matplotlib_rs/_hook.py +94 -0
  41. matplotlib_rs/_image.py +160 -0
  42. matplotlib_rs/_imageio.py +229 -0
  43. matplotlib_rs/_internal_utils.py +65 -0
  44. matplotlib_rs/_kiwi.py +484 -0
  45. matplotlib_rs/_layoutgrid.py +549 -0
  46. matplotlib_rs/_live.py +192 -0
  47. matplotlib_rs/_mathtext.py +3103 -0
  48. matplotlib_rs/_mathtext_data.py +1811 -0
  49. matplotlib_rs/_mplrs.cp315-win_amd64.pyd +0 -0
  50. matplotlib_rs/_path.py +25 -0
  51. matplotlib_rs/_png.py +162 -0
  52. matplotlib_rs/_pylab_helpers.py +137 -0
  53. matplotlib_rs/_qhull.py +66 -0
  54. matplotlib_rs/_rcpush.py +84 -0
  55. matplotlib_rs/_spines_rs.py +108 -0
  56. matplotlib_rs/_style_helpers.py +52 -0
  57. matplotlib_rs/_text_helpers.py +51 -0
  58. matplotlib_rs/_tight_bbox.py +85 -0
  59. matplotlib_rs/_tight_layout.py +302 -0
  60. matplotlib_rs/_tri.py +140 -0
  61. matplotlib_rs/_type1font.py +1228 -0
  62. matplotlib_rs/_vendor/__init__.py +8 -0
  63. matplotlib_rs/_vendor/cycler.py +574 -0
  64. matplotlib_rs/_vendor/dateutil/__init__.py +27 -0
  65. matplotlib_rs/_vendor/dateutil/_common.py +44 -0
  66. matplotlib_rs/_vendor/dateutil/_tzdata_impl.py +148 -0
  67. matplotlib_rs/_vendor/dateutil/_version.py +5 -0
  68. matplotlib_rs/_vendor/dateutil/easter.py +90 -0
  69. matplotlib_rs/_vendor/dateutil/parser/__init__.py +62 -0
  70. matplotlib_rs/_vendor/dateutil/parser/_parser.py +1614 -0
  71. matplotlib_rs/_vendor/dateutil/parser/isoparser.py +417 -0
  72. matplotlib_rs/_vendor/dateutil/relativedelta.py +597 -0
  73. matplotlib_rs/_vendor/dateutil/rrule.py +1765 -0
  74. matplotlib_rs/_vendor/dateutil/tz/__init__.py +61 -0
  75. matplotlib_rs/_vendor/dateutil/tz/_common.py +420 -0
  76. matplotlib_rs/_vendor/dateutil/tz/_factories.py +81 -0
  77. matplotlib_rs/_vendor/dateutil/tz/_tzfile.py +1429 -0
  78. matplotlib_rs/_vendor/dateutil/tz/_tzpath.py +105 -0
  79. matplotlib_rs/_vendor/dateutil/tz/tz.py +1473 -0
  80. matplotlib_rs/_vendor/dateutil/tz/win.py +371 -0
  81. matplotlib_rs/_vendor/dateutil/tzwin.py +3 -0
  82. matplotlib_rs/_vendor/dateutil/utils.py +72 -0
  83. matplotlib_rs/_vendor/dateutil/zoneinfo/__init__.py +234 -0
  84. matplotlib_rs/_vendor/pyparsing/__init__.py +414 -0
  85. matplotlib_rs/_vendor/pyparsing/actions.py +265 -0
  86. matplotlib_rs/_vendor/pyparsing/common.py +571 -0
  87. matplotlib_rs/_vendor/pyparsing/core.py +6973 -0
  88. matplotlib_rs/_vendor/pyparsing/exceptions.py +354 -0
  89. matplotlib_rs/_vendor/pyparsing/helpers.py +1770 -0
  90. matplotlib_rs/_vendor/pyparsing/results.py +929 -0
  91. matplotlib_rs/_vendor/pyparsing/testing.py +399 -0
  92. matplotlib_rs/_vendor/pyparsing/unicode.py +357 -0
  93. matplotlib_rs/_vendor/pyparsing/util.py +515 -0
  94. matplotlib_rs/_vendor/pyparsing/warnings.py +11 -0
  95. matplotlib_rs/_vendor/six.py +1004 -0
  96. matplotlib_rs/animation.py +1843 -0
  97. matplotlib_rs/artist.py +2302 -0
  98. matplotlib_rs/axes/__init__.py +19 -0
  99. matplotlib_rs/axes/_axes.py +9402 -0
  100. matplotlib_rs/axes/_bar.py +185 -0
  101. matplotlib_rs/axes/_base.py +5236 -0
  102. matplotlib_rs/axes/_base_rs.py +727 -0
  103. matplotlib_rs/axes/_boxplot.py +391 -0
  104. matplotlib_rs/axes/_hist.py +99 -0
  105. matplotlib_rs/axes/_secondary_axes.py +357 -0
  106. matplotlib_rs/axis.py +1963 -0
  107. matplotlib_rs/backend_bases.py +3760 -0
  108. matplotlib_rs/backend_managers.py +388 -0
  109. matplotlib_rs/backend_tools.py +1002 -0
  110. matplotlib_rs/backends/__init__.py +6 -0
  111. matplotlib_rs/backends/_backend_pdf_ps.py +451 -0
  112. matplotlib_rs/backends/backend_agg.py +552 -0
  113. matplotlib_rs/backends/backend_mixed.py +123 -0
  114. matplotlib_rs/backends/backend_pdf.py +2711 -0
  115. matplotlib_rs/backends/backend_pgf.py +1031 -0
  116. matplotlib_rs/backends/backend_ps.py +1491 -0
  117. matplotlib_rs/backends/backend_svg.py +1395 -0
  118. matplotlib_rs/backends/backend_template.py +214 -0
  119. matplotlib_rs/backends/registry.py +423 -0
  120. matplotlib_rs/bezier.py +691 -0
  121. matplotlib_rs/category.py +236 -0
  122. matplotlib_rs/cbook.py +2762 -0
  123. matplotlib_rs/cm.py +251 -0
  124. matplotlib_rs/collections.py +2711 -0
  125. matplotlib_rs/colorbar.py +1586 -0
  126. matplotlib_rs/colorizer.py +909 -0
  127. matplotlib_rs/colors.py +4278 -0
  128. matplotlib_rs/container.py +256 -0
  129. matplotlib_rs/contour.py +1756 -0
  130. matplotlib_rs/dates.py +1847 -0
  131. matplotlib_rs/dviread.py +1386 -0
  132. matplotlib_rs/figure.py +3815 -0
  133. matplotlib_rs/font_manager.py +1855 -0
  134. matplotlib_rs/ft2font.py +515 -0
  135. matplotlib_rs/gridspec.py +808 -0
  136. matplotlib_rs/hatch.py +244 -0
  137. matplotlib_rs/image.py +1863 -0
  138. matplotlib_rs/inset.py +291 -0
  139. matplotlib_rs/layout_engine.py +310 -0
  140. matplotlib_rs/legend.py +1480 -0
  141. matplotlib_rs/legend_handler.py +812 -0
  142. matplotlib_rs/lines.py +1886 -0
  143. matplotlib_rs/markers.py +908 -0
  144. matplotlib_rs/mathtext.py +141 -0
  145. matplotlib_rs/mlab.py +959 -0
  146. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Bold.ttf +0 -0
  147. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf +0 -0
  148. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans-Oblique.ttf +0 -0
  149. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSans.ttf +0 -0
  150. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf +0 -0
  151. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Bold.ttf +0 -0
  152. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-BoldOblique.ttf +0 -0
  153. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono-Oblique.ttf +0 -0
  154. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSansMono.ttf +0 -0
  155. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Bold.ttf +0 -0
  156. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-BoldItalic.ttf +0 -0
  157. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif-Italic.ttf +0 -0
  158. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerif.ttf +0 -0
  159. matplotlib_rs/mpl-data/fonts/ttf/DejaVuSerifDisplay.ttf +0 -0
  160. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_DEJAVU +99 -0
  161. matplotlib_rs/mpl-data/fonts/ttf/LICENSE_STIX +124 -0
  162. matplotlib_rs/mpl-data/fonts/ttf/LastResortHE-Regular.ttf +0 -0
  163. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneral.ttf +0 -0
  164. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBol.ttf +0 -0
  165. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralBolIta.ttf +0 -0
  166. matplotlib_rs/mpl-data/fonts/ttf/STIXGeneralItalic.ttf +0 -0
  167. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUni.ttf +0 -0
  168. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBol.ttf +0 -0
  169. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniBolIta.ttf +0 -0
  170. matplotlib_rs/mpl-data/fonts/ttf/STIXNonUniIta.ttf +0 -0
  171. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFiveSymReg.ttf +0 -0
  172. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymBol.ttf +0 -0
  173. matplotlib_rs/mpl-data/fonts/ttf/STIXSizFourSymReg.ttf +0 -0
  174. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymBol.ttf +0 -0
  175. matplotlib_rs/mpl-data/fonts/ttf/STIXSizOneSymReg.ttf +0 -0
  176. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymBol.ttf +0 -0
  177. matplotlib_rs/mpl-data/fonts/ttf/STIXSizThreeSymReg.ttf +0 -0
  178. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymBol.ttf +0 -0
  179. matplotlib_rs/mpl-data/fonts/ttf/STIXSizTwoSymReg.ttf +0 -0
  180. matplotlib_rs/mpl-data/fonts/ttf/cmb10.ttf +0 -0
  181. matplotlib_rs/mpl-data/fonts/ttf/cmex10.ttf +0 -0
  182. matplotlib_rs/mpl-data/fonts/ttf/cmmi10.ttf +0 -0
  183. matplotlib_rs/mpl-data/fonts/ttf/cmr10.ttf +0 -0
  184. matplotlib_rs/mpl-data/fonts/ttf/cmss10.ttf +0 -0
  185. matplotlib_rs/mpl-data/fonts/ttf/cmsy10.ttf +0 -0
  186. matplotlib_rs/mpl-data/fonts/ttf/cmti10.ttf +0 -0
  187. matplotlib_rs/mpl-data/fonts/ttf/cmtt10.ttf +0 -0
  188. matplotlib_rs/mpl-data/images/back-symbolic.svg +46 -0
  189. matplotlib_rs/mpl-data/images/back.pdf +0 -0
  190. matplotlib_rs/mpl-data/images/back.png +0 -0
  191. matplotlib_rs/mpl-data/images/back.svg +46 -0
  192. matplotlib_rs/mpl-data/images/back_large.png +0 -0
  193. matplotlib_rs/mpl-data/images/filesave-symbolic.svg +68 -0
  194. matplotlib_rs/mpl-data/images/filesave.pdf +72 -0
  195. matplotlib_rs/mpl-data/images/filesave.png +0 -0
  196. matplotlib_rs/mpl-data/images/filesave.svg +68 -0
  197. matplotlib_rs/mpl-data/images/filesave_large.png +0 -0
  198. matplotlib_rs/mpl-data/images/forward-symbolic.svg +46 -0
  199. matplotlib_rs/mpl-data/images/forward.pdf +0 -0
  200. matplotlib_rs/mpl-data/images/forward.png +0 -0
  201. matplotlib_rs/mpl-data/images/forward.svg +46 -0
  202. matplotlib_rs/mpl-data/images/forward_large.png +0 -0
  203. matplotlib_rs/mpl-data/images/hand.pdf +0 -0
  204. matplotlib_rs/mpl-data/images/hand.png +0 -0
  205. matplotlib_rs/mpl-data/images/hand.svg +130 -0
  206. matplotlib_rs/mpl-data/images/help-symbolic.svg +52 -0
  207. matplotlib_rs/mpl-data/images/help.pdf +71 -0
  208. matplotlib_rs/mpl-data/images/help.png +0 -0
  209. matplotlib_rs/mpl-data/images/help.svg +52 -0
  210. matplotlib_rs/mpl-data/images/help_large.png +0 -0
  211. matplotlib_rs/mpl-data/images/home-symbolic.svg +59 -0
  212. matplotlib_rs/mpl-data/images/home.pdf +0 -0
  213. matplotlib_rs/mpl-data/images/home.png +0 -0
  214. matplotlib_rs/mpl-data/images/home.svg +59 -0
  215. matplotlib_rs/mpl-data/images/home_large.png +0 -0
  216. matplotlib_rs/mpl-data/images/matplotlib.pdf +0 -0
  217. matplotlib_rs/mpl-data/images/matplotlib.png +0 -0
  218. matplotlib_rs/mpl-data/images/matplotlib.svg +3171 -0
  219. matplotlib_rs/mpl-data/images/matplotlib_large.png +0 -0
  220. matplotlib_rs/mpl-data/images/move-symbolic.svg +73 -0
  221. matplotlib_rs/mpl-data/images/move.pdf +0 -0
  222. matplotlib_rs/mpl-data/images/move.png +0 -0
  223. matplotlib_rs/mpl-data/images/move.svg +73 -0
  224. matplotlib_rs/mpl-data/images/move_large.png +0 -0
  225. matplotlib_rs/mpl-data/images/qt4_editor_options.pdf +0 -0
  226. matplotlib_rs/mpl-data/images/qt4_editor_options.png +0 -0
  227. matplotlib_rs/mpl-data/images/qt4_editor_options.svg +48 -0
  228. matplotlib_rs/mpl-data/images/qt4_editor_options_large.png +0 -0
  229. matplotlib_rs/mpl-data/images/subplots-symbolic.svg +81 -0
  230. matplotlib_rs/mpl-data/images/subplots.pdf +0 -0
  231. matplotlib_rs/mpl-data/images/subplots.png +0 -0
  232. matplotlib_rs/mpl-data/images/subplots.svg +81 -0
  233. matplotlib_rs/mpl-data/images/subplots_large.png +0 -0
  234. matplotlib_rs/mpl-data/images/zoom_to_rect-symbolic.svg +40 -0
  235. matplotlib_rs/mpl-data/images/zoom_to_rect.pdf +69 -0
  236. matplotlib_rs/mpl-data/images/zoom_to_rect.png +0 -0
  237. matplotlib_rs/mpl-data/images/zoom_to_rect.svg +40 -0
  238. matplotlib_rs/mpl-data/images/zoom_to_rect_large.png +0 -0
  239. matplotlib_rs/mpl-data/kpsewhich.lua +4 -0
  240. matplotlib_rs/mpl-data/matplotlibrc +849 -0
  241. matplotlib_rs/mpl-data/plot_directive/plot_directive.css +16 -0
  242. matplotlib_rs/mpl-data/sample_data/Minduka_Present_Blue_Pack.png +0 -0
  243. matplotlib_rs/mpl-data/sample_data/README.txt +2 -0
  244. matplotlib_rs/mpl-data/sample_data/Stocks.csv +526 -0
  245. matplotlib_rs/mpl-data/sample_data/axes_grid/bivariate_normal.npy +0 -0
  246. matplotlib_rs/mpl-data/sample_data/data_x_x2_x3.csv +11 -0
  247. matplotlib_rs/mpl-data/sample_data/eeg.dat +0 -0
  248. matplotlib_rs/mpl-data/sample_data/embedding_in_wx3.xrc +65 -0
  249. matplotlib_rs/mpl-data/sample_data/goog.npz +0 -0
  250. matplotlib_rs/mpl-data/sample_data/grace_hopper.jpg +0 -0
  251. matplotlib_rs/mpl-data/sample_data/jacksboro_fault_dem.npz +0 -0
  252. matplotlib_rs/mpl-data/sample_data/logo2.png +0 -0
  253. matplotlib_rs/mpl-data/sample_data/membrane.dat +0 -0
  254. matplotlib_rs/mpl-data/sample_data/msft.csv +66 -0
  255. matplotlib_rs/mpl-data/sample_data/s1045.ima.gz +0 -0
  256. matplotlib_rs/mpl-data/sample_data/topobathy.npz +0 -0
  257. matplotlib_rs/mpl-data/stylelib/Solarize_Light2.mplstyle +53 -0
  258. matplotlib_rs/mpl-data/stylelib/_classic_test_patch.mplstyle +8 -0
  259. matplotlib_rs/mpl-data/stylelib/_mpl-gallery-nogrid.mplstyle +19 -0
  260. matplotlib_rs/mpl-data/stylelib/_mpl-gallery.mplstyle +19 -0
  261. matplotlib_rs/mpl-data/stylelib/bmh.mplstyle +27 -0
  262. matplotlib_rs/mpl-data/stylelib/classic.mplstyle +491 -0
  263. matplotlib_rs/mpl-data/stylelib/dark_background.mplstyle +26 -0
  264. matplotlib_rs/mpl-data/stylelib/fast.mplstyle +11 -0
  265. matplotlib_rs/mpl-data/stylelib/fivethirtyeight.mplstyle +37 -0
  266. matplotlib_rs/mpl-data/stylelib/ggplot.mplstyle +39 -0
  267. matplotlib_rs/mpl-data/stylelib/grayscale.mplstyle +29 -0
  268. matplotlib_rs/mpl-data/stylelib/petroff10.mplstyle +5 -0
  269. matplotlib_rs/mpl-data/stylelib/petroff6.mplstyle +5 -0
  270. matplotlib_rs/mpl-data/stylelib/petroff8.mplstyle +5 -0
  271. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-bright.mplstyle +3 -0
  272. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-colorblind.mplstyle +3 -0
  273. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark-palette.mplstyle +3 -0
  274. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-dark.mplstyle +30 -0
  275. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-darkgrid.mplstyle +30 -0
  276. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-deep.mplstyle +3 -0
  277. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-muted.mplstyle +3 -0
  278. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-notebook.mplstyle +21 -0
  279. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-paper.mplstyle +21 -0
  280. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-pastel.mplstyle +3 -0
  281. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-poster.mplstyle +21 -0
  282. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-talk.mplstyle +21 -0
  283. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-ticks.mplstyle +30 -0
  284. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-white.mplstyle +30 -0
  285. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8-whitegrid.mplstyle +30 -0
  286. matplotlib_rs/mpl-data/stylelib/seaborn-v0_8.mplstyle +57 -0
  287. matplotlib_rs/mpl-data/stylelib/tableau-colorblind10.mplstyle +3 -0
  288. matplotlib_rs/mpl_toolkits/__init__.py +3 -0
  289. matplotlib_rs/mpl_toolkits/axes_grid1/__init__.py +11 -0
  290. matplotlib_rs/mpl_toolkits/axes_grid1/anchored_artists.py +415 -0
  291. matplotlib_rs/mpl_toolkits/axes_grid1/axes_divider.py +619 -0
  292. matplotlib_rs/mpl_toolkits/axes_grid1/axes_grid.py +565 -0
  293. matplotlib_rs/mpl_toolkits/axes_grid1/axes_rgb.py +158 -0
  294. matplotlib_rs/mpl_toolkits/axes_grid1/axes_size.py +272 -0
  295. matplotlib_rs/mpl_toolkits/axes_grid1/inset_locator.py +525 -0
  296. matplotlib_rs/mpl_toolkits/axes_grid1/mpl_axes.py +129 -0
  297. matplotlib_rs/mpl_toolkits/axes_grid1/parasite_axes.py +261 -0
  298. matplotlib_rs/mpl_toolkits/axisartist/__init__.py +15 -0
  299. matplotlib_rs/mpl_toolkits/axisartist/angle_helper.py +396 -0
  300. matplotlib_rs/mpl_toolkits/axisartist/axes_divider.py +3 -0
  301. matplotlib_rs/mpl_toolkits/axisartist/axis_artist.py +1148 -0
  302. matplotlib_rs/mpl_toolkits/axisartist/axisline_style.py +193 -0
  303. matplotlib_rs/mpl_toolkits/axisartist/axislines.py +475 -0
  304. matplotlib_rs/mpl_toolkits/axisartist/floating_axes.py +265 -0
  305. matplotlib_rs/mpl_toolkits/axisartist/grid_finder.py +329 -0
  306. matplotlib_rs/mpl_toolkits/axisartist/grid_helper_curvelinear.py +353 -0
  307. matplotlib_rs/mpl_toolkits/axisartist/parasite_axes.py +8 -0
  308. matplotlib_rs/mpl_toolkits/mplot3d/__init__.py +4 -0
  309. matplotlib_rs/mpl_toolkits/mplot3d/art3d.py +1758 -0
  310. matplotlib_rs/mpl_toolkits/mplot3d/axes3d.py +4462 -0
  311. matplotlib_rs/mpl_toolkits/mplot3d/axis3d.py +807 -0
  312. matplotlib_rs/mpl_toolkits/mplot3d/proj3d.py +270 -0
  313. matplotlib_rs/offsetbox.py +1726 -0
  314. matplotlib_rs/patches.py +5049 -0
  315. matplotlib_rs/path.py +1147 -0
  316. matplotlib_rs/patheffects.py +512 -0
  317. matplotlib_rs/projections/__init__.py +126 -0
  318. matplotlib_rs/projections/geo.py +512 -0
  319. matplotlib_rs/projections/polar.py +1518 -0
  320. matplotlib_rs/pylab.py +68 -0
  321. matplotlib_rs/pyplot.py +4834 -0
  322. matplotlib_rs/quiver.py +1236 -0
  323. matplotlib_rs/rcsetup.py +3435 -0
  324. matplotlib_rs/sankey.py +815 -0
  325. matplotlib_rs/scale.py +1002 -0
  326. matplotlib_rs/spines.py +618 -0
  327. matplotlib_rs/stackplot.py +144 -0
  328. matplotlib_rs/streamplot.py +768 -0
  329. matplotlib_rs/style/__init__.py +269 -0
  330. matplotlib_rs/style/core.py +28 -0
  331. matplotlib_rs/table.py +860 -0
  332. matplotlib_rs/texmanager.py +375 -0
  333. matplotlib_rs/text.py +2412 -0
  334. matplotlib_rs/textpath.py +377 -0
  335. matplotlib_rs/ticker.py +3111 -0
  336. matplotlib_rs/transforms.py +3069 -0
  337. matplotlib_rs/tri/__init__.py +24 -0
  338. matplotlib_rs/tri/_triangulation.py +248 -0
  339. matplotlib_rs/tri/_tricontour.py +271 -0
  340. matplotlib_rs/tri/_trifinder.py +97 -0
  341. matplotlib_rs/tri/_triinterpolate.py +1575 -0
  342. matplotlib_rs/tri/_tripcolor.py +170 -0
  343. matplotlib_rs/tri/_triplot.py +87 -0
  344. matplotlib_rs/tri/_trirefine.py +308 -0
  345. matplotlib_rs/tri/_tritools.py +264 -0
  346. matplotlib_rs/typing.py +597 -0
  347. matplotlib_rs/units.py +196 -0
  348. matplotlib_rs/widgets.py +4455 -0
  349. matplotlib_rs-0.0.8.dist-info/METADATA +392 -0
  350. matplotlib_rs-0.0.8.dist-info/RECORD +352 -0
  351. matplotlib_rs-0.0.8.dist-info/WHEEL +4 -0
  352. matplotlib_rs-0.0.8.dist-info/sboms/matplotlib-rs.cyclonedx.json +4390 -0
matplotlib_rs/mlab.py ADDED
@@ -0,0 +1,959 @@
1
+ # Vendored from matplotlib 3.11 (see licenses/LICENSE_MATPLOTLIB), adapted for matplotlib_rs.
2
+ """
3
+ Numerical Python functions written for compatibility with MATLAB
4
+ commands with the same names. Most numerical Python functions can be found in
5
+ the `NumPy`_ and `SciPy`_ libraries. What remains here is code for performing
6
+ spectral computations and kernel density estimations.
7
+
8
+ .. _NumPy: https://numpy.org
9
+ .. _SciPy: https://www.scipy.org
10
+
11
+ Spectral functions
12
+ ------------------
13
+
14
+ `cohere`
15
+ Coherence (normalized cross spectral density)
16
+
17
+ `csd`
18
+ Cross spectral density using Welch's average periodogram
19
+
20
+ `detrend`
21
+ Remove the mean or best fit line from an array
22
+
23
+ `psd`
24
+ Power spectral density using Welch's average periodogram
25
+
26
+ `specgram`
27
+ Spectrogram (spectrum over segments of time)
28
+
29
+ `complex_spectrum`
30
+ Return the complex-valued frequency spectrum of a signal
31
+
32
+ `magnitude_spectrum`
33
+ Return the magnitude of the frequency spectrum of a signal
34
+
35
+ `angle_spectrum`
36
+ Return the angle (wrapped phase) of the frequency spectrum of a signal
37
+
38
+ `phase_spectrum`
39
+ Return the phase (unwrapped angle) of the frequency spectrum of a signal
40
+
41
+ `detrend_mean`
42
+ Remove the mean from a line.
43
+
44
+ `detrend_linear`
45
+ Remove the best fit line from a line.
46
+
47
+ `detrend_none`
48
+ Return the original line.
49
+ """
50
+
51
+ import functools
52
+ from numbers import Integral, Number
53
+ import sys
54
+
55
+ import numpy as np
56
+
57
+ from . import _api, _docstring, cbook
58
+
59
+
60
+ def window_hanning(x):
61
+ """
62
+ Return *x* times the Hanning (or Hann) window of len(*x*).
63
+
64
+ See Also
65
+ --------
66
+ window_none : Another window algorithm.
67
+ """
68
+ return np.hanning(len(x))*x
69
+
70
+
71
+ def window_none(x):
72
+ """
73
+ No window function; simply return *x*.
74
+
75
+ See Also
76
+ --------
77
+ window_hanning : Another window algorithm.
78
+ """
79
+ return x
80
+
81
+
82
+ def detrend(x, key=None, axis=None):
83
+ """
84
+ Return *x* with its trend removed.
85
+
86
+ Parameters
87
+ ----------
88
+ x : array or sequence
89
+ Array or sequence containing the data.
90
+
91
+ key : {'default', 'constant', 'mean', 'linear', 'none'} or function
92
+ The detrending algorithm to use. 'default', 'mean', and 'constant' are
93
+ the same as `detrend_mean`. 'linear' is the same as `detrend_linear`.
94
+ 'none' is the same as `detrend_none`. The default is 'mean'. See the
95
+ corresponding functions for more details regarding the algorithms. Can
96
+ also be a function that carries out the detrend operation.
97
+
98
+ axis : int
99
+ The axis along which to do the detrending.
100
+
101
+ See Also
102
+ --------
103
+ detrend_mean : Implementation of the 'mean' algorithm.
104
+ detrend_linear : Implementation of the 'linear' algorithm.
105
+ detrend_none : Implementation of the 'none' algorithm.
106
+ """
107
+ if key is None or key in ['constant', 'mean', 'default']:
108
+ return detrend(x, key=detrend_mean, axis=axis)
109
+ elif key == 'linear':
110
+ return detrend(x, key=detrend_linear, axis=axis)
111
+ elif key == 'none':
112
+ return detrend(x, key=detrend_none, axis=axis)
113
+ elif callable(key):
114
+ x = np.asarray(x)
115
+ if axis is not None and axis + 1 > x.ndim:
116
+ raise ValueError(f'axis(={axis}) out of bounds')
117
+ if (axis is None and x.ndim == 0) or (not axis and x.ndim == 1):
118
+ return key(x)
119
+ # try to use the 'axis' argument if the function supports it,
120
+ # otherwise use apply_along_axis to do it
121
+ try:
122
+ return key(x, axis=axis)
123
+ except TypeError:
124
+ return np.apply_along_axis(key, axis=axis, arr=x)
125
+ else:
126
+ raise ValueError(
127
+ f"Unknown value for key: {key!r}, must be one of: 'default', "
128
+ f"'constant', 'mean', 'linear', or a function")
129
+
130
+
131
+ def detrend_mean(x, axis=None):
132
+ """
133
+ Return *x* minus the mean(*x*).
134
+
135
+ Parameters
136
+ ----------
137
+ x : array or sequence
138
+ Array or sequence containing the data
139
+ Can have any dimensionality
140
+
141
+ axis : int
142
+ The axis along which to take the mean. See `numpy.mean` for a
143
+ description of this argument.
144
+
145
+ See Also
146
+ --------
147
+ detrend_linear : Another detrend algorithm.
148
+ detrend_none : Another detrend algorithm.
149
+ detrend : A wrapper around all the detrend algorithms.
150
+ """
151
+ x = np.asarray(x)
152
+
153
+ if axis is not None and axis+1 > x.ndim:
154
+ raise ValueError('axis(=%s) out of bounds' % axis)
155
+
156
+ return x - x.mean(axis, keepdims=True)
157
+
158
+
159
+ def detrend_none(x, axis=None):
160
+ """
161
+ Return *x*: no detrending.
162
+
163
+ Parameters
164
+ ----------
165
+ x : any object
166
+ An object containing the data
167
+
168
+ axis : int
169
+ This parameter is ignored.
170
+ It is included for compatibility with detrend_mean
171
+
172
+ See Also
173
+ --------
174
+ detrend_mean : Another detrend algorithm.
175
+ detrend_linear : Another detrend algorithm.
176
+ detrend : A wrapper around all the detrend algorithms.
177
+ """
178
+ return x
179
+
180
+
181
+ def detrend_linear(y):
182
+ """
183
+ Return *x* minus best fit line; 'linear' detrending.
184
+
185
+ Parameters
186
+ ----------
187
+ y : 0-D or 1-D array or sequence
188
+ Array or sequence containing the data
189
+
190
+ See Also
191
+ --------
192
+ detrend_mean : Another detrend algorithm.
193
+ detrend_none : Another detrend algorithm.
194
+ detrend : A wrapper around all the detrend algorithms.
195
+ """
196
+ # This is faster than an algorithm based on linalg.lstsq.
197
+ y = np.asarray(y)
198
+
199
+ if y.ndim > 1:
200
+ raise ValueError('y cannot have ndim > 1')
201
+
202
+ # short-circuit 0-D array.
203
+ if not y.ndim:
204
+ return np.array(0., dtype=y.dtype)
205
+
206
+ x = np.arange(y.size, dtype=float)
207
+
208
+ C = np.cov(x, y, bias=1)
209
+ b = C[0, 1]/C[0, 0]
210
+
211
+ a = y.mean() - b*x.mean()
212
+ return y - (b*x + a)
213
+
214
+
215
+ def _stride_windows(x, n, noverlap=0):
216
+ _api.check_isinstance(Integral, n=n, noverlap=noverlap)
217
+ x = np.asarray(x)
218
+ step = n - noverlap
219
+ shape = (n, (x.shape[-1]-noverlap)//step)
220
+ strides = (x.strides[0], step*x.strides[0])
221
+ return np.lib.stride_tricks.as_strided(x, shape=shape, strides=strides)
222
+
223
+
224
+ def _spectral_helper(x, y=None, NFFT=None, Fs=None, detrend_func=None,
225
+ window=None, noverlap=None, pad_to=None,
226
+ sides=None, scale_by_freq=None, mode=None):
227
+ """
228
+ Private helper implementing the common parts between the psd, csd,
229
+ spectrogram and complex, magnitude, angle, and phase spectrums.
230
+ """
231
+ if y is None:
232
+ # if y is None use x for y
233
+ same_data = True
234
+ else:
235
+ # The checks for if y is x are so that we can use the same function to
236
+ # implement the core of psd(), csd(), and spectrogram() without doing
237
+ # extra calculations. We return the unaveraged Pxy, freqs, and t.
238
+ same_data = y is x
239
+
240
+ if Fs is None:
241
+ Fs = 2
242
+ if noverlap is None:
243
+ noverlap = 0
244
+ if detrend_func is None:
245
+ detrend_func = detrend_none
246
+ if window is None:
247
+ window = window_hanning
248
+
249
+ # if NFFT is set to None use the whole signal
250
+ if NFFT is None:
251
+ NFFT = 256
252
+
253
+ if not (0 <= noverlap < NFFT):
254
+ raise ValueError('noverlap must be less than NFFT')
255
+
256
+ if mode is None or mode == 'default':
257
+ mode = 'psd'
258
+ _api.check_in_list(
259
+ ['default', 'psd', 'complex', 'magnitude', 'angle', 'phase'],
260
+ mode=mode)
261
+
262
+ if not same_data and mode != 'psd':
263
+ raise ValueError("x and y must be equal if mode is not 'psd'")
264
+
265
+ # Make sure we're dealing with a numpy array. If y and x were the same
266
+ # object to start with, keep them that way
267
+ x = np.asarray(x)
268
+ if not same_data:
269
+ y = np.asarray(y)
270
+
271
+ if sides is None or sides == 'default':
272
+ if np.iscomplexobj(x):
273
+ sides = 'twosided'
274
+ else:
275
+ sides = 'onesided'
276
+ _api.check_in_list(['default', 'onesided', 'twosided'], sides=sides)
277
+
278
+ # zero pad x and y up to NFFT if they are shorter than NFFT
279
+ if len(x) < NFFT:
280
+ n = len(x)
281
+ x = np.resize(x, NFFT)
282
+ x[n:] = 0
283
+
284
+ if not same_data and len(y) < NFFT:
285
+ n = len(y)
286
+ y = np.resize(y, NFFT)
287
+ y[n:] = 0
288
+
289
+ if pad_to is None:
290
+ pad_to = NFFT
291
+
292
+ if mode != 'psd':
293
+ scale_by_freq = False
294
+ elif scale_by_freq is None:
295
+ scale_by_freq = True
296
+
297
+ # For real x, ignore the negative frequencies unless told otherwise
298
+ if sides == 'twosided':
299
+ numFreqs = pad_to
300
+ if pad_to % 2:
301
+ freqcenter = (pad_to - 1)//2 + 1
302
+ else:
303
+ freqcenter = pad_to//2
304
+ scaling_factor = 1.
305
+ elif sides == 'onesided':
306
+ if pad_to % 2:
307
+ numFreqs = (pad_to + 1)//2
308
+ else:
309
+ numFreqs = pad_to//2 + 1
310
+ scaling_factor = 2.
311
+
312
+ if not np.iterable(window):
313
+ window = window(np.ones(NFFT, x.dtype))
314
+ if len(window) != NFFT:
315
+ raise ValueError(
316
+ "The window length must match the data's first dimension")
317
+
318
+ if sys.maxsize > 2**32:
319
+ result = np.lib.stride_tricks.sliding_window_view(
320
+ x, NFFT, axis=0)[::NFFT - noverlap].T
321
+ else:
322
+ # The NumPy version on 32-bit will OOM, so use old implementation.
323
+ result = _stride_windows(x, NFFT, noverlap=noverlap)
324
+ result = detrend(result, detrend_func, axis=0)
325
+ result = result * window.reshape((-1, 1))
326
+ result = np.fft.fft(result, n=pad_to, axis=0)[:numFreqs, :]
327
+ freqs = np.fft.fftfreq(pad_to, 1/Fs)[:numFreqs]
328
+
329
+ if not same_data:
330
+ # if same_data is False, mode must be 'psd'
331
+ if sys.maxsize > 2**32:
332
+ resultY = np.lib.stride_tricks.sliding_window_view(
333
+ y, NFFT, axis=0)[::NFFT - noverlap].T
334
+ else:
335
+ # The NumPy version on 32-bit will OOM, so use old implementation.
336
+ resultY = _stride_windows(y, NFFT, noverlap=noverlap)
337
+ resultY = detrend(resultY, detrend_func, axis=0)
338
+ resultY = resultY * window.reshape((-1, 1))
339
+ resultY = np.fft.fft(resultY, n=pad_to, axis=0)[:numFreqs, :]
340
+ result = np.conj(result) * resultY
341
+ elif mode == 'psd':
342
+ result = np.conj(result) * result
343
+ elif mode == 'magnitude':
344
+ result = np.abs(result) / window.sum()
345
+ elif mode == 'angle' or mode == 'phase':
346
+ # we unwrap the phase later to handle the onesided vs. twosided case
347
+ result = np.angle(result)
348
+ elif mode == 'complex':
349
+ result /= window.sum()
350
+
351
+ if mode == 'psd':
352
+
353
+ # Also include scaling factors for one-sided densities and dividing by
354
+ # the sampling frequency, if desired. Scale everything, except the DC
355
+ # component and the NFFT/2 component:
356
+
357
+ # if we have an even number of frequencies, don't scale NFFT/2
358
+ if not NFFT % 2:
359
+ slc = slice(1, -1, None)
360
+ # if we have an odd number, just don't scale DC
361
+ else:
362
+ slc = slice(1, None, None)
363
+
364
+ result[slc] *= scaling_factor
365
+
366
+ # MATLAB divides by the sampling frequency so that density function
367
+ # has units of dB/Hz and can be integrated by the plotted frequency
368
+ # values. Perform the same scaling here.
369
+ if scale_by_freq:
370
+ result /= Fs
371
+ # Scale the spectrum by the norm of the window to compensate for
372
+ # windowing loss; see Bendat & Piersol Sec 11.5.2.
373
+ result /= (window**2).sum()
374
+ else:
375
+ # In this case, preserve power in the segment, not amplitude
376
+ result /= window.sum()**2
377
+
378
+ t = np.arange(NFFT/2, len(x) - NFFT/2 + 1, NFFT - noverlap)/Fs
379
+
380
+ if sides == 'twosided':
381
+ # center the frequency range at zero
382
+ freqs = np.roll(freqs, -freqcenter, axis=0)
383
+ result = np.roll(result, -freqcenter, axis=0)
384
+ elif not pad_to % 2:
385
+ # get the last value correctly, it is negative otherwise
386
+ freqs[-1] *= -1
387
+
388
+ # we unwrap the phase here to handle the onesided vs. twosided case
389
+ if mode == 'phase':
390
+ result = np.unwrap(result, axis=0)
391
+
392
+ return result, freqs, t
393
+
394
+
395
+ def _single_spectrum_helper(
396
+ mode, x, Fs=None, window=None, pad_to=None, sides=None):
397
+ """
398
+ Private helper implementing the commonality between the complex, magnitude,
399
+ angle, and phase spectrums.
400
+ """
401
+ _api.check_in_list(['complex', 'magnitude', 'angle', 'phase'], mode=mode)
402
+
403
+ if pad_to is None:
404
+ pad_to = len(x)
405
+
406
+ spec, freqs, _ = _spectral_helper(x=x, y=None, NFFT=len(x), Fs=Fs,
407
+ detrend_func=detrend_none, window=window,
408
+ noverlap=0, pad_to=pad_to,
409
+ sides=sides,
410
+ scale_by_freq=False,
411
+ mode=mode)
412
+ if mode != 'complex':
413
+ spec = spec.real
414
+
415
+ if spec.ndim == 2 and spec.shape[1] == 1:
416
+ spec = spec[:, 0]
417
+
418
+ return spec, freqs
419
+
420
+
421
+ # Split out these keyword docs so that they can be used elsewhere
422
+ _docstring.interpd.register(
423
+ Spectral="""\
424
+ Fs : float, default: 2
425
+ The sampling frequency (samples per time unit). It is used to calculate
426
+ the Fourier frequencies, *freqs*, in cycles per time unit.
427
+
428
+ window : callable or ndarray, default: `.window_hanning`
429
+ A function or a vector of length *NFFT*. To create window vectors see
430
+ `.window_hanning`, `.window_none`, `numpy.blackman`, `numpy.hamming`,
431
+ `numpy.bartlett`, `scipy.signal`, `scipy.signal.get_window`, etc. If a
432
+ function is passed as the argument, it must take a data segment as an
433
+ argument and return the windowed version of the segment.
434
+
435
+ sides : {'default', 'onesided', 'twosided'}, optional
436
+ Which sides of the spectrum to return. 'default' is one-sided for real
437
+ data and two-sided for complex data. 'onesided' forces the return of a
438
+ one-sided spectrum, while 'twosided' forces two-sided.""",
439
+
440
+ Single_Spectrum="""\
441
+ pad_to : int, optional
442
+ The number of points to which the data segment is padded when performing
443
+ the FFT. While not increasing the actual resolution of the spectrum (the
444
+ minimum distance between resolvable peaks), this can give more points in
445
+ the plot, allowing for more detail. This corresponds to the *n* parameter
446
+ in the call to `~numpy.fft.fft`. The default is None, which sets *pad_to*
447
+ equal to the length of the input signal (i.e. no padding).""",
448
+
449
+ PSD="""\
450
+ pad_to : int, optional
451
+ The number of points to which the data segment is padded when performing
452
+ the FFT. This can be different from *NFFT*, which specifies the number
453
+ of data points used. While not increasing the actual resolution of the
454
+ spectrum (the minimum distance between resolvable peaks), this can give
455
+ more points in the plot, allowing for more detail. This corresponds to
456
+ the *n* parameter in the call to `~numpy.fft.fft`. The default is None,
457
+ which sets *pad_to* equal to *NFFT*
458
+
459
+ NFFT : int, default: 256
460
+ The number of data points used in each block for the FFT. A power 2 is
461
+ most efficient. This should *NOT* be used to get zero padding, or the
462
+ scaling of the result will be incorrect; use *pad_to* for this instead.
463
+
464
+ detrend : {'none', 'mean', 'linear'} or callable, default: 'none'
465
+ The function applied to each segment before fft-ing, designed to remove
466
+ the mean or linear trend. Unlike in MATLAB, where the *detrend* parameter
467
+ is a vector, in Matplotlib it is a function. The :mod:`~matplotlib.mlab`
468
+ module defines `.detrend_none`, `.detrend_mean`, and `.detrend_linear`,
469
+ but you can use a custom function as well. You can also use a string to
470
+ choose one of the functions: 'none' calls `.detrend_none`. 'mean' calls
471
+ `.detrend_mean`. 'linear' calls `.detrend_linear`.
472
+
473
+ scale_by_freq : bool, default: True
474
+ Whether the resulting density values should be scaled by the scaling
475
+ frequency, which gives density in units of 1/Hz. This allows for
476
+ integration over the returned frequency values. The default is True for
477
+ MATLAB compatibility.""")
478
+
479
+
480
+ @_docstring.interpd
481
+ def psd(x, NFFT=None, Fs=None, detrend=None, window=None,
482
+ noverlap=None, pad_to=None, sides=None, scale_by_freq=None):
483
+ r"""
484
+ Compute the power spectral density.
485
+
486
+ The power spectral density :math:`P_{xx}` by Welch's average
487
+ periodogram method. The vector *x* is divided into *NFFT* length
488
+ segments. Each segment is detrended by function *detrend* and
489
+ windowed by function *window*. *noverlap* gives the length of
490
+ the overlap between segments. The :math:`|\mathrm{fft}(i)|^2`
491
+ of each segment :math:`i` are averaged to compute :math:`P_{xx}`.
492
+
493
+ If len(*x*) < *NFFT*, it will be zero padded to *NFFT*.
494
+
495
+ Parameters
496
+ ----------
497
+ x : 1-D array or sequence
498
+ Array or sequence containing the data
499
+
500
+ %(Spectral)s
501
+
502
+ %(PSD)s
503
+
504
+ noverlap : int, default: 0 (no overlap)
505
+ The number of points of overlap between segments.
506
+
507
+ Returns
508
+ -------
509
+ Pxx : 1-D array
510
+ The values for the power spectrum :math:`P_{xx}` (real valued)
511
+
512
+ freqs : 1-D array
513
+ The frequencies corresponding to the elements in *Pxx*
514
+
515
+ References
516
+ ----------
517
+ Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
518
+ Wiley & Sons (1986)
519
+
520
+ See Also
521
+ --------
522
+ specgram
523
+ `specgram` differs in the default overlap; in not returning the mean of
524
+ the segment periodograms; and in returning the times of the segments.
525
+
526
+ magnitude_spectrum : returns the magnitude spectrum.
527
+
528
+ csd : returns the spectral density between two signals.
529
+ """
530
+ Pxx, freqs = csd(x=x, y=None, NFFT=NFFT, Fs=Fs, detrend=detrend,
531
+ window=window, noverlap=noverlap, pad_to=pad_to,
532
+ sides=sides, scale_by_freq=scale_by_freq)
533
+ return Pxx.real, freqs
534
+
535
+
536
+ @_docstring.interpd
537
+ def csd(x, y, NFFT=None, Fs=None, detrend=None, window=None,
538
+ noverlap=None, pad_to=None, sides=None, scale_by_freq=None):
539
+ """
540
+ Compute the cross-spectral density.
541
+
542
+ The cross spectral density :math:`P_{xy}` by Welch's average
543
+ periodogram method. The vectors *x* and *y* are divided into
544
+ *NFFT* length segments. Each segment is detrended by function
545
+ *detrend* and windowed by function *window*. *noverlap* gives
546
+ the length of the overlap between segments. The product of
547
+ the direct FFTs of *x* and *y* are averaged over each segment
548
+ to compute :math:`P_{xy}`, with a scaling to correct for power
549
+ loss due to windowing.
550
+
551
+ If len(*x*) < *NFFT* or len(*y*) < *NFFT*, they will be zero
552
+ padded to *NFFT*.
553
+
554
+ Parameters
555
+ ----------
556
+ x, y : 1-D arrays or sequences
557
+ Arrays or sequences containing the data
558
+
559
+ %(Spectral)s
560
+
561
+ %(PSD)s
562
+
563
+ noverlap : int, default: 0 (no overlap)
564
+ The number of points of overlap between segments.
565
+
566
+ Returns
567
+ -------
568
+ Pxy : 1-D array
569
+ The values for the cross spectrum :math:`P_{xy}` before scaling (real
570
+ valued)
571
+
572
+ freqs : 1-D array
573
+ The frequencies corresponding to the elements in *Pxy*
574
+
575
+ References
576
+ ----------
577
+ Bendat & Piersol -- Random Data: Analysis and Measurement Procedures, John
578
+ Wiley & Sons (1986)
579
+
580
+ See Also
581
+ --------
582
+ psd : equivalent to setting ``y = x``.
583
+ """
584
+ if NFFT is None:
585
+ NFFT = 256
586
+ Pxy, freqs, _ = _spectral_helper(x=x, y=y, NFFT=NFFT, Fs=Fs,
587
+ detrend_func=detrend, window=window,
588
+ noverlap=noverlap, pad_to=pad_to,
589
+ sides=sides, scale_by_freq=scale_by_freq,
590
+ mode='psd')
591
+
592
+ if Pxy.ndim == 2:
593
+ if Pxy.shape[1] > 1:
594
+ Pxy = Pxy.mean(axis=1)
595
+ else:
596
+ Pxy = Pxy[:, 0]
597
+ return Pxy, freqs
598
+
599
+
600
+ _single_spectrum_docs = """\
601
+ Compute the {quantity} of *x*.
602
+ Data is padded to a length of *pad_to* and the windowing function *window* is
603
+ applied to the signal.
604
+
605
+ Parameters
606
+ ----------
607
+ x : 1-D array or sequence
608
+ Array or sequence containing the data
609
+
610
+ {Spectral}
611
+
612
+ {Single_Spectrum}
613
+
614
+ Returns
615
+ -------
616
+ spectrum : 1-D array
617
+ The {quantity}.
618
+ freqs : 1-D array
619
+ The frequencies corresponding to the elements in *spectrum*.
620
+
621
+ See Also
622
+ --------
623
+ psd
624
+ Returns the power spectral density.
625
+ complex_spectrum
626
+ Returns the complex-valued frequency spectrum.
627
+ magnitude_spectrum
628
+ Returns the absolute value of the `complex_spectrum`.
629
+ angle_spectrum
630
+ Returns the angle of the `complex_spectrum`.
631
+ phase_spectrum
632
+ Returns the phase (unwrapped angle) of the `complex_spectrum`.
633
+ specgram
634
+ Can return the complex spectrum of segments within the signal.
635
+ """
636
+
637
+
638
+ complex_spectrum = functools.partial(_single_spectrum_helper, "complex")
639
+ complex_spectrum.__doc__ = _single_spectrum_docs.format(
640
+ quantity="complex-valued frequency spectrum",
641
+ **_docstring.interpd.params)
642
+ magnitude_spectrum = functools.partial(_single_spectrum_helper, "magnitude")
643
+ magnitude_spectrum.__doc__ = _single_spectrum_docs.format(
644
+ quantity="magnitude (absolute value) of the frequency spectrum",
645
+ **_docstring.interpd.params)
646
+ angle_spectrum = functools.partial(_single_spectrum_helper, "angle")
647
+ angle_spectrum.__doc__ = _single_spectrum_docs.format(
648
+ quantity="angle of the frequency spectrum (wrapped phase spectrum)",
649
+ **_docstring.interpd.params)
650
+ phase_spectrum = functools.partial(_single_spectrum_helper, "phase")
651
+ phase_spectrum.__doc__ = _single_spectrum_docs.format(
652
+ quantity="phase of the frequency spectrum (unwrapped phase spectrum)",
653
+ **_docstring.interpd.params)
654
+
655
+
656
+ @_docstring.interpd
657
+ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
658
+ noverlap=None, pad_to=None, sides=None, scale_by_freq=None,
659
+ mode=None):
660
+ """
661
+ Compute a spectrogram.
662
+
663
+ Compute and plot a spectrogram of data in *x*. Data are split into
664
+ *NFFT* length segments and the spectrum of each section is
665
+ computed. The windowing function *window* is applied to each
666
+ segment, and the amount of overlap of each segment is
667
+ specified with *noverlap*.
668
+
669
+ Parameters
670
+ ----------
671
+ x : array-like
672
+ 1-D array or sequence.
673
+
674
+ %(Spectral)s
675
+
676
+ %(PSD)s
677
+
678
+ noverlap : int, default: 128
679
+ The number of points of overlap between blocks.
680
+ mode : str, default: 'psd'
681
+ What sort of spectrum to use:
682
+ 'psd'
683
+ Returns the power spectral density.
684
+ 'complex'
685
+ Returns the complex-valued frequency spectrum.
686
+ 'magnitude'
687
+ Returns the magnitude spectrum.
688
+ 'angle'
689
+ Returns the phase spectrum without unwrapping.
690
+ 'phase'
691
+ Returns the phase spectrum with unwrapping.
692
+
693
+ Returns
694
+ -------
695
+ spectrum : array-like
696
+ 2D array, columns are the periodograms of successive segments.
697
+
698
+ freqs : array-like
699
+ 1-D array, frequencies corresponding to the rows in *spectrum*.
700
+
701
+ t : array-like
702
+ 1-D array, the times corresponding to midpoints of segments
703
+ (i.e the columns in *spectrum*).
704
+
705
+ See Also
706
+ --------
707
+ psd : differs in the overlap and in the return values.
708
+ complex_spectrum : similar, but with complex valued frequencies.
709
+ magnitude_spectrum : similar single segment when *mode* is 'magnitude'.
710
+ angle_spectrum : similar to single segment when *mode* is 'angle'.
711
+ phase_spectrum : similar to single segment when *mode* is 'phase'.
712
+
713
+ Notes
714
+ -----
715
+ *detrend* and *scale_by_freq* only apply when *mode* is set to 'psd'.
716
+
717
+ """
718
+ if noverlap is None:
719
+ noverlap = 128 # default in _spectral_helper() is noverlap = 0
720
+ if NFFT is None:
721
+ NFFT = 256 # same default as in _spectral_helper()
722
+ if len(x) <= NFFT:
723
+ _api.warn_external("Only one segment is calculated since parameter "
724
+ f"NFFT (={NFFT}) >= signal length (={len(x)}).")
725
+
726
+ spec, freqs, t = _spectral_helper(x=x, y=None, NFFT=NFFT, Fs=Fs,
727
+ detrend_func=detrend, window=window,
728
+ noverlap=noverlap, pad_to=pad_to,
729
+ sides=sides,
730
+ scale_by_freq=scale_by_freq,
731
+ mode=mode)
732
+
733
+ if mode != 'complex':
734
+ spec = spec.real # Needed since helper implements generically
735
+
736
+ return spec, freqs, t
737
+
738
+
739
+ @_docstring.interpd
740
+ def cohere(x, y, NFFT=256, Fs=2, detrend=detrend_none, window=window_hanning,
741
+ noverlap=0, pad_to=None, sides='default', scale_by_freq=None):
742
+ r"""
743
+ The coherence between *x* and *y*. Coherence is the normalized
744
+ cross spectral density:
745
+
746
+ .. math::
747
+
748
+ C_{xy} = \frac{|P_{xy}|^2}{P_{xx}P_{yy}}
749
+
750
+ Parameters
751
+ ----------
752
+ x, y
753
+ Array or sequence containing the data
754
+
755
+ %(Spectral)s
756
+
757
+ %(PSD)s
758
+
759
+ noverlap : int, default: 0 (no overlap)
760
+ The number of points of overlap between segments.
761
+
762
+ Returns
763
+ -------
764
+ Cxy : 1-D array
765
+ The coherence vector.
766
+ freqs : 1-D array
767
+ The frequencies for the elements in *Cxy*.
768
+
769
+ See Also
770
+ --------
771
+ :func:`psd`, :func:`csd` :
772
+ For information about the methods used to compute :math:`P_{xy}`,
773
+ :math:`P_{xx}` and :math:`P_{yy}`.
774
+ """
775
+ if len(x) < 2 * NFFT:
776
+ raise ValueError(
777
+ "Coherence is calculated by averaging over *NFFT* length "
778
+ "segments. Your signal is too short for your choice of *NFFT*.")
779
+ Pxx, f = psd(x, NFFT, Fs, detrend, window, noverlap, pad_to, sides,
780
+ scale_by_freq)
781
+ Pyy, f = psd(y, NFFT, Fs, detrend, window, noverlap, pad_to, sides,
782
+ scale_by_freq)
783
+ Pxy, f = csd(x, y, NFFT, Fs, detrend, window, noverlap, pad_to, sides,
784
+ scale_by_freq)
785
+ Cxy = np.abs(Pxy) ** 2 / (Pxx * Pyy)
786
+ return Cxy, f
787
+
788
+
789
+ def _rs_kde_1d_arrays(dataset, points, inv_cov):
790
+ """
791
+ Whether `GaussianKDE.evaluate` can take several points at a time: plain
792
+ float64 arrays (so that operations on rows give what the loop gives).
793
+ """
794
+ return all(type(a) is np.ndarray and a.dtype == np.float64
795
+ for a in (dataset, points, inv_cov)) and inv_cov.shape == (1, 1)
796
+
797
+
798
+ class GaussianKDE:
799
+ """
800
+ Representation of a kernel-density estimate using Gaussian kernels.
801
+
802
+ Parameters
803
+ ----------
804
+ dataset : array-like
805
+ Datapoints to estimate from. In case of univariate data this is a 1-D
806
+ array, otherwise a 2D array with shape (# of dims, # of data).
807
+ bw_method : {'scott', 'silverman'} or float or callable, optional
808
+ The method used to calculate the estimator bandwidth. If a
809
+ float, this will be used directly as `!kde.factor`. If a
810
+ callable, it should take a `GaussianKDE` instance as only
811
+ parameter and return a float. If None (default), 'scott' is used.
812
+
813
+ Attributes
814
+ ----------
815
+ dataset : ndarray
816
+ The dataset passed to the constructor.
817
+ dim : int
818
+ Number of dimensions.
819
+ num_dp : int
820
+ Number of datapoints.
821
+ factor : float
822
+ The bandwidth factor, obtained from `~GaussianKDE.covariance_factor`, with which
823
+ the covariance matrix is multiplied.
824
+ covariance : ndarray
825
+ The covariance matrix of *dataset*, scaled by the calculated bandwidth
826
+ (`!kde.factor`).
827
+ inv_cov : ndarray
828
+ The inverse of *covariance*.
829
+
830
+ Methods
831
+ -------
832
+ kde.evaluate(points) : ndarray
833
+ Evaluate the estimated pdf on a provided set of points.
834
+ kde(points) : ndarray
835
+ Same as kde.evaluate(points)
836
+ """
837
+
838
+ # This implementation with minor modification was too good to pass up.
839
+ # from scipy: https://github.com/scipy/scipy/blob/master/scipy/stats/kde.py
840
+
841
+ def __init__(self, dataset, bw_method=None):
842
+ self.dataset = np.atleast_2d(dataset)
843
+ if not np.array(self.dataset).size > 1:
844
+ raise ValueError("`dataset` input should have multiple elements.")
845
+
846
+ self.dim, self.num_dp = np.array(self.dataset).shape
847
+
848
+ if bw_method is None:
849
+ pass
850
+ elif cbook._str_equal(bw_method, 'scott'):
851
+ self.covariance_factor = self.scotts_factor
852
+ elif cbook._str_equal(bw_method, 'silverman'):
853
+ self.covariance_factor = self.silverman_factor
854
+ elif isinstance(bw_method, Number):
855
+ self._bw_method = 'use constant'
856
+ self.covariance_factor = lambda: bw_method
857
+ elif callable(bw_method):
858
+ self._bw_method = bw_method
859
+ self.covariance_factor = lambda: self._bw_method(self)
860
+ else:
861
+ raise ValueError("`bw_method` should be 'scott', 'silverman', a "
862
+ "scalar or a callable")
863
+
864
+ # Computes the covariance matrix for each Gaussian kernel using
865
+ # covariance_factor().
866
+
867
+ self.factor = self.covariance_factor()
868
+ # Cache covariance and inverse covariance of the data
869
+ if not hasattr(self, '_data_inv_cov'):
870
+ self.data_covariance = np.atleast_2d(
871
+ np.cov(
872
+ self.dataset,
873
+ rowvar=1,
874
+ bias=False))
875
+ self.data_inv_cov = np.linalg.inv(self.data_covariance)
876
+
877
+ self.covariance = self.data_covariance * self.factor ** 2
878
+ self.inv_cov = self.data_inv_cov / self.factor ** 2
879
+ self.norm_factor = (np.sqrt(np.linalg.det(2 * np.pi * self.covariance))
880
+ * self.num_dp)
881
+
882
+ def scotts_factor(self):
883
+ return np.power(self.num_dp, -1. / (self.dim + 4))
884
+
885
+ def silverman_factor(self):
886
+ return np.power(
887
+ self.num_dp * (self.dim + 2.0) / 4.0, -1. / (self.dim + 4))
888
+
889
+ # Default method to calculate bandwidth, can be overwritten by subclass
890
+ covariance_factor = scotts_factor
891
+
892
+ def evaluate(self, points):
893
+ """
894
+ Evaluate the estimated pdf on a set of points.
895
+
896
+ Parameters
897
+ ----------
898
+ points : (# of dimensions, # of points)-array
899
+ Alternatively, a (# of dimensions,) vector can be passed in and
900
+ treated as a single point.
901
+
902
+ Returns
903
+ -------
904
+ (# of points,)-array
905
+ The values at each point.
906
+
907
+ Raises
908
+ ------
909
+ ValueError : if the dimensionality of the input points is different
910
+ than the dimensionality of the KDE.
911
+
912
+ """
913
+ points = np.atleast_2d(points)
914
+
915
+ dim, num_m = np.array(points).shape
916
+ if dim != self.dim:
917
+ raise ValueError(f"points have dimension {dim}, dataset has "
918
+ f"dimension {self.dim}")
919
+
920
+ result = np.zeros(num_m)
921
+
922
+ if num_m >= self.num_dp:
923
+ # there are more points than data, so loop over data
924
+ for i in range(self.num_dp):
925
+ diff = self.dataset[:, i, np.newaxis] - points
926
+ tdiff = np.dot(self.inv_cov, diff)
927
+ energy = np.sum(diff * tdiff, axis=0) / 2.0
928
+ result = result + np.exp(-energy)
929
+ elif self.dim == 1 and _rs_kde_1d_arrays(self.dataset, points,
930
+ self.inv_cov):
931
+ # matplotlib_rs: the loop below for one dimension, several points
932
+ # at a time. Every element goes through the same operations in
933
+ # the same order (the product with the 1x1 inverse covariance is
934
+ # one multiplication, the sum over the single dimension is the
935
+ # element itself), and each point's sum over the data is still
936
+ # NumPy's sum of one contiguous row.
937
+ data = self.dataset[0]
938
+ inv_cov = self.inv_cov[0, 0]
939
+ # (about 8,000 elements at a time: larger temporary arrays do
940
+ # not fit the processor's caches and take longer than the loop)
941
+ step = max(1, (1 << 13) // self.num_dp)
942
+ for i in range(0, num_m, step):
943
+ diff = data[np.newaxis, :] - points[0, i:i + step, np.newaxis]
944
+ tdiff = inv_cov * diff
945
+ energy = (diff * tdiff) / 2.0
946
+ result[i:i + step] = np.sum(np.exp(-energy), axis=1)
947
+ else:
948
+ # loop over points
949
+ for i in range(num_m):
950
+ diff = self.dataset - points[:, i, np.newaxis]
951
+ tdiff = np.dot(self.inv_cov, diff)
952
+ energy = np.sum(diff * tdiff, axis=0) / 2.0
953
+ result[i] = np.sum(np.exp(-energy), axis=0)
954
+
955
+ result = result / self.norm_factor
956
+
957
+ return result
958
+
959
+ __call__ = evaluate