dl1wjd2 commited on
Commit
efb9cb0
·
verified ·
1 Parent(s): 2298da3

Upload folder using huggingface_hub (part 11)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +26 -0
  2. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/INSTALLER +1 -0
  3. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/METADATA +175 -0
  4. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/RECORD +0 -0
  5. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/WHEEL +5 -0
  6. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/entry_points.txt +2 -0
  7. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/licenses/LICENSE.txt +37 -0
  8. hug/lib/python3.12/site-packages/networkx-3.7.dist-info/top_level.txt +1 -0
  9. hug/lib/python3.12/site-packages/networkx/utils/tests/test_backends.py +225 -0
  10. hug/lib/python3.12/site-packages/networkx/utils/tests/test_config.py +263 -0
  11. hug/lib/python3.12/site-packages/networkx/utils/tests/test_decorators.py +534 -0
  12. hug/lib/python3.12/site-packages/networkx/utils/tests/test_heaps.py +131 -0
  13. hug/lib/python3.12/site-packages/networkx/utils/tests/test_mapped_queue.py +268 -0
  14. hug/lib/python3.12/site-packages/networkx/utils/tests/test_misc.py +415 -0
  15. hug/lib/python3.12/site-packages/networkx/utils/tests/test_random_sequence.py +53 -0
  16. hug/lib/python3.12/site-packages/networkx/utils/tests/test_rcm.py +63 -0
  17. hug/lib/python3.12/site-packages/networkx/utils/tests/test_unionfind.py +55 -0
  18. hug/lib/python3.12/site-packages/networkx/utils/union_find.py +106 -0
  19. hug/lib/python3.12/site-packages/numpy/__config__.py +170 -0
  20. hug/lib/python3.12/site-packages/numpy/__config__.pyi +114 -0
  21. hug/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd +1312 -0
  22. hug/lib/python3.12/site-packages/numpy/__init__.pxd +12 -0
  23. hug/lib/python3.12/site-packages/numpy/__init__.py +926 -0
  24. hug/lib/python3.12/site-packages/numpy/__init__.pyi +0 -0
  25. hug/lib/python3.12/site-packages/numpy/__pycache__/__config__.cpython-312.pyc +0 -0
  26. hug/lib/python3.12/site-packages/numpy/__pycache__/__init__.cpython-312.pyc +0 -0
  27. hug/lib/python3.12/site-packages/numpy/__pycache__/_array_api_info.cpython-312.pyc +0 -0
  28. hug/lib/python3.12/site-packages/numpy/__pycache__/_configtool.cpython-312.pyc +0 -0
  29. hug/lib/python3.12/site-packages/numpy/__pycache__/_distributor_init.cpython-312.pyc +0 -0
  30. hug/lib/python3.12/site-packages/numpy/__pycache__/_expired_attrs_2_0.cpython-312.pyc +0 -0
  31. hug/lib/python3.12/site-packages/numpy/__pycache__/_globals.cpython-312.pyc +0 -0
  32. hug/lib/python3.12/site-packages/numpy/__pycache__/_pytesttester.cpython-312.pyc +0 -0
  33. hug/lib/python3.12/site-packages/numpy/__pycache__/conftest.cpython-312.pyc +0 -0
  34. hug/lib/python3.12/site-packages/numpy/__pycache__/dtypes.cpython-312.pyc +0 -0
  35. hug/lib/python3.12/site-packages/numpy/__pycache__/exceptions.cpython-312.pyc +0 -0
  36. hug/lib/python3.12/site-packages/numpy/__pycache__/matlib.cpython-312.pyc +0 -0
  37. hug/lib/python3.12/site-packages/numpy/__pycache__/version.cpython-312.pyc +0 -0
  38. hug/lib/python3.12/site-packages/numpy/_array_api_info.py +349 -0
  39. hug/lib/python3.12/site-packages/numpy/_array_api_info.pyi +177 -0
  40. hug/lib/python3.12/site-packages/numpy/_configtool.py +39 -0
  41. hug/lib/python3.12/site-packages/numpy/_configtool.pyi +1 -0
  42. hug/lib/python3.12/site-packages/numpy/_core/__init__.py +203 -0
  43. hug/lib/python3.12/site-packages/numpy/_core/__init__.pyi +673 -0
  44. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/__init__.cpython-312.pyc +0 -0
  45. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_add_newdocs.cpython-312.pyc +3 -0
  46. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_add_newdocs_scalars.cpython-312.pyc +0 -0
  47. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_asarray.cpython-312.pyc +0 -0
  48. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_dtype.cpython-312.pyc +0 -0
  49. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_dtype_ctypes.cpython-312.pyc +0 -0
  50. hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_exceptions.cpython-312.pyc +0 -0
.gitattributes CHANGED
@@ -152,3 +152,29 @@ hug/lib/python3.12/site-packages/mpmath/tests/__pycache__/test_fp.cpython-312.py
152
  hug/lib/python3.12/site-packages/mpmath/tests/__pycache__/test_functions2.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
153
  hug/lib/python3.12/site-packages/networkx/drawing/__pycache__/nx_pylab.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
154
  hug/lib/python3.12/site-packages/networkx/drawing/tests/baseline/test_display_complex.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  hug/lib/python3.12/site-packages/mpmath/tests/__pycache__/test_functions2.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
153
  hug/lib/python3.12/site-packages/networkx/drawing/__pycache__/nx_pylab.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
154
  hug/lib/python3.12/site-packages/networkx/drawing/tests/baseline/test_display_complex.png filter=lfs diff=lfs merge=lfs -text
155
+ hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_add_newdocs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
156
+ hug/lib/python3.12/site-packages/numpy/_core/__pycache__/fromnumeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
157
+ hug/lib/python3.12/site-packages/numpy/_core/_multiarray_tests.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
158
+ hug/lib/python3.12/site-packages/numpy/_core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
159
+ hug/lib/python3.12/site-packages/numpy/_core/_simd.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
160
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_datetime.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
161
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_dtype.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
162
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_indexing.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
163
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_multiarray.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
164
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_nditer.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
165
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_numeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
166
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_regression.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
167
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_stringdtype.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
168
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_ufunc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
169
+ hug/lib/python3.12/site-packages/numpy/_core/tests/__pycache__/test_umath.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
170
+ hug/lib/python3.12/site-packages/numpy/f2py/__pycache__/crackfortran.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
171
+ hug/lib/python3.12/site-packages/numpy/fft/_pocketfft_umath.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
172
+ hug/lib/python3.12/site-packages/numpy/lib/__pycache__/_function_base_impl.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
173
+ hug/lib/python3.12/site-packages/numpy/lib/tests/__pycache__/test_function_base.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
174
+ hug/lib/python3.12/site-packages/numpy/lib/tests/__pycache__/test_io.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
175
+ hug/lib/python3.12/site-packages/numpy/linalg/__pycache__/_linalg.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
176
+ hug/lib/python3.12/site-packages/numpy/linalg/_umath_linalg.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
177
+ hug/lib/python3.12/site-packages/numpy/linalg/tests/__pycache__/test_linalg.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
178
+ hug/lib/python3.12/site-packages/numpy/ma/__pycache__/core.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
179
+ hug/lib/python3.12/site-packages/numpy/ma/tests/__pycache__/test_core.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
180
+ hug/lib/python3.12/site-packages/numpy/ma/tests/__pycache__/test_extras.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/METADATA ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: networkx
3
+ Version: 3.7
4
+ Summary: Python package for creating and manipulating graphs and networks
5
+ Author-email: Aric Hagberg <hagberg@lanl.gov>
6
+ Maintainer-email: NetworkX Developers <networkx-discuss@googlegroups.com>
7
+ License-Expression: BSD-3-Clause
8
+ Project-URL: Homepage, https://networkx.org/
9
+ Project-URL: Bug Tracker, https://github.com/networkx/networkx/issues
10
+ Project-URL: Documentation, https://networkx.org/documentation/stable/
11
+ Project-URL: Source Code, https://github.com/networkx/networkx
12
+ Keywords: Networks,Graph Theory,Mathematics,network,graph,discrete mathematics,math
13
+ Platform: Linux
14
+ Platform: Mac OSX
15
+ Platform: Windows
16
+ Platform: Unix
17
+ Classifier: Development Status :: 5 - Production/Stable
18
+ Classifier: Intended Audience :: Developers
19
+ Classifier: Intended Audience :: Science/Research
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Programming Language :: Python :: 3.15
26
+ Classifier: Programming Language :: Python :: 3 :: Only
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
29
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
30
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
31
+ Classifier: Topic :: Scientific/Engineering :: Physics
32
+ Requires-Python: !=3.14.1,>=3.12
33
+ Description-Content-Type: text/x-rst
34
+ License-File: LICENSE.txt
35
+ Provides-Extra: benchmarking
36
+ Requires-Dist: asv>=0.6.5; extra == "benchmarking"
37
+ Requires-Dist: py-rattler<0.22,>=0.21; extra == "benchmarking"
38
+ Requires-Dist: virtualenv; extra == "benchmarking"
39
+ Provides-Extra: default
40
+ Requires-Dist: numpy>=2.2; extra == "default"
41
+ Requires-Dist: scipy>=1.15; extra == "default"
42
+ Requires-Dist: matplotlib>=3.10; extra == "default"
43
+ Requires-Dist: pandas>=2.3; extra == "default"
44
+ Provides-Extra: developer
45
+ Requires-Dist: pre-commit>=4.1; extra == "developer"
46
+ Requires-Dist: mypy>=1.15; extra == "developer"
47
+ Provides-Extra: doc
48
+ Requires-Dist: sphinx>=8.0; extra == "doc"
49
+ Requires-Dist: pydata-sphinx-theme>=0.16; extra == "doc"
50
+ Requires-Dist: sphinx-gallery>=0.18; extra == "doc"
51
+ Requires-Dist: numpydoc>=1.8.0; extra == "doc"
52
+ Requires-Dist: pillow>=10; extra == "doc"
53
+ Requires-Dist: texext>=0.6.7; extra == "doc"
54
+ Requires-Dist: myst-nb>=1.1; extra == "doc"
55
+ Requires-Dist: intersphinx-registry; extra == "doc"
56
+ Provides-Extra: example
57
+ Requires-Dist: osmnx>=2.0.0; extra == "example"
58
+ Requires-Dist: momepy>=0.7.2; extra == "example"
59
+ Requires-Dist: contextily>=1.6; extra == "example"
60
+ Requires-Dist: seaborn>=0.13; extra == "example"
61
+ Requires-Dist: cairocffi>=1.7; extra == "example"
62
+ Requires-Dist: igraph>=0.11; extra == "example"
63
+ Requires-Dist: scikit-learn>=1.6; extra == "example"
64
+ Requires-Dist: iplotx>=0.9.0; extra == "example"
65
+ Requires-Dist: hiveplotlib>=0.28; extra == "example"
66
+ Provides-Extra: extra
67
+ Requires-Dist: lxml>=4.6; extra == "extra"
68
+ Requires-Dist: pygraphviz>=2.0; extra == "extra"
69
+ Requires-Dist: pydot>=3.0.1; extra == "extra"
70
+ Requires-Dist: sympy>=1.10; extra == "extra"
71
+ Provides-Extra: release
72
+ Requires-Dist: build>=0.10; extra == "release"
73
+ Requires-Dist: twine>=4.0; extra == "release"
74
+ Requires-Dist: wheel>=0.40; extra == "release"
75
+ Requires-Dist: changelist==0.5; extra == "release"
76
+ Provides-Extra: test
77
+ Requires-Dist: pytest>=7.2; extra == "test"
78
+ Requires-Dist: pytest-cov>=4.0; extra == "test"
79
+ Requires-Dist: pytest-xdist>=3.0; extra == "test"
80
+ Provides-Extra: test-extras
81
+ Requires-Dist: pytest-mpl; extra == "test-extras"
82
+ Requires-Dist: pytest-randomly; extra == "test-extras"
83
+ Dynamic: license-file
84
+
85
+ NetworkX
86
+ ========
87
+
88
+
89
+ .. image::
90
+ https://github.com/networkx/networkx/actions/workflows/test.yml/badge.svg?branch=main
91
+ :target: https://github.com/networkx/networkx/actions/workflows/test.yml
92
+
93
+ .. image::
94
+ https://img.shields.io/pypi/v/networkx.svg?
95
+ :target: https://pypi.python.org/pypi/networkx
96
+
97
+ .. image::
98
+ https://img.shields.io/pypi/l/networkx.svg?
99
+ :target: https://github.com/networkx/networkx/blob/main/LICENSE.txt
100
+
101
+ .. image::
102
+ https://img.shields.io/pypi/pyversions/networkx.svg?
103
+ :target: https://pypi.python.org/pypi/networkx
104
+
105
+ .. image::
106
+ https://insights.linuxfoundation.org/api/badge/health-score?project=networkx
107
+ :target: https://insights.linuxfoundation.org/project/networkx
108
+
109
+
110
+ NetworkX is a Python package for the creation, manipulation,
111
+ and study of the structure, dynamics, and functions
112
+ of complex networks.
113
+
114
+ - **Website (including documentation):** https://networkx.org
115
+ - **Mailing list:** https://groups.google.com/forum/#!forum/networkx-discuss
116
+ - **Source:** https://github.com/networkx/networkx
117
+ - **Bug reports:** https://github.com/networkx/networkx/issues
118
+ - **Report a security vulnerability:** https://tidelift.com/security
119
+ - **Tutorial:** https://networkx.org/documentation/latest/tutorial.html
120
+ - **GitHub Discussions:** https://github.com/networkx/networkx/discussions
121
+ - **Discord (Scientific Python) invite link:** https://discord.com/invite/vur45CbwMz
122
+ - **NetworkX meetings calendar (open to all):** https://scientific-python.org/calendars/networkx.ics
123
+
124
+ Simple example
125
+ --------------
126
+
127
+ Find the shortest path between two nodes in an undirected graph:
128
+
129
+ .. code:: pycon
130
+
131
+ >>> import networkx as nx
132
+ >>> G = nx.Graph()
133
+ >>> G.add_edge("A", "B", weight=4)
134
+ >>> G.add_edge("B", "D", weight=2)
135
+ >>> G.add_edge("A", "C", weight=3)
136
+ >>> G.add_edge("C", "D", weight=4)
137
+ >>> nx.shortest_path(G, "A", "D", weight="weight")
138
+ ['A', 'B', 'D']
139
+
140
+ Install
141
+ -------
142
+
143
+ Install the latest released version of NetworkX:
144
+
145
+ .. code:: shell
146
+
147
+ $ pip install networkx
148
+
149
+ Install with all optional dependencies:
150
+
151
+ .. code:: shell
152
+
153
+ $ pip install networkx[default]
154
+
155
+ For additional details,
156
+ please see the `installation guide <https://networkx.org/documentation/stable/install.html>`_.
157
+
158
+ Bugs
159
+ ----
160
+
161
+ Please report any bugs that you find `here <https://github.com/networkx/networkx/issues>`_.
162
+ Or, even better, fork the repository on `GitHub <https://github.com/networkx/networkx>`_
163
+ and create a pull request (PR). We welcome all changes, big or small, and we
164
+ will help you make the PR if you are new to `git` (just ask on the issue and/or
165
+ see the `contributor guide <https://networkx.org/documentation/latest/developer/contribute.html>`_).
166
+
167
+ License
168
+ -------
169
+
170
+ Released under the `3-clause BSD license <https://github.com/networkx/networkx/blob/main/LICENSE.txt>`_::
171
+
172
+ Copyright (c) 2004-2026, NetworkX Developers
173
+ Aric Hagberg <hagberg@lanl.gov>
174
+ Dan Schult <dschult@colgate.edu>
175
+ Pieter Swart <swart@lanl.gov>
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/RECORD ADDED
The diff for this file is too large to render. See raw diff
 
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/entry_points.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [networkx.backends]
2
+ nx_loopback = networkx.classes.tests.dispatch_interface:backend_interface
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/licenses/LICENSE.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NetworkX is distributed with the 3-clause BSD license.
2
+
3
+ ::
4
+
5
+ Copyright (c) 2004-2026, NetworkX Developers
6
+ Aric Hagberg <hagberg@lanl.gov>
7
+ Dan Schult <dschult@colgate.edu>
8
+ Pieter Swart <swart@lanl.gov>
9
+ All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are
13
+ met:
14
+
15
+ * Redistributions of source code must retain the above copyright
16
+ notice, this list of conditions and the following disclaimer.
17
+
18
+ * Redistributions in binary form must reproduce the above
19
+ copyright notice, this list of conditions and the following
20
+ disclaimer in the documentation and/or other materials provided
21
+ with the distribution.
22
+
23
+ * Neither the name of the NetworkX Developers nor the names of its
24
+ contributors may be used to endorse or promote products derived
25
+ from this software without specific prior written permission.
26
+
27
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
hug/lib/python3.12/site-packages/networkx-3.7.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ networkx
hug/lib/python3.12/site-packages/networkx/utils/tests/test_backends.py ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pickle
2
+
3
+ import pytest
4
+
5
+ import networkx as nx
6
+
7
+ sp = pytest.importorskip("scipy")
8
+ pytest.importorskip("numpy")
9
+
10
+
11
+ @nx._dispatchable(implemented_by_nx=False)
12
+ def _stub_func(G):
13
+ raise NotImplementedError("_stub_func is a stub")
14
+
15
+
16
+ def test_dispatch_kwds_vs_args():
17
+ G = nx.path_graph(4)
18
+ nx.pagerank(G)
19
+ nx.pagerank(G=G)
20
+ with pytest.raises(TypeError):
21
+ nx.pagerank()
22
+
23
+
24
+ def test_pickle():
25
+ count = 0
26
+ for name, func in nx.utils.backends._registered_algorithms.items():
27
+ pickled = pickle.dumps(func.__wrapped__)
28
+ assert pickle.loads(pickled) is func.__wrapped__
29
+ try:
30
+ # Some functions can't be pickled, but it's not b/c of _dispatchable
31
+ pickled = pickle.dumps(func)
32
+ except pickle.PicklingError:
33
+ continue
34
+ assert pickle.loads(pickled) is func
35
+ count += 1
36
+ assert count > 0
37
+ assert pickle.loads(pickle.dumps(nx.inverse_line_graph)) is nx.inverse_line_graph
38
+
39
+
40
+ @pytest.mark.skipif(
41
+ "not nx.config.backend_priority.algos "
42
+ "or nx.config.backend_priority.algos[0] != 'nx_loopback'"
43
+ )
44
+ def test_graph_converter_needs_backend():
45
+ # When testing, `nx.from_scipy_sparse_array` will *always* call the backend
46
+ # implementation if it's implemented. If `backend=` isn't given, then the result
47
+ # will be converted back to NetworkX via `convert_to_nx`.
48
+ # If not testing, then calling `nx.from_scipy_sparse_array` w/o `backend=` will
49
+ # always call the original version. `backend=` is *required* to call the backend.
50
+ from networkx.classes.tests.dispatch_interface import (
51
+ LoopbackBackendInterface,
52
+ LoopbackGraph,
53
+ )
54
+
55
+ A = sp.sparse.coo_array([[0, 3, 2], [3, 0, 1], [2, 1, 0]])
56
+
57
+ side_effects = []
58
+
59
+ def from_scipy_sparse_array(self, *args, **kwargs):
60
+ side_effects.append(1) # Just to prove this was called
61
+ return self.convert_from_nx(
62
+ self.__getattr__("from_scipy_sparse_array")(*args, **kwargs),
63
+ preserve_edge_attrs=True,
64
+ preserve_node_attrs=True,
65
+ preserve_graph_attrs=True,
66
+ )
67
+
68
+ @staticmethod
69
+ def convert_to_nx(obj, *, name=None):
70
+ if type(obj) is nx.Graph:
71
+ return obj
72
+ return nx.Graph(obj)
73
+
74
+ # *This mutates LoopbackBackendInterface!*
75
+ orig_convert_to_nx = LoopbackBackendInterface.convert_to_nx
76
+ LoopbackBackendInterface.convert_to_nx = convert_to_nx
77
+ LoopbackBackendInterface.from_scipy_sparse_array = from_scipy_sparse_array
78
+
79
+ try:
80
+ assert side_effects == []
81
+ assert type(nx.from_scipy_sparse_array(A)) is nx.Graph
82
+ assert side_effects == [1]
83
+ assert (
84
+ type(nx.from_scipy_sparse_array(A, backend="nx_loopback")) is LoopbackGraph
85
+ )
86
+ assert side_effects == [1, 1]
87
+ # backend="networkx" is default implementation
88
+ assert type(nx.from_scipy_sparse_array(A, backend="networkx")) is nx.Graph
89
+ assert side_effects == [1, 1]
90
+ finally:
91
+ LoopbackBackendInterface.convert_to_nx = staticmethod(orig_convert_to_nx)
92
+ del LoopbackBackendInterface.from_scipy_sparse_array
93
+ with pytest.raises(ImportError, match="backend is not installed"):
94
+ nx.from_scipy_sparse_array(A, backend="bad-backend-name")
95
+
96
+
97
+ @pytest.mark.skipif(
98
+ "not nx.config.backend_priority.algos "
99
+ "or nx.config.backend_priority.algos[0] != 'nx_loopback'"
100
+ )
101
+ def test_networkx_backend():
102
+ """Test using `backend="networkx"` in a dispatchable function."""
103
+ # (Implementing this test is harder than it should be)
104
+ from networkx.classes.tests.dispatch_interface import (
105
+ LoopbackBackendInterface,
106
+ LoopbackGraph,
107
+ )
108
+
109
+ G = LoopbackGraph()
110
+ G.add_edges_from([(0, 1), (1, 2), (1, 3), (2, 4)])
111
+
112
+ @staticmethod
113
+ def convert_to_nx(obj, *, name=None):
114
+ if isinstance(obj, LoopbackGraph):
115
+ new_graph = nx.Graph()
116
+ new_graph.__dict__.update(obj.__dict__)
117
+ return new_graph
118
+ return obj
119
+
120
+ # *This mutates LoopbackBackendInterface!*
121
+ # This uses the same trick as in the previous test.
122
+ orig_convert_to_nx = LoopbackBackendInterface.convert_to_nx
123
+ LoopbackBackendInterface.convert_to_nx = convert_to_nx
124
+ try:
125
+ G2 = nx.ego_graph(G, 0, backend="networkx")
126
+ assert type(G2) is nx.Graph
127
+ finally:
128
+ LoopbackBackendInterface.convert_to_nx = staticmethod(orig_convert_to_nx)
129
+
130
+
131
+ def test_dispatchable_are_functions():
132
+ assert type(nx.pagerank) is type(nx.pagerank.orig_func)
133
+
134
+
135
+ @pytest.mark.skipif("not nx.utils.backends.backends")
136
+ def test_mixing_backend_graphs():
137
+ from networkx.classes.tests import dispatch_interface
138
+
139
+ G = nx.Graph()
140
+ G.add_edge(1, 2)
141
+ G.add_edge(2, 3)
142
+ H = nx.Graph()
143
+ H.add_edge(2, 3)
144
+ rv = nx.intersection(G, H)
145
+ assert set(nx.intersection(G, H)) == {2, 3}
146
+ G2 = dispatch_interface.convert(G)
147
+ H2 = dispatch_interface.convert(H)
148
+ if "nx_loopback" in nx.config.backend_priority:
149
+ # Auto-convert
150
+ assert set(nx.intersection(G2, H)) == {2, 3}
151
+ assert set(nx.intersection(G, H2)) == {2, 3}
152
+ elif not nx.config.backend_priority and "nx_loopback" not in nx.config.backends:
153
+ # G2 and H2 are backend objects for a backend that is not registered!
154
+ with pytest.raises(ImportError, match="backend is not installed"):
155
+ nx.intersection(G2, H)
156
+ with pytest.raises(ImportError, match="backend is not installed"):
157
+ nx.intersection(G, H2)
158
+ # It would be nice to test passing graphs from *different* backends,
159
+ # but we are not set up to do this yet.
160
+
161
+
162
+ def test_bad_backend_name():
163
+ """Using `backend=` raises with unknown backend even if there are no backends."""
164
+ with pytest.raises(
165
+ ImportError, match="'this_backend_does_not_exist' backend is not installed"
166
+ ):
167
+ nx.null_graph(backend="this_backend_does_not_exist")
168
+
169
+
170
+ def test_not_implemented_by_nx():
171
+ assert "networkx" in nx.pagerank.backends
172
+ assert "networkx" not in _stub_func.backends
173
+
174
+ if "nx_loopback" in nx.config.backends:
175
+ from networkx.classes.tests.dispatch_interface import LoopbackBackendInterface
176
+
177
+ def stub_func_implementation(G):
178
+ return True
179
+
180
+ LoopbackBackendInterface._stub_func = staticmethod(stub_func_implementation)
181
+ try:
182
+ assert _stub_func(nx.Graph()) is True
183
+ finally:
184
+ del LoopbackBackendInterface._stub_func
185
+
186
+ with pytest.raises(NotImplementedError):
187
+ _stub_func(nx.Graph())
188
+
189
+
190
+ @pytest.mark.skipif(
191
+ "not nx.config.backend_priority.algos "
192
+ "or nx.config.backend_priority.algos[0] != 'nx_loopback'"
193
+ )
194
+ def test_dispatch_graph_new():
195
+ from networkx.classes.tests.dispatch_interface import LoopbackGraph
196
+
197
+ G = nx.Graph()
198
+ assert not isinstance(G, LoopbackGraph)
199
+
200
+ # `backend=` argument that gets passed to __init__ is ignored.
201
+ # Best practice is that it should not be in the `.graph` dict.
202
+ G = nx.Graph(backend="networkx")
203
+ assert type(G) is nx.Graph
204
+ assert "backend" not in G.graph
205
+
206
+ G = nx.Graph(backend="nx_loopback")
207
+ assert isinstance(G, LoopbackGraph)
208
+ assert "backend" not in G.graph
209
+
210
+ # Args are passed
211
+ G1 = nx.Graph([(0, 1), (1, 2)])
212
+ assert not isinstance(G1, LoopbackGraph)
213
+ G2 = nx.Graph([(0, 1), (1, 2)], backend="nx_loopback")
214
+ assert isinstance(G2, LoopbackGraph)
215
+ assert nx.utils.misc.graphs_equal(G1, G2)
216
+
217
+ # Test config for automatic usage
218
+ with nx.config.backend_priority(classes=["nx_loopback"]):
219
+ G = nx.Graph()
220
+ assert isinstance(G, LoopbackGraph)
221
+ # LoopbackDiGraph __new__ is not implemented
222
+ G = nx.DiGraph()
223
+ assert not isinstance(G, LoopbackGraph)
224
+ G = nx.Graph()
225
+ assert not isinstance(G, LoopbackGraph)
hug/lib/python3.12/site-packages/networkx/utils/tests/test_config.py ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import collections
2
+ import pickle
3
+
4
+ import pytest
5
+
6
+ import networkx as nx
7
+ from networkx.utils.configs import BackendPriorities, Config
8
+
9
+
10
+ # Define this at module level so we can test pickling
11
+ class ExampleConfig(Config):
12
+ """Example configuration."""
13
+
14
+ x: int
15
+ y: str
16
+
17
+ def _on_setattr(self, key, value):
18
+ if key == "x" and value <= 0:
19
+ raise ValueError("x must be positive")
20
+ if key == "y" and not isinstance(value, str):
21
+ raise TypeError("y must be a str")
22
+ return value
23
+
24
+
25
+ class EmptyConfig(Config):
26
+ pass
27
+
28
+
29
+ @pytest.mark.parametrize("cfg", [EmptyConfig(), Config()])
30
+ def test_config_empty(cfg):
31
+ assert dir(cfg) == []
32
+ with pytest.raises(AttributeError):
33
+ cfg.x = 1
34
+ with pytest.raises(KeyError):
35
+ cfg["x"] = 1
36
+ with pytest.raises(AttributeError):
37
+ cfg.x
38
+ with pytest.raises(KeyError):
39
+ cfg["x"]
40
+ assert len(cfg) == 0
41
+ assert "x" not in cfg
42
+ assert cfg == cfg
43
+ assert cfg.get("x", 2) == 2
44
+ assert set(cfg.keys()) == set()
45
+ assert set(cfg.values()) == set()
46
+ assert set(cfg.items()) == set()
47
+ cfg2 = pickle.loads(pickle.dumps(cfg))
48
+ assert cfg == cfg2
49
+ assert isinstance(cfg, collections.abc.Collection)
50
+ assert isinstance(cfg, collections.abc.Mapping)
51
+
52
+
53
+ def test_config_subclass():
54
+ with pytest.raises(TypeError, match="missing 2 required keyword-only"):
55
+ ExampleConfig()
56
+ with pytest.raises(ValueError, match="x must be positive"):
57
+ ExampleConfig(x=0, y="foo")
58
+ with pytest.raises(TypeError, match="unexpected keyword"):
59
+ ExampleConfig(x=1, y="foo", z="bad config")
60
+ with pytest.raises(TypeError, match="unexpected keyword"):
61
+ EmptyConfig(z="bad config")
62
+ cfg = ExampleConfig(x=1, y="foo")
63
+ assert cfg.x == 1
64
+ assert cfg["x"] == 1
65
+ assert cfg["y"] == "foo"
66
+ assert cfg.y == "foo"
67
+ assert "x" in cfg
68
+ assert "y" in cfg
69
+ assert "z" not in cfg
70
+ assert len(cfg) == 2
71
+ assert set(iter(cfg)) == {"x", "y"}
72
+ assert set(cfg.keys()) == {"x", "y"}
73
+ assert set(cfg.values()) == {1, "foo"}
74
+ assert set(cfg.items()) == {("x", 1), ("y", "foo")}
75
+ assert dir(cfg) == ["x", "y"]
76
+ cfg.x = 2
77
+ cfg["y"] = "bar"
78
+ assert cfg["x"] == 2
79
+ assert cfg.y == "bar"
80
+ with pytest.raises(TypeError, match="can't be deleted"):
81
+ del cfg.x
82
+ with pytest.raises(TypeError, match="can't be deleted"):
83
+ del cfg["y"]
84
+ assert cfg.x == 2
85
+ assert cfg == cfg
86
+ assert cfg == ExampleConfig(x=2, y="bar")
87
+ assert cfg != ExampleConfig(x=3, y="baz")
88
+ assert cfg != Config(x=2, y="bar")
89
+ with pytest.raises(TypeError, match="y must be a str"):
90
+ cfg["y"] = 5
91
+ with pytest.raises(ValueError, match="x must be positive"):
92
+ cfg.x = -5
93
+ assert cfg.get("x", 10) == 2
94
+ with pytest.raises(AttributeError):
95
+ cfg.z = 5
96
+ with pytest.raises(KeyError):
97
+ cfg["z"] = 5
98
+ with pytest.raises(AttributeError):
99
+ cfg.z
100
+ with pytest.raises(KeyError):
101
+ cfg["z"]
102
+ cfg2 = pickle.loads(pickle.dumps(cfg))
103
+ assert cfg == cfg2
104
+ assert cfg.__doc__ == "Example configuration."
105
+ assert cfg2.__doc__ == "Example configuration."
106
+
107
+
108
+ def test_config_defaults():
109
+ class DefaultConfig(Config):
110
+ x: int = 0
111
+ y: int
112
+
113
+ cfg = DefaultConfig(y=1)
114
+ assert cfg.x == 0
115
+ cfg = DefaultConfig(x=2, y=1)
116
+ assert cfg.x == 2
117
+
118
+
119
+ def test_nxconfig():
120
+ assert isinstance(nx.config.backend_priority, BackendPriorities)
121
+ assert isinstance(nx.config.backend_priority.algos, list)
122
+ assert isinstance(nx.config.backends, Config)
123
+ with pytest.raises(TypeError, match="must be a list of backend names"):
124
+ nx.config.backend_priority.algos = "nx_loopback"
125
+ with pytest.raises(ValueError, match="Unknown backend when setting"):
126
+ nx.config.backend_priority.algos = ["this_almost_certainly_is_not_a_backend"]
127
+ with pytest.raises(TypeError, match="must be a Config of backend configs"):
128
+ nx.config.backends = {}
129
+ with pytest.raises(TypeError, match="must be a Config of backend configs"):
130
+ nx.config.backends = Config(plausible_backend_name={})
131
+ with pytest.raises(ValueError, match="Unknown backend when setting"):
132
+ nx.config.backends = Config(this_almost_certainly_is_not_a_backend=Config())
133
+ with pytest.raises(TypeError, match="must be True or False"):
134
+ nx.config.cache_converted_graphs = "bad value"
135
+ with pytest.raises(TypeError, match="must be a set of "):
136
+ nx.config.warnings_to_ignore = 7
137
+ with pytest.raises(ValueError, match="Unknown warning "):
138
+ nx.config.warnings_to_ignore = {"bad value"}
139
+
140
+ prev = nx.config.backend_priority
141
+ try:
142
+ nx.config.backend_priority = ["networkx"]
143
+ assert isinstance(nx.config.backend_priority, BackendPriorities)
144
+ assert nx.config.backend_priority.algos == ["networkx"]
145
+ finally:
146
+ nx.config.backend_priority = prev
147
+
148
+
149
+ def test_nxconfig_context():
150
+ # We do some special handling so that `nx.config.backend_priority = val`
151
+ # actually does `nx.config.backend_priority.algos = val`.
152
+ orig = nx.config.backend_priority.algos
153
+ val = [] if orig else ["networkx"]
154
+ assert orig != val
155
+ assert nx.config.backend_priority.algos != val
156
+ with nx.config(backend_priority=val):
157
+ assert nx.config.backend_priority.algos == val
158
+ assert nx.config.backend_priority.algos == orig
159
+ with nx.config.backend_priority(algos=val):
160
+ assert nx.config.backend_priority.algos == val
161
+ assert nx.config.backend_priority.algos == orig
162
+ bad = ["bad-backend"]
163
+ with pytest.raises(ValueError, match="Unknown backend"):
164
+ nx.config.backend_priority = bad
165
+ with pytest.raises(ValueError, match="Unknown backend"):
166
+ with nx.config(backend_priority=bad):
167
+ pass
168
+ with pytest.raises(ValueError, match="Unknown backend"):
169
+ with nx.config.backend_priority(algos=bad):
170
+ pass
171
+
172
+
173
+ def test_not_strict():
174
+ class FlexibleConfig(Config, strict=False):
175
+ x: int
176
+
177
+ cfg = FlexibleConfig(x=1)
178
+ assert "_strict" not in cfg
179
+ assert len(cfg) == 1
180
+ assert list(cfg) == ["x"]
181
+ assert list(cfg.keys()) == ["x"]
182
+ assert list(cfg.values()) == [1]
183
+ assert list(cfg.items()) == [("x", 1)]
184
+ assert cfg.x == 1
185
+ assert cfg["x"] == 1
186
+ assert "x" in cfg
187
+ assert hasattr(cfg, "x")
188
+ assert "FlexibleConfig(x=1)" in repr(cfg)
189
+ assert cfg == FlexibleConfig(x=1)
190
+ del cfg.x
191
+ assert "FlexibleConfig()" in repr(cfg)
192
+ assert len(cfg) == 0
193
+ assert not hasattr(cfg, "x")
194
+ assert "x" not in cfg
195
+ assert not hasattr(cfg, "y")
196
+ assert "y" not in cfg
197
+ cfg.y = 2
198
+ assert len(cfg) == 1
199
+ assert list(cfg) == ["y"]
200
+ assert list(cfg.keys()) == ["y"]
201
+ assert list(cfg.values()) == [2]
202
+ assert list(cfg.items()) == [("y", 2)]
203
+ assert cfg.y == 2
204
+ assert cfg["y"] == 2
205
+ assert hasattr(cfg, "y")
206
+ assert "y" in cfg
207
+ del cfg["y"]
208
+ assert len(cfg) == 0
209
+ assert list(cfg) == []
210
+ with pytest.raises(AttributeError, match="y"):
211
+ del cfg.y
212
+ with pytest.raises(KeyError, match="y"):
213
+ del cfg["y"]
214
+ with pytest.raises(TypeError, match="missing 1 required keyword-only"):
215
+ FlexibleConfig()
216
+ # Be strict when first creating the config object
217
+ with pytest.raises(TypeError, match="unexpected keyword argument 'y'"):
218
+ FlexibleConfig(x=1, y=2)
219
+
220
+ class FlexibleConfigWithDefault(Config, strict=False):
221
+ x: int = 0
222
+
223
+ assert FlexibleConfigWithDefault().x == 0
224
+ assert FlexibleConfigWithDefault(x=1)["x"] == 1
225
+
226
+
227
+ def test_context():
228
+ cfg = Config(x=1)
229
+ with cfg(x=2) as c:
230
+ assert c.x == 2
231
+ c.x = 3
232
+ assert cfg.x == 3
233
+ assert cfg.x == 1
234
+
235
+ with cfg(x=2) as c:
236
+ assert c == cfg
237
+ assert cfg.x == 2
238
+ with cfg(x=3) as c2:
239
+ assert c2 == cfg
240
+ assert cfg.x == 3
241
+ with pytest.raises(RuntimeError, match="context manager without"):
242
+ with cfg as c3: # Forgot to call `cfg(...)`
243
+ pass
244
+ assert cfg.x == 3
245
+ assert cfg.x == 2
246
+ assert cfg.x == 1
247
+
248
+ c = cfg(x=4) # Not yet as context (not recommended, but possible)
249
+ assert c == cfg
250
+ assert cfg.x == 4
251
+ # Cheat by looking at internal data; context stack should only grow with __enter__
252
+ assert cfg._prev is not None
253
+ assert cfg._context_stack == []
254
+ with c:
255
+ assert c == cfg
256
+ assert cfg.x == 4
257
+ assert cfg.x == 1
258
+ # Cheat again; there was no preceding `cfg(...)` call this time
259
+ assert cfg._prev is None
260
+ with pytest.raises(RuntimeError, match="context manager without"):
261
+ with cfg:
262
+ pass
263
+ assert cfg.x == 1
hug/lib/python3.12/site-packages/networkx/utils/tests/test_decorators.py ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import pathlib
3
+ import random
4
+ import tempfile
5
+
6
+ import pytest
7
+
8
+ import networkx as nx
9
+ from networkx.utils.decorators import (
10
+ argmap,
11
+ not_implemented_for,
12
+ np_random_state,
13
+ open_file,
14
+ py_random_state,
15
+ )
16
+ from networkx.utils.misc import PythonRandomInterface, PythonRandomViaNumpyBits
17
+
18
+
19
+ def test_not_implemented_decorator():
20
+ @not_implemented_for("directed")
21
+ def test_d(G):
22
+ pass
23
+
24
+ test_d(nx.Graph())
25
+ with pytest.raises(nx.NetworkXNotImplemented):
26
+ test_d(nx.DiGraph())
27
+
28
+ @not_implemented_for("undirected")
29
+ def test_u(G):
30
+ pass
31
+
32
+ test_u(nx.DiGraph())
33
+ with pytest.raises(nx.NetworkXNotImplemented):
34
+ test_u(nx.Graph())
35
+
36
+ @not_implemented_for("multigraph")
37
+ def test_m(G):
38
+ pass
39
+
40
+ test_m(nx.Graph())
41
+ with pytest.raises(nx.NetworkXNotImplemented):
42
+ test_m(nx.MultiGraph())
43
+
44
+ @not_implemented_for("graph")
45
+ def test_g(G):
46
+ pass
47
+
48
+ test_g(nx.MultiGraph())
49
+ with pytest.raises(nx.NetworkXNotImplemented):
50
+ test_g(nx.Graph())
51
+
52
+ # not MultiDiGraph (multiple arguments => AND)
53
+ @not_implemented_for("directed", "multigraph")
54
+ def test_not_md(G):
55
+ pass
56
+
57
+ test_not_md(nx.Graph())
58
+ test_not_md(nx.DiGraph())
59
+ test_not_md(nx.MultiGraph())
60
+ with pytest.raises(nx.NetworkXNotImplemented):
61
+ test_not_md(nx.MultiDiGraph())
62
+
63
+ # Graph only (multiple decorators => OR)
64
+ @not_implemented_for("directed")
65
+ @not_implemented_for("multigraph")
66
+ def test_graph_only(G):
67
+ pass
68
+
69
+ test_graph_only(nx.Graph())
70
+ with pytest.raises(nx.NetworkXNotImplemented):
71
+ test_graph_only(nx.DiGraph())
72
+ with pytest.raises(nx.NetworkXNotImplemented):
73
+ test_graph_only(nx.MultiGraph())
74
+ with pytest.raises(nx.NetworkXNotImplemented):
75
+ test_graph_only(nx.MultiDiGraph())
76
+
77
+ with pytest.raises(ValueError):
78
+ not_implemented_for("directed", "undirected")
79
+
80
+ with pytest.raises(ValueError):
81
+ not_implemented_for("multigraph", "graph")
82
+
83
+
84
+ def test_not_implemented_decorator_key():
85
+ with pytest.raises(KeyError):
86
+
87
+ @not_implemented_for("foo")
88
+ def test1(G):
89
+ pass
90
+
91
+ test1(nx.Graph())
92
+
93
+
94
+ def test_not_implemented_decorator_raise():
95
+ with pytest.raises(nx.NetworkXNotImplemented):
96
+
97
+ @not_implemented_for("graph")
98
+ def test1(G):
99
+ pass
100
+
101
+ test1(nx.Graph())
102
+
103
+
104
+ class TestOpenFileDecorator:
105
+ def setup_method(self):
106
+ self.text = ["Blah... ", "BLAH ", "BLAH!!!!"]
107
+ self.fobj = tempfile.NamedTemporaryFile("wb+", delete=False)
108
+ self.name = self.fobj.name
109
+
110
+ def teardown_method(self):
111
+ self.fobj.close()
112
+ os.unlink(self.name)
113
+
114
+ def write(self, path):
115
+ for text in self.text:
116
+ path.write(text.encode("ascii"))
117
+
118
+ @open_file(1, "r")
119
+ def read(self, path):
120
+ return path.readlines()[0]
121
+
122
+ @staticmethod
123
+ @open_file(0, "wb")
124
+ def writer_arg0(path):
125
+ path.write(b"demo")
126
+
127
+ @open_file(1, "wb+")
128
+ def writer_arg1(self, path):
129
+ self.write(path)
130
+
131
+ @open_file(2, "wb")
132
+ def writer_arg2default(self, x, path=None):
133
+ if path is None:
134
+ with tempfile.NamedTemporaryFile("wb+") as fh:
135
+ self.write(fh)
136
+ else:
137
+ self.write(path)
138
+
139
+ @open_file(4, "wb")
140
+ def writer_arg4default(self, x, y, other="hello", path=None, **kwargs):
141
+ if path is None:
142
+ with tempfile.NamedTemporaryFile("wb+") as fh:
143
+ self.write(fh)
144
+ else:
145
+ self.write(path)
146
+
147
+ @open_file("path", "wb")
148
+ def writer_kwarg(self, **kwargs):
149
+ path = kwargs.get("path", None)
150
+ if path is None:
151
+ with tempfile.NamedTemporaryFile("wb+") as fh:
152
+ self.write(fh)
153
+ else:
154
+ self.write(path)
155
+
156
+ def test_writer_arg0_str(self):
157
+ self.writer_arg0(self.name)
158
+
159
+ def test_writer_arg0_fobj(self):
160
+ self.writer_arg0(self.fobj)
161
+
162
+ def test_writer_arg0_pathlib(self):
163
+ self.writer_arg0(pathlib.Path(self.name))
164
+
165
+ def test_writer_arg1_str(self):
166
+ self.writer_arg1(self.name)
167
+ assert self.read(self.name) == "".join(self.text)
168
+
169
+ def test_writer_arg1_fobj(self):
170
+ self.writer_arg1(self.fobj)
171
+ assert not self.fobj.closed
172
+ self.fobj.close()
173
+ assert self.read(self.name) == "".join(self.text)
174
+
175
+ def test_writer_arg2default_str(self):
176
+ self.writer_arg2default(0, path=None)
177
+ self.writer_arg2default(0, path=self.name)
178
+ assert self.read(self.name) == "".join(self.text)
179
+
180
+ def test_writer_arg2default_fobj(self):
181
+ self.writer_arg2default(0, path=self.fobj)
182
+ assert not self.fobj.closed
183
+ self.fobj.close()
184
+ assert self.read(self.name) == "".join(self.text)
185
+
186
+ def test_writer_arg2default_fobj_path_none(self):
187
+ self.writer_arg2default(0, path=None)
188
+
189
+ def test_writer_arg4default_fobj(self):
190
+ self.writer_arg4default(0, 1, dog="dog", other="other")
191
+ self.writer_arg4default(0, 1, dog="dog", other="other", path=self.name)
192
+ assert self.read(self.name) == "".join(self.text)
193
+
194
+ def test_writer_kwarg_str(self):
195
+ self.writer_kwarg(path=self.name)
196
+ assert self.read(self.name) == "".join(self.text)
197
+
198
+ def test_writer_kwarg_fobj(self):
199
+ self.writer_kwarg(path=self.fobj)
200
+ self.fobj.close()
201
+ assert self.read(self.name) == "".join(self.text)
202
+
203
+ def test_writer_kwarg_path_none(self):
204
+ self.writer_kwarg(path=None)
205
+
206
+
207
+ class TestRandomState:
208
+ @classmethod
209
+ def setup_class(cls):
210
+ global np
211
+ np = pytest.importorskip("numpy")
212
+
213
+ @np_random_state(1)
214
+ def instantiate_np_random_state(self, random_state):
215
+ allowed = (np.random.RandomState, np.random.Generator)
216
+ assert isinstance(random_state, allowed)
217
+ return random_state.random()
218
+
219
+ @py_random_state(1)
220
+ def instantiate_py_random_state(self, random_state):
221
+ allowed = (random.Random, PythonRandomInterface, PythonRandomViaNumpyBits)
222
+ assert isinstance(random_state, allowed)
223
+ return random_state.random()
224
+
225
+ def test_random_state_None(self):
226
+ np.random.seed(42)
227
+ rv = np.random.random()
228
+ np.random.seed(42)
229
+ assert rv == self.instantiate_np_random_state(None)
230
+
231
+ random.seed(42)
232
+ rv = random.random()
233
+ random.seed(42)
234
+ assert rv == self.instantiate_py_random_state(None)
235
+
236
+ def test_random_state_np_random(self):
237
+ np.random.seed(42)
238
+ rv = np.random.random()
239
+ np.random.seed(42)
240
+ assert rv == self.instantiate_np_random_state(np.random)
241
+ np.random.seed(42)
242
+ assert rv == self.instantiate_py_random_state(np.random)
243
+
244
+ def test_random_state_int(self):
245
+ np.random.seed(42)
246
+ np_rv = np.random.random()
247
+ random.seed(42)
248
+ py_rv = random.random()
249
+
250
+ np.random.seed(42)
251
+ seed = 1
252
+ rval = self.instantiate_np_random_state(seed)
253
+ rval_expected = np.random.RandomState(seed).rand()
254
+ assert rval == rval_expected
255
+ # test that global seed wasn't changed in function
256
+ assert np_rv == np.random.random()
257
+
258
+ random.seed(42)
259
+ rval = self.instantiate_py_random_state(seed)
260
+ rval_expected = random.Random(seed).random()
261
+ assert rval == rval_expected
262
+ # test that global seed wasn't changed in function
263
+ assert py_rv == random.random()
264
+
265
+ def test_random_state_np_random_Generator(self):
266
+ np.random.seed(42)
267
+ np_rv = np.random.random()
268
+ np.random.seed(42)
269
+ seed = 1
270
+
271
+ rng = np.random.default_rng(seed)
272
+ rval = self.instantiate_np_random_state(rng)
273
+ rval_expected = np.random.default_rng(seed).random()
274
+ assert rval == rval_expected
275
+
276
+ rval = self.instantiate_py_random_state(rng)
277
+ rval_expected = np.random.default_rng(seed).random(size=2)[1]
278
+ assert rval == rval_expected
279
+ # test that global seed wasn't changed in function
280
+ assert np_rv == np.random.random()
281
+
282
+ def test_random_state_np_random_RandomState(self):
283
+ np.random.seed(42)
284
+ np_rv = np.random.random()
285
+ np.random.seed(42)
286
+ seed = 1
287
+
288
+ rng = np.random.RandomState(seed)
289
+ rval = self.instantiate_np_random_state(rng)
290
+ rval_expected = np.random.RandomState(seed).random()
291
+ assert rval == rval_expected
292
+
293
+ rval = self.instantiate_py_random_state(rng)
294
+ rval_expected = np.random.RandomState(seed).random(size=2)[1]
295
+ assert rval == rval_expected
296
+ # test that global seed wasn't changed in function
297
+ assert np_rv == np.random.random()
298
+
299
+ def test_random_state_py_random(self):
300
+ seed = 1
301
+ rng = random.Random(seed)
302
+ rv = self.instantiate_py_random_state(rng)
303
+ assert rv == random.Random(seed).random()
304
+
305
+ pytest.raises(ValueError, self.instantiate_np_random_state, rng)
306
+
307
+
308
+ def test_random_state_string_arg_index():
309
+ with pytest.raises(nx.NetworkXError):
310
+
311
+ @np_random_state("a")
312
+ def make_random_state(rs):
313
+ pass
314
+
315
+ rstate = make_random_state(1)
316
+
317
+
318
+ def test_py_random_state_string_arg_index():
319
+ with pytest.raises(nx.NetworkXError):
320
+
321
+ @py_random_state("a")
322
+ def make_random_state(rs):
323
+ pass
324
+
325
+ rstate = make_random_state(1)
326
+
327
+
328
+ def test_random_state_invalid_arg_index():
329
+ with pytest.raises(nx.NetworkXError):
330
+
331
+ @np_random_state(2)
332
+ def make_random_state(rs):
333
+ pass
334
+
335
+ rstate = make_random_state(1)
336
+
337
+
338
+ def test_py_random_state_invalid_arg_index():
339
+ with pytest.raises(nx.NetworkXError):
340
+
341
+ @py_random_state(2)
342
+ def make_random_state(rs):
343
+ pass
344
+
345
+ rstate = make_random_state(1)
346
+
347
+
348
+ class TestArgmap:
349
+ class ArgmapError(RuntimeError):
350
+ pass
351
+
352
+ def test_trivial_function(self):
353
+ def do_not_call(x):
354
+ raise ArgmapError("do not call this function")
355
+
356
+ @argmap(do_not_call)
357
+ def trivial_argmap():
358
+ return 1
359
+
360
+ assert trivial_argmap() == 1
361
+
362
+ def test_trivial_iterator(self):
363
+ def do_not_call(x):
364
+ raise ArgmapError("do not call this function")
365
+
366
+ @argmap(do_not_call)
367
+ def trivial_argmap():
368
+ yield from (1, 2, 3)
369
+
370
+ assert tuple(trivial_argmap()) == (1, 2, 3)
371
+
372
+ def test_contextmanager(self):
373
+ container = []
374
+
375
+ def contextmanager(x):
376
+ nonlocal container
377
+ return x, lambda: container.append(x)
378
+
379
+ @argmap(contextmanager, 0, 1, 2, try_finally=True)
380
+ def foo(x, y, z):
381
+ return x, y, z
382
+
383
+ x, y, z = foo("a", "b", "c")
384
+
385
+ # context exits are called in reverse
386
+ assert container == ["c", "b", "a"]
387
+
388
+ def test_tryfinally_generator(self):
389
+ container = []
390
+
391
+ def singleton(x):
392
+ return (x,)
393
+
394
+ with pytest.raises(nx.NetworkXError):
395
+
396
+ @argmap(singleton, 0, 1, 2, try_finally=True)
397
+ def foo(x, y, z):
398
+ yield from (x, y, z)
399
+
400
+ @argmap(singleton, 0, 1, 2)
401
+ def foo(x, y, z):
402
+ return x + y + z
403
+
404
+ q = foo("a", "b", "c")
405
+
406
+ assert q == ("a", "b", "c")
407
+
408
+ def test_actual_vararg(self):
409
+ @argmap(lambda x: -x, 4)
410
+ def foo(x, y, *args):
411
+ return (x, y) + tuple(args)
412
+
413
+ assert foo(1, 2, 3, 4, 5, 6) == (1, 2, 3, 4, -5, 6)
414
+
415
+ def test_signature_destroying_intermediate_decorator(self):
416
+ def add_one_to_first_bad_decorator(f):
417
+ """Bad because it doesn't wrap the f signature (clobbers it)"""
418
+
419
+ def decorated(a, *args, **kwargs):
420
+ return f(a + 1, *args, **kwargs)
421
+
422
+ return decorated
423
+
424
+ add_two_to_second = argmap(lambda b: b + 2, 1)
425
+
426
+ @add_two_to_second
427
+ @add_one_to_first_bad_decorator
428
+ def add_one_and_two(a, b):
429
+ return a, b
430
+
431
+ assert add_one_and_two(5, 5) == (6, 7)
432
+
433
+ def test_actual_kwarg(self):
434
+ @argmap(lambda x: -x, "arg")
435
+ def foo(*, arg):
436
+ return arg
437
+
438
+ assert foo(arg=3) == -3
439
+
440
+ def test_nested_tuple(self):
441
+ def xform(x, y):
442
+ u, v = y
443
+ return x + u + v, (x + u, x + v)
444
+
445
+ # we're testing args and kwargs here, too
446
+ @argmap(xform, (0, ("t", 2)))
447
+ def foo(a, *args, **kwargs):
448
+ return a, args, kwargs
449
+
450
+ a, args, kwargs = foo(1, 2, 3, t=4)
451
+
452
+ assert a == 1 + 4 + 3
453
+ assert args == (2, 1 + 3)
454
+ assert kwargs == {"t": 1 + 4}
455
+
456
+ def test_flatten(self):
457
+ assert tuple(argmap._flatten([[[[[], []], [], []], [], [], []]], set())) == ()
458
+
459
+ rlist = ["a", ["b", "c"], [["d"], "e"], "f"]
460
+ assert "".join(argmap._flatten(rlist, set())) == "abcdef"
461
+
462
+ def test_indent(self):
463
+ code = "\n".join(
464
+ argmap._indent(
465
+ *[
466
+ "try:",
467
+ "try:",
468
+ "pass#",
469
+ "finally:",
470
+ "pass#",
471
+ "#",
472
+ "finally:",
473
+ "pass#",
474
+ ]
475
+ )
476
+ )
477
+ assert (
478
+ code
479
+ == """try:
480
+ try:
481
+ pass#
482
+ finally:
483
+ pass#
484
+ #
485
+ finally:
486
+ pass#"""
487
+ )
488
+
489
+ def test_immediate_raise(self):
490
+ @not_implemented_for("directed")
491
+ def yield_nodes(G):
492
+ yield from G
493
+
494
+ G = nx.Graph([(1, 2)])
495
+ D = nx.DiGraph()
496
+
497
+ # test first call (argmap is compiled and executed)
498
+ with pytest.raises(nx.NetworkXNotImplemented):
499
+ node_iter = yield_nodes(D)
500
+
501
+ # test second call (argmap is only executed)
502
+ with pytest.raises(nx.NetworkXNotImplemented):
503
+ node_iter = yield_nodes(D)
504
+
505
+ # ensure that generators still make generators
506
+ node_iter = yield_nodes(G)
507
+ next(node_iter)
508
+ next(node_iter)
509
+ with pytest.raises(StopIteration):
510
+ next(node_iter)
511
+
512
+ def test_lazy_compile_thread_safety(self):
513
+ # Regression test for gh-8658.
514
+ import threading
515
+
516
+ n = 64
517
+ wrappers = [argmap(lambda x: x, 0)(lambda x, s=s: s) for s in range(n)]
518
+ barrier = threading.Barrier(n)
519
+ errors = []
520
+
521
+ def worker(start):
522
+ barrier.wait()
523
+ try:
524
+ for i in range(n):
525
+ assert wrappers[(start + i) % n](None) == (start + i) % n
526
+ except Exception as e:
527
+ errors.append(repr(e))
528
+
529
+ threads = [threading.Thread(target=worker, args=(i,)) for i in range(n)]
530
+ for t in threads:
531
+ t.start()
532
+ for t in threads:
533
+ t.join()
534
+ assert not errors, errors[:3]
hug/lib/python3.12/site-packages/networkx/utils/tests/test_heaps.py ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ import networkx as nx
4
+ from networkx.utils import BinaryHeap, PairingHeap
5
+
6
+
7
+ class X:
8
+ def __eq__(self, other):
9
+ raise self is other
10
+
11
+ def __ne__(self, other):
12
+ raise self is not other
13
+
14
+ def __lt__(self, other):
15
+ raise TypeError("cannot compare")
16
+
17
+ def __le__(self, other):
18
+ raise TypeError("cannot compare")
19
+
20
+ def __ge__(self, other):
21
+ raise TypeError("cannot compare")
22
+
23
+ def __gt__(self, other):
24
+ raise TypeError("cannot compare")
25
+
26
+ def __hash__(self):
27
+ return hash(id(self))
28
+
29
+
30
+ x = X()
31
+
32
+
33
+ data = [ # min should not invent an element.
34
+ ("min", nx.NetworkXError),
35
+ # Popping an empty heap should fail.
36
+ ("pop", nx.NetworkXError),
37
+ # Getting nonexisting elements should return None.
38
+ ("get", 0, None),
39
+ ("get", x, None),
40
+ ("get", None, None),
41
+ # Inserting a new key should succeed.
42
+ ("insert", x, 1, True),
43
+ ("get", x, 1),
44
+ ("min", (x, 1)),
45
+ # min should not pop the top element.
46
+ ("min", (x, 1)),
47
+ # Inserting a new key of different type should succeed.
48
+ ("insert", 1, -2.0, True),
49
+ # int and float values should interop.
50
+ ("min", (1, -2.0)),
51
+ # pop removes minimum-valued element.
52
+ ("insert", 3, -(10**100), True),
53
+ ("insert", 4, 5, True),
54
+ ("pop", (3, -(10**100))),
55
+ ("pop", (1, -2.0)),
56
+ # Decrease-insert should succeed.
57
+ ("insert", 4, -50, True),
58
+ ("insert", 4, -60, False, True),
59
+ # Decrease-insert should not create duplicate keys.
60
+ ("pop", (4, -60)),
61
+ ("pop", (x, 1)),
62
+ # Popping all elements should empty the heap.
63
+ ("min", nx.NetworkXError),
64
+ ("pop", nx.NetworkXError),
65
+ # Non-value-changing insert should fail.
66
+ ("insert", x, 0, True),
67
+ ("insert", x, 0, False, False),
68
+ ("min", (x, 0)),
69
+ ("insert", x, 0, True, False),
70
+ ("min", (x, 0)),
71
+ # Failed insert should not create duplicate keys.
72
+ ("pop", (x, 0)),
73
+ ("pop", nx.NetworkXError),
74
+ # Increase-insert should succeed when allowed.
75
+ ("insert", None, 0, True),
76
+ ("insert", 2, -1, True),
77
+ ("min", (2, -1)),
78
+ ("insert", 2, 1, True, False),
79
+ ("min", (None, 0)),
80
+ # Increase-insert should fail when disallowed.
81
+ ("insert", None, 2, False, False),
82
+ ("min", (None, 0)),
83
+ # Failed increase-insert should not create duplicate keys.
84
+ ("pop", (None, 0)),
85
+ ("pop", (2, 1)),
86
+ ("min", nx.NetworkXError),
87
+ ("pop", nx.NetworkXError),
88
+ ]
89
+
90
+
91
+ def _test_heap_class(cls, *args, **kwargs):
92
+ heap = cls(*args, **kwargs)
93
+ # Basic behavioral test
94
+ for op in data:
95
+ if op[-1] is not nx.NetworkXError:
96
+ assert op[-1] == getattr(heap, op[0])(*op[1:-1])
97
+ else:
98
+ pytest.raises(op[-1], getattr(heap, op[0]), *op[1:-1])
99
+ # Coverage test.
100
+ for i in range(99, -1, -1):
101
+ assert heap.insert(i, i)
102
+ for i in range(50):
103
+ assert heap.pop() == (i, i)
104
+ for i in range(100):
105
+ assert heap.insert(i, i) == (i < 50)
106
+ for i in range(100):
107
+ assert not heap.insert(i, i + 1)
108
+ for i in range(50):
109
+ assert heap.pop() == (i, i)
110
+ for i in range(100):
111
+ assert heap.insert(i, i + 1) == (i < 50)
112
+ for i in range(49):
113
+ assert heap.pop() == (i, i + 1)
114
+ assert sorted([heap.pop(), heap.pop()]) == [(49, 50), (50, 50)]
115
+ for i in range(51, 100):
116
+ assert not heap.insert(i, i + 1, True)
117
+ for i in range(51, 70):
118
+ assert heap.pop() == (i, i + 1)
119
+ for i in range(100):
120
+ assert heap.insert(i, i)
121
+ for i in range(100):
122
+ assert heap.pop() == (i, i)
123
+ pytest.raises(nx.NetworkXError, heap.pop)
124
+
125
+
126
+ def test_PairingHeap():
127
+ _test_heap_class(PairingHeap)
128
+
129
+
130
+ def test_BinaryHeap():
131
+ _test_heap_class(BinaryHeap)
hug/lib/python3.12/site-packages/networkx/utils/tests/test_mapped_queue.py ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from networkx.utils.mapped_queue import MappedQueue, _HeapElement
4
+
5
+
6
+ def test_HeapElement_gtlt():
7
+ bar = _HeapElement(1.1, "a")
8
+ foo = _HeapElement(1, "b")
9
+ assert foo < bar
10
+ assert bar > foo
11
+ assert foo < 1.1
12
+ assert 1 < bar
13
+
14
+
15
+ def test_HeapElement_gtlt_tied_priority():
16
+ bar = _HeapElement(1, "a")
17
+ foo = _HeapElement(1, "b")
18
+ assert foo > bar
19
+ assert bar < foo
20
+
21
+
22
+ def test_HeapElement_eq():
23
+ bar = _HeapElement(1.1, "a")
24
+ foo = _HeapElement(1, "a")
25
+ assert foo == bar
26
+ assert bar == foo
27
+ assert foo == "a"
28
+
29
+
30
+ def test_HeapElement_iter():
31
+ foo = _HeapElement(1, "a")
32
+ bar = _HeapElement(1.1, (3, 2, 1))
33
+ assert list(foo) == [1, "a"]
34
+ assert list(bar) == [1.1, 3, 2, 1]
35
+
36
+
37
+ def test_HeapElement_getitem():
38
+ foo = _HeapElement(1, "a")
39
+ bar = _HeapElement(1.1, (3, 2, 1))
40
+ assert foo[1] == "a"
41
+ assert foo[0] == 1
42
+ assert bar[0] == 1.1
43
+ assert bar[2] == 2
44
+ assert bar[3] == 1
45
+ pytest.raises(IndexError, bar.__getitem__, 4)
46
+ pytest.raises(IndexError, foo.__getitem__, 2)
47
+
48
+
49
+ class TestMappedQueue:
50
+ def setup_method(self):
51
+ pass
52
+
53
+ def _check_map(self, q):
54
+ assert q.position == {elt: pos for pos, elt in enumerate(q.heap)}
55
+
56
+ def _make_mapped_queue(self, h):
57
+ q = MappedQueue()
58
+ q.heap = h
59
+ q.position = {elt: pos for pos, elt in enumerate(h)}
60
+ return q
61
+
62
+ def test_heapify(self):
63
+ h = [5, 4, 3, 2, 1, 0]
64
+ q = self._make_mapped_queue(h)
65
+ q._heapify()
66
+ self._check_map(q)
67
+
68
+ def test_init(self):
69
+ h = [5, 4, 3, 2, 1, 0]
70
+ q = MappedQueue(h)
71
+ self._check_map(q)
72
+
73
+ def test_incomparable(self):
74
+ h = [5, 4, "a", 2, 1, 0]
75
+ pytest.raises(TypeError, MappedQueue, h)
76
+
77
+ def test_len(self):
78
+ h = [5, 4, 3, 2, 1, 0]
79
+ q = MappedQueue(h)
80
+ self._check_map(q)
81
+ assert len(q) == 6
82
+
83
+ def test_siftup_leaf(self):
84
+ h = [2]
85
+ h_sifted = [2]
86
+ q = self._make_mapped_queue(h)
87
+ q._siftup(0)
88
+ assert q.heap == h_sifted
89
+ self._check_map(q)
90
+
91
+ def test_siftup_one_child(self):
92
+ h = [2, 0]
93
+ h_sifted = [0, 2]
94
+ q = self._make_mapped_queue(h)
95
+ q._siftup(0)
96
+ assert q.heap == h_sifted
97
+ self._check_map(q)
98
+
99
+ def test_siftup_left_child(self):
100
+ h = [2, 0, 1]
101
+ h_sifted = [0, 2, 1]
102
+ q = self._make_mapped_queue(h)
103
+ q._siftup(0)
104
+ assert q.heap == h_sifted
105
+ self._check_map(q)
106
+
107
+ def test_siftup_right_child(self):
108
+ h = [2, 1, 0]
109
+ h_sifted = [0, 1, 2]
110
+ q = self._make_mapped_queue(h)
111
+ q._siftup(0)
112
+ assert q.heap == h_sifted
113
+ self._check_map(q)
114
+
115
+ def test_siftup_multiple(self):
116
+ h = [0, 1, 2, 4, 3, 5, 6]
117
+ h_sifted = [0, 1, 2, 4, 3, 5, 6]
118
+ q = self._make_mapped_queue(h)
119
+ q._siftup(0)
120
+ assert q.heap == h_sifted
121
+ self._check_map(q)
122
+
123
+ def test_siftdown_leaf(self):
124
+ h = [2]
125
+ h_sifted = [2]
126
+ q = self._make_mapped_queue(h)
127
+ q._siftdown(0, 0)
128
+ assert q.heap == h_sifted
129
+ self._check_map(q)
130
+
131
+ def test_siftdown_single(self):
132
+ h = [1, 0]
133
+ h_sifted = [0, 1]
134
+ q = self._make_mapped_queue(h)
135
+ q._siftdown(0, len(h) - 1)
136
+ assert q.heap == h_sifted
137
+ self._check_map(q)
138
+
139
+ def test_siftdown_multiple(self):
140
+ h = [1, 2, 3, 4, 5, 6, 7, 0]
141
+ h_sifted = [0, 1, 3, 2, 5, 6, 7, 4]
142
+ q = self._make_mapped_queue(h)
143
+ q._siftdown(0, len(h) - 1)
144
+ assert q.heap == h_sifted
145
+ self._check_map(q)
146
+
147
+ def test_push(self):
148
+ to_push = [6, 1, 4, 3, 2, 5, 0]
149
+ h_sifted = [0, 2, 1, 6, 3, 5, 4]
150
+ q = MappedQueue()
151
+ for elt in to_push:
152
+ q.push(elt)
153
+ assert q.heap == h_sifted
154
+ self._check_map(q)
155
+
156
+ def test_push_duplicate(self):
157
+ to_push = [2, 1, 0]
158
+ h_sifted = [0, 2, 1]
159
+ q = MappedQueue()
160
+ for elt in to_push:
161
+ inserted = q.push(elt)
162
+ assert inserted
163
+ assert q.heap == h_sifted
164
+ self._check_map(q)
165
+ inserted = q.push(1)
166
+ assert not inserted
167
+
168
+ def test_pop(self):
169
+ h = [3, 4, 6, 0, 1, 2, 5]
170
+ h_sorted = sorted(h)
171
+ q = self._make_mapped_queue(h)
172
+ q._heapify()
173
+ popped = [q.pop() for _ in range(len(h))]
174
+ assert popped == h_sorted
175
+ self._check_map(q)
176
+
177
+ def test_remove_leaf(self):
178
+ h = [0, 2, 1, 6, 3, 5, 4]
179
+ h_removed = [0, 2, 1, 6, 4, 5]
180
+ q = self._make_mapped_queue(h)
181
+ removed = q.remove(3)
182
+ assert q.heap == h_removed
183
+
184
+ def test_remove_root(self):
185
+ h = [0, 2, 1, 6, 3, 5, 4]
186
+ h_removed = [1, 2, 4, 6, 3, 5]
187
+ q = self._make_mapped_queue(h)
188
+ removed = q.remove(0)
189
+ assert q.heap == h_removed
190
+
191
+ def test_update_leaf(self):
192
+ h = [0, 20, 10, 60, 30, 50, 40]
193
+ h_updated = [0, 15, 10, 60, 20, 50, 40]
194
+ q = self._make_mapped_queue(h)
195
+ removed = q.update(30, 15)
196
+ assert q.heap == h_updated
197
+
198
+ def test_update_root(self):
199
+ h = [0, 20, 10, 60, 30, 50, 40]
200
+ h_updated = [10, 20, 35, 60, 30, 50, 40]
201
+ q = self._make_mapped_queue(h)
202
+ removed = q.update(0, 35)
203
+ assert q.heap == h_updated
204
+
205
+
206
+ class TestMappedDict(TestMappedQueue):
207
+ def _make_mapped_queue(self, h):
208
+ priority_dict = {elt: elt for elt in h}
209
+ return MappedQueue(priority_dict)
210
+
211
+ def test_init(self):
212
+ d = {5: 0, 4: 1, "a": 2, 2: 3, 1: 4}
213
+ q = MappedQueue(d)
214
+ assert q.position == d
215
+
216
+ def test_ties(self):
217
+ d = {5: 0, 4: 1, 3: 2, 2: 3, 1: 4}
218
+ q = MappedQueue(d)
219
+ assert q.position == {elt: pos for pos, elt in enumerate(q.heap)}
220
+
221
+ def test_pop(self):
222
+ d = {5: 0, 4: 1, 3: 2, 2: 3, 1: 4}
223
+ q = MappedQueue(d)
224
+ assert q.pop() == _HeapElement(0, 5)
225
+ assert q.position == {elt: pos for pos, elt in enumerate(q.heap)}
226
+
227
+ def test_empty_pop(self):
228
+ q = MappedQueue()
229
+ pytest.raises(IndexError, q.pop)
230
+
231
+ def test_incomparable_ties(self):
232
+ d = {5: 0, 4: 0, "a": 0, 2: 0, 1: 0}
233
+ pytest.raises(TypeError, MappedQueue, d)
234
+
235
+ def test_push(self):
236
+ to_push = [6, 1, 4, 3, 2, 5, 0]
237
+ h_sifted = [0, 2, 1, 6, 3, 5, 4]
238
+ q = MappedQueue()
239
+ for elt in to_push:
240
+ q.push(elt, priority=elt)
241
+ assert q.heap == h_sifted
242
+ self._check_map(q)
243
+
244
+ def test_push_duplicate(self):
245
+ to_push = [2, 1, 0]
246
+ h_sifted = [0, 2, 1]
247
+ q = MappedQueue()
248
+ for elt in to_push:
249
+ inserted = q.push(elt, priority=elt)
250
+ assert inserted
251
+ assert q.heap == h_sifted
252
+ self._check_map(q)
253
+ inserted = q.push(1, priority=1)
254
+ assert not inserted
255
+
256
+ def test_update_leaf(self):
257
+ h = [0, 20, 10, 60, 30, 50, 40]
258
+ h_updated = [0, 15, 10, 60, 20, 50, 40]
259
+ q = self._make_mapped_queue(h)
260
+ removed = q.update(30, 15, priority=15)
261
+ assert q.heap == h_updated
262
+
263
+ def test_update_root(self):
264
+ h = [0, 20, 10, 60, 30, 50, 40]
265
+ h_updated = [10, 20, 35, 60, 30, 50, 40]
266
+ q = self._make_mapped_queue(h)
267
+ removed = q.update(0, 35, priority=35)
268
+ assert q.heap == h_updated
hug/lib/python3.12/site-packages/networkx/utils/tests/test_misc.py ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ from copy import copy
3
+
4
+ import pytest
5
+
6
+ import networkx as nx
7
+ from networkx.utils import (
8
+ PythonRandomInterface,
9
+ PythonRandomViaNumpyBits,
10
+ arbitrary_element,
11
+ create_py_random_state,
12
+ create_random_state,
13
+ dict_to_numpy_array,
14
+ discrete_sequence,
15
+ edges_equal,
16
+ flatten,
17
+ groups,
18
+ make_list_of_ints,
19
+ pairwise,
20
+ powerlaw_sequence,
21
+ )
22
+ from networkx.utils.misc import _dict_to_numpy_array1, _dict_to_numpy_array2
23
+
24
+ nested_depth = (
25
+ 1,
26
+ 2,
27
+ (3, 4, ((5, 6, (7,), (8, (9, 10), 11), (12, 13, (14, 15)), 16), 17), 18, 19),
28
+ 20,
29
+ )
30
+
31
+ nested_set = {
32
+ (1, 2, 3, 4),
33
+ (5, 6, 7, 8, 9),
34
+ (10, 11, (12, 13, 14), (15, 16, 17, 18)),
35
+ 19,
36
+ 20,
37
+ }
38
+
39
+ nested_mixed = [
40
+ 1,
41
+ (2, 3, {4, (5, 6), 7}, [8, 9]),
42
+ {10: "foo", 11: "bar", (12, 13): "baz"},
43
+ {(14, 15): "qwe", 16: "asd"},
44
+ (17, (18, "19"), 20),
45
+ ]
46
+
47
+
48
+ @pytest.mark.parametrize("result", [None, [], ["existing"], ["existing1", "existing2"]])
49
+ @pytest.mark.parametrize("nested", [nested_depth, nested_mixed, nested_set])
50
+ def test_flatten(nested, result):
51
+ if result is None:
52
+ val = flatten(nested, result)
53
+ assert len(val) == 20
54
+ else:
55
+ _result = copy(result) # because pytest passes parameters as is
56
+ nexisting = len(_result)
57
+ val = flatten(nested, _result)
58
+ assert len(val) == len(_result) == 20 + nexisting
59
+
60
+ assert issubclass(type(val), tuple)
61
+
62
+
63
+ def test_make_list_of_ints():
64
+ mylist = [1, 2, 3.0, 42, -2]
65
+ assert make_list_of_ints(mylist) is mylist
66
+ assert make_list_of_ints(mylist) == mylist
67
+ assert isinstance(make_list_of_ints(mylist)[2], int)
68
+ pytest.raises(nx.NetworkXError, make_list_of_ints, [1, 2, 3, "kermit"])
69
+ pytest.raises(nx.NetworkXError, make_list_of_ints, [1, 2, 3.1])
70
+
71
+
72
+ def test_random_number_distribution():
73
+ # smoke test only
74
+ z = powerlaw_sequence(20, exponent=2.5)
75
+ z = discrete_sequence(20, distribution=[0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3])
76
+
77
+
78
+ class TestNumpyArray:
79
+ @classmethod
80
+ def setup_class(cls):
81
+ global np
82
+ np = pytest.importorskip("numpy")
83
+
84
+ def test_numpy_to_list_of_ints(self):
85
+ a = np.array([1, 2, 3], dtype=np.int64)
86
+ b = np.array([1.0, 2, 3])
87
+ c = np.array([1.1, 2, 3])
88
+ assert isinstance(make_list_of_ints(a), list)
89
+ assert make_list_of_ints(b) == list(b)
90
+ B = make_list_of_ints(b)
91
+ assert isinstance(B[0], int)
92
+ pytest.raises(nx.NetworkXError, make_list_of_ints, c)
93
+
94
+ def test__dict_to_numpy_array1(self):
95
+ d = {"a": 1, "b": 2}
96
+ a = _dict_to_numpy_array1(d, mapping={"a": 0, "b": 1})
97
+ np.testing.assert_allclose(a, np.array([1, 2]))
98
+ a = _dict_to_numpy_array1(d, mapping={"b": 0, "a": 1})
99
+ np.testing.assert_allclose(a, np.array([2, 1]))
100
+
101
+ a = _dict_to_numpy_array1(d)
102
+ np.testing.assert_allclose(a.sum(), 3)
103
+
104
+ def test__dict_to_numpy_array2(self):
105
+ d = {"a": {"a": 1, "b": 2}, "b": {"a": 10, "b": 20}}
106
+
107
+ mapping = {"a": 1, "b": 0}
108
+ a = _dict_to_numpy_array2(d, mapping=mapping)
109
+ np.testing.assert_allclose(a, np.array([[20, 10], [2, 1]]))
110
+
111
+ a = _dict_to_numpy_array2(d)
112
+ np.testing.assert_allclose(a.sum(), 33)
113
+
114
+ def test_dict_to_numpy_array_a(self):
115
+ d = {"a": {"a": 1, "b": 2}, "b": {"a": 10, "b": 20}}
116
+
117
+ mapping = {"a": 0, "b": 1}
118
+ a = dict_to_numpy_array(d, mapping=mapping)
119
+ np.testing.assert_allclose(a, np.array([[1, 2], [10, 20]]))
120
+
121
+ mapping = {"a": 1, "b": 0}
122
+ a = dict_to_numpy_array(d, mapping=mapping)
123
+ np.testing.assert_allclose(a, np.array([[20, 10], [2, 1]]))
124
+
125
+ a = _dict_to_numpy_array2(d)
126
+ np.testing.assert_allclose(a.sum(), 33)
127
+
128
+ def test_dict_to_numpy_array_b(self):
129
+ d = {"a": 1, "b": 2}
130
+
131
+ mapping = {"a": 0, "b": 1}
132
+ a = dict_to_numpy_array(d, mapping=mapping)
133
+ np.testing.assert_allclose(a, np.array([1, 2]))
134
+
135
+ a = _dict_to_numpy_array1(d)
136
+ np.testing.assert_allclose(a.sum(), 3)
137
+
138
+
139
+ def test_pairwise():
140
+ nodes = range(4)
141
+ node_pairs = [(0, 1), (1, 2), (2, 3)]
142
+ node_pairs_cycle = node_pairs + [(3, 0)]
143
+ assert list(pairwise(nodes)) == node_pairs
144
+ assert list(pairwise(iter(nodes))) == node_pairs
145
+ assert list(pairwise(nodes, cyclic=True)) == node_pairs_cycle
146
+ empty_iter = iter(())
147
+ assert list(pairwise(empty_iter)) == []
148
+ empty_iter = iter(())
149
+ assert list(pairwise(empty_iter, cyclic=True)) == []
150
+
151
+
152
+ def test_groups():
153
+ many_to_one = dict(zip("abcde", [0, 0, 1, 1, 2]))
154
+ actual = groups(many_to_one)
155
+ expected = {0: {"a", "b"}, 1: {"c", "d"}, 2: {"e"}}
156
+ assert actual == expected
157
+ assert {} == groups({})
158
+
159
+
160
+ def test_create_random_state():
161
+ np = pytest.importorskip("numpy")
162
+ rs = np.random.RandomState
163
+
164
+ assert isinstance(create_random_state(1), rs)
165
+ assert isinstance(create_random_state(None), rs)
166
+ assert isinstance(create_random_state(np.random), rs)
167
+ assert isinstance(create_random_state(rs(1)), rs)
168
+ # Support for numpy.random.Generator
169
+ rng = np.random.default_rng()
170
+ assert isinstance(create_random_state(rng), np.random.Generator)
171
+ pytest.raises(ValueError, create_random_state, "a")
172
+
173
+ assert np.all(rs(1).rand(10) == create_random_state(1).rand(10))
174
+
175
+
176
+ def test_create_py_random_state():
177
+ pyrs = random.Random
178
+
179
+ assert isinstance(create_py_random_state(1), pyrs)
180
+ assert isinstance(create_py_random_state(None), pyrs)
181
+ assert isinstance(create_py_random_state(pyrs(1)), pyrs)
182
+ pytest.raises(ValueError, create_py_random_state, "a")
183
+
184
+ np = pytest.importorskip("numpy")
185
+
186
+ rs = np.random.RandomState
187
+ rng = np.random.default_rng(1000)
188
+ rng_explicit = np.random.Generator(np.random.SFC64())
189
+ old_nprs = PythonRandomInterface
190
+ nprs = PythonRandomViaNumpyBits
191
+ assert isinstance(create_py_random_state(np.random), nprs)
192
+ assert isinstance(create_py_random_state(rs(1)), old_nprs)
193
+ assert isinstance(create_py_random_state(rng), nprs)
194
+ assert isinstance(create_py_random_state(rng_explicit), nprs)
195
+ # test default rng input
196
+ old_nprs_instance = old_nprs()
197
+ nprs_instance = nprs()
198
+ assert isinstance(old_nprs_instance, old_nprs)
199
+ assert isinstance(nprs_instance, nprs)
200
+ assert create_py_random_state(old_nprs_instance) == old_nprs_instance
201
+ assert create_py_random_state(nprs_instance) == nprs_instance
202
+
203
+ # VeryLargeIntegers Smoke test (they raise error for np.random)
204
+ int64max = 9223372036854775807 # from np.iinfo(np.int64).max
205
+ for r in (rng, rs(1)):
206
+ prs = create_py_random_state(r)
207
+ prs.randrange(3, int64max + 5)
208
+ prs.randint(3, int64max + 5)
209
+
210
+
211
+ def test_PythonRandomInterface_RandomState():
212
+ np = pytest.importorskip("numpy")
213
+
214
+ seed = 42
215
+ rs = np.random.RandomState
216
+ rng = PythonRandomInterface(rs(seed))
217
+ rs42 = rs(seed)
218
+
219
+ # make sure these functions are same as expected outcome
220
+ assert rng.randrange(3, 5) == rs42.randint(3, 5)
221
+ assert rng.randrange(2) == rs42.randint(0, 2)
222
+ assert rng.uniform(1, 10) == rs42.uniform(1, 10)
223
+ assert rng.choice([1, 2, 3]) == rs42.choice([1, 2, 3])
224
+ assert rng.gauss(0, 1) == rs42.normal(0, 1)
225
+ assert rng.expovariate(1.5) == rs42.exponential(1 / 1.5)
226
+ assert rng.paretovariate(2) == rs42.pareto(2)
227
+ assert np.all(rng.shuffle([1, 2, 3]) == rs42.shuffle([1, 2, 3]))
228
+ assert np.all(
229
+ rng.sample([1, 2, 3], 2) == rs42.choice([1, 2, 3], (2,), replace=False)
230
+ )
231
+ assert np.all(
232
+ [rng.randint(3, 5) for _ in range(100)]
233
+ == [rs42.randint(3, 6) for _ in range(100)]
234
+ )
235
+ assert rng.random() == rs42.random_sample()
236
+
237
+
238
+ def test_PythonRandomInterface_Generator():
239
+ np = pytest.importorskip("numpy")
240
+
241
+ seed = 42
242
+ rng = np.random.default_rng(seed)
243
+ pri = PythonRandomInterface(np.random.default_rng(seed))
244
+
245
+ # make sure these functions are same as expected outcome
246
+ assert pri.randrange(3, 5) == rng.integers(3, 5)
247
+ assert pri.randrange(2) == rng.integers(0, 2)
248
+ assert pri.uniform(1, 10) == rng.uniform(1, 10)
249
+ assert pri.choice([1, 2, 3]) == rng.choice([1, 2, 3])
250
+ assert pri.gauss(0, 1) == rng.normal(0, 1)
251
+ assert pri.expovariate(1.5) == rng.exponential(1 / 1.5)
252
+ assert pri.paretovariate(2) == rng.pareto(2)
253
+ assert np.all(pri.shuffle([1, 2, 3]) == rng.shuffle([1, 2, 3]))
254
+ assert np.all(
255
+ pri.sample([1, 2, 3], 2) == rng.choice([1, 2, 3], (2,), replace=False)
256
+ )
257
+ assert np.all(
258
+ [pri.randint(3, 5) for _ in range(100)]
259
+ == [rng.integers(3, 6) for _ in range(100)]
260
+ )
261
+ assert pri.random() == rng.random()
262
+
263
+
264
+ def test_python_random_interface_choices_error_message():
265
+ np = pytest.importorskip("numpy")
266
+
267
+ seed = 42
268
+ pri = PythonRandomInterface(np.random.RandomState(seed))
269
+
270
+ msg = "random.choices is not supported when using numpy.random.RandomState"
271
+ with pytest.raises(AttributeError, match=msg):
272
+ pri.choices([1, 2, 3], k=2)
273
+
274
+
275
+ def test_python_random_interface_unknown_attribute():
276
+ np = pytest.importorskip("numpy")
277
+
278
+ seed = 42
279
+ pri = PythonRandomInterface(np.random.RandomState(seed))
280
+
281
+ msg = "'PythonRandomInterface' object has no attribute 'choises'"
282
+ with pytest.raises(AttributeError, match=msg):
283
+ pri.choises([1, 2, 3], k=2)
284
+
285
+
286
+ @pytest.mark.parametrize(
287
+ ("iterable_type", "expected"), ((list, 1), (tuple, 1), (str, "["), (set, 1))
288
+ )
289
+ def test_arbitrary_element(iterable_type, expected):
290
+ iterable = iterable_type([1, 2, 3])
291
+ assert arbitrary_element(iterable) == expected
292
+
293
+
294
+ @pytest.mark.parametrize(
295
+ "iterator",
296
+ ((i for i in range(3)), iter([1, 2, 3])), # generator
297
+ )
298
+ def test_arbitrary_element_raises(iterator):
299
+ """Value error is raised when input is an iterator."""
300
+ with pytest.raises(ValueError, match="from an iterator"):
301
+ arbitrary_element(iterator)
302
+
303
+
304
+ @pytest.mark.parametrize("n", [5, 10, 20])
305
+ @pytest.mark.parametrize("gen", [nx.complete_graph, nx.path_graph, nx.cycle_graph])
306
+ @pytest.mark.parametrize("create_using", [nx.Graph, nx.DiGraph])
307
+ def test_edges_equal(n, gen, create_using):
308
+ """Test whether edges_equal properly compares edges without attribute data."""
309
+ G = gen(n, create_using=create_using)
310
+ H = gen(n, create_using=create_using)
311
+ assert edges_equal(G.edges(), H.edges(), directed=G.is_directed())
312
+ assert edges_equal(H.edges(), G.edges(), directed=H.is_directed())
313
+
314
+ H.remove_edge(0, 1)
315
+ assert edges_equal(H.edges(), H.edges(), directed=H.is_directed())
316
+ assert not edges_equal(G.edges(), H.edges(), directed=G.is_directed())
317
+ assert not edges_equal(H.edges(), G.edges(), directed=H.is_directed())
318
+
319
+
320
+ @pytest.mark.parametrize("n", [5, 10, 20])
321
+ @pytest.mark.parametrize("gen", [nx.complete_graph, nx.path_graph, nx.cycle_graph])
322
+ @pytest.mark.parametrize("create_using", [nx.MultiGraph, nx.MultiDiGraph])
323
+ def test_edges_equal_multiedge(n, gen, create_using):
324
+ """Test whether ``edges_equal`` properly compares edges in multigraphs."""
325
+ G = gen(n, create_using=create_using)
326
+ H = gen(n, create_using=create_using)
327
+
328
+ G_edges = list(G.edges())
329
+ G.add_edges_from(G_edges)
330
+ H.add_edges_from(G_edges)
331
+ assert edges_equal(G.edges(), H.edges(), directed=G.is_directed())
332
+
333
+ H.remove_edge(0, 1)
334
+ assert edges_equal(H.edges(), H.edges(), directed=H.is_directed())
335
+ assert not edges_equal(G.edges(), H.edges(), directed=G.is_directed())
336
+
337
+
338
+ @pytest.mark.parametrize("n", [5, 10, 20])
339
+ @pytest.mark.parametrize("gen", [nx.complete_graph, nx.path_graph, nx.cycle_graph])
340
+ @pytest.mark.parametrize("weight", [1, 2, 3])
341
+ def test_edges_equal_weighted(n, gen, weight):
342
+ """Test whether ``edges_equal`` properly compares edges with weight data."""
343
+ G = gen(n)
344
+ H = gen(n)
345
+
346
+ G_edges = list(G.edges())
347
+ G.add_weighted_edges_from((*e, weight) for e in G_edges)
348
+ assert edges_equal(G.edges(), G.edges())
349
+
350
+ H.add_weighted_edges_from((*e, weight + 1) for e in G_edges)
351
+ assert edges_equal(H.edges(), H.edges())
352
+ assert not edges_equal(G.edges(data=True), H.edges(data=True))
353
+
354
+
355
+ def test_edges_equal_data():
356
+ """Test whether ``edges_equal`` properly compares edges with attribute dictionaries."""
357
+ G = nx.path_graph(3)
358
+ H = nx.path_graph(3)
359
+ I = nx.path_graph(3, create_using=nx.MultiGraph)
360
+
361
+ attrs = {(0, 1): {"attr1": 20, "attr2": "nothing"}, (1, 2): {"attr2": 3}}
362
+ nx.set_edge_attributes(G, attrs)
363
+ assert edges_equal(G.edges(data=True), G.edges(data=True))
364
+ assert not edges_equal(G.edges(data=True), G.edges())
365
+
366
+ nx.set_edge_attributes(H, attrs)
367
+ assert edges_equal(G.edges(), H.edges())
368
+ assert edges_equal(G.edges(data=True), H.edges(data=True))
369
+
370
+ H[0][1]["attr2"] = "something"
371
+ assert edges_equal(G.edges(), H.edges())
372
+ assert not edges_equal(G.edges(data=True), H.edges(data=True))
373
+
374
+
375
+ def test_edges_equal_multigraph_data():
376
+ """Test whether ``edges_equal`` properly compares edges with attribute dictionaries in ``MultiGraphs``."""
377
+ G = nx.path_graph(3, create_using=nx.MultiGraph)
378
+ I = nx.path_graph(3, create_using=nx.MultiGraph)
379
+
380
+ G.add_edge(0, 1, 0, attr1="blue")
381
+ G.add_edge(1, 2, 1, attr2="green")
382
+ I.add_edge(0, 1, 0, attr1="blue")
383
+ I.add_edge(0, 1, 1, attr2="green")
384
+ assert edges_equal(G.edges(data=True), G.edges(data=True))
385
+ assert not edges_equal(G.edges(), I.edges())
386
+ assert not edges_equal(G.edges(data=True), I.edges(data=True))
387
+ assert not edges_equal(G.edges(keys=True), I.edges(keys=True))
388
+ assert not edges_equal(G.edges(keys=True, data=True), I.edges(keys=True, data=True))
389
+
390
+
391
+ def test_edges_equal_directed():
392
+ """Test whether ``edges_equal`` properly compares directed edges."""
393
+ G = nx.DiGraph([(0, 1)])
394
+ I = nx.DiGraph([(1, 0)])
395
+
396
+ assert edges_equal(G.edges(), I.edges(), directed=False)
397
+ assert not edges_equal(G.edges(), I.edges(), directed=True)
398
+
399
+
400
+ def test_edges_equal_directed_data():
401
+ """Test whether ``edges_equal`` properly compares directed edges with attribute dictionaries."""
402
+ G = nx.DiGraph()
403
+ I = nx.DiGraph()
404
+
405
+ G.add_edge(0, 1, attr1="blue")
406
+ I.add_edge(0, 1, attr1="blue")
407
+ assert edges_equal(G.edges(data=True), G.edges(data=True), directed=True)
408
+ I.add_edge(1, 2, attr2="green")
409
+ assert not edges_equal(G.edges(data=True), I.edges(data=True), directed=True)
410
+ G.add_edge(1, 2, attr2="green")
411
+ assert edges_equal(G.edges(data=True), I.edges(data=True), directed=True)
412
+ G.remove_edge(1, 2)
413
+ G.add_edge(2, 1, attr2="green")
414
+ assert edges_equal(G.edges(data=True), I.edges(data=True), directed=False)
415
+ assert not edges_equal(G.edges(data=True), I.edges(data=True), directed=True)
hug/lib/python3.12/site-packages/networkx/utils/tests/test_random_sequence.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ import networkx as nx
4
+
5
+
6
+ def test_degree_sequences():
7
+ seq = nx.utils.powerlaw_sequence(10, seed=1)
8
+ seq = nx.utils.powerlaw_sequence(10)
9
+ assert len(seq) == 10
10
+
11
+
12
+ @pytest.mark.parametrize(
13
+ ("deg_seq", "valid", "reason"),
14
+ [
15
+ ([], False, "must have one more node"),
16
+ ([0], True, ""),
17
+ ([2], False, "must have one more node"),
18
+ ([2, 0], False, "must have strictly positive"),
19
+ ([3, 1, 1, 1], True, ""),
20
+ ],
21
+ )
22
+ def test_valid_degree_sequence(deg_seq, valid, reason):
23
+ v, r = nx.utils.is_valid_tree_degree_sequence(deg_seq)
24
+ assert v == valid
25
+ assert reason in r
26
+
27
+
28
+ def test_zipf_rv():
29
+ r = nx.utils.zipf_rv(2.3, xmin=2, seed=1)
30
+ r = nx.utils.zipf_rv(2.3, 2, 1)
31
+ r = nx.utils.zipf_rv(2.3)
32
+ assert type(r), int
33
+ pytest.raises(ValueError, nx.utils.zipf_rv, 0.5)
34
+ pytest.raises(ValueError, nx.utils.zipf_rv, 2, xmin=0)
35
+
36
+
37
+ def test_random_weighted_sample():
38
+ mapping = {"a": 10, "b": 20}
39
+ s = nx.utils.random_weighted_sample(mapping, 2, seed=1)
40
+ s = nx.utils.random_weighted_sample(mapping, 2)
41
+ assert sorted(s) == sorted(mapping.keys())
42
+ pytest.raises(ValueError, nx.utils.random_weighted_sample, mapping, 3)
43
+
44
+
45
+ def test_random_weighted_choice():
46
+ mapping = {"a": 10, "b": 0}
47
+ c = nx.utils.weighted_choice(mapping, seed=1)
48
+ c = nx.utils.weighted_choice(mapping)
49
+ assert c == "a"
50
+
51
+
52
+ def test_random_sequence_low_precision():
53
+ assert nx.utils.cumulative_distribution([0.1] * 100)[-1] == 1.0
hug/lib/python3.12/site-packages/networkx/utils/tests/test_rcm.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import networkx as nx
2
+ from networkx.utils import reverse_cuthill_mckee_ordering
3
+
4
+
5
+ def test_reverse_cuthill_mckee():
6
+ # example graph from
7
+ # http://www.boost.org/doc/libs/1_37_0/libs/graph/example/cuthill_mckee_ordering.cpp
8
+ G = nx.Graph(
9
+ [
10
+ (0, 3),
11
+ (0, 5),
12
+ (1, 2),
13
+ (1, 4),
14
+ (1, 6),
15
+ (1, 9),
16
+ (2, 3),
17
+ (2, 4),
18
+ (3, 5),
19
+ (3, 8),
20
+ (4, 6),
21
+ (5, 6),
22
+ (5, 7),
23
+ (6, 7),
24
+ ]
25
+ )
26
+ rcm = list(reverse_cuthill_mckee_ordering(G))
27
+ assert rcm in [[0, 8, 5, 7, 3, 6, 2, 4, 1, 9], [0, 8, 5, 7, 3, 6, 4, 2, 1, 9]]
28
+
29
+
30
+ def test_rcm_alternate_heuristic():
31
+ # example from
32
+ G = nx.Graph(
33
+ [
34
+ (0, 0),
35
+ (0, 4),
36
+ (1, 1),
37
+ (1, 2),
38
+ (1, 5),
39
+ (1, 7),
40
+ (2, 2),
41
+ (2, 4),
42
+ (3, 3),
43
+ (3, 6),
44
+ (4, 4),
45
+ (5, 5),
46
+ (5, 7),
47
+ (6, 6),
48
+ (7, 7),
49
+ ]
50
+ )
51
+
52
+ answers = [
53
+ [6, 3, 5, 7, 1, 2, 4, 0],
54
+ [6, 3, 7, 5, 1, 2, 4, 0],
55
+ [7, 5, 1, 2, 4, 0, 6, 3],
56
+ ]
57
+
58
+ def smallest_degree(G):
59
+ deg, node = min((d, n) for n, d in G.degree())
60
+ return node
61
+
62
+ rcm = list(reverse_cuthill_mckee_ordering(G, heuristic=smallest_degree))
63
+ assert rcm in answers
hug/lib/python3.12/site-packages/networkx/utils/tests/test_unionfind.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import networkx as nx
2
+
3
+
4
+ def test_unionfind():
5
+ # Fixed by: 2cddd5958689bdecdcd89b91ac9aaf6ce0e4f6b8
6
+ # Previously (in 2.x), the UnionFind class could handle mixed types.
7
+ # But in Python 3.x, this causes a TypeError such as:
8
+ # TypeError: unorderable types: str() > int()
9
+ #
10
+ # Now we just make sure that no exception is raised.
11
+ x = nx.utils.UnionFind()
12
+ x.union(0, "a")
13
+
14
+
15
+ def test_subtree_union():
16
+ # See https://github.com/networkx/networkx/pull/3224
17
+ # (35db1b551ee65780794a357794f521d8768d5049).
18
+ # Test if subtree unions hare handled correctly by to_sets().
19
+ uf = nx.utils.UnionFind()
20
+ uf.union(1, 2)
21
+ uf.union(3, 4)
22
+ uf.union(4, 5)
23
+ uf.union(1, 5)
24
+ assert list(uf.to_sets()) == [{1, 2, 3, 4, 5}]
25
+
26
+
27
+ def test_unionfind_weights():
28
+ # Tests if weights are computed correctly with unions of many elements
29
+ uf = nx.utils.UnionFind()
30
+ uf.union(1, 4, 7)
31
+ uf.union(2, 5, 8)
32
+ uf.union(3, 6, 9)
33
+ uf.union(1, 2, 3, 4, 5, 6, 7, 8, 9)
34
+ assert uf.weights[uf[1]] == 9
35
+
36
+
37
+ def test_unbalanced_merge_weights():
38
+ # Tests if the largest set's root is used as the new root when merging
39
+ uf = nx.utils.UnionFind()
40
+ uf.union(1, 2, 3)
41
+ uf.union(4, 5, 6, 7, 8, 9)
42
+ assert uf.weights[uf[1]] == 3
43
+ assert uf.weights[uf[4]] == 6
44
+ largest_root = uf[4]
45
+ uf.union(1, 4)
46
+ assert uf[1] == largest_root
47
+ assert uf.weights[largest_root] == 9
48
+
49
+
50
+ def test_empty_union():
51
+ # Tests if a null-union does nothing.
52
+ uf = nx.utils.UnionFind((0, 1))
53
+ uf.union()
54
+ assert uf[0] == 0
55
+ assert uf[1] == 1
hug/lib/python3.12/site-packages/networkx/utils/union_find.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Union-find data structure.
3
+ """
4
+
5
+ from networkx.utils import groups
6
+
7
+
8
+ class UnionFind:
9
+ """Union-find data structure.
10
+
11
+ Each unionFind instance X maintains a family of disjoint sets of
12
+ hashable objects, supporting the following two methods:
13
+
14
+ - X[item] returns a name for the set containing the given item.
15
+ Each set is named by an arbitrarily-chosen one of its members; as
16
+ long as the set remains unchanged it will keep the same name. If
17
+ the item is not yet part of a set in X, a new singleton set is
18
+ created for it.
19
+
20
+ - X.union(item1, item2, ...) merges the sets containing each item
21
+ into a single larger set. If any item is not yet part of a set
22
+ in X, it is added to X as one of the members of the merged set.
23
+
24
+ Union-find data structure. Based on Josiah Carlson's code,
25
+ https://code.activestate.com/recipes/215912/
26
+ with significant additional changes by D. Eppstein.
27
+ http://www.ics.uci.edu/~eppstein/PADS/UnionFind.py
28
+
29
+ """
30
+
31
+ def __init__(self, elements=None):
32
+ """Create a new empty union-find structure.
33
+
34
+ If *elements* is an iterable, this structure will be initialized
35
+ with the discrete partition on the given set of elements.
36
+
37
+ """
38
+ if elements is None:
39
+ elements = ()
40
+ self.parents = {}
41
+ self.weights = {}
42
+ for x in elements:
43
+ self.weights[x] = 1
44
+ self.parents[x] = x
45
+
46
+ def __getitem__(self, object):
47
+ """Find and return the name of the set containing the object."""
48
+
49
+ # check for previously unknown object
50
+ if object not in self.parents:
51
+ self.parents[object] = object
52
+ self.weights[object] = 1
53
+ return object
54
+
55
+ # find path of objects leading to the root
56
+ path = []
57
+ root = self.parents[object]
58
+ while root != object:
59
+ path.append(object)
60
+ object = root
61
+ root = self.parents[object]
62
+
63
+ # compress the path and return
64
+ for ancestor in path:
65
+ self.parents[ancestor] = root
66
+ return root
67
+
68
+ def __iter__(self):
69
+ """Iterate through all items ever found or unioned by this structure."""
70
+ return iter(self.parents)
71
+
72
+ def to_sets(self):
73
+ """Iterates over the sets stored in this structure.
74
+
75
+ For example::
76
+
77
+ >>> partition = UnionFind("xyz")
78
+ >>> sorted(map(sorted, partition.to_sets()))
79
+ [['x'], ['y'], ['z']]
80
+ >>> partition.union("x", "y")
81
+ >>> sorted(map(sorted, partition.to_sets()))
82
+ [['x', 'y'], ['z']]
83
+
84
+ """
85
+ # Ensure fully pruned paths
86
+ for x in self.parents:
87
+ _ = self[x] # Evaluated for side-effect only
88
+
89
+ yield from groups(self.parents).values()
90
+
91
+ def union(self, *objects):
92
+ """Find the sets containing the objects and merge them all."""
93
+ # Find the heaviest root according to its weight.
94
+ roots = iter(
95
+ sorted(
96
+ {self[x] for x in objects}, key=lambda r: self.weights[r], reverse=True
97
+ )
98
+ )
99
+ try:
100
+ root = next(roots)
101
+ except StopIteration:
102
+ return
103
+
104
+ for r in roots:
105
+ self.weights[root] += self.weights[r]
106
+ self.parents[r] = root
hug/lib/python3.12/site-packages/numpy/__config__.py ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file is generated by numpy's build process
2
+ # It contains system_info results at the time of building this package.
3
+ from enum import Enum
4
+ from numpy._core._multiarray_umath import (
5
+ __cpu_features__,
6
+ __cpu_baseline__,
7
+ __cpu_dispatch__,
8
+ )
9
+
10
+ __all__ = ["show_config"]
11
+ _built_with_meson = True
12
+
13
+
14
+ class DisplayModes(Enum):
15
+ stdout = "stdout"
16
+ dicts = "dicts"
17
+
18
+
19
+ def _cleanup(d):
20
+ """
21
+ Removes empty values in a `dict` recursively
22
+ This ensures we remove values that Meson could not provide to CONFIG
23
+ """
24
+ if isinstance(d, dict):
25
+ return {k: _cleanup(v) for k, v in d.items() if v and _cleanup(v)}
26
+ else:
27
+ return d
28
+
29
+
30
+ CONFIG = _cleanup(
31
+ {
32
+ "Compilers": {
33
+ "c": {
34
+ "name": "gcc",
35
+ "linker": r"ld.bfd",
36
+ "version": "14.2.1",
37
+ "commands": r"cc",
38
+ "args": r"",
39
+ "linker args": r"",
40
+ },
41
+ "cython": {
42
+ "name": "cython",
43
+ "linker": r"cython",
44
+ "version": "3.3.0",
45
+ "commands": r"cython",
46
+ "args": r"",
47
+ "linker args": r"",
48
+ },
49
+ "c++": {
50
+ "name": "gcc",
51
+ "linker": r"ld.bfd",
52
+ "version": "14.2.1",
53
+ "commands": r"c++",
54
+ "args": r"",
55
+ "linker args": r"",
56
+ },
57
+ },
58
+ "Machine Information": {
59
+ "host": {
60
+ "cpu": "x86_64",
61
+ "family": "x86_64",
62
+ "endian": "little",
63
+ "system": "linux",
64
+ },
65
+ "build": {
66
+ "cpu": "x86_64",
67
+ "family": "x86_64",
68
+ "endian": "little",
69
+ "system": "linux",
70
+ },
71
+ "cross-compiled": False,
72
+ },
73
+ "Build Dependencies": {
74
+ "blas": {
75
+ "name": "scipy-openblas",
76
+ "found": True,
77
+ "version": "0.3.34.106.0",
78
+ "detection method": "pkgconfig",
79
+ "include directory": r"/opt/_internal/cpython-3.12.13/lib/python3.12/site-packages/scipy_openblas64/include",
80
+ "lib directory": r"/opt/_internal/cpython-3.12.13/lib/python3.12/site-packages/scipy_openblas64/lib",
81
+ "openblas configuration": r"OpenBLAS 0.3.34.106.0 USE64BITINT DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=64",
82
+ "pc file directory": r"/project/.openblas",
83
+ },
84
+ "lapack": {
85
+ "name": "scipy-openblas",
86
+ "found": True,
87
+ "version": "0.3.34.106.0",
88
+ "detection method": "pkgconfig",
89
+ "include directory": r"/opt/_internal/cpython-3.12.13/lib/python3.12/site-packages/scipy_openblas64/include",
90
+ "lib directory": r"/opt/_internal/cpython-3.12.13/lib/python3.12/site-packages/scipy_openblas64/lib",
91
+ "openblas configuration": r"OpenBLAS 0.3.34.106.0 USE64BITINT DYNAMIC_ARCH NO_AFFINITY SkylakeX MAX_THREADS=64",
92
+ "pc file directory": r"/project/.openblas",
93
+ },
94
+ },
95
+ "Python Information": {
96
+ "path": r"/tmp/build-env-ptu49_tp/bin/python",
97
+ "version": "3.12",
98
+ },
99
+ "SIMD Extensions": {
100
+ "baseline": __cpu_baseline__,
101
+ "found": [
102
+ feature for feature in __cpu_dispatch__ if __cpu_features__[feature]
103
+ ],
104
+ "not found": [
105
+ feature for feature in __cpu_dispatch__ if not __cpu_features__[feature]
106
+ ],
107
+ },
108
+ }
109
+ )
110
+
111
+
112
+ def _check_pyyaml():
113
+ import yaml
114
+
115
+ return yaml
116
+
117
+
118
+ def show(mode=DisplayModes.stdout.value):
119
+ """
120
+ Show libraries and system information on which NumPy was built
121
+ and is being used
122
+
123
+ Parameters
124
+ ----------
125
+ mode : {`'stdout'`, `'dicts'`}, optional.
126
+ Indicates how to display the config information.
127
+ `'stdout'` prints to console, `'dicts'` returns a dictionary
128
+ of the configuration.
129
+
130
+ Returns
131
+ -------
132
+ out : {`dict`, `None`}
133
+ If mode is `'dicts'`, a dict is returned, else None
134
+
135
+ See Also
136
+ --------
137
+ get_include : Returns the directory containing NumPy C
138
+ header files.
139
+
140
+ Notes
141
+ -----
142
+ 1. The `'stdout'` mode will give more readable
143
+ output if ``pyyaml`` is installed
144
+
145
+ """
146
+ if mode == DisplayModes.stdout.value:
147
+ try: # Non-standard library, check import
148
+ yaml = _check_pyyaml()
149
+
150
+ print(yaml.dump(CONFIG))
151
+ except ModuleNotFoundError:
152
+ import warnings
153
+ import json
154
+
155
+ warnings.warn("Install `pyyaml` for better output", stacklevel=1)
156
+ print(json.dumps(CONFIG, indent=2))
157
+ elif mode == DisplayModes.dicts.value:
158
+ return CONFIG
159
+ else:
160
+ raise AttributeError(
161
+ f"Invalid `mode`, use one of: {', '.join([e.value for e in DisplayModes])}"
162
+ )
163
+
164
+
165
+ def show_config(mode=DisplayModes.stdout.value):
166
+ return show(mode)
167
+
168
+
169
+ show_config.__doc__ = show.__doc__
170
+ show_config.__module__ = "numpy"
hug/lib/python3.12/site-packages/numpy/__config__.pyi ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from enum import Enum
2
+ from types import ModuleType
3
+ from typing import (
4
+ Final,
5
+ Literal as L,
6
+ NotRequired,
7
+ TypedDict,
8
+ overload,
9
+ type_check_only,
10
+ )
11
+
12
+ _CompilerConfigDictValue = TypedDict(
13
+ "_CompilerConfigDictValue",
14
+ {
15
+ "name": str,
16
+ "linker": str,
17
+ "version": str,
18
+ "commands": str,
19
+ "args": str,
20
+ "linker args": str,
21
+ },
22
+ )
23
+ _CompilerConfigDict = TypedDict(
24
+ "_CompilerConfigDict",
25
+ {
26
+ "c": _CompilerConfigDictValue,
27
+ "cython": _CompilerConfigDictValue,
28
+ "c++": _CompilerConfigDictValue,
29
+ },
30
+ )
31
+ _MachineInformationDict = TypedDict(
32
+ "_MachineInformationDict",
33
+ {
34
+ "host": _MachineInformationDictValue,
35
+ "build": _MachineInformationDictValue,
36
+ "cross-compiled": NotRequired[L[True]],
37
+ },
38
+ )
39
+
40
+ @type_check_only
41
+ class _MachineInformationDictValue(TypedDict):
42
+ cpu: str
43
+ family: str
44
+ endian: L["little", "big"]
45
+ system: str
46
+
47
+ _BuildDependenciesDictValue = TypedDict(
48
+ "_BuildDependenciesDictValue",
49
+ {
50
+ "name": str,
51
+ "found": NotRequired[L[True]],
52
+ "version": str,
53
+ "include directory": str,
54
+ "lib directory": str,
55
+ "openblas configuration": str,
56
+ "pc file directory": str,
57
+ },
58
+ )
59
+
60
+ class _BuildDependenciesDict(TypedDict):
61
+ blas: _BuildDependenciesDictValue
62
+ lapack: _BuildDependenciesDictValue
63
+
64
+ class _PythonInformationDict(TypedDict):
65
+ path: str
66
+ version: str
67
+
68
+ _SIMDExtensionsDict = TypedDict(
69
+ "_SIMDExtensionsDict",
70
+ {
71
+ "baseline": list[str],
72
+ "found": list[str],
73
+ "not found": list[str],
74
+ },
75
+ )
76
+
77
+ _ConfigDict = TypedDict(
78
+ "_ConfigDict",
79
+ {
80
+ "Compilers": _CompilerConfigDict,
81
+ "Machine Information": _MachineInformationDict,
82
+ "Build Dependencies": _BuildDependenciesDict,
83
+ "Python Information": _PythonInformationDict,
84
+ "SIMD Extensions": _SIMDExtensionsDict,
85
+ },
86
+ )
87
+
88
+ ###
89
+
90
+ __all__ = ["show_config"]
91
+
92
+ CONFIG: Final[_ConfigDict] = ...
93
+
94
+ __cpu_features__: Final[dict[str, bool]] = ...
95
+ __cpu_baseline__: Final[list[str]] = ...
96
+ __cpu_dispatch__: Final[list[str]] = ...
97
+
98
+ class DisplayModes(Enum):
99
+ stdout = "stdout"
100
+ dicts = "dicts"
101
+
102
+ def _check_pyyaml() -> ModuleType: ...
103
+
104
+ #
105
+ @overload
106
+ def show(mode: L["stdout"] = "stdout") -> None: ...
107
+ @overload
108
+ def show(mode: L["dicts"]) -> _ConfigDict: ...
109
+
110
+ #
111
+ @overload
112
+ def show_config(mode: L["stdout"] = "stdout") -> None: ...
113
+ @overload
114
+ def show_config(mode: L["dicts"]) -> _ConfigDict: ...
hug/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd ADDED
@@ -0,0 +1,1312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NumPy static imports for Cython >= 3.0
2
+ #
3
+ # If any of the PyArray_* functions are called, import_array must be
4
+ # called first. This is done automatically by Cython 3.0+ if a call
5
+ # is not detected inside of the module.
6
+ #
7
+ # Author: Dag Sverre Seljebotn
8
+ #
9
+
10
+ from cpython.ref cimport Py_INCREF
11
+ from cpython.object cimport PyObject, PyTypeObject, PyObject_TypeCheck
12
+ cimport libc.stdio as stdio
13
+
14
+
15
+ cdef extern from *:
16
+ # Leave a marker that the NumPy declarations came from NumPy itself and not from Cython.
17
+ # See https://github.com/cython/cython/issues/3573
18
+ """
19
+ /* Using NumPy API declarations from "numpy/__init__.cython-30.pxd" */
20
+ """
21
+
22
+
23
+ cdef extern from "numpy/arrayobject.h":
24
+ # It would be nice to use size_t and ssize_t, but ssize_t has special
25
+ # implicit conversion rules, so just use "long".
26
+ # Note: The actual type only matters for Cython promotion, so long
27
+ # is closer than int, but could lead to incorrect promotion.
28
+ # (Not to worrying, and always the status-quo.)
29
+ ctypedef signed long npy_intp
30
+ ctypedef unsigned long npy_uintp
31
+
32
+ ctypedef unsigned char npy_bool
33
+
34
+ ctypedef signed char npy_byte
35
+ ctypedef signed short npy_short
36
+ ctypedef signed int npy_int
37
+ ctypedef signed long npy_long
38
+ ctypedef signed long long npy_longlong
39
+
40
+ ctypedef unsigned char npy_ubyte
41
+ ctypedef unsigned short npy_ushort
42
+ ctypedef unsigned int npy_uint
43
+ ctypedef unsigned long npy_ulong
44
+ ctypedef unsigned long long npy_ulonglong
45
+
46
+ ctypedef float npy_float
47
+ ctypedef double npy_double
48
+ ctypedef long double npy_longdouble
49
+
50
+ ctypedef signed char npy_int8
51
+ ctypedef signed short npy_int16
52
+ ctypedef signed int npy_int32
53
+ ctypedef signed long long npy_int64
54
+
55
+ ctypedef unsigned char npy_uint8
56
+ ctypedef unsigned short npy_uint16
57
+ ctypedef unsigned int npy_uint32
58
+ ctypedef unsigned long long npy_uint64
59
+
60
+ ctypedef float npy_float32
61
+ ctypedef double npy_float64
62
+ ctypedef long double npy_float80
63
+ ctypedef long double npy_float96
64
+ ctypedef long double npy_float128
65
+
66
+ ctypedef struct npy_cfloat:
67
+ pass
68
+
69
+ ctypedef struct npy_cdouble:
70
+ pass
71
+
72
+ ctypedef struct npy_clongdouble:
73
+ pass
74
+
75
+ ctypedef struct npy_complex64:
76
+ pass
77
+
78
+ ctypedef struct npy_complex128:
79
+ pass
80
+
81
+ ctypedef struct npy_complex160:
82
+ pass
83
+
84
+ ctypedef struct npy_complex192:
85
+ pass
86
+
87
+ ctypedef struct npy_complex256:
88
+ pass
89
+
90
+ ctypedef struct PyArray_Dims:
91
+ npy_intp *ptr
92
+ int len
93
+
94
+
95
+ cdef enum NPY_TYPES:
96
+ NPY_BOOL
97
+ NPY_BYTE
98
+ NPY_UBYTE
99
+ NPY_SHORT
100
+ NPY_USHORT
101
+ NPY_INT
102
+ NPY_UINT
103
+ NPY_LONG
104
+ NPY_ULONG
105
+ NPY_LONGLONG
106
+ NPY_ULONGLONG
107
+ NPY_FLOAT
108
+ NPY_DOUBLE
109
+ NPY_LONGDOUBLE
110
+ NPY_CFLOAT
111
+ NPY_CDOUBLE
112
+ NPY_CLONGDOUBLE
113
+ NPY_OBJECT
114
+ NPY_STRING
115
+ NPY_UNICODE
116
+ NPY_VSTRING
117
+ NPY_VOID
118
+ NPY_DATETIME
119
+ NPY_TIMEDELTA
120
+ NPY_NTYPES_LEGACY
121
+ NPY_NOTYPE
122
+
123
+ NPY_INT8
124
+ NPY_INT16
125
+ NPY_INT32
126
+ NPY_INT64
127
+ NPY_UINT8
128
+ NPY_UINT16
129
+ NPY_UINT32
130
+ NPY_UINT64
131
+ NPY_FLOAT16
132
+ NPY_FLOAT32
133
+ NPY_FLOAT64
134
+ NPY_FLOAT80
135
+ NPY_FLOAT96
136
+ NPY_FLOAT128
137
+ NPY_COMPLEX64
138
+ NPY_COMPLEX128
139
+ NPY_COMPLEX160
140
+ NPY_COMPLEX192
141
+ NPY_COMPLEX256
142
+
143
+ NPY_INTP
144
+ NPY_UINTP
145
+ NPY_DEFAULT_INT # Not a compile time constant (normally)!
146
+
147
+ ctypedef enum NPY_ORDER:
148
+ NPY_ANYORDER
149
+ NPY_CORDER
150
+ NPY_FORTRANORDER
151
+ NPY_KEEPORDER
152
+
153
+ ctypedef enum NPY_CASTING:
154
+ NPY_NO_CASTING
155
+ NPY_EQUIV_CASTING
156
+ NPY_SAFE_CASTING
157
+ NPY_SAME_KIND_CASTING
158
+ NPY_UNSAFE_CASTING
159
+ NPY_SAME_VALUE_CASTING
160
+
161
+ ctypedef enum NPY_CLIPMODE:
162
+ NPY_CLIP
163
+ NPY_WRAP
164
+ NPY_RAISE
165
+
166
+ ctypedef enum NPY_SCALARKIND:
167
+ NPY_NOSCALAR,
168
+ NPY_BOOL_SCALAR,
169
+ NPY_INTPOS_SCALAR,
170
+ NPY_INTNEG_SCALAR,
171
+ NPY_FLOAT_SCALAR,
172
+ NPY_COMPLEX_SCALAR,
173
+ NPY_OBJECT_SCALAR
174
+
175
+ ctypedef enum NPY_SORTKIND:
176
+ NPY_QUICKSORT
177
+ NPY_HEAPSORT
178
+ NPY_MERGESORT
179
+
180
+ ctypedef enum NPY_SEARCHSIDE:
181
+ NPY_SEARCHLEFT
182
+ NPY_SEARCHRIGHT
183
+
184
+ enum:
185
+ NPY_ARRAY_C_CONTIGUOUS
186
+ NPY_ARRAY_F_CONTIGUOUS
187
+ NPY_ARRAY_OWNDATA
188
+ NPY_ARRAY_FORCECAST
189
+ NPY_ARRAY_ENSURECOPY
190
+ NPY_ARRAY_ENSUREARRAY
191
+ NPY_ARRAY_ELEMENTSTRIDES
192
+ NPY_ARRAY_ALIGNED
193
+ NPY_ARRAY_NOTSWAPPED
194
+ NPY_ARRAY_WRITEABLE
195
+ NPY_ARRAY_WRITEBACKIFCOPY
196
+
197
+ NPY_ARRAY_BEHAVED
198
+ NPY_ARRAY_BEHAVED_NS
199
+ NPY_ARRAY_CARRAY
200
+ NPY_ARRAY_CARRAY_RO
201
+ NPY_ARRAY_FARRAY
202
+ NPY_ARRAY_FARRAY_RO
203
+ NPY_ARRAY_DEFAULT
204
+
205
+ NPY_ARRAY_IN_ARRAY
206
+ NPY_ARRAY_OUT_ARRAY
207
+ NPY_ARRAY_INOUT_ARRAY
208
+ NPY_ARRAY_IN_FARRAY
209
+ NPY_ARRAY_OUT_FARRAY
210
+ NPY_ARRAY_INOUT_FARRAY
211
+
212
+ NPY_ARRAY_UPDATE_ALL
213
+
214
+ cdef enum:
215
+ NPY_MAXDIMS # 64 on NumPy 2.x and 32 on NumPy 1.x
216
+ NPY_RAVEL_AXIS # Used for functions like PyArray_Mean
217
+
218
+ ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
219
+
220
+ ctypedef struct PyArray_ArrayDescr:
221
+ # shape is a tuple, but Cython doesn't support "tuple shape"
222
+ # inside a non-PyObject declaration, so we have to declare it
223
+ # as just a PyObject*.
224
+ PyObject* shape
225
+
226
+ ctypedef struct PyArray_Descr:
227
+ pass
228
+
229
+ ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]:
230
+ @property
231
+ cdef inline PyTypeObject* typeobj(self) noexcept nogil:
232
+ return PyDataType_TYPEOBJ(self)
233
+
234
+ @property
235
+ cdef inline char kind(self) noexcept nogil:
236
+ return PyDataType_KIND(self)
237
+
238
+ @property
239
+ cdef inline char type(self) noexcept nogil:
240
+ return PyDataType_TYPE(self)
241
+
242
+ # Numpy sometimes mutates this without warning (e.g. it'll
243
+ # sometimes change "|" to "<" in shared dtype objects on
244
+ # little-endian machines). If this matters to you, use
245
+ # PyArray_IsNativeByteOrder(dtype.byteorder) instead of
246
+ # directly accessing this field.
247
+ @property
248
+ cdef inline char byteorder(self) noexcept nogil:
249
+ return PyDataType_BYTEORDER(self)
250
+
251
+ @property
252
+ cdef inline int type_num(self) noexcept nogil:
253
+ return PyDataType_TYPENUM(self)
254
+
255
+ @property
256
+ cdef inline npy_intp itemsize(self) noexcept nogil:
257
+ return PyDataType_ELSIZE(self)
258
+
259
+ @property
260
+ cdef inline npy_intp alignment(self) noexcept nogil:
261
+ return PyDataType_ALIGNMENT(self)
262
+
263
+ # Use fields/names with care as they may be NULL. You must check
264
+ # for this using PyDataType_HASFIELDS.
265
+ @property
266
+ cdef inline object fields(self):
267
+ return <object>PyDataType_FIELDS(self)
268
+
269
+ @property
270
+ cdef inline tuple names(self):
271
+ return <tuple>PyDataType_NAMES(self)
272
+
273
+ # Use PyDataType_HASSUBARRAY to test whether this field is
274
+ # valid (the pointer can be NULL). Most users should access
275
+ # this field via the inline helper method PyDataType_SHAPE.
276
+ @property
277
+ cdef inline PyArray_ArrayDescr* subarray(self) noexcept nogil:
278
+ return PyDataType_SUBARRAY(self)
279
+
280
+ @property
281
+ cdef inline npy_uint64 flags(self) noexcept nogil:
282
+ """The data types flags."""
283
+ return PyDataType_FLAGS(self)
284
+
285
+
286
+ ctypedef class numpy.flatiter [object PyArrayIterObject, check_size ignore]:
287
+ # Use through macros
288
+ pass
289
+
290
+ ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]:
291
+
292
+ @property
293
+ cdef inline int numiter(self) noexcept nogil:
294
+ """The number of arrays that need to be broadcast to the same shape."""
295
+ return PyArray_MultiIter_NUMITER(self)
296
+
297
+ @property
298
+ cdef inline npy_intp size(self) noexcept nogil:
299
+ """The total broadcasted size."""
300
+ return PyArray_MultiIter_SIZE(self)
301
+
302
+ @property
303
+ cdef inline npy_intp index(self) noexcept nogil:
304
+ """The current (1-d) index into the broadcasted result."""
305
+ return PyArray_MultiIter_INDEX(self)
306
+
307
+ @property
308
+ cdef inline int nd(self) noexcept nogil:
309
+ """The number of dimensions in the broadcasted result."""
310
+ return PyArray_MultiIter_NDIM(self)
311
+
312
+ @property
313
+ cdef inline npy_intp* dimensions(self) noexcept nogil:
314
+ """The shape of the broadcasted result."""
315
+ return PyArray_MultiIter_DIMS(self)
316
+
317
+ @property
318
+ cdef inline void** iters(self) noexcept nogil:
319
+ """An array of iterator objects that holds the iterators for the arrays to be broadcast together.
320
+ On return, the iterators are adjusted for broadcasting."""
321
+ return PyArray_MultiIter_ITERS(self)
322
+
323
+
324
+ ctypedef struct PyArrayObject:
325
+ # For use in situations where ndarray can't replace PyArrayObject*,
326
+ # like PyArrayObject**.
327
+ pass
328
+
329
+ ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]:
330
+ cdef __cythonbufferdefaults__ = {"mode": "strided"}
331
+
332
+ # NOTE: no field declarations since direct access is deprecated since NumPy 1.7
333
+ # Instead, we use properties that map to the corresponding C-API functions.
334
+
335
+ @property
336
+ cdef inline PyObject* base(self) noexcept nogil:
337
+ """Returns a borrowed reference to the object owning the data/memory.
338
+ """
339
+ return PyArray_BASE(self)
340
+
341
+ @property
342
+ cdef inline dtype descr(self):
343
+ """Returns an owned reference to the dtype of the array.
344
+ """
345
+ return <dtype>PyArray_DESCR(self)
346
+
347
+ @property
348
+ cdef inline int ndim(self) noexcept nogil:
349
+ """Returns the number of dimensions in the array.
350
+ """
351
+ return PyArray_NDIM(self)
352
+
353
+ @property
354
+ cdef inline npy_intp *shape(self) noexcept nogil:
355
+ """Returns a pointer to the dimensions/shape of the array.
356
+ The number of elements matches the number of dimensions of the array (ndim).
357
+ Can return NULL for 0-dimensional arrays.
358
+ """
359
+ return PyArray_DIMS(self)
360
+
361
+ @property
362
+ cdef inline npy_intp *strides(self) noexcept nogil:
363
+ """Returns a pointer to the strides of the array.
364
+ The number of elements matches the number of dimensions of the array (ndim).
365
+ """
366
+ return PyArray_STRIDES(self)
367
+
368
+ @property
369
+ cdef inline npy_intp size(self) noexcept nogil:
370
+ """Returns the total size (in number of elements) of the array.
371
+ """
372
+ return PyArray_SIZE(self)
373
+
374
+ @property
375
+ cdef inline char* data(self) noexcept nogil:
376
+ """The pointer to the data buffer as a char*.
377
+ This is provided for legacy reasons to avoid direct struct field access.
378
+ For new code that needs this access, you probably want to cast the result
379
+ of `PyArray_DATA()` instead, which returns a 'void*'.
380
+ """
381
+ return PyArray_BYTES(self)
382
+
383
+
384
+ int _import_array() except -1
385
+ # A second definition so _import_array isn't marked as used when we use it here.
386
+ # Do not use - subject to change any time.
387
+ int __pyx_import_array "_import_array"() except -1
388
+
389
+ #
390
+ # Macros from ndarrayobject.h
391
+ #
392
+ bint PyArray_CHKFLAGS(ndarray m, int flags) nogil
393
+ bint PyArray_IS_C_CONTIGUOUS(ndarray arr) nogil
394
+ bint PyArray_IS_F_CONTIGUOUS(ndarray arr) nogil
395
+ bint PyArray_ISCONTIGUOUS(ndarray m) nogil
396
+ bint PyArray_ISWRITEABLE(ndarray m) nogil
397
+ bint PyArray_ISALIGNED(ndarray m) nogil
398
+
399
+ int PyArray_NDIM(ndarray) nogil
400
+ bint PyArray_ISONESEGMENT(ndarray) nogil
401
+ bint PyArray_ISFORTRAN(ndarray) nogil
402
+ int PyArray_FORTRANIF(ndarray) nogil
403
+
404
+ void* PyArray_DATA(ndarray) nogil
405
+ char* PyArray_BYTES(ndarray) nogil
406
+
407
+ npy_intp* PyArray_DIMS(ndarray) nogil
408
+ npy_intp* PyArray_STRIDES(ndarray) nogil
409
+ npy_intp PyArray_DIM(ndarray, size_t) nogil
410
+ npy_intp PyArray_STRIDE(ndarray, size_t) nogil
411
+
412
+ PyObject *PyArray_BASE(ndarray) nogil # returns borrowed reference!
413
+ PyArray_Descr *PyArray_DESCR(ndarray) nogil # returns borrowed reference to dtype!
414
+ PyArray_Descr *PyArray_DTYPE(ndarray) nogil # returns borrowed reference to dtype! NP 1.7+ alias for descr.
415
+ int PyArray_FLAGS(ndarray) nogil
416
+ void PyArray_CLEARFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7
417
+ void PyArray_ENABLEFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7
418
+ npy_intp PyArray_ITEMSIZE(ndarray) nogil
419
+ int PyArray_TYPE(ndarray arr) nogil
420
+
421
+ object PyArray_GETITEM(ndarray arr, void *itemptr)
422
+ int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) except -1
423
+
424
+ bint PyTypeNum_ISBOOL(int) nogil
425
+ bint PyTypeNum_ISUNSIGNED(int) nogil
426
+ bint PyTypeNum_ISSIGNED(int) nogil
427
+ bint PyTypeNum_ISINTEGER(int) nogil
428
+ bint PyTypeNum_ISFLOAT(int) nogil
429
+ bint PyTypeNum_ISNUMBER(int) nogil
430
+ bint PyTypeNum_ISSTRING(int) nogil
431
+ bint PyTypeNum_ISCOMPLEX(int) nogil
432
+ bint PyTypeNum_ISFLEXIBLE(int) nogil
433
+ bint PyTypeNum_ISUSERDEF(int) nogil
434
+ bint PyTypeNum_ISEXTENDED(int) nogil
435
+ bint PyTypeNum_ISOBJECT(int) nogil
436
+
437
+ npy_intp PyDataType_ELSIZE(dtype) nogil
438
+ npy_intp PyDataType_ALIGNMENT(dtype) nogil
439
+ PyObject* PyDataType_METADATA(dtype) nogil
440
+ PyArray_ArrayDescr* PyDataType_SUBARRAY(dtype) nogil
441
+ PyObject* PyDataType_NAMES(dtype) nogil
442
+ PyObject* PyDataType_FIELDS(dtype) nogil
443
+ char PyDataType_TYPE(dtype) nogil
444
+ char PyDataType_KIND(dtype) nogil
445
+ int PyDataType_TYPENUM(dtype) nogil
446
+ char PyDataType_BYTEORDER(dtype) nogil
447
+ PyTypeObject* PyDataType_TYPEOBJ(dtype) nogil
448
+
449
+ bint PyDataType_ISBOOL(dtype) nogil
450
+ bint PyDataType_ISUNSIGNED(dtype) nogil
451
+ bint PyDataType_ISSIGNED(dtype) nogil
452
+ bint PyDataType_ISINTEGER(dtype) nogil
453
+ bint PyDataType_ISFLOAT(dtype) nogil
454
+ bint PyDataType_ISNUMBER(dtype) nogil
455
+ bint PyDataType_ISSTRING(dtype) nogil
456
+ bint PyDataType_ISCOMPLEX(dtype) nogil
457
+ bint PyDataType_ISFLEXIBLE(dtype) nogil
458
+ bint PyDataType_ISUSERDEF(dtype) nogil
459
+ bint PyDataType_ISEXTENDED(dtype) nogil
460
+ bint PyDataType_ISOBJECT(dtype) nogil
461
+ bint PyDataType_HASFIELDS(dtype) nogil
462
+ bint PyDataType_HASSUBARRAY(dtype) nogil
463
+ npy_uint64 PyDataType_FLAGS(dtype) nogil
464
+
465
+ bint PyArray_ISBOOL(ndarray) nogil
466
+ bint PyArray_ISUNSIGNED(ndarray) nogil
467
+ bint PyArray_ISSIGNED(ndarray) nogil
468
+ bint PyArray_ISINTEGER(ndarray) nogil
469
+ bint PyArray_ISFLOAT(ndarray) nogil
470
+ bint PyArray_ISNUMBER(ndarray) nogil
471
+ bint PyArray_ISSTRING(ndarray) nogil
472
+ bint PyArray_ISCOMPLEX(ndarray) nogil
473
+ bint PyArray_ISFLEXIBLE(ndarray) nogil
474
+ bint PyArray_ISUSERDEF(ndarray) nogil
475
+ bint PyArray_ISEXTENDED(ndarray) nogil
476
+ bint PyArray_ISOBJECT(ndarray) nogil
477
+ bint PyArray_HASFIELDS(ndarray) nogil
478
+
479
+ bint PyArray_ISVARIABLE(ndarray) nogil
480
+
481
+ bint PyArray_SAFEALIGNEDCOPY(ndarray) nogil
482
+ bint PyArray_ISNBO(char) nogil # works on ndarray.byteorder
483
+ bint PyArray_IsNativeByteOrder(char) nogil # works on ndarray.byteorder
484
+ bint PyArray_ISNOTSWAPPED(ndarray) nogil
485
+ bint PyArray_ISBYTESWAPPED(ndarray) nogil
486
+
487
+ bint PyArray_FLAGSWAP(ndarray, int) nogil
488
+
489
+ bint PyArray_ISCARRAY(ndarray) nogil
490
+ bint PyArray_ISCARRAY_RO(ndarray) nogil
491
+ bint PyArray_ISFARRAY(ndarray) nogil
492
+ bint PyArray_ISFARRAY_RO(ndarray) nogil
493
+ bint PyArray_ISBEHAVED(ndarray) nogil
494
+ bint PyArray_ISBEHAVED_RO(ndarray) nogil
495
+
496
+
497
+ bint PyDataType_ISNOTSWAPPED(dtype) nogil
498
+ bint PyDataType_ISBYTESWAPPED(dtype) nogil
499
+
500
+ bint PyArray_DescrCheck(object)
501
+
502
+ bint PyArray_Check(object)
503
+ bint PyArray_CheckExact(object)
504
+
505
+ # Cannot be supported due to out arg:
506
+ # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
507
+ # bint PyArray_HasArrayInterface(op, out)
508
+
509
+
510
+ bint PyArray_IsZeroDim(object)
511
+ # Cannot be supported due to ## ## in macro:
512
+ # bint PyArray_IsScalar(object, verbatim work)
513
+ bint PyArray_CheckScalar(object)
514
+ bint PyArray_IsPythonNumber(object)
515
+ bint PyArray_IsPythonScalar(object)
516
+ bint PyArray_IsAnyScalar(object)
517
+ bint PyArray_CheckAnyScalar(object)
518
+
519
+ ndarray PyArray_GETCONTIGUOUS(ndarray)
520
+ bint PyArray_SAMESHAPE(ndarray, ndarray) nogil
521
+ npy_intp PyArray_SIZE(ndarray) nogil
522
+ npy_intp PyArray_NBYTES(ndarray) nogil
523
+
524
+ object PyArray_FROM_O(object)
525
+ object PyArray_FROM_OF(object m, int flags)
526
+ object PyArray_FROM_OT(object m, int type)
527
+ object PyArray_FROM_OTF(object m, int type, int flags)
528
+ object PyArray_FROMANY(object m, int type, int min, int max, int flags)
529
+ object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran)
530
+ object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran)
531
+ void PyArray_FILLWBYTE(ndarray, int val)
532
+ object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth)
533
+ unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2)
534
+ bint PyArray_EquivByteorders(int b1, int b2) nogil
535
+ object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum)
536
+ object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data)
537
+ #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr)
538
+ object PyArray_ToScalar(void* data, ndarray arr)
539
+
540
+ void* PyArray_GETPTR1(ndarray m, npy_intp i) nogil
541
+ void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) nogil
542
+ void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) nogil
543
+ void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) nogil
544
+
545
+ # Cannot be supported due to out arg
546
+ # void PyArray_DESCR_REPLACE(descr)
547
+
548
+
549
+ object PyArray_Copy(ndarray)
550
+ object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
551
+ object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
552
+ object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
553
+
554
+ object PyArray_Cast(ndarray mp, int type_num)
555
+ object PyArray_Take(ndarray ap, object items, int axis)
556
+ object PyArray_Put(ndarray ap, object items, object values)
557
+
558
+ void PyArray_ITER_RESET(flatiter it) nogil
559
+ void PyArray_ITER_NEXT(flatiter it) nogil
560
+ void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
561
+ void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
562
+ void* PyArray_ITER_DATA(flatiter it) nogil
563
+ bint PyArray_ITER_NOTDONE(flatiter it) nogil
564
+
565
+ void PyArray_MultiIter_RESET(broadcast multi) nogil
566
+ void PyArray_MultiIter_NEXT(broadcast multi) nogil
567
+ void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
568
+ void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil
569
+ void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil
570
+ void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil
571
+ bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil
572
+ npy_intp PyArray_MultiIter_SIZE(broadcast multi) nogil
573
+ int PyArray_MultiIter_NDIM(broadcast multi) nogil
574
+ npy_intp PyArray_MultiIter_INDEX(broadcast multi) nogil
575
+ int PyArray_MultiIter_NUMITER(broadcast multi) nogil
576
+ npy_intp* PyArray_MultiIter_DIMS(broadcast multi) nogil
577
+ void** PyArray_MultiIter_ITERS(broadcast multi) nogil
578
+
579
+ # Functions from __multiarray_api.h
580
+
581
+ # Functions taking dtype and returning object/ndarray are disabled
582
+ # for now as they steal dtype references. I'm conservative and disable
583
+ # more than is probably needed until it can be checked further.
584
+ int PyArray_INCREF (ndarray) except * # uses PyArray_Item_INCREF...
585
+ int PyArray_XDECREF (ndarray) except * # uses PyArray_Item_DECREF...
586
+ dtype PyArray_DescrFromType (int)
587
+ object PyArray_TypeObjectFromType (int)
588
+ char * PyArray_Zero (ndarray)
589
+ char * PyArray_One (ndarray)
590
+ #object PyArray_CastToType (ndarray, dtype, int)
591
+ int PyArray_CanCastSafely (int, int) # writes errors
592
+ npy_bool PyArray_CanCastTo (dtype, dtype) # writes errors
593
+ int PyArray_ObjectType (object, int) except 0
594
+ dtype PyArray_DescrFromObject (object, dtype)
595
+ #ndarray* PyArray_ConvertToCommonType (object, int *)
596
+ dtype PyArray_DescrFromScalar (object)
597
+ dtype PyArray_DescrFromTypeObject (object)
598
+ npy_intp PyArray_Size (object)
599
+ #object PyArray_Scalar (void *, dtype, object)
600
+ #object PyArray_FromScalar (object, dtype)
601
+ void PyArray_ScalarAsCtype (object, void *)
602
+ #int PyArray_CastScalarToCtype (object, void *, dtype)
603
+ #int PyArray_CastScalarDirect (object, dtype, void *, int)
604
+ #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int)
605
+ #object PyArray_FromAny (object, dtype, int, int, int, object)
606
+ object PyArray_EnsureArray (object)
607
+ object PyArray_EnsureAnyArray (object)
608
+ #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *)
609
+ #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *)
610
+ #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp)
611
+ #object PyArray_FromIter (object, dtype, npy_intp)
612
+ object PyArray_Return (ndarray)
613
+ #object PyArray_GetField (ndarray, dtype, int)
614
+ #int PyArray_SetField (ndarray, dtype, int, object) except -1
615
+ object PyArray_Byteswap (ndarray, npy_bool)
616
+ object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER)
617
+ int PyArray_CopyInto (ndarray, ndarray) except -1
618
+ int PyArray_CopyAnyInto (ndarray, ndarray) except -1
619
+ int PyArray_CopyObject (ndarray, object) except -1
620
+ object PyArray_NewCopy (ndarray, NPY_ORDER)
621
+ object PyArray_ToList (ndarray)
622
+ object PyArray_ToString (ndarray, NPY_ORDER)
623
+ int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *) except -1
624
+ int PyArray_Dump (object, object, int) except -1
625
+ object PyArray_Dumps (object, int)
626
+ int PyArray_ValidType (int) # Cannot error
627
+ void PyArray_UpdateFlags (ndarray, int)
628
+ object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
629
+ #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
630
+ #dtype PyArray_DescrNew (dtype)
631
+ dtype PyArray_DescrNewFromType (int)
632
+ double PyArray_GetPriority (object, double) # clears errors as of 1.25
633
+ object PyArray_IterNew (object)
634
+ object PyArray_MultiIterNew (int, ...)
635
+
636
+ int PyArray_PyIntAsInt (object) except? -1
637
+ npy_intp PyArray_PyIntAsIntp (object)
638
+ int PyArray_Broadcast (broadcast) except -1
639
+ int PyArray_FillWithScalar (ndarray, object) except -1
640
+ npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
641
+ dtype PyArray_DescrNewByteorder (dtype, char)
642
+ object PyArray_IterAllButAxis (object, int *)
643
+ #object PyArray_CheckFromAny (object, dtype, int, int, int, object)
644
+ #object PyArray_FromArray (ndarray, dtype, int)
645
+ object PyArray_FromInterface (object)
646
+ object PyArray_FromStructInterface (object)
647
+ #object PyArray_FromArrayAttr (object, dtype, object)
648
+ #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*)
649
+ int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND)
650
+ npy_bool PyArray_CanCastScalar (type, type)
651
+ int PyArray_RemoveSmallest (broadcast) except -1
652
+ int PyArray_ElementStrides (object)
653
+ void PyArray_Item_INCREF (char *, dtype) except *
654
+ void PyArray_Item_XDECREF (char *, dtype) except *
655
+ object PyArray_Transpose (ndarray, PyArray_Dims *)
656
+ object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE)
657
+ object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE)
658
+ object PyArray_PutMask (ndarray, object, object)
659
+ object PyArray_Repeat (ndarray, object, int)
660
+ object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE)
661
+ int PyArray_Sort (ndarray, int, NPY_SORTKIND) except -1
662
+ object PyArray_ArgSort (ndarray, int, NPY_SORTKIND)
663
+ object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject *)
664
+ object PyArray_ArgMax (ndarray, int, ndarray)
665
+ object PyArray_ArgMin (ndarray, int, ndarray)
666
+ object PyArray_Reshape (ndarray, object)
667
+ object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER)
668
+ object PyArray_Squeeze (ndarray)
669
+ #object PyArray_View (ndarray, dtype, type)
670
+ object PyArray_SwapAxes (ndarray, int, int)
671
+ object PyArray_Max (ndarray, int, ndarray)
672
+ object PyArray_Min (ndarray, int, ndarray)
673
+ object PyArray_Ptp (ndarray, int, ndarray)
674
+ object PyArray_Mean (ndarray, int, int, ndarray)
675
+ object PyArray_Trace (ndarray, int, int, int, int, ndarray)
676
+ object PyArray_Diagonal (ndarray, int, int, int)
677
+ object PyArray_Clip (ndarray, object, object, ndarray)
678
+ object PyArray_Conjugate (ndarray, ndarray)
679
+ object PyArray_Nonzero (ndarray)
680
+ object PyArray_Std (ndarray, int, int, ndarray, int)
681
+ object PyArray_Sum (ndarray, int, int, ndarray)
682
+ object PyArray_CumSum (ndarray, int, int, ndarray)
683
+ object PyArray_Prod (ndarray, int, int, ndarray)
684
+ object PyArray_CumProd (ndarray, int, int, ndarray)
685
+ object PyArray_All (ndarray, int, ndarray)
686
+ object PyArray_Any (ndarray, int, ndarray)
687
+ object PyArray_Compress (ndarray, object, int, ndarray)
688
+ object PyArray_Flatten (ndarray, NPY_ORDER)
689
+ object PyArray_Ravel (ndarray, NPY_ORDER)
690
+ npy_intp PyArray_MultiplyList (npy_intp *, int)
691
+ int PyArray_MultiplyIntList (int *, int)
692
+ void * PyArray_GetPtr (ndarray, npy_intp*)
693
+ int PyArray_CompareLists (npy_intp *, npy_intp *, int)
694
+ #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype)
695
+ int PyArray_Free (object, void *)
696
+ #int PyArray_Converter (object, object*)
697
+ int PyArray_IntpFromSequence (object, npy_intp *, int) except -1
698
+ object PyArray_Concatenate (object, int)
699
+ object PyArray_InnerProduct (object, object)
700
+ object PyArray_MatrixProduct (object, object)
701
+ object PyArray_Correlate (object, object, int)
702
+ #int PyArray_DescrConverter (object, dtype*) except 0
703
+ #int PyArray_DescrConverter2 (object, dtype*) except 0
704
+ int PyArray_IntpConverter (object, PyArray_Dims *) except 0
705
+ #int PyArray_BufferConverter (object, chunk) except 0
706
+ int PyArray_AxisConverter (object, int *) except 0
707
+ int PyArray_BoolConverter (object, npy_bool *) except 0
708
+ int PyArray_ByteorderConverter (object, char *) except 0
709
+ int PyArray_OrderConverter (object, NPY_ORDER *) except 0
710
+ unsigned char PyArray_EquivTypes (dtype, dtype) # clears errors
711
+ #object PyArray_Zeros (int, npy_intp *, dtype, int)
712
+ #object PyArray_Empty (int, npy_intp *, dtype, int)
713
+ object PyArray_Where (object, object, object)
714
+ object PyArray_Arange (double, double, double, int)
715
+ #object PyArray_ArangeObj (object, object, object, dtype)
716
+ int PyArray_SortkindConverter (object, NPY_SORTKIND *) except 0
717
+ object PyArray_LexSort (object, int)
718
+ object PyArray_Round (ndarray, int, ndarray)
719
+ unsigned char PyArray_EquivTypenums (int, int)
720
+ int PyArray_RegisterDataType (dtype) except -1
721
+ int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *) except -1
722
+ int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND) except -1
723
+ #void PyArray_InitArrFuncs (PyArray_ArrFuncs *)
724
+ object PyArray_IntTupleFromIntp (int, npy_intp *)
725
+ int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *) except 0
726
+ #int PyArray_OutputConverter (object, ndarray*) except 0
727
+ object PyArray_BroadcastToShape (object, npy_intp *, int)
728
+ #int PyArray_DescrAlignConverter (object, dtype*) except 0
729
+ #int PyArray_DescrAlignConverter2 (object, dtype*) except 0
730
+ int PyArray_SearchsideConverter (object, void *) except 0
731
+ object PyArray_CheckAxis (ndarray, int *, int)
732
+ npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
733
+ int PyArray_SetBaseObject(ndarray, base) except -1 # NOTE: steals a reference to base! Use "set_array_base()" instead.
734
+
735
+ # The memory handler functions require the NumPy 1.22 API
736
+ # and may require defining NPY_TARGET_VERSION
737
+ ctypedef struct PyDataMemAllocator:
738
+ void *ctx
739
+ void* (*malloc) (void *ctx, size_t size)
740
+ void* (*calloc) (void *ctx, size_t nelem, size_t elsize)
741
+ void* (*realloc) (void *ctx, void *ptr, size_t new_size)
742
+ void (*free) (void *ctx, void *ptr, size_t size)
743
+
744
+ ctypedef struct PyDataMem_Handler:
745
+ char* name
746
+ npy_uint8 version
747
+ PyDataMemAllocator allocator
748
+
749
+ object PyDataMem_SetHandler(object handler)
750
+ object PyDataMem_GetHandler()
751
+
752
+ # additional datetime related functions are defined below
753
+
754
+
755
+ # Typedefs that matches the runtime dtype objects in
756
+ # the numpy module.
757
+
758
+ # The ones that are commented out needs an IFDEF function
759
+ # in Cython to enable them only on the right systems.
760
+
761
+ ctypedef npy_int8 int8_t
762
+ ctypedef npy_int16 int16_t
763
+ ctypedef npy_int32 int32_t
764
+ ctypedef npy_int64 int64_t
765
+
766
+ ctypedef npy_uint8 uint8_t
767
+ ctypedef npy_uint16 uint16_t
768
+ ctypedef npy_uint32 uint32_t
769
+ ctypedef npy_uint64 uint64_t
770
+
771
+ ctypedef npy_float32 float32_t
772
+ ctypedef npy_float64 float64_t
773
+ #ctypedef npy_float80 float80_t
774
+ #ctypedef npy_float128 float128_t
775
+
776
+ ctypedef float complex complex64_t
777
+ ctypedef double complex complex128_t
778
+
779
+ ctypedef npy_longlong longlong_t
780
+ ctypedef npy_ulonglong ulonglong_t
781
+
782
+ ctypedef npy_intp intp_t
783
+ ctypedef npy_uintp uintp_t
784
+
785
+ ctypedef npy_double float_t
786
+ ctypedef npy_double double_t
787
+ ctypedef npy_longdouble longdouble_t
788
+
789
+ ctypedef float complex cfloat_t
790
+ ctypedef double complex cdouble_t
791
+ ctypedef double complex complex_t
792
+ ctypedef long double complex clongdouble_t
793
+
794
+ cdef inline object PyArray_MultiIterNew1(a):
795
+ return PyArray_MultiIterNew(1, <void*>a)
796
+
797
+ cdef inline object PyArray_MultiIterNew2(a, b):
798
+ return PyArray_MultiIterNew(2, <void*>a, <void*>b)
799
+
800
+ cdef inline object PyArray_MultiIterNew3(a, b, c):
801
+ return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
802
+
803
+ cdef inline object PyArray_MultiIterNew4(a, b, c, d):
804
+ return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
805
+
806
+ cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
807
+ return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
808
+
809
+ cdef inline tuple PyDataType_SHAPE(dtype d):
810
+ if PyDataType_HASSUBARRAY(d):
811
+ return <tuple>d.subarray.shape
812
+ else:
813
+ return ()
814
+
815
+
816
+ cdef extern from "numpy/ndarrayobject.h":
817
+ PyTypeObject PyTimedeltaArrType_Type
818
+ PyTypeObject PyDatetimeArrType_Type
819
+ ctypedef int64_t npy_timedelta
820
+ ctypedef int64_t npy_datetime
821
+
822
+ cdef extern from "numpy/ndarraytypes.h":
823
+ ctypedef struct PyArray_DatetimeMetaData:
824
+ NPY_DATETIMEUNIT base
825
+ int64_t num
826
+
827
+ ctypedef struct npy_datetimestruct:
828
+ int64_t year
829
+ int32_t month, day, hour, min, sec, us, ps, as
830
+
831
+ # Iterator API added in v1.6
832
+ #
833
+ # These don't match the definition in the C API because Cython can't wrap
834
+ # function pointers that return functions.
835
+ # https://github.com/cython/cython/issues/6720
836
+ ctypedef int (*NpyIter_IterNextFunc "NpyIter_IterNextFunc *")(NpyIter* it) noexcept nogil
837
+ ctypedef void (*NpyIter_GetMultiIndexFunc "NpyIter_GetMultiIndexFunc *")(NpyIter* it, npy_intp* outcoords) noexcept nogil
838
+
839
+ PyArray_DatetimeMetaData _PyDatetimeScalarObject_GetMetadata(object) noexcept nogil
840
+ PyArray_DatetimeMetaData _PyTimedeltaScalarObject_GetMetadata(object) noexcept nogil
841
+ npy_datetime _PyDatetimeScalarObject_GetValue(object) noexcept nogil
842
+ npy_timedelta _PyTimedeltaScalarObject_GetValue(object) noexcept nogil
843
+
844
+ cdef extern from "numpy/arrayscalars.h":
845
+
846
+ # abstract types
847
+ ctypedef class numpy.generic [object PyObject]:
848
+ pass
849
+ ctypedef class numpy.number [object PyObject]:
850
+ pass
851
+ ctypedef class numpy.integer [object PyObject]:
852
+ pass
853
+ ctypedef class numpy.signedinteger [object PyObject]:
854
+ pass
855
+ ctypedef class numpy.unsignedinteger [object PyObject]:
856
+ pass
857
+ ctypedef class numpy.inexact [object PyObject]:
858
+ pass
859
+ ctypedef class numpy.floating [object PyObject]:
860
+ pass
861
+ ctypedef class numpy.complexfloating [object PyObject]:
862
+ pass
863
+ ctypedef class numpy.flexible [object PyObject]:
864
+ pass
865
+ ctypedef class numpy.character [object PyObject]:
866
+ pass
867
+
868
+ ctypedef struct PyDatetimeScalarObject:
869
+ # PyObject_HEAD
870
+ npy_datetime obval
871
+ PyArray_DatetimeMetaData obmeta
872
+
873
+ ctypedef struct PyTimedeltaScalarObject:
874
+ # PyObject_HEAD
875
+ npy_timedelta obval
876
+ PyArray_DatetimeMetaData obmeta
877
+
878
+ ctypedef enum NPY_DATETIMEUNIT:
879
+ NPY_FR_Y
880
+ NPY_FR_M
881
+ NPY_FR_W
882
+ NPY_FR_D
883
+ NPY_FR_B
884
+ NPY_FR_h
885
+ NPY_FR_m
886
+ NPY_FR_s
887
+ NPY_FR_ms
888
+ NPY_FR_us
889
+ NPY_FR_ns
890
+ NPY_FR_ps
891
+ NPY_FR_fs
892
+ NPY_FR_as
893
+ NPY_FR_GENERIC
894
+
895
+
896
+ cdef extern from "numpy/arrayobject.h":
897
+ # These are part of the C-API defined in `__multiarray_api.h`
898
+
899
+ # NumPy internal definitions in datetime_strings.c:
900
+ int get_datetime_iso_8601_strlen "NpyDatetime_GetDatetimeISO8601StrLen" (
901
+ int local, NPY_DATETIMEUNIT base)
902
+ int make_iso_8601_datetime "NpyDatetime_MakeISO8601Datetime" (
903
+ npy_datetimestruct *dts, char *outstr, npy_intp outlen,
904
+ int local, int utc, NPY_DATETIMEUNIT base, int tzoffset,
905
+ NPY_CASTING casting) except -1
906
+
907
+ # NumPy internal definition in datetime.c:
908
+ # May return 1 to indicate that object does not appear to be a datetime
909
+ # (returns 0 on success).
910
+ int convert_pydatetime_to_datetimestruct "NpyDatetime_ConvertPyDateTimeToDatetimeStruct" (
911
+ PyObject *obj, npy_datetimestruct *out,
912
+ NPY_DATETIMEUNIT *out_bestunit, int apply_tzinfo) except -1
913
+ int convert_datetime64_to_datetimestruct "NpyDatetime_ConvertDatetime64ToDatetimeStruct" (
914
+ PyArray_DatetimeMetaData *meta, npy_datetime dt,
915
+ npy_datetimestruct *out) except -1
916
+ int convert_datetimestruct_to_datetime64 "NpyDatetime_ConvertDatetimeStructToDatetime64"(
917
+ PyArray_DatetimeMetaData *meta, const npy_datetimestruct *dts,
918
+ npy_datetime *out) except -1
919
+
920
+
921
+ #
922
+ # ufunc API
923
+ #
924
+
925
+ cdef extern from "numpy/ufuncobject.h":
926
+
927
+ ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
928
+
929
+ ctypedef struct PyUFuncObject_fields:
930
+ int nin, nout, nargs
931
+ int identity
932
+ PyUFuncGenericFunction *functions
933
+ void **data
934
+ int ntypes
935
+ int check_return
936
+ char *name
937
+ char *types
938
+ char *doc
939
+ void *ptr
940
+ PyObject *obj
941
+ PyObject *userloops
942
+
943
+ ctypedef struct PyUFuncObject:
944
+ pass
945
+
946
+ ctypedef class numpy.ufunc [object PyUFuncObject, check_size ignore]:
947
+ @property
948
+ cdef inline int nin(self) noexcept nogil:
949
+ return _PyUFuncObject_GET_ITEM_DATA(self).nin
950
+
951
+ @property
952
+ cdef inline int nout(self) noexcept nogil:
953
+ return _PyUFuncObject_GET_ITEM_DATA(self).nout
954
+
955
+ @property
956
+ cdef inline int nargs(self) noexcept nogil:
957
+ return _PyUFuncObject_GET_ITEM_DATA(self).nargs
958
+
959
+ @property
960
+ cdef inline PyUFuncGenericFunction* functions(self) noexcept nogil:
961
+ return _PyUFuncObject_GET_ITEM_DATA(self).functions
962
+
963
+ @property
964
+ cdef inline void ** data(self) noexcept nogil:
965
+ return <void **>_PyUFuncObject_GET_ITEM_DATA(self).data
966
+
967
+ @property
968
+ cdef inline int ntypes(self) noexcept nogil:
969
+ return _PyUFuncObject_GET_ITEM_DATA(self).ntypes
970
+
971
+ @property
972
+ cdef inline const char* name(self) noexcept nogil:
973
+ return _PyUFuncObject_GET_ITEM_DATA(self).name
974
+
975
+ @property
976
+ cdef inline const char* doc(self) noexcept nogil:
977
+ return _PyUFuncObject_GET_ITEM_DATA(self).doc
978
+
979
+ @property
980
+ cdef inline void* ptr(self) noexcept nogil:
981
+ return _PyUFuncObject_GET_ITEM_DATA(self).ptr
982
+
983
+ @property
984
+ cdef inline PyObject* obj(self) noexcept nogil:
985
+ return _PyUFuncObject_GET_ITEM_DATA(self).obj
986
+
987
+ @property
988
+ cdef inline PyObject* userloops(self) noexcept nogil:
989
+ return _PyUFuncObject_GET_ITEM_DATA(self).userloops
990
+
991
+ PyUFuncObject_fields *_PyUFuncObject_GET_ITEM_DATA(ufunc) nogil
992
+
993
+ cdef enum:
994
+ PyUFunc_Zero
995
+ PyUFunc_One
996
+ PyUFunc_None
997
+ # deprecated
998
+ UFUNC_FPE_DIVIDEBYZERO
999
+ UFUNC_FPE_OVERFLOW
1000
+ UFUNC_FPE_UNDERFLOW
1001
+ UFUNC_FPE_INVALID
1002
+ # use these instead
1003
+ NPY_FPE_DIVIDEBYZERO
1004
+ NPY_FPE_OVERFLOW
1005
+ NPY_FPE_UNDERFLOW
1006
+ NPY_FPE_INVALID
1007
+
1008
+
1009
+ object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
1010
+ void **, char *, int, int, int, int, char *, char *, int)
1011
+ int PyUFunc_RegisterLoopForType(ufunc, int,
1012
+ PyUFuncGenericFunction, int *, void *) except -1
1013
+ void PyUFunc_f_f_As_d_d \
1014
+ (char **, npy_intp *, npy_intp *, void *)
1015
+ void PyUFunc_d_d \
1016
+ (char **, npy_intp *, npy_intp *, void *)
1017
+ void PyUFunc_f_f \
1018
+ (char **, npy_intp *, npy_intp *, void *)
1019
+ void PyUFunc_g_g \
1020
+ (char **, npy_intp *, npy_intp *, void *)
1021
+ void PyUFunc_F_F_As_D_D \
1022
+ (char **, npy_intp *, npy_intp *, void *)
1023
+ void PyUFunc_F_F \
1024
+ (char **, npy_intp *, npy_intp *, void *)
1025
+ void PyUFunc_D_D \
1026
+ (char **, npy_intp *, npy_intp *, void *)
1027
+ void PyUFunc_G_G \
1028
+ (char **, npy_intp *, npy_intp *, void *)
1029
+ void PyUFunc_O_O \
1030
+ (char **, npy_intp *, npy_intp *, void *)
1031
+ void PyUFunc_ff_f_As_dd_d \
1032
+ (char **, npy_intp *, npy_intp *, void *)
1033
+ void PyUFunc_ff_f \
1034
+ (char **, npy_intp *, npy_intp *, void *)
1035
+ void PyUFunc_dd_d \
1036
+ (char **, npy_intp *, npy_intp *, void *)
1037
+ void PyUFunc_gg_g \
1038
+ (char **, npy_intp *, npy_intp *, void *)
1039
+ void PyUFunc_FF_F_As_DD_D \
1040
+ (char **, npy_intp *, npy_intp *, void *)
1041
+ void PyUFunc_DD_D \
1042
+ (char **, npy_intp *, npy_intp *, void *)
1043
+ void PyUFunc_FF_F \
1044
+ (char **, npy_intp *, npy_intp *, void *)
1045
+ void PyUFunc_GG_G \
1046
+ (char **, npy_intp *, npy_intp *, void *)
1047
+ void PyUFunc_OO_O \
1048
+ (char **, npy_intp *, npy_intp *, void *)
1049
+ void PyUFunc_O_O_method \
1050
+ (char **, npy_intp *, npy_intp *, void *)
1051
+ void PyUFunc_OO_O_method \
1052
+ (char **, npy_intp *, npy_intp *, void *)
1053
+ void PyUFunc_On_Om \
1054
+ (char **, npy_intp *, npy_intp *, void *)
1055
+ void PyUFunc_clearfperr()
1056
+ int PyUFunc_getfperr()
1057
+ int PyUFunc_ReplaceLoopBySignature \
1058
+ (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)
1059
+ object PyUFunc_FromFuncAndDataAndSignature \
1060
+ (PyUFuncGenericFunction *, void **, char *, int, int, int,
1061
+ int, char *, char *, int, char *)
1062
+
1063
+ int _import_umath() except -1
1064
+
1065
+ cdef inline void set_array_base(ndarray arr, object base) except *:
1066
+ Py_INCREF(base) # important to do this before stealing the reference below!
1067
+ PyArray_SetBaseObject(arr, base)
1068
+
1069
+ cdef inline object get_array_base(ndarray arr):
1070
+ base = PyArray_BASE(arr)
1071
+ if base is NULL:
1072
+ return None
1073
+ return <object>base
1074
+
1075
+ # Versions of the import_* functions which are more suitable for
1076
+ # Cython code.
1077
+ cdef inline int import_array() except -1:
1078
+ try:
1079
+ __pyx_import_array()
1080
+ except Exception:
1081
+ raise ImportError("numpy._core.multiarray failed to import")
1082
+
1083
+ cdef inline int import_umath() except -1:
1084
+ try:
1085
+ _import_umath()
1086
+ except Exception:
1087
+ raise ImportError("numpy._core.umath failed to import")
1088
+
1089
+ cdef inline int import_ufunc() except -1:
1090
+ try:
1091
+ _import_umath()
1092
+ except Exception:
1093
+ raise ImportError("numpy._core.umath failed to import")
1094
+
1095
+
1096
+ cdef inline bint is_timedelta64_object(object obj) noexcept:
1097
+ """
1098
+ Cython equivalent of `isinstance(obj, np.timedelta64)`
1099
+
1100
+ Parameters
1101
+ ----------
1102
+ obj : object
1103
+
1104
+ Returns
1105
+ -------
1106
+ bool
1107
+ """
1108
+ return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)
1109
+
1110
+
1111
+ cdef inline bint is_datetime64_object(object obj) noexcept:
1112
+ """
1113
+ Cython equivalent of `isinstance(obj, np.datetime64)`
1114
+
1115
+ Parameters
1116
+ ----------
1117
+ obj : object
1118
+
1119
+ Returns
1120
+ -------
1121
+ bool
1122
+ """
1123
+ return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)
1124
+
1125
+
1126
+ cdef inline npy_datetime get_datetime64_value(object obj) noexcept nogil:
1127
+ """
1128
+ returns the int64 value underlying scalar numpy datetime64 object
1129
+
1130
+ Note that to interpret this as a datetime, the corresponding unit is
1131
+ also needed. That can be found using `get_datetime64_unit`.
1132
+ """
1133
+ return _PyDatetimeScalarObject_GetValue(obj)
1134
+
1135
+
1136
+ cdef inline npy_timedelta get_timedelta64_value(object obj) noexcept nogil:
1137
+ """
1138
+ returns the int64 value underlying scalar numpy timedelta64 object
1139
+ """
1140
+ return _PyTimedeltaScalarObject_GetValue(obj)
1141
+
1142
+
1143
+ cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) noexcept nogil:
1144
+ """
1145
+ returns the unit part of the dtype for a numpy datetime64 object.
1146
+ """
1147
+ return _PyDatetimeScalarObject_GetMetadata(obj).base
1148
+
1149
+
1150
+ cdef extern from "numpy/arrayobject.h":
1151
+
1152
+ ctypedef struct NpyIter:
1153
+ pass
1154
+
1155
+ cdef enum:
1156
+ NPY_FAIL
1157
+ NPY_SUCCEED
1158
+
1159
+ cdef enum:
1160
+ # Track an index representing C order
1161
+ NPY_ITER_C_INDEX
1162
+ # Track an index representing Fortran order
1163
+ NPY_ITER_F_INDEX
1164
+ # Track a multi-index
1165
+ NPY_ITER_MULTI_INDEX
1166
+ # User code external to the iterator does the 1-dimensional innermost loop
1167
+ NPY_ITER_EXTERNAL_LOOP
1168
+ # Convert all the operands to a common data type
1169
+ NPY_ITER_COMMON_DTYPE
1170
+ # Operands may hold references, requiring API access during iteration
1171
+ NPY_ITER_REFS_OK
1172
+ # Zero-sized operands should be permitted, iteration checks IterSize for 0
1173
+ NPY_ITER_ZEROSIZE_OK
1174
+ # Permits reductions (size-0 stride with dimension size > 1)
1175
+ NPY_ITER_REDUCE_OK
1176
+ # Enables sub-range iteration
1177
+ NPY_ITER_RANGED
1178
+ # Enables buffering
1179
+ NPY_ITER_BUFFERED
1180
+ # When buffering is enabled, grows the inner loop if possible
1181
+ NPY_ITER_GROWINNER
1182
+ # Delay allocation of buffers until first Reset* call
1183
+ NPY_ITER_DELAY_BUFALLOC
1184
+ # When NPY_KEEPORDER is specified, disable reversing negative-stride axes
1185
+ NPY_ITER_DONT_NEGATE_STRIDES
1186
+ NPY_ITER_COPY_IF_OVERLAP
1187
+ # The operand will be read from and written to
1188
+ NPY_ITER_READWRITE
1189
+ # The operand will only be read from
1190
+ NPY_ITER_READONLY
1191
+ # The operand will only be written to
1192
+ NPY_ITER_WRITEONLY
1193
+ # The operand's data must be in native byte order
1194
+ NPY_ITER_NBO
1195
+ # The operand's data must be aligned
1196
+ NPY_ITER_ALIGNED
1197
+ # The operand's data must be contiguous (within the inner loop)
1198
+ NPY_ITER_CONTIG
1199
+ # The operand may be copied to satisfy requirements
1200
+ NPY_ITER_COPY
1201
+ # The operand may be copied with WRITEBACKIFCOPY to satisfy requirements
1202
+ NPY_ITER_UPDATEIFCOPY
1203
+ # Allocate the operand if it is NULL
1204
+ NPY_ITER_ALLOCATE
1205
+ # If an operand is allocated, don't use any subtype
1206
+ NPY_ITER_NO_SUBTYPE
1207
+ # This is a virtual array slot, operand is NULL but temporary data is there
1208
+ NPY_ITER_VIRTUAL
1209
+ # Require that the dimension match the iterator dimensions exactly
1210
+ NPY_ITER_NO_BROADCAST
1211
+ # A mask is being used on this array, affects buffer -> array copy
1212
+ NPY_ITER_WRITEMASKED
1213
+ # This array is the mask for all WRITEMASKED operands
1214
+ NPY_ITER_ARRAYMASK
1215
+ # Assume iterator order data access for COPY_IF_OVERLAP
1216
+ NPY_ITER_OVERLAP_ASSUME_ELEMENTWISE
1217
+
1218
+ # construction and destruction functions
1219
+ NpyIter* NpyIter_New(ndarray arr, npy_uint32 flags, NPY_ORDER order,
1220
+ NPY_CASTING casting, dtype datatype) except NULL
1221
+ NpyIter* NpyIter_MultiNew(npy_intp nop, PyArrayObject** op, npy_uint32 flags,
1222
+ NPY_ORDER order, NPY_CASTING casting, npy_uint32*
1223
+ op_flags, PyArray_Descr** op_dtypes) except NULL
1224
+ NpyIter* NpyIter_AdvancedNew(npy_intp nop, PyArrayObject** op,
1225
+ npy_uint32 flags, NPY_ORDER order,
1226
+ NPY_CASTING casting, npy_uint32* op_flags,
1227
+ PyArray_Descr** op_dtypes, int oa_ndim,
1228
+ int** op_axes, const npy_intp* itershape,
1229
+ npy_intp buffersize) except NULL
1230
+ NpyIter* NpyIter_Copy(NpyIter* it) except NULL
1231
+ int NpyIter_RemoveAxis(NpyIter* it, int axis) except NPY_FAIL
1232
+ int NpyIter_RemoveMultiIndex(NpyIter* it) except NPY_FAIL
1233
+ int NpyIter_EnableExternalLoop(NpyIter* it) except NPY_FAIL
1234
+ int NpyIter_Deallocate(NpyIter* it) except NPY_FAIL
1235
+ int NpyIter_Reset(NpyIter* it, char** errmsg) except NPY_FAIL
1236
+ int NpyIter_ResetToIterIndexRange(NpyIter* it, npy_intp istart,
1237
+ npy_intp iend, char** errmsg) except NPY_FAIL
1238
+ int NpyIter_ResetBasePointers(NpyIter* it, char** baseptrs, char** errmsg) except NPY_FAIL
1239
+ int NpyIter_GotoMultiIndex(NpyIter* it, const npy_intp* multi_index) except NPY_FAIL
1240
+ int NpyIter_GotoIndex(NpyIter* it, npy_intp index) except NPY_FAIL
1241
+ npy_intp NpyIter_GetIterSize(NpyIter* it) nogil
1242
+ npy_intp NpyIter_GetIterIndex(NpyIter* it) nogil
1243
+ void NpyIter_GetIterIndexRange(NpyIter* it, npy_intp* istart,
1244
+ npy_intp* iend) nogil
1245
+ int NpyIter_GotoIterIndex(NpyIter* it, npy_intp iterindex) except NPY_FAIL
1246
+ npy_bool NpyIter_HasDelayedBufAlloc(NpyIter* it) nogil
1247
+ npy_bool NpyIter_HasExternalLoop(NpyIter* it) nogil
1248
+ npy_bool NpyIter_HasMultiIndex(NpyIter* it) nogil
1249
+ npy_bool NpyIter_HasIndex(NpyIter* it) nogil
1250
+ npy_bool NpyIter_RequiresBuffering(NpyIter* it) nogil
1251
+ npy_bool NpyIter_IsBuffered(NpyIter* it) nogil
1252
+ npy_bool NpyIter_IsGrowInner(NpyIter* it) nogil
1253
+ npy_intp NpyIter_GetBufferSize(NpyIter* it) nogil
1254
+ int NpyIter_GetNDim(NpyIter* it) nogil
1255
+ int NpyIter_GetNOp(NpyIter* it) nogil
1256
+ npy_intp* NpyIter_GetAxisStrideArray(NpyIter* it, int axis) except NULL
1257
+ int NpyIter_GetShape(NpyIter* it, npy_intp* outshape) nogil
1258
+ PyArray_Descr** NpyIter_GetDescrArray(NpyIter* it)
1259
+ PyArrayObject** NpyIter_GetOperandArray(NpyIter* it)
1260
+ ndarray NpyIter_GetIterView(NpyIter* it, npy_intp i)
1261
+ void NpyIter_GetReadFlags(NpyIter* it, char* outreadflags)
1262
+ void NpyIter_GetWriteFlags(NpyIter* it, char* outwriteflags)
1263
+ int NpyIter_CreateCompatibleStrides(NpyIter* it, npy_intp itemsize,
1264
+ npy_intp* outstrides) except NPY_FAIL
1265
+ npy_bool NpyIter_IsFirstVisit(NpyIter* it, int iop) nogil
1266
+ # functions for iterating an NpyIter object
1267
+ #
1268
+ # These don't match the definition in the C API because Cython can't wrap
1269
+ # function pointers that return functions.
1270
+ NpyIter_IterNextFunc NpyIter_GetIterNext(NpyIter* it, char** errmsg) except NULL
1271
+ NpyIter_GetMultiIndexFunc NpyIter_GetGetMultiIndex(NpyIter* it,
1272
+ char** errmsg) except NULL
1273
+ char** NpyIter_GetDataPtrArray(NpyIter* it) nogil
1274
+ char** NpyIter_GetInitialDataPtrArray(NpyIter* it) nogil
1275
+ npy_intp* NpyIter_GetIndexPtr(NpyIter* it)
1276
+ npy_intp* NpyIter_GetInnerStrideArray(NpyIter* it) nogil
1277
+ npy_intp* NpyIter_GetInnerLoopSizePtr(NpyIter* it) nogil
1278
+ void NpyIter_GetInnerFixedStrideArray(NpyIter* it, npy_intp* outstrides) nogil
1279
+ npy_bool NpyIter_IterationNeedsAPI(NpyIter* it) nogil
1280
+ void NpyIter_DebugPrint(NpyIter* it)
1281
+
1282
+ # NpyString API
1283
+ cdef extern from "numpy/ndarraytypes.h":
1284
+ ctypedef struct npy_string_allocator:
1285
+ pass
1286
+
1287
+ ctypedef struct npy_packed_static_string:
1288
+ pass
1289
+
1290
+ ctypedef struct npy_static_string:
1291
+ size_t size
1292
+ const char *buf
1293
+
1294
+ ctypedef struct PyArray_StringDTypeObject:
1295
+ PyArray_Descr base
1296
+ PyObject *na_object
1297
+ char coerce
1298
+ char has_nan_na
1299
+ char has_string_na
1300
+ char array_owned
1301
+ npy_static_string default_string
1302
+ npy_static_string na_name
1303
+ npy_string_allocator *allocator
1304
+
1305
+ cdef extern from "numpy/arrayobject.h":
1306
+ npy_string_allocator *NpyString_acquire_allocator(const PyArray_StringDTypeObject *descr)
1307
+ void NpyString_acquire_allocators(size_t n_descriptors, PyArray_Descr *const descrs[], npy_string_allocator *allocators[])
1308
+ void NpyString_release_allocator(npy_string_allocator *allocator)
1309
+ void NpyString_release_allocators(size_t length, npy_string_allocator *allocators[])
1310
+ int NpyString_load(npy_string_allocator *allocator, const npy_packed_static_string *packed_string, npy_static_string *unpacked_string)
1311
+ int NpyString_pack_null(npy_string_allocator *allocator, npy_packed_static_string *packed_string)
1312
+ int NpyString_pack(npy_string_allocator *allocator, npy_packed_static_string *packed_string, const char *buf, size_t size)
hug/lib/python3.12/site-packages/numpy/__init__.pxd ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NumPy static imports for Cython < 3.0
2
+ #
3
+ # DO NOT USE OR REFER TO THIS HEADER
4
+ #
5
+ # This is provided only to generate an error message on older Cython
6
+ # versions.
7
+ #
8
+ # See __init__.cython-30.pxd for the real Cython header
9
+ #
10
+
11
+ # intentionally created compiler error that only triggers on Cython < 3.0.0
12
+ DEF err = int('Build aborted: the NumPy Cython headers require Cython 3.0.0 or newer.')
hug/lib/python3.12/site-packages/numpy/__init__.py ADDED
@@ -0,0 +1,926 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ NumPy
3
+ =====
4
+
5
+ Provides
6
+ 1. An array object of arbitrary homogeneous items
7
+ 2. Fast mathematical operations over arrays
8
+ 3. Linear Algebra, Fourier Transforms, Random Number Generation
9
+
10
+ How to use the documentation
11
+ ----------------------------
12
+ Documentation is available in two forms: docstrings provided
13
+ with the code, and a loose standing reference guide, available from
14
+ `the NumPy homepage <https://numpy.org>`_.
15
+
16
+ We recommend exploring the docstrings using
17
+ `IPython <https://ipython.org>`_, an advanced Python shell with
18
+ TAB-completion and introspection capabilities. See below for further
19
+ instructions.
20
+
21
+ The docstring examples assume that `numpy` has been imported as ``np``::
22
+
23
+ >>> import numpy as np
24
+
25
+ Code snippets are indicated by three greater-than signs::
26
+
27
+ >>> x = 42
28
+ >>> x = x + 1
29
+
30
+ Use the built-in ``help`` function to view a function's docstring::
31
+
32
+ >>> help(np.sort)
33
+ ... # doctest: +SKIP
34
+
35
+ For some objects, ``np.info(obj)`` may provide additional help. This is
36
+ particularly true if you see the line "Help on ufunc object:" at the top
37
+ of the help() page. Ufuncs are implemented in C, not Python, for speed.
38
+ The native Python help() does not know how to view their help, but our
39
+ np.info() function does.
40
+
41
+ Available subpackages
42
+ ---------------------
43
+ lib
44
+ Basic functions used by several sub-packages.
45
+ random
46
+ Core Random Tools
47
+ linalg
48
+ Core Linear Algebra Tools
49
+ fft
50
+ Core FFT routines
51
+ polynomial
52
+ Polynomial tools
53
+ testing
54
+ NumPy testing tools
55
+
56
+ Utilities
57
+ ---------
58
+ test
59
+ Run numpy unittests
60
+ show_config
61
+ Show numpy build configuration
62
+ __version__
63
+ NumPy version string
64
+
65
+ Viewing documentation using IPython
66
+ -----------------------------------
67
+
68
+ Start IPython and import `numpy` usually under the alias ``np``: `import
69
+ numpy as np`. Then, directly past or use the ``%cpaste`` magic to paste
70
+ examples into the shell. To see which functions are available in `numpy`,
71
+ type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
72
+ ``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
73
+ down the list. To view the docstring for a function, use
74
+ ``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
75
+ the source code).
76
+
77
+ Copies vs. in-place operation
78
+ -----------------------------
79
+ Most of the functions in `numpy` return a copy of the array argument
80
+ (e.g., `np.sort`). In-place versions of these functions are often
81
+ available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
82
+ Exceptions to this rule are documented.
83
+
84
+ """
85
+ import os
86
+ import sys
87
+ import warnings
88
+
89
+ # If a version with git hash was stored, use that instead
90
+ from . import version
91
+ from ._expired_attrs_2_0 import __expired_attributes__
92
+ from ._globals import _CopyMode, _NoValue
93
+ from .version import __version__
94
+
95
+ # We first need to detect if we're being called as part of the numpy setup
96
+ # procedure itself in a reliable manner.
97
+ try:
98
+ __NUMPY_SETUP__ # noqa: B018
99
+ except NameError:
100
+ __NUMPY_SETUP__ = False
101
+
102
+ if __NUMPY_SETUP__:
103
+ sys.stderr.write('Running from numpy source directory.\n')
104
+ else:
105
+ # Allow distributors to run custom init code before importing numpy._core
106
+ from . import _distributor_init
107
+
108
+ try:
109
+ from numpy.__config__ import show_config
110
+ except ImportError as e:
111
+ if isinstance(e, ModuleNotFoundError) and e.name == "numpy.__config__":
112
+ # The __config__ module itself was not found, so add this info:
113
+ msg = """Error importing numpy: you should not try to import numpy from
114
+ its source directory; please exit the numpy source tree, and relaunch
115
+ your python interpreter from there."""
116
+ raise ImportError(msg) from e
117
+ raise
118
+
119
+ from . import _core
120
+ from ._core import (
121
+ False_,
122
+ ScalarType,
123
+ True_,
124
+ abs,
125
+ absolute,
126
+ acos,
127
+ acosh,
128
+ add,
129
+ all,
130
+ allclose,
131
+ amax,
132
+ amin,
133
+ any,
134
+ arange,
135
+ arccos,
136
+ arccosh,
137
+ arcsin,
138
+ arcsinh,
139
+ arctan,
140
+ arctan2,
141
+ arctanh,
142
+ argmax,
143
+ argmin,
144
+ argpartition,
145
+ argsort,
146
+ argwhere,
147
+ around,
148
+ array,
149
+ array2string,
150
+ array_equal,
151
+ array_equiv,
152
+ array_repr,
153
+ array_str,
154
+ asanyarray,
155
+ asarray,
156
+ ascontiguousarray,
157
+ asfortranarray,
158
+ asin,
159
+ asinh,
160
+ astype,
161
+ atan,
162
+ atan2,
163
+ atanh,
164
+ atleast_1d,
165
+ atleast_2d,
166
+ atleast_3d,
167
+ base_repr,
168
+ binary_repr,
169
+ bitwise_and,
170
+ bitwise_count,
171
+ bitwise_invert,
172
+ bitwise_left_shift,
173
+ bitwise_not,
174
+ bitwise_or,
175
+ bitwise_right_shift,
176
+ bitwise_xor,
177
+ block,
178
+ bool,
179
+ bool_,
180
+ broadcast,
181
+ busday_count,
182
+ busday_offset,
183
+ busdaycalendar,
184
+ byte,
185
+ bytes_,
186
+ can_cast,
187
+ cbrt,
188
+ cdouble,
189
+ ceil,
190
+ character,
191
+ choose,
192
+ clip,
193
+ clongdouble,
194
+ complex64,
195
+ complex128,
196
+ complexfloating,
197
+ compress,
198
+ concat,
199
+ concatenate,
200
+ conj,
201
+ conjugate,
202
+ convolve,
203
+ copysign,
204
+ copyto,
205
+ correlate,
206
+ cos,
207
+ cosh,
208
+ count_nonzero,
209
+ cross,
210
+ csingle,
211
+ cumprod,
212
+ cumsum,
213
+ cumulative_prod,
214
+ cumulative_sum,
215
+ datetime64,
216
+ datetime_as_string,
217
+ datetime_data,
218
+ deg2rad,
219
+ degrees,
220
+ diagonal,
221
+ divide,
222
+ divmod,
223
+ dot,
224
+ double,
225
+ dtype,
226
+ e,
227
+ einsum,
228
+ einsum_path,
229
+ empty,
230
+ empty_like,
231
+ equal,
232
+ errstate,
233
+ euler_gamma,
234
+ exp,
235
+ exp2,
236
+ expm1,
237
+ fabs,
238
+ finfo,
239
+ flatiter,
240
+ flatnonzero,
241
+ flexible,
242
+ float16,
243
+ float32,
244
+ float64,
245
+ float_power,
246
+ floating,
247
+ floor,
248
+ floor_divide,
249
+ fmax,
250
+ fmin,
251
+ fmod,
252
+ format_float_positional,
253
+ format_float_scientific,
254
+ frexp,
255
+ from_dlpack,
256
+ frombuffer,
257
+ fromfile,
258
+ fromfunction,
259
+ fromiter,
260
+ frompyfunc,
261
+ fromstring,
262
+ full,
263
+ full_like,
264
+ gcd,
265
+ generic,
266
+ geomspace,
267
+ get_printoptions,
268
+ getbufsize,
269
+ geterr,
270
+ geterrcall,
271
+ greater,
272
+ greater_equal,
273
+ half,
274
+ heaviside,
275
+ hstack,
276
+ hypot,
277
+ identity,
278
+ iinfo,
279
+ indices,
280
+ inexact,
281
+ inf,
282
+ inner,
283
+ int8,
284
+ int16,
285
+ int32,
286
+ int64,
287
+ int_,
288
+ intc,
289
+ integer,
290
+ intp,
291
+ invert,
292
+ is_busday,
293
+ isclose,
294
+ isdtype,
295
+ isfinite,
296
+ isfortran,
297
+ isinf,
298
+ isnan,
299
+ isnat,
300
+ isscalar,
301
+ issubdtype,
302
+ lcm,
303
+ ldexp,
304
+ left_shift,
305
+ less,
306
+ less_equal,
307
+ lexsort,
308
+ linspace,
309
+ little_endian,
310
+ log,
311
+ log1p,
312
+ log2,
313
+ log10,
314
+ logaddexp,
315
+ logaddexp2,
316
+ logical_and,
317
+ logical_not,
318
+ logical_or,
319
+ logical_xor,
320
+ logspace,
321
+ long,
322
+ longdouble,
323
+ longlong,
324
+ matmul,
325
+ matrix_transpose,
326
+ matvec,
327
+ max,
328
+ maximum,
329
+ may_share_memory,
330
+ mean,
331
+ memmap,
332
+ min,
333
+ min_scalar_type,
334
+ minimum,
335
+ mod,
336
+ modf,
337
+ moveaxis,
338
+ multiply,
339
+ nan,
340
+ ndarray,
341
+ ndim,
342
+ nditer,
343
+ negative,
344
+ nested_iters,
345
+ newaxis,
346
+ nextafter,
347
+ nonzero,
348
+ not_equal,
349
+ number,
350
+ object_,
351
+ ones,
352
+ ones_like,
353
+ outer,
354
+ partition,
355
+ permute_dims,
356
+ pi,
357
+ positive,
358
+ pow,
359
+ power,
360
+ printoptions,
361
+ prod,
362
+ promote_types,
363
+ ptp,
364
+ put,
365
+ putmask,
366
+ rad2deg,
367
+ radians,
368
+ ravel,
369
+ recarray,
370
+ reciprocal,
371
+ record,
372
+ remainder,
373
+ repeat,
374
+ require,
375
+ reshape,
376
+ resize,
377
+ result_type,
378
+ right_shift,
379
+ rint,
380
+ roll,
381
+ rollaxis,
382
+ round,
383
+ sctypeDict,
384
+ searchsorted,
385
+ set_printoptions,
386
+ setbufsize,
387
+ seterr,
388
+ seterrcall,
389
+ shape,
390
+ shares_memory,
391
+ short,
392
+ sign,
393
+ signbit,
394
+ signedinteger,
395
+ sin,
396
+ single,
397
+ sinh,
398
+ size,
399
+ sort,
400
+ spacing,
401
+ sqrt,
402
+ square,
403
+ squeeze,
404
+ stack,
405
+ std,
406
+ str_,
407
+ subtract,
408
+ sum,
409
+ swapaxes,
410
+ take,
411
+ tan,
412
+ tanh,
413
+ tensordot,
414
+ timedelta64,
415
+ trace,
416
+ transpose,
417
+ true_divide,
418
+ trunc,
419
+ typecodes,
420
+ ubyte,
421
+ ufunc,
422
+ uint,
423
+ uint8,
424
+ uint16,
425
+ uint32,
426
+ uint64,
427
+ uintc,
428
+ uintp,
429
+ ulong,
430
+ ulonglong,
431
+ unsignedinteger,
432
+ unstack,
433
+ ushort,
434
+ var,
435
+ vdot,
436
+ vecdot,
437
+ vecmat,
438
+ void,
439
+ vstack,
440
+ where,
441
+ zeros,
442
+ zeros_like,
443
+ )
444
+
445
+ # NOTE: It's still under discussion whether these aliases
446
+ # should be removed.
447
+ for ta in ["float96", "float128", "complex192", "complex256"]:
448
+ try:
449
+ globals()[ta] = getattr(_core, ta)
450
+ except AttributeError:
451
+ pass
452
+ del ta
453
+
454
+ from . import lib, matrixlib as _mat
455
+ from .lib import scimath as emath
456
+ from .lib._arraypad_impl import pad
457
+ from .lib._arraysetops_impl import (
458
+ ediff1d,
459
+ intersect1d,
460
+ isin,
461
+ setdiff1d,
462
+ setxor1d,
463
+ union1d,
464
+ unique,
465
+ unique_all,
466
+ unique_counts,
467
+ unique_inverse,
468
+ unique_values,
469
+ )
470
+ from .lib._function_base_impl import (
471
+ angle,
472
+ append,
473
+ asarray_chkfinite,
474
+ average,
475
+ bartlett,
476
+ bincount,
477
+ blackman,
478
+ copy,
479
+ corrcoef,
480
+ cov,
481
+ delete,
482
+ diff,
483
+ digitize,
484
+ extract,
485
+ flip,
486
+ gradient,
487
+ hamming,
488
+ hanning,
489
+ i0,
490
+ insert,
491
+ interp,
492
+ iterable,
493
+ kaiser,
494
+ median,
495
+ meshgrid,
496
+ percentile,
497
+ piecewise,
498
+ place,
499
+ quantile,
500
+ rot90,
501
+ select,
502
+ sinc,
503
+ sort_complex,
504
+ trapezoid,
505
+ trim_zeros,
506
+ unwrap,
507
+ vectorize,
508
+ )
509
+ from .lib._histograms_impl import histogram, histogram_bin_edges, histogramdd
510
+ from .lib._index_tricks_impl import (
511
+ c_,
512
+ diag_indices,
513
+ diag_indices_from,
514
+ fill_diagonal,
515
+ index_exp,
516
+ ix_,
517
+ mgrid,
518
+ ndenumerate,
519
+ ndindex,
520
+ ogrid,
521
+ r_,
522
+ ravel_multi_index,
523
+ s_,
524
+ unravel_index,
525
+ )
526
+ from .lib._nanfunctions_impl import (
527
+ nanargmax,
528
+ nanargmin,
529
+ nancumprod,
530
+ nancumsum,
531
+ nanmax,
532
+ nanmean,
533
+ nanmedian,
534
+ nanmin,
535
+ nanpercentile,
536
+ nanprod,
537
+ nanquantile,
538
+ nanstd,
539
+ nansum,
540
+ nanvar,
541
+ )
542
+ from .lib._npyio_impl import (
543
+ fromregex,
544
+ genfromtxt,
545
+ load,
546
+ loadtxt,
547
+ packbits,
548
+ save,
549
+ savetxt,
550
+ savez,
551
+ savez_compressed,
552
+ unpackbits,
553
+ )
554
+ from .lib._polynomial_impl import (
555
+ poly,
556
+ poly1d,
557
+ polyadd,
558
+ polyder,
559
+ polydiv,
560
+ polyfit,
561
+ polyint,
562
+ polymul,
563
+ polysub,
564
+ polyval,
565
+ roots,
566
+ )
567
+ from .lib._shape_base_impl import (
568
+ apply_along_axis,
569
+ apply_over_axes,
570
+ array_split,
571
+ column_stack,
572
+ dsplit,
573
+ dstack,
574
+ expand_dims,
575
+ hsplit,
576
+ kron,
577
+ put_along_axis,
578
+ split,
579
+ take_along_axis,
580
+ tile,
581
+ vsplit,
582
+ )
583
+ from .lib._stride_tricks_impl import (
584
+ broadcast_arrays,
585
+ broadcast_shapes,
586
+ broadcast_to,
587
+ )
588
+ from .lib._twodim_base_impl import (
589
+ diag,
590
+ diagflat,
591
+ eye,
592
+ fliplr,
593
+ flipud,
594
+ histogram2d,
595
+ mask_indices,
596
+ tri,
597
+ tril,
598
+ tril_indices,
599
+ tril_indices_from,
600
+ triu,
601
+ triu_indices,
602
+ triu_indices_from,
603
+ vander,
604
+ )
605
+ from .lib._type_check_impl import (
606
+ common_type,
607
+ imag,
608
+ iscomplex,
609
+ iscomplexobj,
610
+ isreal,
611
+ isrealobj,
612
+ mintypecode,
613
+ nan_to_num,
614
+ real,
615
+ real_if_close,
616
+ typename,
617
+ )
618
+ from .lib._ufunclike_impl import fix, isneginf, isposinf
619
+ from .lib._utils_impl import get_include, info, show_runtime
620
+ from .matrixlib import asmatrix, bmat, matrix
621
+
622
+ # public submodules are imported lazily, therefore are accessible from
623
+ # __getattr__. Note that `array_api`
624
+ # (experimental label) is not added here, because `from numpy import *`
625
+ # must not raise any warnings - that's too disruptive.
626
+ __numpy_submodules__ = {
627
+ "linalg", "fft", "dtypes", "random", "polynomial", "ma",
628
+ "exceptions", "lib", "ctypeslib", "testing", "typing",
629
+ "f2py", "test", "rec", "char", "core", "strings",
630
+ }
631
+
632
+ # We build warning messages for former attributes
633
+ _msg = (
634
+ "module 'numpy' has no attribute '{n}'.\n"
635
+ "`np.{n}` was a deprecated alias for the builtin `{n}`. "
636
+ "To avoid this error in existing code, use `{n}` by itself. "
637
+ "Doing this will not modify any behavior and is safe. {extended_msg}\n"
638
+ "The aliases was originally deprecated in NumPy 1.20; for more "
639
+ "details and guidance see the original release note at:\n"
640
+ " https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")
641
+
642
+ _specific_msg = (
643
+ "If you specifically wanted the numpy scalar type, use `np.{}` here.")
644
+
645
+ _int_extended_msg = (
646
+ "When replacing `np.{}`, you may wish to use e.g. `np.int64` "
647
+ "or `np.int32` to specify the precision. If you wish to review "
648
+ "your current use, check the release note link for "
649
+ "additional information.")
650
+
651
+ _type_info = [
652
+ ("object", ""), # The NumPy scalar only exists by name.
653
+ ("float", _specific_msg.format("float64")),
654
+ ("complex", _specific_msg.format("complex128")),
655
+ ("str", _specific_msg.format("str_")),
656
+ ("int", _int_extended_msg.format("int"))]
657
+
658
+ __former_attrs__ = {
659
+ n: _msg.format(n=n, extended_msg=extended_msg)
660
+ for n, extended_msg in _type_info
661
+ }
662
+
663
+ # Some of these could be defined right away, but most were aliases to
664
+ # the Python objects and only removed in NumPy 1.24. Defining them should
665
+ # probably wait for NumPy 1.26 or 2.0.
666
+ # When defined, these should possibly not be added to `__all__` to avoid
667
+ # import with `from numpy import *`.
668
+ __future_scalars__ = {"str", "bytes", "object"}
669
+
670
+ __array_api_version__ = "2025.12"
671
+
672
+ from ._array_api_info import __array_namespace_info__
673
+
674
+ __all__ = list(
675
+ __numpy_submodules__ |
676
+ set(_core.__all__) |
677
+ set(_mat.__all__) |
678
+ set(lib._histograms_impl.__all__) |
679
+ set(lib._nanfunctions_impl.__all__) |
680
+ set(lib._function_base_impl.__all__) |
681
+ set(lib._twodim_base_impl.__all__) |
682
+ set(lib._shape_base_impl.__all__) |
683
+ set(lib._type_check_impl.__all__) |
684
+ set(lib._arraysetops_impl.__all__) |
685
+ set(lib._ufunclike_impl.__all__) |
686
+ set(lib._arraypad_impl.__all__) |
687
+ set(lib._utils_impl.__all__) |
688
+ set(lib._stride_tricks_impl.__all__) |
689
+ set(lib._polynomial_impl.__all__) |
690
+ set(lib._npyio_impl.__all__) |
691
+ set(lib._index_tricks_impl.__all__) |
692
+ {"emath", "show_config", "__version__", "__array_namespace_info__"}
693
+ )
694
+
695
+ # Filter out Cython harmless warnings
696
+ warnings.filterwarnings("ignore", message="numpy.dtype size changed")
697
+ warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
698
+ warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
699
+
700
+ def __getattr__(attr):
701
+ # Warn for expired attributes
702
+ import warnings
703
+
704
+ if attr == "linalg":
705
+ import numpy.linalg as linalg
706
+ return linalg
707
+ elif attr == "fft":
708
+ import numpy.fft as fft
709
+ return fft
710
+ elif attr == "dtypes":
711
+ import numpy.dtypes as dtypes
712
+ return dtypes
713
+ elif attr == "random":
714
+ import numpy.random as random
715
+ return random
716
+ elif attr == "polynomial":
717
+ import numpy.polynomial as polynomial
718
+ return polynomial
719
+ elif attr == "ma":
720
+ import numpy.ma as ma
721
+ return ma
722
+ elif attr == "ctypeslib":
723
+ import numpy.ctypeslib as ctypeslib
724
+ return ctypeslib
725
+ elif attr == "exceptions":
726
+ import numpy.exceptions as exceptions
727
+ return exceptions
728
+ elif attr == "testing":
729
+ import numpy.testing as testing
730
+ return testing
731
+ elif attr == "matlib":
732
+ import numpy.matlib as matlib
733
+ return matlib
734
+ elif attr == "f2py":
735
+ import numpy.f2py as f2py
736
+ return f2py
737
+ elif attr == "typing":
738
+ import numpy.typing as typing
739
+ return typing
740
+ elif attr == "rec":
741
+ import numpy.rec as rec
742
+ return rec
743
+ elif attr == "char":
744
+ import numpy.char as char
745
+ return char
746
+ elif attr == "core":
747
+ import numpy.core as core
748
+ return core
749
+ elif attr == "strings":
750
+ import numpy.strings as strings
751
+ return strings
752
+ if attr in __future_scalars__:
753
+ # And future warnings for those that will change, but also give
754
+ # the AttributeError
755
+ warnings.warn(
756
+ f"In the future `np.{attr}` will be defined as the "
757
+ "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
758
+
759
+ if attr in __former_attrs__:
760
+ raise AttributeError(__former_attrs__[attr], name=None)
761
+
762
+ if attr in __expired_attributes__:
763
+ raise AttributeError(
764
+ f"`np.{attr}` was removed in the NumPy 2.0 release. "
765
+ f"{__expired_attributes__[attr]}",
766
+ name=None
767
+ )
768
+
769
+ raise AttributeError(f"module {__name__!r} has no attribute {attr!r}")
770
+
771
+ def __dir__():
772
+ public_symbols = (
773
+ globals().keys() | __numpy_submodules__
774
+ )
775
+ public_symbols -= {
776
+ "matrixlib", "matlib", "tests", "conftest", "version",
777
+ "array_api"
778
+ }
779
+ return list(public_symbols)
780
+
781
+ # Pytest testing
782
+ from numpy._pytesttester import PytestTester
783
+ test = PytestTester(__name__)
784
+ del PytestTester
785
+
786
+ def _sanity_check():
787
+ """
788
+ Quick sanity checks for common bugs caused by environment.
789
+ There are some cases e.g. with wrong BLAS ABI that cause wrong
790
+ results under specific runtime conditions that are not necessarily
791
+ achieved during test suite runs, and it is useful to catch those early.
792
+
793
+ See https://github.com/numpy/numpy/issues/8577 and other
794
+ similar bug reports.
795
+
796
+ """
797
+ try:
798
+ x = ones(2, dtype=float32)
799
+ if not abs(x.dot(x) - float32(2.0)) < 1e-5:
800
+ raise AssertionError
801
+ except AssertionError:
802
+ msg = ("The current Numpy installation ({!r}) fails to "
803
+ "pass simple sanity checks. This can be caused for example "
804
+ "by incorrect BLAS library being linked in, or by mixing "
805
+ "package managers (pip, conda, apt, ...). Search closed "
806
+ "numpy issues for similar problems.")
807
+ raise RuntimeError(msg.format(__file__)) from None
808
+
809
+ _sanity_check()
810
+ del _sanity_check
811
+
812
+ def _mac_os_check():
813
+ """
814
+ Quick Sanity check for Mac OS look for accelerate build bugs.
815
+ Testing numpy polyfit calls init_dgelsd(LAPACK)
816
+ """
817
+ try:
818
+ c = array([3., 2., 1.])
819
+ x = linspace(0, 2, 5)
820
+ y = polyval(c, x)
821
+ _ = polyfit(x, y, 2, cov=True)
822
+ except ValueError:
823
+ pass
824
+
825
+ if sys.platform == "darwin":
826
+ from . import exceptions
827
+ with warnings.catch_warnings(record=True) as w:
828
+ _mac_os_check()
829
+ # Throw runtime error, if the test failed
830
+ # Check for warning and report the error_message
831
+ if len(w) > 0:
832
+ for _wn in w:
833
+ if _wn.category is exceptions.RankWarning:
834
+ # Ignore other warnings, they may not be relevant (see gh-25433)
835
+ error_message = (
836
+ f"{_wn.category.__name__}: {_wn.message}"
837
+ )
838
+ msg = (
839
+ "Polyfit sanity test emitted a warning, most likely due "
840
+ "to using a buggy Accelerate backend."
841
+ "\nIf you compiled yourself, more information is available at:" # noqa: E501
842
+ "\nhttps://numpy.org/devdocs/building/index.html"
843
+ "\nOtherwise report this to the vendor "
844
+ f"that provided NumPy.\n\n{error_message}\n")
845
+ raise RuntimeError(msg)
846
+ del _wn
847
+ del w
848
+ del _mac_os_check
849
+
850
+ def blas_fpe_check():
851
+ if sys.platform != "darwin":
852
+ # We currently assume this is limited to MacOS as downstream NumPy
853
+ # import during dlopen caused a deadlock regression: gh-31284
854
+ return
855
+
856
+ # Check if BLAS adds spurious FPEs, seen on M4 arms with Accelerate.
857
+ # In this case we disable FPE reporting since the use of SME poisons
858
+ # it and Accelerate doesn't sanitize them.
859
+ with errstate(all='raise'):
860
+ x = ones((20, 20))
861
+ try:
862
+ x @ x
863
+ except FloatingPointError:
864
+ res = _core._multiarray_umath._blas_supports_fpe(False)
865
+ if res: # res was not modified (hardcoded to True for now)
866
+ warnings.warn(
867
+ "Spurious warnings given by blas but suppression not "
868
+ "set up on this platform. Please open a NumPy issue.",
869
+ UserWarning, stacklevel=2)
870
+
871
+ blas_fpe_check()
872
+ del blas_fpe_check
873
+
874
+ def hugepage_setup():
875
+ """
876
+ We usually use madvise hugepages support, but on some old kernels it
877
+ is slow and thus better avoided. Specifically kernel version 4.6
878
+ had a bug fix which probably fixed this:
879
+ https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff
880
+ """
881
+ use_hugepage = os.environ.get("NUMPY_MADVISE_HUGEPAGE", None)
882
+ if sys.platform == "linux" and use_hugepage is None:
883
+ # If there is an issue with parsing the kernel version,
884
+ # set use_hugepage to 0. Usage of LooseVersion will handle
885
+ # the kernel version parsing better, but avoided since it
886
+ # will increase the import time.
887
+ # See: #16679 for related discussion.
888
+ try:
889
+ use_hugepage = 1
890
+ kernel_version = os.uname().release.split(".")[:2]
891
+ kernel_version = tuple(int(v) for v in kernel_version)
892
+ if kernel_version < (4, 6):
893
+ use_hugepage = 0
894
+ except ValueError:
895
+ use_hugepage = 0
896
+ elif use_hugepage is None:
897
+ # This is not Linux, so it should not matter, just enable anyway
898
+ use_hugepage = 1
899
+ else:
900
+ use_hugepage = int(use_hugepage)
901
+ return use_hugepage
902
+
903
+ # Note that this will currently only make a difference on Linux
904
+ _core.multiarray._set_madvise_hugepage(hugepage_setup())
905
+ del hugepage_setup
906
+
907
+ # Give a warning if NumPy is reloaded or imported on a sub-interpreter
908
+ # We do this from python, since the C-module may not be reloaded and
909
+ # it is tidier organized.
910
+ _core.multiarray._multiarray_umath._reload_guard()
911
+
912
+ # TODO: Remove the environment variable entirely now that it is "weak"
913
+ if (os.environ.get("NPY_PROMOTION_STATE", "weak") != "weak"):
914
+ warnings.warn(
915
+ "NPY_PROMOTION_STATE was a temporary feature for NumPy 2.0 "
916
+ "transition and is ignored after NumPy 2.2.",
917
+ UserWarning, stacklevel=2)
918
+
919
+ # Tell PyInstaller where to find hook-numpy.py
920
+ def _pyinstaller_hooks_dir():
921
+ from pathlib import Path
922
+ return [str(Path(__file__).with_name("_pyinstaller").resolve())]
923
+
924
+
925
+ # Remove symbols imported for internal use
926
+ del os, sys, warnings
hug/lib/python3.12/site-packages/numpy/__init__.pyi ADDED
The diff for this file is too large to render. See raw diff
 
hug/lib/python3.12/site-packages/numpy/__pycache__/__config__.cpython-312.pyc ADDED
Binary file (4.78 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (27.6 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_array_api_info.cpython-312.pyc ADDED
Binary file (11.3 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_configtool.cpython-312.pyc ADDED
Binary file (1.66 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_distributor_init.cpython-312.pyc ADDED
Binary file (650 Bytes). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_expired_attrs_2_0.cpython-312.pyc ADDED
Binary file (4.24 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_globals.cpython-312.pyc ADDED
Binary file (4.55 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/_pytesttester.cpython-312.pyc ADDED
Binary file (6.23 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/conftest.cpython-312.pyc ADDED
Binary file (9.79 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/dtypes.cpython-312.pyc ADDED
Binary file (3.14 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/exceptions.cpython-312.pyc ADDED
Binary file (8.63 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/matlib.cpython-312.pyc ADDED
Binary file (12 kB). View file
 
hug/lib/python3.12/site-packages/numpy/__pycache__/version.cpython-312.pyc ADDED
Binary file (539 Bytes). View file
 
hug/lib/python3.12/site-packages/numpy/_array_api_info.py ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Array API Inspection namespace
3
+
4
+ This is the namespace for inspection functions as defined by the array API
5
+ standard. See
6
+ https://data-apis.org/array-api/latest/API_specification/inspection.html for
7
+ more details.
8
+
9
+ """
10
+ from numpy._core import (
11
+ bool,
12
+ complex64,
13
+ complex128,
14
+ dtype,
15
+ float32,
16
+ float64,
17
+ int8,
18
+ int16,
19
+ int32,
20
+ int64,
21
+ intp,
22
+ uint8,
23
+ uint16,
24
+ uint32,
25
+ uint64,
26
+ )
27
+ from numpy._utils import set_module
28
+
29
+
30
+ @set_module('numpy')
31
+ class __array_namespace_info__:
32
+ """
33
+ Get the array API inspection namespace for NumPy.
34
+
35
+ The array API inspection namespace defines the following functions:
36
+
37
+ - capabilities()
38
+ - default_device()
39
+ - default_dtypes()
40
+ - dtypes()
41
+ - devices()
42
+
43
+ See
44
+ https://data-apis.org/array-api/latest/API_specification/inspection.html
45
+ for more details.
46
+
47
+ Returns
48
+ -------
49
+ info : ModuleType
50
+ The array API inspection namespace for NumPy.
51
+
52
+ Examples
53
+ --------
54
+ >>> info = np.__array_namespace_info__()
55
+ >>> info.default_dtypes()
56
+ {'real floating': numpy.float64,
57
+ 'complex floating': numpy.complex128,
58
+ 'integral': numpy.int64,
59
+ 'indexing': numpy.int64}
60
+
61
+ """
62
+
63
+ def capabilities(self):
64
+ """
65
+ Return a dictionary of array API library capabilities.
66
+
67
+ The resulting dictionary has the following keys:
68
+
69
+ - **"boolean indexing"**: boolean indicating whether an array library
70
+ supports boolean indexing. Always ``True`` for NumPy.
71
+
72
+ - **"data-dependent shapes"**: boolean indicating whether an array
73
+ library supports data-dependent output shapes. Always ``True`` for
74
+ NumPy.
75
+
76
+ - **"max dimensions"**: integer indicating maximum number of supported
77
+ dimensions. Always ``64`` for NumPy.
78
+
79
+ See
80
+ https://data-apis.org/array-api/latest/API_specification/generated/array_api.info.capabilities.html
81
+ for more details.
82
+
83
+ See Also
84
+ --------
85
+ __array_namespace_info__.default_device,
86
+ __array_namespace_info__.default_dtypes,
87
+ __array_namespace_info__.dtypes,
88
+ __array_namespace_info__.devices
89
+
90
+ Returns
91
+ -------
92
+ capabilities : dict
93
+ A dictionary of array API library capabilities.
94
+
95
+ Examples
96
+ --------
97
+ >>> info = np.__array_namespace_info__()
98
+ >>> info.capabilities()
99
+ {'boolean indexing': True,
100
+ 'data-dependent shapes': True,
101
+ 'max dimensions': 64}
102
+
103
+ """
104
+ return {
105
+ "boolean indexing": True,
106
+ "data-dependent shapes": True,
107
+ "max dimensions": 64,
108
+ }
109
+
110
+ def default_device(self):
111
+ """
112
+ The default device used for new NumPy arrays.
113
+
114
+ For NumPy, this always returns ``'cpu'``.
115
+
116
+ See Also
117
+ --------
118
+ __array_namespace_info__.capabilities,
119
+ __array_namespace_info__.default_dtypes,
120
+ __array_namespace_info__.dtypes,
121
+ __array_namespace_info__.devices
122
+
123
+ Returns
124
+ -------
125
+ device : str
126
+ The default device used for new NumPy arrays.
127
+
128
+ Examples
129
+ --------
130
+ >>> info = np.__array_namespace_info__()
131
+ >>> info.default_device()
132
+ 'cpu'
133
+
134
+ """
135
+ return "cpu"
136
+
137
+ def default_dtypes(self, *, device=None):
138
+ """
139
+ The default data types used for new NumPy arrays.
140
+
141
+ For NumPy, this always returns the following dictionary:
142
+
143
+ - **"real floating"**: ``numpy.float64``
144
+ - **"complex floating"**: ``numpy.complex128``
145
+ - **"integral"**: ``numpy.intp``
146
+ - **"indexing"**: ``numpy.intp``
147
+
148
+ Parameters
149
+ ----------
150
+ device : str, optional
151
+ The device to get the default data types for. For NumPy, only
152
+ ``'cpu'`` is allowed.
153
+
154
+ Returns
155
+ -------
156
+ dtypes : dict
157
+ A dictionary describing the default data types used for new NumPy
158
+ arrays.
159
+
160
+ See Also
161
+ --------
162
+ __array_namespace_info__.capabilities,
163
+ __array_namespace_info__.default_device,
164
+ __array_namespace_info__.dtypes,
165
+ __array_namespace_info__.devices
166
+
167
+ Examples
168
+ --------
169
+ >>> info = np.__array_namespace_info__()
170
+ >>> info.default_dtypes()
171
+ {'real floating': numpy.float64,
172
+ 'complex floating': numpy.complex128,
173
+ 'integral': numpy.int64,
174
+ 'indexing': numpy.int64}
175
+
176
+ """
177
+ if device not in ["cpu", None]:
178
+ raise ValueError(
179
+ 'Device not understood. Only "cpu" is allowed, but received:'
180
+ f' {device}'
181
+ )
182
+ return {
183
+ "real floating": dtype(float64),
184
+ "complex floating": dtype(complex128),
185
+ "integral": dtype(intp),
186
+ "indexing": dtype(intp),
187
+ }
188
+
189
+ def dtypes(self, *, device=None, kind=None):
190
+ """
191
+ The array API data types supported by NumPy.
192
+
193
+ Note that this function only returns data types that are defined by
194
+ the array API.
195
+
196
+ Parameters
197
+ ----------
198
+ device : str, optional
199
+ The device to get the data types for. For NumPy, only ``'cpu'`` is
200
+ allowed.
201
+ kind : str or tuple of str, optional
202
+ The kind of data types to return. If ``None``, all data types are
203
+ returned. If a string, only data types of that kind are returned.
204
+ If a tuple, a dictionary containing the union of the given kinds
205
+ is returned. The following kinds are supported:
206
+
207
+ - ``'bool'``: boolean data types (i.e., ``bool``).
208
+ - ``'signed integer'``: signed integer data types (i.e., ``int8``,
209
+ ``int16``, ``int32``, ``int64``).
210
+ - ``'unsigned integer'``: unsigned integer data types (i.e.,
211
+ ``uint8``, ``uint16``, ``uint32``, ``uint64``).
212
+ - ``'integral'``: integer data types. Shorthand for ``('signed
213
+ integer', 'unsigned integer')``.
214
+ - ``'real floating'``: real-valued floating-point data types
215
+ (i.e., ``float32``, ``float64``).
216
+ - ``'complex floating'``: complex floating-point data types (i.e.,
217
+ ``complex64``, ``complex128``).
218
+ - ``'numeric'``: numeric data types. Shorthand for ``('integral',
219
+ 'real floating', 'complex floating')``.
220
+
221
+ Returns
222
+ -------
223
+ dtypes : dict
224
+ A dictionary mapping the names of data types to the corresponding
225
+ NumPy data types.
226
+
227
+ See Also
228
+ --------
229
+ __array_namespace_info__.capabilities,
230
+ __array_namespace_info__.default_device,
231
+ __array_namespace_info__.default_dtypes,
232
+ __array_namespace_info__.devices
233
+
234
+ Examples
235
+ --------
236
+ >>> info = np.__array_namespace_info__()
237
+ >>> info.dtypes(kind='signed integer')
238
+ {'int8': numpy.int8,
239
+ 'int16': numpy.int16,
240
+ 'int32': numpy.int32,
241
+ 'int64': numpy.int64}
242
+
243
+ """
244
+ if device not in ["cpu", None]:
245
+ raise ValueError(
246
+ 'Device not understood. Only "cpu" is allowed, but received:'
247
+ f' {device}'
248
+ )
249
+ if kind is None:
250
+ return {
251
+ "bool": dtype(bool),
252
+ "int8": dtype(int8),
253
+ "int16": dtype(int16),
254
+ "int32": dtype(int32),
255
+ "int64": dtype(int64),
256
+ "uint8": dtype(uint8),
257
+ "uint16": dtype(uint16),
258
+ "uint32": dtype(uint32),
259
+ "uint64": dtype(uint64),
260
+ "float32": dtype(float32),
261
+ "float64": dtype(float64),
262
+ "complex64": dtype(complex64),
263
+ "complex128": dtype(complex128),
264
+ }
265
+ if kind == "bool":
266
+ return {"bool": bool}
267
+ if kind == "signed integer":
268
+ return {
269
+ "int8": dtype(int8),
270
+ "int16": dtype(int16),
271
+ "int32": dtype(int32),
272
+ "int64": dtype(int64),
273
+ }
274
+ if kind == "unsigned integer":
275
+ return {
276
+ "uint8": dtype(uint8),
277
+ "uint16": dtype(uint16),
278
+ "uint32": dtype(uint32),
279
+ "uint64": dtype(uint64),
280
+ }
281
+ if kind == "integral":
282
+ return {
283
+ "int8": dtype(int8),
284
+ "int16": dtype(int16),
285
+ "int32": dtype(int32),
286
+ "int64": dtype(int64),
287
+ "uint8": dtype(uint8),
288
+ "uint16": dtype(uint16),
289
+ "uint32": dtype(uint32),
290
+ "uint64": dtype(uint64),
291
+ }
292
+ if kind == "real floating":
293
+ return {
294
+ "float32": dtype(float32),
295
+ "float64": dtype(float64),
296
+ }
297
+ if kind == "complex floating":
298
+ return {
299
+ "complex64": dtype(complex64),
300
+ "complex128": dtype(complex128),
301
+ }
302
+ if kind == "numeric":
303
+ return {
304
+ "int8": dtype(int8),
305
+ "int16": dtype(int16),
306
+ "int32": dtype(int32),
307
+ "int64": dtype(int64),
308
+ "uint8": dtype(uint8),
309
+ "uint16": dtype(uint16),
310
+ "uint32": dtype(uint32),
311
+ "uint64": dtype(uint64),
312
+ "float32": dtype(float32),
313
+ "float64": dtype(float64),
314
+ "complex64": dtype(complex64),
315
+ "complex128": dtype(complex128),
316
+ }
317
+ if isinstance(kind, tuple):
318
+ res = {}
319
+ for k in kind:
320
+ res.update(self.dtypes(kind=k))
321
+ return res
322
+ raise ValueError(f"unsupported kind: {kind!r}")
323
+
324
+ def devices(self):
325
+ """
326
+ The devices supported by NumPy.
327
+
328
+ For NumPy, this always returns ``('cpu',)``.
329
+
330
+ Returns
331
+ -------
332
+ devices : list of str
333
+ The devices supported by NumPy.
334
+
335
+ See Also
336
+ --------
337
+ __array_namespace_info__.capabilities,
338
+ __array_namespace_info__.default_device,
339
+ __array_namespace_info__.default_dtypes,
340
+ __array_namespace_info__.dtypes
341
+
342
+ Examples
343
+ --------
344
+ >>> info = np.__array_namespace_info__()
345
+ >>> info.devices()
346
+ ('cpu',)
347
+
348
+ """
349
+ return ("cpu",)
hug/lib/python3.12/site-packages/numpy/_array_api_info.pyi ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal, Never, TypedDict, final, overload, type_check_only
2
+
3
+ import numpy as np
4
+
5
+ type _Device = Literal["cpu"]
6
+ type _DeviceLike = _Device | None
7
+
8
+ _Capabilities = TypedDict(
9
+ "_Capabilities",
10
+ {
11
+ "boolean indexing": Literal[True],
12
+ "data-dependent shapes": Literal[True],
13
+ "max dimensions": Literal[64],
14
+ },
15
+ )
16
+
17
+ _DefaultDTypes = TypedDict(
18
+ "_DefaultDTypes",
19
+ {
20
+ "real floating": np.dtype[np.float64],
21
+ "complex floating": np.dtype[np.complex128],
22
+ "integral": np.dtype[np.intp],
23
+ "indexing": np.dtype[np.intp],
24
+ },
25
+ )
26
+
27
+ type _KindBool = Literal["bool"]
28
+ type _KindInt = Literal["signed integer"]
29
+ type _KindUInt = Literal["unsigned integer"]
30
+ type _KindInteger = Literal["integral"]
31
+ type _KindFloat = Literal["real floating"]
32
+ type _KindComplex = Literal["complex floating"]
33
+ type _KindNumber = Literal["numeric"]
34
+ type _Kind = _KindBool | _KindInt | _KindUInt | _KindInteger | _KindFloat | _KindComplex | _KindNumber
35
+
36
+ type _Permute1[T1] = T1 | tuple[T1]
37
+ type _Permute2[T1, T2] = tuple[T1, T2] | tuple[T2, T1]
38
+ type _Permute3[T1, T2, T3] = (
39
+ tuple[T1, T2, T3] | tuple[T1, T3, T2]
40
+ | tuple[T2, T1, T3] | tuple[T2, T3, T1]
41
+ | tuple[T3, T1, T2] | tuple[T3, T2, T1]
42
+ ) # fmt: skip
43
+
44
+ @type_check_only
45
+ class _DTypesBool(TypedDict):
46
+ bool: np.dtype[np.bool]
47
+
48
+ @type_check_only
49
+ class _DTypesInt(TypedDict):
50
+ int8: np.dtype[np.int8]
51
+ int16: np.dtype[np.int16]
52
+ int32: np.dtype[np.int32]
53
+ int64: np.dtype[np.int64]
54
+
55
+ @type_check_only
56
+ class _DTypesUInt(TypedDict):
57
+ uint8: np.dtype[np.uint8]
58
+ uint16: np.dtype[np.uint16]
59
+ uint32: np.dtype[np.uint32]
60
+ uint64: np.dtype[np.uint64]
61
+
62
+ @type_check_only
63
+ class _DTypesInteger(_DTypesInt, _DTypesUInt): ...
64
+
65
+ @type_check_only
66
+ class _DTypesFloat(TypedDict):
67
+ float32: np.dtype[np.float32]
68
+ float64: np.dtype[np.float64]
69
+
70
+ @type_check_only
71
+ class _DTypesComplex(TypedDict):
72
+ complex64: np.dtype[np.complex64]
73
+ complex128: np.dtype[np.complex128]
74
+
75
+ @type_check_only
76
+ class _DTypesNumber(_DTypesInteger, _DTypesFloat, _DTypesComplex): ...
77
+
78
+ @type_check_only
79
+ class _DTypes(_DTypesBool, _DTypesNumber): ...
80
+
81
+ @type_check_only
82
+ class _DTypesUnion(TypedDict, total=False):
83
+ bool: np.dtype[np.bool]
84
+ int8: np.dtype[np.int8]
85
+ int16: np.dtype[np.int16]
86
+ int32: np.dtype[np.int32]
87
+ int64: np.dtype[np.int64]
88
+ uint8: np.dtype[np.uint8]
89
+ uint16: np.dtype[np.uint16]
90
+ uint32: np.dtype[np.uint32]
91
+ uint64: np.dtype[np.uint64]
92
+ float32: np.dtype[np.float32]
93
+ float64: np.dtype[np.float64]
94
+ complex64: np.dtype[np.complex64]
95
+ complex128: np.dtype[np.complex128]
96
+
97
+ type _EmptyDict = dict[Never, Never]
98
+
99
+ @final
100
+ class __array_namespace_info__:
101
+ __module__: Literal["numpy"] = "numpy" # pyrefly: ignore[bad-override]
102
+
103
+ def capabilities(self) -> _Capabilities: ...
104
+ def default_device(self) -> _Device: ...
105
+ def default_dtypes(self, *, device: _DeviceLike = None) -> _DefaultDTypes: ...
106
+ def devices(self) -> list[_Device]: ...
107
+
108
+ @overload
109
+ def dtypes(
110
+ self,
111
+ *,
112
+ device: _DeviceLike = None,
113
+ kind: None = None,
114
+ ) -> _DTypes: ...
115
+ @overload
116
+ def dtypes(
117
+ self,
118
+ *,
119
+ device: _DeviceLike = None,
120
+ kind: _Permute1[_KindBool],
121
+ ) -> _DTypesBool: ...
122
+ @overload
123
+ def dtypes(
124
+ self,
125
+ *,
126
+ device: _DeviceLike = None,
127
+ kind: _Permute1[_KindInt],
128
+ ) -> _DTypesInt: ...
129
+ @overload
130
+ def dtypes(
131
+ self,
132
+ *,
133
+ device: _DeviceLike = None,
134
+ kind: _Permute1[_KindUInt],
135
+ ) -> _DTypesUInt: ...
136
+ @overload
137
+ def dtypes(
138
+ self,
139
+ *,
140
+ device: _DeviceLike = None,
141
+ kind: _Permute1[_KindFloat],
142
+ ) -> _DTypesFloat: ...
143
+ @overload
144
+ def dtypes(
145
+ self,
146
+ *,
147
+ device: _DeviceLike = None,
148
+ kind: _Permute1[_KindComplex],
149
+ ) -> _DTypesComplex: ...
150
+ @overload
151
+ def dtypes(
152
+ self,
153
+ *,
154
+ device: _DeviceLike = None,
155
+ kind: _Permute1[_KindInteger] | _Permute2[_KindInt, _KindUInt],
156
+ ) -> _DTypesInteger: ...
157
+ @overload
158
+ def dtypes(
159
+ self,
160
+ *,
161
+ device: _DeviceLike = None,
162
+ kind: _Permute1[_KindNumber] | _Permute3[_KindInteger, _KindFloat, _KindComplex],
163
+ ) -> _DTypesNumber: ...
164
+ @overload
165
+ def dtypes(
166
+ self,
167
+ *,
168
+ device: _DeviceLike = None,
169
+ kind: tuple[()],
170
+ ) -> _EmptyDict: ...
171
+ @overload
172
+ def dtypes(
173
+ self,
174
+ *,
175
+ device: _DeviceLike = None,
176
+ kind: tuple[_Kind, ...],
177
+ ) -> _DTypesUnion: ...
hug/lib/python3.12/site-packages/numpy/_configtool.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import argparse
2
+ import sys
3
+ from pathlib import Path
4
+
5
+ from .lib._utils_impl import get_include
6
+ from .version import __version__
7
+
8
+
9
+ def main() -> None:
10
+ parser = argparse.ArgumentParser()
11
+ parser.add_argument(
12
+ "--version",
13
+ action="version",
14
+ version=__version__,
15
+ help="Print the version and exit.",
16
+ )
17
+ parser.add_argument(
18
+ "--cflags",
19
+ action="store_true",
20
+ help="Compile flag needed when using the NumPy headers.",
21
+ )
22
+ parser.add_argument(
23
+ "--pkgconfigdir",
24
+ action="store_true",
25
+ help=("Print the pkgconfig directory in which `numpy.pc` is stored "
26
+ "(useful for setting $PKG_CONFIG_PATH)."),
27
+ )
28
+ args = parser.parse_args()
29
+ if not sys.argv[1:]:
30
+ parser.print_help()
31
+ if args.cflags:
32
+ print("-I" + get_include())
33
+ if args.pkgconfigdir:
34
+ _path = Path(get_include()) / '..' / 'lib' / 'pkgconfig'
35
+ print(_path.resolve())
36
+
37
+
38
+ if __name__ == "__main__":
39
+ main()
hug/lib/python3.12/site-packages/numpy/_configtool.pyi ADDED
@@ -0,0 +1 @@
 
 
1
+ def main() -> None: ...
hug/lib/python3.12/site-packages/numpy/_core/__init__.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Contains the core of NumPy: ndarray, ufuncs, dtypes, etc.
3
+
4
+ Please note that this module is private. All functions and objects
5
+ are available in the main ``numpy`` namespace - use that instead.
6
+
7
+ """
8
+
9
+ import os
10
+
11
+ from numpy.version import version as __version__
12
+
13
+ # disables OpenBLAS affinity setting of the main thread that limits
14
+ # python threads or processes to one core
15
+ env_added = []
16
+ for envkey in ['OPENBLAS_MAIN_FREE']:
17
+ if envkey not in os.environ:
18
+ # Note: using `putenv` (and `unsetenv` further down) instead of updating
19
+ # `os.environ` on purpose to avoid a race condition, see gh-30627.
20
+ os.putenv(envkey, '1')
21
+ env_added.append(envkey)
22
+
23
+ try:
24
+ from . import multiarray
25
+ except ImportError as exc:
26
+ import sys
27
+
28
+ # Bypass for the module re-initialization opt-out
29
+ if exc.msg == "cannot load module more than once per process":
30
+ raise
31
+
32
+ # Basically always, the problem should be that the C module is wrong/missing...
33
+ if (
34
+ isinstance(exc, ModuleNotFoundError)
35
+ and exc.name == "numpy._core._multiarray_umath"
36
+ ):
37
+ import sys
38
+ candidates = []
39
+ for path in __path__:
40
+ candidates.extend(
41
+ f for f in os.listdir(path) if f.startswith("_multiarray_umath"))
42
+ if len(candidates) == 0:
43
+ bad_c_module_info = (
44
+ "We found no compiled module, did NumPy build successfully?\n")
45
+ else:
46
+ candidate_str = '\n * '.join(candidates)
47
+ # cache_tag is documented to be possibly None, so just use name if it is
48
+ # this guesses at cache_tag being the same as the extension module scheme
49
+ tag = sys.implementation.cache_tag or sys.implementation.name
50
+ bad_c_module_info = (
51
+ f"The following compiled module files exist, but seem incompatible\n"
52
+ f"with with either python '{tag}' or the "
53
+ f"platform '{sys.platform}':\n\n * {candidate_str}\n"
54
+ )
55
+ else:
56
+ bad_c_module_info = ""
57
+
58
+ major, minor, *_ = sys.version_info
59
+ msg = f"""
60
+
61
+ IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
62
+
63
+ Importing the numpy C-extensions failed. This error can happen for
64
+ many reasons, often due to issues with your setup or how NumPy was
65
+ installed.
66
+ {bad_c_module_info}
67
+ We have compiled some common reasons and troubleshooting tips at:
68
+
69
+ https://numpy.org/devdocs/user/troubleshooting-importerror.html
70
+
71
+ Please note and check the following:
72
+
73
+ * The Python version is: Python {major}.{minor} from "{sys.executable}"
74
+ * The NumPy version is: "{__version__}"
75
+
76
+ and make sure that they are the versions you expect.
77
+
78
+ Please carefully study the information and documentation linked above.
79
+ This is unlikely to be a NumPy issue but will be caused by a bad install
80
+ or environment on your machine.
81
+
82
+ Original error was: {exc}
83
+ """
84
+
85
+ raise ImportError(msg) from exc
86
+ finally:
87
+ for envkey in env_added:
88
+ os.unsetenv(envkey)
89
+ del envkey
90
+ del env_added
91
+ del os
92
+
93
+ from . import umath
94
+
95
+ # Check that multiarray,umath are pure python modules wrapping
96
+ # _multiarray_umath and not either of the old c-extension modules
97
+ if not (hasattr(multiarray, '_multiarray_umath') and
98
+ hasattr(umath, '_multiarray_umath')):
99
+ import sys
100
+ path = sys.modules['numpy'].__path__
101
+ msg = ("Something is wrong with the numpy installation. "
102
+ "While importing we detected an older version of "
103
+ "numpy in {}. One method of fixing this is to repeatedly uninstall "
104
+ "numpy until none is found, then reinstall this version.")
105
+ raise ImportError(msg.format(path))
106
+
107
+ from . import numerictypes as nt
108
+ from .numerictypes import sctypeDict, sctypes
109
+
110
+ multiarray.set_typeDict(nt.sctypeDict)
111
+ from . import einsumfunc, fromnumeric, function_base, getlimits, numeric, shape_base
112
+ from .einsumfunc import *
113
+ from .fromnumeric import *
114
+ from .function_base import *
115
+ from .getlimits import *
116
+
117
+ # Note: module name memmap is overwritten by a class with same name
118
+ from .memmap import *
119
+ from .numeric import *
120
+ from .records import recarray, record
121
+ from .shape_base import *
122
+
123
+ del nt
124
+
125
+ # do this after everything else, to minimize the chance of this misleadingly
126
+ # appearing in an import-time traceback
127
+ # add these for module-freeze analysis (like PyInstaller)
128
+ from . import (
129
+ _add_newdocs,
130
+ _add_newdocs_scalars,
131
+ _dtype,
132
+ _dtype_ctypes,
133
+ _internal,
134
+ _methods,
135
+ )
136
+ from .numeric import absolute as abs
137
+
138
+ acos = numeric.arccos
139
+ acosh = numeric.arccosh
140
+ asin = numeric.arcsin
141
+ asinh = numeric.arcsinh
142
+ atan = numeric.arctan
143
+ atanh = numeric.arctanh
144
+ atan2 = numeric.arctan2
145
+ concat = numeric.concatenate
146
+ bitwise_left_shift = numeric.left_shift
147
+ bitwise_invert = numeric.invert
148
+ bitwise_right_shift = numeric.right_shift
149
+ permute_dims = numeric.transpose
150
+ pow = numeric.power
151
+
152
+ __all__ = [
153
+ "abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2",
154
+ "bitwise_invert", "bitwise_left_shift", "bitwise_right_shift", "concat",
155
+ "pow", "permute_dims", "memmap", "sctypeDict", "record", "recarray"
156
+ ]
157
+ __all__ += numeric.__all__
158
+ __all__ += function_base.__all__
159
+ __all__ += getlimits.__all__
160
+ __all__ += shape_base.__all__
161
+ __all__ += einsumfunc.__all__
162
+
163
+
164
+ def _ufunc_reduce(func):
165
+ # Report the `__name__`. pickle will try to find the module. Note that
166
+ # pickle supports for this `__name__` to be a `__qualname__`. It may
167
+ # make sense to add a `__qualname__` to ufuncs, to allow this more
168
+ # explicitly (Numba has ufuncs as attributes).
169
+ # See also: https://github.com/dask/distributed/issues/3450
170
+ return func.__name__
171
+
172
+
173
+ def _DType_reconstruct(scalar_type):
174
+ # This is a work-around to pickle type(np.dtype(np.float64)), etc.
175
+ # and it should eventually be replaced with a better solution, e.g. when
176
+ # DTypes become HeapTypes.
177
+ return type(dtype(scalar_type))
178
+
179
+
180
+ def _DType_reduce(DType):
181
+ # As types/classes, most DTypes can simply be pickled by their name:
182
+ if not DType._legacy or DType.__module__ == "numpy.dtypes":
183
+ return DType.__name__
184
+
185
+ # However, user defined legacy dtypes (like rational) do not end up in
186
+ # `numpy.dtypes` as module and do not have a public class at all.
187
+ # For these, we pickle them by reconstructing them from the scalar type:
188
+ scalar_type = DType.type
189
+ return _DType_reconstruct, (scalar_type,)
190
+
191
+
192
+ import copyreg
193
+
194
+ copyreg.pickle(ufunc, _ufunc_reduce)
195
+ copyreg.pickle(type(dtype), _DType_reduce, _DType_reconstruct)
196
+
197
+ # Unclutter namespace (must keep _*_reconstruct for unpickling)
198
+ del copyreg, _ufunc_reduce, _DType_reduce
199
+
200
+ from numpy._pytesttester import PytestTester
201
+
202
+ test = PytestTester(__name__)
203
+ del PytestTester
hug/lib/python3.12/site-packages/numpy/_core/__init__.pyi ADDED
@@ -0,0 +1,673 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # keep in sync with https://github.com/numpy/numtype/blob/main/src/numpy-stubs/_core/__init__.pyi
2
+
3
+ from typing import Final
4
+
5
+ from numpy._pytesttester import PytestTester
6
+
7
+ from ._asarray import require
8
+ from ._ufunc_config import (
9
+ errstate,
10
+ getbufsize,
11
+ geterr,
12
+ geterrcall,
13
+ setbufsize,
14
+ seterr,
15
+ seterrcall,
16
+ )
17
+ from .arrayprint import (
18
+ array2string,
19
+ array_repr,
20
+ array_str,
21
+ format_float_positional,
22
+ format_float_scientific,
23
+ get_printoptions,
24
+ printoptions,
25
+ set_printoptions,
26
+ )
27
+ from .einsumfunc import einsum, einsum_path
28
+ from .fromnumeric import (
29
+ all,
30
+ amax,
31
+ amin,
32
+ any,
33
+ argmax,
34
+ argmin,
35
+ argpartition,
36
+ argsort,
37
+ around,
38
+ choose,
39
+ clip,
40
+ compress,
41
+ cumprod,
42
+ cumsum,
43
+ cumulative_prod,
44
+ cumulative_sum,
45
+ diagonal,
46
+ matrix_transpose,
47
+ max,
48
+ mean,
49
+ min,
50
+ ndim,
51
+ nonzero,
52
+ partition,
53
+ prod,
54
+ ptp,
55
+ put,
56
+ ravel,
57
+ repeat,
58
+ reshape,
59
+ resize,
60
+ round,
61
+ searchsorted,
62
+ shape,
63
+ size,
64
+ sort,
65
+ squeeze,
66
+ std,
67
+ sum,
68
+ swapaxes,
69
+ take,
70
+ trace,
71
+ transpose,
72
+ transpose as permute_dims,
73
+ var,
74
+ )
75
+ from .function_base import geomspace, linspace, logspace
76
+ from .getlimits import finfo, iinfo
77
+ from .memmap import memmap
78
+ from .numeric import (
79
+ False_,
80
+ True_,
81
+ allclose,
82
+ arange,
83
+ argwhere,
84
+ array,
85
+ array_equal,
86
+ array_equiv,
87
+ asanyarray,
88
+ asarray,
89
+ ascontiguousarray,
90
+ asfortranarray,
91
+ astype,
92
+ base_repr,
93
+ binary_repr,
94
+ bitwise_not,
95
+ broadcast,
96
+ can_cast,
97
+ concatenate,
98
+ concatenate as concat,
99
+ convolve,
100
+ copyto,
101
+ correlate,
102
+ count_nonzero,
103
+ cross,
104
+ dot,
105
+ dtype,
106
+ empty,
107
+ empty_like,
108
+ flatiter,
109
+ flatnonzero,
110
+ from_dlpack,
111
+ frombuffer,
112
+ fromfile,
113
+ fromfunction,
114
+ fromiter,
115
+ fromstring,
116
+ full,
117
+ full_like,
118
+ identity,
119
+ indices,
120
+ inf,
121
+ inner,
122
+ isclose,
123
+ isfortran,
124
+ isscalar,
125
+ lexsort,
126
+ little_endian,
127
+ matmul,
128
+ may_share_memory,
129
+ min_scalar_type,
130
+ moveaxis,
131
+ nan,
132
+ ndarray,
133
+ nditer,
134
+ nested_iters,
135
+ newaxis,
136
+ ones,
137
+ ones_like,
138
+ outer,
139
+ promote_types,
140
+ putmask,
141
+ result_type,
142
+ roll,
143
+ rollaxis,
144
+ shares_memory,
145
+ tensordot,
146
+ ufunc,
147
+ vdot,
148
+ vecdot,
149
+ where,
150
+ zeros,
151
+ zeros_like,
152
+ )
153
+ from .numerictypes import (
154
+ ScalarType,
155
+ bool,
156
+ bool_,
157
+ busday_count,
158
+ busday_offset,
159
+ busdaycalendar,
160
+ byte,
161
+ bytes_,
162
+ cdouble,
163
+ character,
164
+ clongdouble,
165
+ complex64,
166
+ complex128,
167
+ complex192,
168
+ complex256,
169
+ complexfloating,
170
+ csingle,
171
+ datetime64,
172
+ datetime_as_string,
173
+ datetime_data,
174
+ double,
175
+ flexible,
176
+ float16,
177
+ float32,
178
+ float64,
179
+ float96,
180
+ float128,
181
+ floating,
182
+ generic,
183
+ half,
184
+ inexact,
185
+ int8,
186
+ int16,
187
+ int32,
188
+ int64,
189
+ int_,
190
+ intc,
191
+ integer,
192
+ intp,
193
+ is_busday,
194
+ isdtype,
195
+ issubdtype,
196
+ long,
197
+ longdouble,
198
+ longlong,
199
+ number,
200
+ object_,
201
+ sctypeDict,
202
+ sctypes as sctypes,
203
+ short,
204
+ signedinteger,
205
+ single,
206
+ str_,
207
+ timedelta64,
208
+ typecodes,
209
+ ubyte,
210
+ uint,
211
+ uint8,
212
+ uint16,
213
+ uint32,
214
+ uint64,
215
+ uintc,
216
+ uintp,
217
+ ulong,
218
+ ulonglong,
219
+ unsignedinteger,
220
+ ushort,
221
+ void,
222
+ )
223
+ from .records import recarray, record
224
+ from .shape_base import (
225
+ atleast_1d,
226
+ atleast_2d,
227
+ atleast_3d,
228
+ block,
229
+ hstack,
230
+ stack,
231
+ unstack,
232
+ vstack,
233
+ )
234
+ from .umath import (
235
+ absolute,
236
+ absolute as abs,
237
+ add,
238
+ arccos,
239
+ arccos as acos,
240
+ arccosh,
241
+ arccosh as acosh,
242
+ arcsin,
243
+ arcsin as asin,
244
+ arcsinh,
245
+ arcsinh as asinh,
246
+ arctan,
247
+ arctan as atan,
248
+ arctan2,
249
+ arctan2 as atan2,
250
+ arctanh,
251
+ arctanh as atanh,
252
+ bitwise_and,
253
+ bitwise_count,
254
+ bitwise_or,
255
+ bitwise_xor,
256
+ cbrt,
257
+ ceil,
258
+ conj,
259
+ conjugate,
260
+ copysign,
261
+ cos,
262
+ cosh,
263
+ deg2rad,
264
+ degrees,
265
+ divide,
266
+ divmod,
267
+ e,
268
+ equal,
269
+ euler_gamma,
270
+ exp,
271
+ exp2,
272
+ expm1,
273
+ fabs,
274
+ float_power,
275
+ floor,
276
+ floor_divide,
277
+ fmax,
278
+ fmin,
279
+ fmod,
280
+ frexp,
281
+ frompyfunc,
282
+ gcd,
283
+ greater,
284
+ greater_equal,
285
+ heaviside,
286
+ hypot,
287
+ invert,
288
+ invert as bitwise_invert,
289
+ isfinite,
290
+ isinf,
291
+ isnan,
292
+ isnat,
293
+ lcm,
294
+ ldexp,
295
+ left_shift,
296
+ left_shift as bitwise_left_shift,
297
+ less,
298
+ less_equal,
299
+ log,
300
+ log1p,
301
+ log2,
302
+ log10,
303
+ logaddexp,
304
+ logaddexp2,
305
+ logical_and,
306
+ logical_not,
307
+ logical_or,
308
+ logical_xor,
309
+ matvec,
310
+ maximum,
311
+ minimum,
312
+ mod,
313
+ modf,
314
+ multiply,
315
+ negative,
316
+ nextafter,
317
+ not_equal,
318
+ pi,
319
+ positive,
320
+ power,
321
+ power as pow,
322
+ rad2deg,
323
+ radians,
324
+ reciprocal,
325
+ remainder,
326
+ right_shift,
327
+ right_shift as bitwise_right_shift,
328
+ rint,
329
+ sign,
330
+ signbit,
331
+ sin,
332
+ sinh,
333
+ spacing,
334
+ sqrt,
335
+ square,
336
+ subtract,
337
+ tan,
338
+ tanh,
339
+ true_divide,
340
+ trunc,
341
+ vecmat,
342
+ )
343
+
344
+ __all__ = [
345
+ "False_",
346
+ "ScalarType",
347
+ "True_",
348
+ "abs",
349
+ "absolute",
350
+ "acos",
351
+ "acosh",
352
+ "add",
353
+ "all",
354
+ "allclose",
355
+ "amax",
356
+ "amin",
357
+ "any",
358
+ "arange",
359
+ "arccos",
360
+ "arccosh",
361
+ "arcsin",
362
+ "arcsinh",
363
+ "arctan",
364
+ "arctan2",
365
+ "arctanh",
366
+ "argmax",
367
+ "argmin",
368
+ "argpartition",
369
+ "argsort",
370
+ "argwhere",
371
+ "around",
372
+ "array",
373
+ "array2string",
374
+ "array_equal",
375
+ "array_equiv",
376
+ "array_repr",
377
+ "array_str",
378
+ "asanyarray",
379
+ "asarray",
380
+ "ascontiguousarray",
381
+ "asfortranarray",
382
+ "asin",
383
+ "asinh",
384
+ "astype",
385
+ "atan",
386
+ "atan2",
387
+ "atanh",
388
+ "atleast_1d",
389
+ "atleast_2d",
390
+ "atleast_3d",
391
+ "base_repr",
392
+ "binary_repr",
393
+ "bitwise_and",
394
+ "bitwise_count",
395
+ "bitwise_invert",
396
+ "bitwise_left_shift",
397
+ "bitwise_not",
398
+ "bitwise_or",
399
+ "bitwise_right_shift",
400
+ "bitwise_xor",
401
+ "block",
402
+ "bool",
403
+ "bool_",
404
+ "broadcast",
405
+ "busday_count",
406
+ "busday_offset",
407
+ "busdaycalendar",
408
+ "byte",
409
+ "bytes_",
410
+ "can_cast",
411
+ "cbrt",
412
+ "cdouble",
413
+ "ceil",
414
+ "character",
415
+ "choose",
416
+ "clip",
417
+ "clongdouble",
418
+ "complex64",
419
+ "complex128",
420
+ "complex192",
421
+ "complex256",
422
+ "complexfloating",
423
+ "compress",
424
+ "concat",
425
+ "concatenate",
426
+ "conj",
427
+ "conjugate",
428
+ "convolve",
429
+ "copysign",
430
+ "copyto",
431
+ "correlate",
432
+ "cos",
433
+ "cosh",
434
+ "count_nonzero",
435
+ "cross",
436
+ "csingle",
437
+ "cumprod",
438
+ "cumsum",
439
+ "cumulative_prod",
440
+ "cumulative_sum",
441
+ "datetime64",
442
+ "datetime_as_string",
443
+ "datetime_data",
444
+ "deg2rad",
445
+ "degrees",
446
+ "diagonal",
447
+ "divide",
448
+ "divmod",
449
+ "dot",
450
+ "double",
451
+ "dtype",
452
+ "e",
453
+ "einsum",
454
+ "einsum_path",
455
+ "empty",
456
+ "empty_like",
457
+ "equal",
458
+ "errstate",
459
+ "euler_gamma",
460
+ "exp",
461
+ "exp2",
462
+ "expm1",
463
+ "fabs",
464
+ "finfo",
465
+ "flatiter",
466
+ "flatnonzero",
467
+ "flexible",
468
+ "float16",
469
+ "float32",
470
+ "float64",
471
+ "float96",
472
+ "float128",
473
+ "float_power",
474
+ "floating",
475
+ "floor",
476
+ "floor_divide",
477
+ "fmax",
478
+ "fmin",
479
+ "fmod",
480
+ "format_float_positional",
481
+ "format_float_scientific",
482
+ "frexp",
483
+ "from_dlpack",
484
+ "frombuffer",
485
+ "fromfile",
486
+ "fromfunction",
487
+ "fromiter",
488
+ "frompyfunc",
489
+ "fromstring",
490
+ "full",
491
+ "full_like",
492
+ "gcd",
493
+ "generic",
494
+ "geomspace",
495
+ "get_printoptions",
496
+ "getbufsize",
497
+ "geterr",
498
+ "geterrcall",
499
+ "greater",
500
+ "greater_equal",
501
+ "half",
502
+ "heaviside",
503
+ "hstack",
504
+ "hypot",
505
+ "identity",
506
+ "iinfo",
507
+ "indices",
508
+ "inexact",
509
+ "inf",
510
+ "inner",
511
+ "int8",
512
+ "int16",
513
+ "int32",
514
+ "int64",
515
+ "int_",
516
+ "intc",
517
+ "integer",
518
+ "intp",
519
+ "invert",
520
+ "is_busday",
521
+ "isclose",
522
+ "isdtype",
523
+ "isfinite",
524
+ "isfortran",
525
+ "isinf",
526
+ "isnan",
527
+ "isnat",
528
+ "isscalar",
529
+ "issubdtype",
530
+ "lcm",
531
+ "ldexp",
532
+ "left_shift",
533
+ "less",
534
+ "less_equal",
535
+ "lexsort",
536
+ "linspace",
537
+ "little_endian",
538
+ "log",
539
+ "log1p",
540
+ "log2",
541
+ "log10",
542
+ "logaddexp",
543
+ "logaddexp2",
544
+ "logical_and",
545
+ "logical_not",
546
+ "logical_or",
547
+ "logical_xor",
548
+ "logspace",
549
+ "long",
550
+ "longdouble",
551
+ "longlong",
552
+ "matmul",
553
+ "matrix_transpose",
554
+ "matvec",
555
+ "max",
556
+ "maximum",
557
+ "may_share_memory",
558
+ "mean",
559
+ "memmap",
560
+ "min",
561
+ "min_scalar_type",
562
+ "minimum",
563
+ "mod",
564
+ "modf",
565
+ "moveaxis",
566
+ "multiply",
567
+ "nan",
568
+ "ndarray",
569
+ "ndim",
570
+ "nditer",
571
+ "negative",
572
+ "nested_iters",
573
+ "newaxis",
574
+ "nextafter",
575
+ "nonzero",
576
+ "not_equal",
577
+ "number",
578
+ "object_",
579
+ "ones",
580
+ "ones_like",
581
+ "outer",
582
+ "partition",
583
+ "permute_dims",
584
+ "pi",
585
+ "positive",
586
+ "pow",
587
+ "power",
588
+ "printoptions",
589
+ "prod",
590
+ "promote_types",
591
+ "ptp",
592
+ "put",
593
+ "putmask",
594
+ "rad2deg",
595
+ "radians",
596
+ "ravel",
597
+ "recarray",
598
+ "reciprocal",
599
+ "record",
600
+ "remainder",
601
+ "repeat",
602
+ "require",
603
+ "reshape",
604
+ "resize",
605
+ "result_type",
606
+ "right_shift",
607
+ "rint",
608
+ "roll",
609
+ "rollaxis",
610
+ "round",
611
+ "sctypeDict",
612
+ "searchsorted",
613
+ "set_printoptions",
614
+ "setbufsize",
615
+ "seterr",
616
+ "seterrcall",
617
+ "shape",
618
+ "shares_memory",
619
+ "short",
620
+ "sign",
621
+ "signbit",
622
+ "signedinteger",
623
+ "sin",
624
+ "single",
625
+ "sinh",
626
+ "size",
627
+ "sort",
628
+ "spacing",
629
+ "sqrt",
630
+ "square",
631
+ "squeeze",
632
+ "stack",
633
+ "std",
634
+ "str_",
635
+ "subtract",
636
+ "sum",
637
+ "swapaxes",
638
+ "take",
639
+ "tan",
640
+ "tanh",
641
+ "tensordot",
642
+ "timedelta64",
643
+ "trace",
644
+ "transpose",
645
+ "true_divide",
646
+ "trunc",
647
+ "typecodes",
648
+ "ubyte",
649
+ "ufunc",
650
+ "uint",
651
+ "uint8",
652
+ "uint16",
653
+ "uint32",
654
+ "uint64",
655
+ "uintc",
656
+ "uintp",
657
+ "ulong",
658
+ "ulonglong",
659
+ "unsignedinteger",
660
+ "unstack",
661
+ "ushort",
662
+ "var",
663
+ "vdot",
664
+ "vecdot",
665
+ "vecmat",
666
+ "void",
667
+ "vstack",
668
+ "where",
669
+ "zeros",
670
+ "zeros_like",
671
+ ]
672
+
673
+ test: Final[PytestTester] = ...
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (6.59 kB). View file
 
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_add_newdocs.cpython-312.pyc ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdf836a29044eaa4577465526d622b9e67529621881cfb41ac03e160c854cc07
3
+ size 208851
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_add_newdocs_scalars.cpython-312.pyc ADDED
Binary file (13.3 kB). View file
 
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_asarray.cpython-312.pyc ADDED
Binary file (4.27 kB). View file
 
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_dtype.cpython-312.pyc ADDED
Binary file (13.5 kB). View file
 
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_dtype_ctypes.cpython-312.pyc ADDED
Binary file (4.83 kB). View file
 
hug/lib/python3.12/site-packages/numpy/_core/__pycache__/_exceptions.cpython-312.pyc ADDED
Binary file (8.28 kB). View file