BryanW commited on
Commit
5b18d32
·
verified ·
1 Parent(s): f83a577

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/INSTALLER +1 -0
  2. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/LICENSE +21 -0
  3. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/METADATA +278 -0
  4. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/RECORD +47 -0
  5. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/WHEEL +5 -0
  6. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/top_level.txt +1 -0
  7. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/__init__.py +14 -0
  8. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/_staggered.py +204 -0
  9. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py +259 -0
  10. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/py.typed +0 -0
  11. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/types.py +15 -0
  12. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/utils.py +97 -0
  13. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/__init__.py +48 -0
  14. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/__main__.py +6 -0
  15. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/api.py +668 -0
  16. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/cd.py +395 -0
  17. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/constant.py +1998 -0
  18. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/legacy.py +66 -0
  19. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-x86_64-linux-gnu.so +0 -0
  20. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/md.py +630 -0
  21. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/models.py +360 -0
  22. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/py.typed +0 -0
  23. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/utils.py +408 -0
  24. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/version.py +8 -0
  25. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/INSTALLER +1 -0
  26. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/METADATA +58 -0
  27. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/RECORD +24 -0
  28. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/WHEEL +4 -0
  29. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/INSTALLER +1 -0
  30. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/LICENSE +46 -0
  31. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/METADATA +32 -0
  32. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/RECORD +18 -0
  33. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/WHEEL +4 -0
  34. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/__init__.py +48 -0
  35. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/__init__.pyi +152 -0
  36. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_abc.py +48 -0
  37. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_compat.py +14 -0
  38. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_multidict_base.py +152 -0
  39. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_multidict_py.py +527 -0
  40. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/py.typed +1 -0
  41. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__config__.py +162 -0
  42. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd +1050 -0
  43. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.pxd +1015 -0
  44. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.py +461 -0
  45. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.pyi +0 -0
  46. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/_distributor_init.py +15 -0
  47. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/conftest.py +138 -0
  48. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/ctypeslib.py +545 -0
  49. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/ctypeslib.pyi +251 -0
  50. Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/dtypes.py +77 -0
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016-2024 Tsuyoshi Hombashi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/METADATA ADDED
@@ -0,0 +1,278 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: DataProperty
3
+ Version: 1.1.0
4
+ Summary: Python library for extract property from data.
5
+ Home-page: https://github.com/thombashi/DataProperty
6
+ Author: Tsuyoshi Hombashi
7
+ Author-email: tsuyoshi.hombashi@gmail.com
8
+ Maintainer: Tsuyoshi Hombashi
9
+ Maintainer-email: tsuyoshi.hombashi@gmail.com
10
+ License: MIT License
11
+ Project-URL: Changelog, https://github.com/thombashi/DataProperty/releases
12
+ Project-URL: Source, https://github.com/thombashi/DataProperty
13
+ Project-URL: Tracker, https://github.com/thombashi/DataProperty/issues
14
+ Keywords: data,library,property
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Intended Audience :: Information Technology
18
+ Classifier: License :: OSI Approved :: MIT License
19
+ Classifier: Operating System :: OS Independent
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.9
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
28
+ Classifier: Topic :: Software Development :: Libraries
29
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
30
+ Classifier: Typing :: Typed
31
+ Requires-Python: >=3.9
32
+ Description-Content-Type: text/x-rst
33
+ License-File: LICENSE
34
+ Requires-Dist: mbstrdecoder<2,>=1.0.0
35
+ Requires-Dist: typepy[datetime]<2,>=1.3.2
36
+ Provides-Extra: logging
37
+ Requires-Dist: loguru<1,>=0.4.1; extra == "logging"
38
+ Provides-Extra: test
39
+ Requires-Dist: pytest>=6.0.1; extra == "test"
40
+ Requires-Dist: pytest-md-report>=0.6.2; extra == "test"
41
+ Requires-Dist: tcolorpy>=0.1.2; extra == "test"
42
+
43
+ .. contents:: **DataProperty**
44
+ :backlinks: top
45
+ :local:
46
+
47
+
48
+ Summary
49
+ =======
50
+ A Python library for extract property from data.
51
+
52
+
53
+ .. image:: https://badge.fury.io/py/DataProperty.svg
54
+ :target: https://badge.fury.io/py/DataProperty
55
+ :alt: PyPI package version
56
+
57
+ .. image:: https://anaconda.org/conda-forge/DataProperty/badges/version.svg
58
+ :target: https://anaconda.org/conda-forge/DataProperty
59
+ :alt: conda-forge package version
60
+
61
+ .. image:: https://img.shields.io/pypi/pyversions/DataProperty.svg
62
+ :target: https://pypi.org/project/DataProperty
63
+ :alt: Supported Python versions
64
+
65
+ .. image:: https://img.shields.io/pypi/implementation/DataProperty.svg
66
+ :target: https://pypi.org/project/DataProperty
67
+ :alt: Supported Python implementations
68
+
69
+ .. image:: https://github.com/thombashi/DataProperty/actions/workflows/ci.yml/badge.svg
70
+ :target: https://github.com/thombashi/DataProperty/actions/workflows/ci.yml
71
+ :alt: CI status of Linux/macOS/Windows
72
+
73
+ .. image:: https://coveralls.io/repos/github/thombashi/DataProperty/badge.svg?branch=master
74
+ :target: https://coveralls.io/github/thombashi/DataProperty?branch=master
75
+ :alt: Test coverage
76
+
77
+ .. image:: https://github.com/thombashi/DataProperty/actions/workflows/github-code-scanning/codeql/badge.svg
78
+ :target: https://github.com/thombashi/DataProperty/actions/workflows/github-code-scanning/codeql
79
+ :alt: CodeQL
80
+
81
+
82
+ Installation
83
+ ============
84
+
85
+ Installation: pip
86
+ ------------------------------
87
+ ::
88
+
89
+ pip install DataProperty
90
+
91
+ Installation: conda
92
+ ------------------------------
93
+ ::
94
+
95
+ conda install -c conda-forge dataproperty
96
+
97
+ Installation: apt
98
+ ------------------------------
99
+ ::
100
+
101
+ sudo add-apt-repository ppa:thombashi/ppa
102
+ sudo apt update
103
+ sudo apt install python3-dataproperty
104
+
105
+
106
+ Usage
107
+ =====
108
+
109
+ Extract property of data
110
+ ------------------------
111
+
112
+ e.g. Extract a ``float`` value property
113
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
114
+ .. code:: python
115
+
116
+ >>> from dataproperty import DataProperty
117
+ >>> DataProperty(-1.1)
118
+ data=-1.1, type=REAL_NUMBER, align=right, ascii_width=4, int_digits=1, decimal_places=1, extra_len=1
119
+
120
+ e.g. Extract a ``int`` value property
121
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
+ .. code:: python
123
+
124
+ >>> from dataproperty import DataProperty
125
+ >>> DataProperty(123456789)
126
+ data=123456789, type=INTEGER, align=right, ascii_width=9, int_digits=9, decimal_places=0, extra_len=0
127
+
128
+ e.g. Extract a ``str`` (ascii) value property
129
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
130
+ .. code:: python
131
+
132
+ >>> from dataproperty import DataProperty
133
+ >>> DataProperty("sample string")
134
+ data=sample string, type=STRING, align=left, length=13, ascii_width=13, extra_len=0
135
+
136
+ e.g. Extract a ``str`` (multi-byte) value property
137
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138
+ .. code:: python
139
+
140
+ >>> from dataproperty import DataProperty
141
+ >>> str(DataProperty("吾輩は猫である"))
142
+ data=吾輩は猫である, type=STRING, align=left, length=7, ascii_width=14, extra_len=0
143
+
144
+ e.g. Extract a time (``datetime``) value property
145
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146
+ .. code:: python
147
+
148
+ >>> import datetime
149
+ >>> from dataproperty import DataProperty
150
+ >>> DataProperty(datetime.datetime(2017, 1, 1, 0, 0, 0))
151
+ data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii_width=19, extra_len=0
152
+
153
+ e.g. Extract a ``bool`` value property
154
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
155
+ .. code:: python
156
+
157
+ >>> from dataproperty import DataProperty
158
+ >>> DataProperty(True)
159
+ data=True, type=BOOL, align=left, ascii_width=4, extra_len=0
160
+
161
+
162
+ Extract data property for each element from a matrix
163
+ ----------------------------------------------------
164
+ ``DataPropertyExtractor.to_dp_matrix`` method returns a matrix of ``DataProperty`` instances from a data matrix.
165
+ An example data set and the result are as follows:
166
+
167
+ :Sample Code:
168
+ .. code:: python
169
+
170
+ import datetime
171
+ from dataproperty import DataPropertyExtractor
172
+
173
+ dp_extractor = DataPropertyExtractor()
174
+ dt = datetime.datetime(2017, 1, 1, 0, 0, 0)
175
+ inf = float("inf")
176
+ nan = float("nan")
177
+
178
+ dp_matrix = dp_extractor.to_dp_matrix([
179
+ [1, 1.1, "aa", 1, 1, True, inf, nan, dt],
180
+ [2, 2.2, "bbb", 2.2, 2.2, False, "inf", "nan", dt],
181
+ [3, 3.33, "cccc", -3, "ccc", "true", inf, "NAN", "2017-01-01T01:23:45+0900"],
182
+ ])
183
+
184
+ for row, dp_list in enumerate(dp_matrix):
185
+ for col, dp in enumerate(dp_list):
186
+ print("row={:d}, col={:d}, {}".format(row, col, str(dp)))
187
+
188
+ :Output:
189
+ ::
190
+
191
+ row=0, col=0, data=1, type=INTEGER, align=right, ascii_width=1, int_digits=1, decimal_places=0, extra_len=0
192
+ row=0, col=1, data=1.1, type=REAL_NUMBER, align=right, ascii_width=3, int_digits=1, decimal_places=1, extra_len=0
193
+ row=0, col=2, data=aa, type=STRING, align=left, ascii_width=2, length=2, extra_len=0
194
+ row=0, col=3, data=1, type=INTEGER, align=right, ascii_width=1, int_digits=1, decimal_places=0, extra_len=0
195
+ row=0, col=4, data=1, type=INTEGER, align=right, ascii_width=1, int_digits=1, decimal_places=0, extra_len=0
196
+ row=0, col=5, data=True, type=BOOL, align=left, ascii_width=4, extra_len=0
197
+ row=0, col=6, data=Infinity, type=INFINITY, align=left, ascii_width=8, extra_len=0
198
+ row=0, col=7, data=NaN, type=NAN, align=left, ascii_width=3, extra_len=0
199
+ row=0, col=8, data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii_width=19, extra_len=0
200
+ row=1, col=0, data=2, type=INTEGER, align=right, ascii_width=1, int_digits=1, decimal_places=0, extra_len=0
201
+ row=1, col=1, data=2.2, type=REAL_NUMBER, align=right, ascii_width=3, int_digits=1, decimal_places=1, extra_len=0
202
+ row=1, col=2, data=bbb, type=STRING, align=left, ascii_width=3, length=3, extra_len=0
203
+ row=1, col=3, data=2.2, type=REAL_NUMBER, align=right, ascii_width=3, int_digits=1, decimal_places=1, extra_len=0
204
+ row=1, col=4, data=2.2, type=REAL_NUMBER, align=right, ascii_width=3, int_digits=1, decimal_places=1, extra_len=0
205
+ row=1, col=5, data=False, type=BOOL, align=left, ascii_width=5, extra_len=0
206
+ row=1, col=6, data=Infinity, type=INFINITY, align=left, ascii_width=8, extra_len=0
207
+ row=1, col=7, data=NaN, type=NAN, align=left, ascii_width=3, extra_len=0
208
+ row=1, col=8, data=2017-01-01 00:00:00, type=DATETIME, align=left, ascii_width=19, extra_len=0
209
+ row=2, col=0, data=3, type=INTEGER, align=right, ascii_width=1, int_digits=1, decimal_places=0, extra_len=0
210
+ row=2, col=1, data=3.33, type=REAL_NUMBER, align=right, ascii_width=4, int_digits=1, decimal_places=2, extra_len=0
211
+ row=2, col=2, data=cccc, type=STRING, align=left, ascii_width=4, length=4, extra_len=0
212
+ row=2, col=3, data=-3, type=INTEGER, align=right, ascii_width=2, int_digits=1, decimal_places=0, extra_len=1
213
+ row=2, col=4, data=ccc, type=STRING, align=left, ascii_width=3, length=3, extra_len=0
214
+ row=2, col=5, data=True, type=BOOL, align=left, ascii_width=4, extra_len=0
215
+ row=2, col=6, data=Infinity, type=INFINITY, align=left, ascii_width=8, extra_len=0
216
+ row=2, col=7, data=NaN, type=NAN, align=left, ascii_width=3, extra_len=0
217
+ row=2, col=8, data=2017-01-01T01:23:45+0900, type=STRING, align=left, ascii_width=24, length=24, extra_len=0
218
+
219
+
220
+ Full example source code can be found at *examples/py/to_dp_matrix.py*
221
+
222
+
223
+ Extract properties for each column from a matrix
224
+ ------------------------------------------------------
225
+ ``DataPropertyExtractor.to_column_dp_list`` method returns a list of ``DataProperty`` instances from a data matrix. The list represents the properties for each column.
226
+ An example data set and the result are as follows:
227
+
228
+ Example data set and result are as follows:
229
+
230
+ :Sample Code:
231
+ .. code:: python
232
+
233
+ import datetime
234
+ from dataproperty import DataPropertyExtractor
235
+
236
+ dp_extractor = DataPropertyExtractor()
237
+ dt = datetime.datetime(2017, 1, 1, 0, 0, 0)
238
+ inf = float("inf")
239
+ nan = float("nan")
240
+
241
+ data_matrix = [
242
+ [1, 1.1, "aa", 1, 1, True, inf, nan, dt],
243
+ [2, 2.2, "bbb", 2.2, 2.2, False, "inf", "nan", dt],
244
+ [3, 3.33, "cccc", -3, "ccc", "true", inf, "NAN", "2017-01-01T01:23:45+0900"],
245
+ ]
246
+
247
+ dp_extractor.headers = ["int", "float", "str", "num", "mix", "bool", "inf", "nan", "time"]
248
+ col_dp_list = dp_extractor.to_column_dp_list(dp_extractor.to_dp_matrix(dp_matrix))
249
+
250
+ for col_idx, col_dp in enumerate(col_dp_list):
251
+ print(str(col_dp))
252
+
253
+ :Output:
254
+ ::
255
+
256
+ column=0, type=INTEGER, align=right, ascii_width=3, bit_len=2, int_digits=1, decimal_places=0
257
+ column=1, type=REAL_NUMBER, align=right, ascii_width=5, int_digits=1, decimal_places=(min=1, max=2)
258
+ column=2, type=STRING, align=left, ascii_width=4
259
+ column=3, type=REAL_NUMBER, align=right, ascii_width=4, int_digits=1, decimal_places=(min=0, max=1), extra_len=(min=0, max=1)
260
+ column=4, type=STRING, align=left, ascii_width=3, int_digits=1, decimal_places=(min=0, max=1)
261
+ column=5, type=BOOL, align=left, ascii_width=5
262
+ column=6, type=INFINITY, align=left, ascii_width=8
263
+ column=7, type=NAN, align=left, ascii_width=3
264
+ column=8, type=STRING, align=left, ascii_width=24
265
+
266
+
267
+ Full example source code can be found at *examples/py/to_column_dp_list.py*
268
+
269
+
270
+ Dependencies
271
+ ============
272
+ - Python 3.9+
273
+ - `Python package dependencies (automatically installed) <https://github.com/thombashi/DataProperty/network/dependencies>`__
274
+
275
+ Optional dependencies
276
+ ---------------------
277
+ - `loguru <https://github.com/Delgan/loguru>`__
278
+ - Used for logging if the package installed
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/RECORD ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ DataProperty-1.1.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ DataProperty-1.1.0.dist-info/LICENSE,sha256=NiiRV-Nxqq5bXTukvoc1ntB1SM3HqfGf9h3GfPxTapw,1089
3
+ DataProperty-1.1.0.dist-info/METADATA,sha256=IBRAJe_iO6Q9ANZXB3mGQXUY-7rVOkWScLJScbLLKwE,11604
4
+ DataProperty-1.1.0.dist-info/RECORD,,
5
+ DataProperty-1.1.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
6
+ DataProperty-1.1.0.dist-info/top_level.txt,sha256=RiW0aJCSmIPslrGSqg9wyPRas0Rl7Kcdi_fBBEd0-LY,13
7
+ dataproperty/__init__.py,sha256=y_LoBUs28gC7b7AXv49X1XCPHckXo3oKECpW-Oj6LbM,1308
8
+ dataproperty/__pycache__/__init__.cpython-312.pyc,,
9
+ dataproperty/__pycache__/__version__.cpython-312.pyc,,
10
+ dataproperty/__pycache__/_align.cpython-312.pyc,,
11
+ dataproperty/__pycache__/_align_getter.cpython-312.pyc,,
12
+ dataproperty/__pycache__/_base.cpython-312.pyc,,
13
+ dataproperty/__pycache__/_column.cpython-312.pyc,,
14
+ dataproperty/__pycache__/_common.cpython-312.pyc,,
15
+ dataproperty/__pycache__/_container.cpython-312.pyc,,
16
+ dataproperty/__pycache__/_converter.cpython-312.pyc,,
17
+ dataproperty/__pycache__/_dataproperty.cpython-312.pyc,,
18
+ dataproperty/__pycache__/_extractor.cpython-312.pyc,,
19
+ dataproperty/__pycache__/_formatter.cpython-312.pyc,,
20
+ dataproperty/__pycache__/_function.cpython-312.pyc,,
21
+ dataproperty/__pycache__/_interface.cpython-312.pyc,,
22
+ dataproperty/__pycache__/_line_break.cpython-312.pyc,,
23
+ dataproperty/__pycache__/_preprocessor.cpython-312.pyc,,
24
+ dataproperty/__pycache__/typing.cpython-312.pyc,,
25
+ dataproperty/__version__.py,sha256=20XeJZJjWYfDK_1uO_Cw_PfXRL196B8J1hTCAMl1zqA,268
26
+ dataproperty/_align.py,sha256=VQCp3HUN-rw5lDcG0CHwoQNwabSOwMF8Fpn52nHpQs8,535
27
+ dataproperty/_align_getter.py,sha256=GV8rvnGaF8-8C6E7SNa3SsXw-gp80jR93knG_XDwcZQ,833
28
+ dataproperty/_base.py,sha256=e1EIrIOoQ2a0ZHUU8dZaB5VB7Hyla9BI6Ui4EQTlQJ4,2522
29
+ dataproperty/_column.py,sha256=IrO0BFlL8GZzezCNXNF0iOKmhe-D4Jfa3mc_o6K3f8I,11641
30
+ dataproperty/_common.py,sha256=S2FEfleQ3mjdMwaqW3KBpOrc-txr2vY2rpsV-WD-dxQ,2036
31
+ dataproperty/_container.py,sha256=nA8j6FK1XZRshdkc0IKrSnWiNUCsWtEaWE97gvwUsWE,5189
32
+ dataproperty/_converter.py,sha256=ztL51KpTfo4k-UJVPGruGHQqXM9gpZie7Gp3lbj_20M,3284
33
+ dataproperty/_dataproperty.py,sha256=Iby_m1h7HoRx2t2ZhjfRp0tk_dM6rN7ZD2LpsKTlFAY,11329
34
+ dataproperty/_extractor.py,sha256=M5it_2JHayk2EyfmfobcjzWFkycvg7WwnSNimn7N1zY,26019
35
+ dataproperty/_formatter.py,sha256=9bUxfuEQonKT9rqSaK9mc4fmNg_dnlkmftR48sGOytY,3022
36
+ dataproperty/_function.py,sha256=EKa13rpLHMYM84jqsCiTbpR2pd7lofd9uWRhx34HTEk,3267
37
+ dataproperty/_interface.py,sha256=eBR3lK1Ub3JOA9VRfTxB2AKnZI4k0-n3s1htvGzZCog,674
38
+ dataproperty/_line_break.py,sha256=FGjtuWKftOchoeJZJ9DxHJ9DUY0PPO_tPTiAM1e-Wck,114
39
+ dataproperty/_preprocessor.py,sha256=RHqbt41Edy14iQIbHUJ1pd3S-QUVDPDSN-zBlZ5_dbA,5491
40
+ dataproperty/logger/__init__.py,sha256=OnQCZS8T1Av5eQxFkuP-GAtmS-WdLXvy-yTvldwNoBI,104
41
+ dataproperty/logger/__pycache__/__init__.cpython-312.pyc,,
42
+ dataproperty/logger/__pycache__/_logger.cpython-312.pyc,,
43
+ dataproperty/logger/__pycache__/_null_logger.cpython-312.pyc,,
44
+ dataproperty/logger/_logger.py,sha256=-Kc7JXkSgq2BLy7kfP0SiwauShwsb66dzvCiNrTLDQg,442
45
+ dataproperty/logger/_null_logger.py,sha256=xWCR2KAa2aKAcpKi8DosfCOgaRMb_YXr9MKrK7xMD-A,1071
46
+ dataproperty/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
+ dataproperty/typing.py,sha256=l_nHqtIIQrBtHKBsWfCUy6A1UBuwCqJNUSvXvHfeWY4,1440
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/WHEEL ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/DataProperty-1.1.0.dist-info/top_level.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ dataproperty
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/__init__.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __version__ = "2.5.0"
2
+
3
+ from .impl import start_connection
4
+ from .types import AddrInfoType, SocketFactoryType
5
+ from .utils import addr_to_addr_infos, pop_addr_infos_interleave, remove_addr_infos
6
+
7
+ __all__ = (
8
+ "AddrInfoType",
9
+ "SocketFactoryType",
10
+ "addr_to_addr_infos",
11
+ "pop_addr_infos_interleave",
12
+ "remove_addr_infos",
13
+ "start_connection",
14
+ )
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/_staggered.py ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import contextlib
3
+ from typing import (
4
+ TYPE_CHECKING,
5
+ Any,
6
+ Awaitable,
7
+ Callable,
8
+ Iterable,
9
+ List,
10
+ Optional,
11
+ Set,
12
+ Tuple,
13
+ TypeVar,
14
+ Union,
15
+ )
16
+
17
+ _T = TypeVar("_T")
18
+
19
+ RE_RAISE_EXCEPTIONS = (SystemExit, KeyboardInterrupt)
20
+
21
+
22
+ def _set_result(wait_next: "asyncio.Future[None]") -> None:
23
+ """Set the result of a future if it is not already done."""
24
+ if not wait_next.done():
25
+ wait_next.set_result(None)
26
+
27
+
28
+ async def _wait_one(
29
+ futures: "Iterable[asyncio.Future[Any]]",
30
+ loop: asyncio.AbstractEventLoop,
31
+ ) -> _T:
32
+ """Wait for the first future to complete."""
33
+ wait_next = loop.create_future()
34
+
35
+ def _on_completion(fut: "asyncio.Future[Any]") -> None:
36
+ if not wait_next.done():
37
+ wait_next.set_result(fut)
38
+
39
+ for f in futures:
40
+ f.add_done_callback(_on_completion)
41
+
42
+ try:
43
+ return await wait_next
44
+ finally:
45
+ for f in futures:
46
+ f.remove_done_callback(_on_completion)
47
+
48
+
49
+ async def staggered_race(
50
+ coro_fns: Iterable[Callable[[], Awaitable[_T]]],
51
+ delay: Optional[float],
52
+ *,
53
+ loop: Optional[asyncio.AbstractEventLoop] = None,
54
+ ) -> Tuple[Optional[_T], Optional[int], List[Optional[BaseException]]]:
55
+ """
56
+ Run coroutines with staggered start times and take the first to finish.
57
+
58
+ This method takes an iterable of coroutine functions. The first one is
59
+ started immediately. From then on, whenever the immediately preceding one
60
+ fails (raises an exception), or when *delay* seconds has passed, the next
61
+ coroutine is started. This continues until one of the coroutines complete
62
+ successfully, in which case all others are cancelled, or until all
63
+ coroutines fail.
64
+
65
+ The coroutines provided should be well-behaved in the following way:
66
+
67
+ * They should only ``return`` if completed successfully.
68
+
69
+ * They should always raise an exception if they did not complete
70
+ successfully. In particular, if they handle cancellation, they should
71
+ probably reraise, like this::
72
+
73
+ try:
74
+ # do work
75
+ except asyncio.CancelledError:
76
+ # undo partially completed work
77
+ raise
78
+
79
+ Args:
80
+ ----
81
+ coro_fns: an iterable of coroutine functions, i.e. callables that
82
+ return a coroutine object when called. Use ``functools.partial`` or
83
+ lambdas to pass arguments.
84
+
85
+ delay: amount of time, in seconds, between starting coroutines. If
86
+ ``None``, the coroutines will run sequentially.
87
+
88
+ loop: the event loop to use. If ``None``, the running loop is used.
89
+
90
+ Returns:
91
+ -------
92
+ tuple *(winner_result, winner_index, exceptions)* where
93
+
94
+ - *winner_result*: the result of the winning coroutine, or ``None``
95
+ if no coroutines won.
96
+
97
+ - *winner_index*: the index of the winning coroutine in
98
+ ``coro_fns``, or ``None`` if no coroutines won. If the winning
99
+ coroutine may return None on success, *winner_index* can be used
100
+ to definitively determine whether any coroutine won.
101
+
102
+ - *exceptions*: list of exceptions returned by the coroutines.
103
+ ``len(exceptions)`` is equal to the number of coroutines actually
104
+ started, and the order is the same as in ``coro_fns``. The winning
105
+ coroutine's entry is ``None``.
106
+
107
+ """
108
+ loop = loop or asyncio.get_running_loop()
109
+ exceptions: List[Optional[BaseException]] = []
110
+ tasks: Set[asyncio.Task[Optional[Tuple[_T, int]]]] = set()
111
+
112
+ async def run_one_coro(
113
+ coro_fn: Callable[[], Awaitable[_T]],
114
+ this_index: int,
115
+ start_next: "asyncio.Future[None]",
116
+ ) -> Optional[Tuple[_T, int]]:
117
+ """
118
+ Run a single coroutine.
119
+
120
+ If the coroutine fails, set the exception in the exceptions list and
121
+ start the next coroutine by setting the result of the start_next.
122
+
123
+ If the coroutine succeeds, return the result and the index of the
124
+ coroutine in the coro_fns list.
125
+
126
+ If SystemExit or KeyboardInterrupt is raised, re-raise it.
127
+ """
128
+ try:
129
+ result = await coro_fn()
130
+ except RE_RAISE_EXCEPTIONS:
131
+ raise
132
+ except BaseException as e:
133
+ exceptions[this_index] = e
134
+ _set_result(start_next) # Kickstart the next coroutine
135
+ return None
136
+
137
+ return result, this_index
138
+
139
+ start_next_timer: Optional[asyncio.TimerHandle] = None
140
+ start_next: Optional[asyncio.Future[None]]
141
+ task: asyncio.Task[Optional[Tuple[_T, int]]]
142
+ done: Union[asyncio.Future[None], asyncio.Task[Optional[Tuple[_T, int]]]]
143
+ coro_iter = iter(coro_fns)
144
+ this_index = -1
145
+ try:
146
+ while True:
147
+ if coro_fn := next(coro_iter, None):
148
+ this_index += 1
149
+ exceptions.append(None)
150
+ start_next = loop.create_future()
151
+ task = loop.create_task(run_one_coro(coro_fn, this_index, start_next))
152
+ tasks.add(task)
153
+ start_next_timer = (
154
+ loop.call_later(delay, _set_result, start_next) if delay else None
155
+ )
156
+ elif not tasks:
157
+ # We exhausted the coro_fns list and no tasks are running
158
+ # so we have no winner and all coroutines failed.
159
+ break
160
+
161
+ while tasks or start_next:
162
+ done = await _wait_one(
163
+ (*tasks, start_next) if start_next else tasks, loop
164
+ )
165
+ if done is start_next:
166
+ # The current task has failed or the timer has expired
167
+ # so we need to start the next task.
168
+ start_next = None
169
+ if start_next_timer:
170
+ start_next_timer.cancel()
171
+ start_next_timer = None
172
+
173
+ # Break out of the task waiting loop to start the next
174
+ # task.
175
+ break
176
+
177
+ if TYPE_CHECKING:
178
+ assert isinstance(done, asyncio.Task)
179
+
180
+ tasks.remove(done)
181
+ if winner := done.result():
182
+ return *winner, exceptions
183
+ finally:
184
+ # We either have:
185
+ # - a winner
186
+ # - all tasks failed
187
+ # - a KeyboardInterrupt or SystemExit.
188
+
189
+ #
190
+ # If the timer is still running, cancel it.
191
+ #
192
+ if start_next_timer:
193
+ start_next_timer.cancel()
194
+
195
+ #
196
+ # If there are any tasks left, cancel them and than
197
+ # wait them so they fill the exceptions list.
198
+ #
199
+ for task in tasks:
200
+ task.cancel()
201
+ with contextlib.suppress(asyncio.CancelledError):
202
+ await task
203
+
204
+ return None, None, exceptions
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/impl.py ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Base implementation."""
2
+
3
+ import asyncio
4
+ import collections
5
+ import contextlib
6
+ import functools
7
+ import itertools
8
+ import socket
9
+ from typing import List, Optional, Sequence, Set, Union
10
+
11
+ from . import _staggered
12
+ from .types import AddrInfoType, SocketFactoryType
13
+
14
+
15
+ async def start_connection(
16
+ addr_infos: Sequence[AddrInfoType],
17
+ *,
18
+ local_addr_infos: Optional[Sequence[AddrInfoType]] = None,
19
+ happy_eyeballs_delay: Optional[float] = None,
20
+ interleave: Optional[int] = None,
21
+ loop: Optional[asyncio.AbstractEventLoop] = None,
22
+ socket_factory: Optional[SocketFactoryType] = None,
23
+ ) -> socket.socket:
24
+ """
25
+ Connect to a TCP server.
26
+
27
+ Create a socket connection to a specified destination. The
28
+ destination is specified as a list of AddrInfoType tuples as
29
+ returned from getaddrinfo().
30
+
31
+ The arguments are, in order:
32
+
33
+ * ``family``: the address family, e.g. ``socket.AF_INET`` or
34
+ ``socket.AF_INET6``.
35
+ * ``type``: the socket type, e.g. ``socket.SOCK_STREAM`` or
36
+ ``socket.SOCK_DGRAM``.
37
+ * ``proto``: the protocol, e.g. ``socket.IPPROTO_TCP`` or
38
+ ``socket.IPPROTO_UDP``.
39
+ * ``canonname``: the canonical name of the address, e.g.
40
+ ``"www.python.org"``.
41
+ * ``sockaddr``: the socket address
42
+
43
+ This method is a coroutine which will try to establish the connection
44
+ in the background. When successful, the coroutine returns a
45
+ socket.
46
+
47
+ The expected use case is to use this method in conjunction with
48
+ loop.create_connection() to establish a connection to a server::
49
+
50
+ socket = await start_connection(addr_infos)
51
+ transport, protocol = await loop.create_connection(
52
+ MyProtocol, sock=socket, ...)
53
+ """
54
+ if not (current_loop := loop):
55
+ current_loop = asyncio.get_running_loop()
56
+
57
+ single_addr_info = len(addr_infos) == 1
58
+
59
+ if happy_eyeballs_delay is not None and interleave is None:
60
+ # If using happy eyeballs, default to interleave addresses by family
61
+ interleave = 1
62
+
63
+ if interleave and not single_addr_info:
64
+ addr_infos = _interleave_addrinfos(addr_infos, interleave)
65
+
66
+ sock: Optional[socket.socket] = None
67
+ # uvloop can raise RuntimeError instead of OSError
68
+ exceptions: List[List[Union[OSError, RuntimeError]]] = []
69
+ if happy_eyeballs_delay is None or single_addr_info:
70
+ # not using happy eyeballs
71
+ for addrinfo in addr_infos:
72
+ try:
73
+ sock = await _connect_sock(
74
+ current_loop,
75
+ exceptions,
76
+ addrinfo,
77
+ local_addr_infos,
78
+ None,
79
+ socket_factory,
80
+ )
81
+ break
82
+ except (RuntimeError, OSError):
83
+ continue
84
+ else: # using happy eyeballs
85
+ open_sockets: Set[socket.socket] = set()
86
+ try:
87
+ sock, _, _ = await _staggered.staggered_race(
88
+ (
89
+ functools.partial(
90
+ _connect_sock,
91
+ current_loop,
92
+ exceptions,
93
+ addrinfo,
94
+ local_addr_infos,
95
+ open_sockets,
96
+ socket_factory,
97
+ )
98
+ for addrinfo in addr_infos
99
+ ),
100
+ happy_eyeballs_delay,
101
+ )
102
+ finally:
103
+ # If we have a winner, staggered_race will
104
+ # cancel the other tasks, however there is a
105
+ # small race window where any of the other tasks
106
+ # can be done before they are cancelled which
107
+ # will leave the socket open. To avoid this problem
108
+ # we pass a set to _connect_sock to keep track of
109
+ # the open sockets and close them here if there
110
+ # are any "runner up" sockets.
111
+ for s in open_sockets:
112
+ if s is not sock:
113
+ with contextlib.suppress(OSError):
114
+ s.close()
115
+ open_sockets = None # type: ignore[assignment]
116
+
117
+ if sock is None:
118
+ all_exceptions = [exc for sub in exceptions for exc in sub]
119
+ try:
120
+ first_exception = all_exceptions[0]
121
+ if len(all_exceptions) == 1:
122
+ raise first_exception
123
+ else:
124
+ # If they all have the same str(), raise one.
125
+ model = str(first_exception)
126
+ if all(str(exc) == model for exc in all_exceptions):
127
+ raise first_exception
128
+ # Raise a combined exception so the user can see all
129
+ # the various error messages.
130
+ msg = "Multiple exceptions: {}".format(
131
+ ", ".join(str(exc) for exc in all_exceptions)
132
+ )
133
+ # If the errno is the same for all exceptions, raise
134
+ # an OSError with that errno.
135
+ if isinstance(first_exception, OSError):
136
+ first_errno = first_exception.errno
137
+ if all(
138
+ isinstance(exc, OSError) and exc.errno == first_errno
139
+ for exc in all_exceptions
140
+ ):
141
+ raise OSError(first_errno, msg)
142
+ elif isinstance(first_exception, RuntimeError) and all(
143
+ isinstance(exc, RuntimeError) for exc in all_exceptions
144
+ ):
145
+ raise RuntimeError(msg)
146
+ # We have a mix of OSError and RuntimeError
147
+ # so we have to pick which one to raise.
148
+ # and we raise OSError for compatibility
149
+ raise OSError(msg)
150
+ finally:
151
+ all_exceptions = None # type: ignore[assignment]
152
+ exceptions = None # type: ignore[assignment]
153
+
154
+ return sock
155
+
156
+
157
+ async def _connect_sock(
158
+ loop: asyncio.AbstractEventLoop,
159
+ exceptions: List[List[Union[OSError, RuntimeError]]],
160
+ addr_info: AddrInfoType,
161
+ local_addr_infos: Optional[Sequence[AddrInfoType]] = None,
162
+ open_sockets: Optional[Set[socket.socket]] = None,
163
+ socket_factory: Optional[SocketFactoryType] = None,
164
+ ) -> socket.socket:
165
+ """
166
+ Create, bind and connect one socket.
167
+
168
+ If open_sockets is passed, add the socket to the set of open sockets.
169
+ Any failure caught here will remove the socket from the set and close it.
170
+
171
+ Callers can use this set to close any sockets that are not the winner
172
+ of all staggered tasks in the result there are runner up sockets aka
173
+ multiple winners.
174
+ """
175
+ my_exceptions: List[Union[OSError, RuntimeError]] = []
176
+ exceptions.append(my_exceptions)
177
+ family, type_, proto, _, address = addr_info
178
+ sock = None
179
+ try:
180
+ if socket_factory is not None:
181
+ sock = socket_factory(addr_info)
182
+ else:
183
+ sock = socket.socket(family=family, type=type_, proto=proto)
184
+ if open_sockets is not None:
185
+ open_sockets.add(sock)
186
+ sock.setblocking(False)
187
+ if local_addr_infos is not None:
188
+ for lfamily, _, _, _, laddr in local_addr_infos:
189
+ # skip local addresses of different family
190
+ if lfamily != family:
191
+ continue
192
+ try:
193
+ sock.bind(laddr)
194
+ break
195
+ except OSError as exc:
196
+ msg = (
197
+ f"error while attempting to bind on "
198
+ f"address {laddr!r}: "
199
+ f"{(exc.strerror or '').lower()}"
200
+ )
201
+ exc = OSError(exc.errno, msg)
202
+ my_exceptions.append(exc)
203
+ else: # all bind attempts failed
204
+ if my_exceptions:
205
+ raise my_exceptions.pop()
206
+ else:
207
+ raise OSError(f"no matching local address with {family=} found")
208
+ await loop.sock_connect(sock, address)
209
+ return sock
210
+ except (RuntimeError, OSError) as exc:
211
+ my_exceptions.append(exc)
212
+ if sock is not None:
213
+ if open_sockets is not None:
214
+ open_sockets.remove(sock)
215
+ try:
216
+ sock.close()
217
+ except OSError as e:
218
+ my_exceptions.append(e)
219
+ raise
220
+ raise
221
+ except:
222
+ if sock is not None:
223
+ if open_sockets is not None:
224
+ open_sockets.remove(sock)
225
+ try:
226
+ sock.close()
227
+ except OSError as e:
228
+ my_exceptions.append(e)
229
+ raise
230
+ raise
231
+ finally:
232
+ exceptions = my_exceptions = None # type: ignore[assignment]
233
+
234
+
235
+ def _interleave_addrinfos(
236
+ addrinfos: Sequence[AddrInfoType], first_address_family_count: int = 1
237
+ ) -> List[AddrInfoType]:
238
+ """Interleave list of addrinfo tuples by family."""
239
+ # Group addresses by family
240
+ addrinfos_by_family: collections.OrderedDict[int, List[AddrInfoType]] = (
241
+ collections.OrderedDict()
242
+ )
243
+ for addr in addrinfos:
244
+ family = addr[0]
245
+ if family not in addrinfos_by_family:
246
+ addrinfos_by_family[family] = []
247
+ addrinfos_by_family[family].append(addr)
248
+ addrinfos_lists = list(addrinfos_by_family.values())
249
+
250
+ reordered: List[AddrInfoType] = []
251
+ if first_address_family_count > 1:
252
+ reordered.extend(addrinfos_lists[0][: first_address_family_count - 1])
253
+ del addrinfos_lists[0][: first_address_family_count - 1]
254
+ reordered.extend(
255
+ a
256
+ for a in itertools.chain.from_iterable(itertools.zip_longest(*addrinfos_lists))
257
+ if a is not None
258
+ )
259
+ return reordered
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/py.typed ADDED
File without changes
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/types.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Types for aiohappyeyeballs."""
2
+
3
+ import socket
4
+ from collections.abc import Callable
5
+ from typing import Tuple, Union
6
+
7
+ AddrInfoType = Tuple[
8
+ Union[int, socket.AddressFamily],
9
+ Union[int, socket.SocketKind],
10
+ int,
11
+ str,
12
+ Tuple, # type: ignore[type-arg]
13
+ ]
14
+
15
+ SocketFactoryType = Callable[[AddrInfoType], socket.socket]
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/aiohappyeyeballs/utils.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utility functions for aiohappyeyeballs."""
2
+
3
+ import ipaddress
4
+ import socket
5
+ from typing import Dict, List, Optional, Tuple, Union
6
+
7
+ from .types import AddrInfoType
8
+
9
+
10
+ def addr_to_addr_infos(
11
+ addr: Optional[
12
+ Union[Tuple[str, int, int, int], Tuple[str, int, int], Tuple[str, int]]
13
+ ],
14
+ ) -> Optional[List[AddrInfoType]]:
15
+ """Convert an address tuple to a list of addr_info tuples."""
16
+ if addr is None:
17
+ return None
18
+ host = addr[0]
19
+ port = addr[1]
20
+ is_ipv6 = ":" in host
21
+ if is_ipv6:
22
+ flowinfo = 0
23
+ scopeid = 0
24
+ addr_len = len(addr)
25
+ if addr_len >= 4:
26
+ scopeid = addr[3] # type: ignore[misc]
27
+ if addr_len >= 3:
28
+ flowinfo = addr[2] # type: ignore[misc]
29
+ addr = (host, port, flowinfo, scopeid)
30
+ family = socket.AF_INET6
31
+ else:
32
+ addr = (host, port)
33
+ family = socket.AF_INET
34
+ return [(family, socket.SOCK_STREAM, socket.IPPROTO_TCP, "", addr)]
35
+
36
+
37
+ def pop_addr_infos_interleave(
38
+ addr_infos: List[AddrInfoType], interleave: Optional[int] = None
39
+ ) -> None:
40
+ """
41
+ Pop addr_info from the list of addr_infos by family up to interleave times.
42
+
43
+ The interleave parameter is used to know how many addr_infos for
44
+ each family should be popped of the top of the list.
45
+ """
46
+ seen: Dict[int, int] = {}
47
+ if interleave is None:
48
+ interleave = 1
49
+ to_remove: List[AddrInfoType] = []
50
+ for addr_info in addr_infos:
51
+ family = addr_info[0]
52
+ if family not in seen:
53
+ seen[family] = 0
54
+ if seen[family] < interleave:
55
+ to_remove.append(addr_info)
56
+ seen[family] += 1
57
+ for addr_info in to_remove:
58
+ addr_infos.remove(addr_info)
59
+
60
+
61
+ def _addr_tuple_to_ip_address(
62
+ addr: Union[Tuple[str, int], Tuple[str, int, int, int]],
63
+ ) -> Union[
64
+ Tuple[ipaddress.IPv4Address, int], Tuple[ipaddress.IPv6Address, int, int, int]
65
+ ]:
66
+ """Convert an address tuple to an IPv4Address."""
67
+ return (ipaddress.ip_address(addr[0]), *addr[1:])
68
+
69
+
70
+ def remove_addr_infos(
71
+ addr_infos: List[AddrInfoType],
72
+ addr: Union[Tuple[str, int], Tuple[str, int, int, int]],
73
+ ) -> None:
74
+ """
75
+ Remove an address from the list of addr_infos.
76
+
77
+ The addr value is typically the return value of
78
+ sock.getpeername().
79
+ """
80
+ bad_addrs_infos: List[AddrInfoType] = []
81
+ for addr_info in addr_infos:
82
+ if addr_info[-1] == addr:
83
+ bad_addrs_infos.append(addr_info)
84
+ if bad_addrs_infos:
85
+ for bad_addr_info in bad_addrs_infos:
86
+ addr_infos.remove(bad_addr_info)
87
+ return
88
+ # Slow path in case addr is formatted differently
89
+ match_addr = _addr_tuple_to_ip_address(addr)
90
+ for addr_info in addr_infos:
91
+ if match_addr == _addr_tuple_to_ip_address(addr_info[-1]):
92
+ bad_addrs_infos.append(addr_info)
93
+ if bad_addrs_infos:
94
+ for bad_addr_info in bad_addrs_infos:
95
+ addr_infos.remove(bad_addr_info)
96
+ return
97
+ raise ValueError(f"Address {addr} not found in addr_infos")
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/__init__.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Charset-Normalizer
3
+ ~~~~~~~~~~~~~~
4
+ The Real First Universal Charset Detector.
5
+ A library that helps you read text from an unknown charset encoding.
6
+ Motivated by chardet, This package is trying to resolve the issue by taking a new approach.
7
+ All IANA character set names for which the Python core library provides codecs are supported.
8
+
9
+ Basic usage:
10
+ >>> from charset_normalizer import from_bytes
11
+ >>> results = from_bytes('Bсеки човек има право на образование. Oбразованието!'.encode('utf_8'))
12
+ >>> best_guess = results.best()
13
+ >>> str(best_guess)
14
+ 'Bсеки човек има право на образование. Oбразованието!'
15
+
16
+ Others methods and usages are available - see the full documentation
17
+ at <https://github.com/Ousret/charset_normalizer>.
18
+ :copyright: (c) 2021 by Ahmed TAHRI
19
+ :license: MIT, see LICENSE for more details.
20
+ """
21
+
22
+ from __future__ import annotations
23
+
24
+ import logging
25
+
26
+ from .api import from_bytes, from_fp, from_path, is_binary
27
+ from .legacy import detect
28
+ from .models import CharsetMatch, CharsetMatches
29
+ from .utils import set_logging_handler
30
+ from .version import VERSION, __version__
31
+
32
+ __all__ = (
33
+ "from_fp",
34
+ "from_path",
35
+ "from_bytes",
36
+ "is_binary",
37
+ "detect",
38
+ "CharsetMatch",
39
+ "CharsetMatches",
40
+ "__version__",
41
+ "VERSION",
42
+ "set_logging_handler",
43
+ )
44
+
45
+ # Attach a NullHandler to the top level logger by default
46
+ # https://docs.python.org/3.3/howto/logging.html#configuring-logging-for-a-library
47
+
48
+ logging.getLogger("charset_normalizer").addHandler(logging.NullHandler())
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/__main__.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from .cli import cli_detect
4
+
5
+ if __name__ == "__main__":
6
+ cli_detect()
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/api.py ADDED
@@ -0,0 +1,668 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ from os import PathLike
5
+ from typing import BinaryIO
6
+
7
+ from .cd import (
8
+ coherence_ratio,
9
+ encoding_languages,
10
+ mb_encoding_languages,
11
+ merge_coherence_ratios,
12
+ )
13
+ from .constant import IANA_SUPPORTED, TOO_BIG_SEQUENCE, TOO_SMALL_SEQUENCE, TRACE
14
+ from .md import mess_ratio
15
+ from .models import CharsetMatch, CharsetMatches
16
+ from .utils import (
17
+ any_specified_encoding,
18
+ cut_sequence_chunks,
19
+ iana_name,
20
+ identify_sig_or_bom,
21
+ is_cp_similar,
22
+ is_multi_byte_encoding,
23
+ should_strip_sig_or_bom,
24
+ )
25
+
26
+ logger = logging.getLogger("charset_normalizer")
27
+ explain_handler = logging.StreamHandler()
28
+ explain_handler.setFormatter(
29
+ logging.Formatter("%(asctime)s | %(levelname)s | %(message)s")
30
+ )
31
+
32
+
33
+ def from_bytes(
34
+ sequences: bytes | bytearray,
35
+ steps: int = 5,
36
+ chunk_size: int = 512,
37
+ threshold: float = 0.2,
38
+ cp_isolation: list[str] | None = None,
39
+ cp_exclusion: list[str] | None = None,
40
+ preemptive_behaviour: bool = True,
41
+ explain: bool = False,
42
+ language_threshold: float = 0.1,
43
+ enable_fallback: bool = True,
44
+ ) -> CharsetMatches:
45
+ """
46
+ Given a raw bytes sequence, return the best possibles charset usable to render str objects.
47
+ If there is no results, it is a strong indicator that the source is binary/not text.
48
+ By default, the process will extract 5 blocks of 512o each to assess the mess and coherence of a given sequence.
49
+ And will give up a particular code page after 20% of measured mess. Those criteria are customizable at will.
50
+
51
+ The preemptive behavior DOES NOT replace the traditional detection workflow, it prioritize a particular code page
52
+ but never take it for granted. Can improve the performance.
53
+
54
+ You may want to focus your attention to some code page or/and not others, use cp_isolation and cp_exclusion for that
55
+ purpose.
56
+
57
+ This function will strip the SIG in the payload/sequence every time except on UTF-16, UTF-32.
58
+ By default the library does not setup any handler other than the NullHandler, if you choose to set the 'explain'
59
+ toggle to True it will alter the logger configuration to add a StreamHandler that is suitable for debugging.
60
+ Custom logging format and handler can be set manually.
61
+ """
62
+
63
+ if not isinstance(sequences, (bytearray, bytes)):
64
+ raise TypeError(
65
+ "Expected object of type bytes or bytearray, got: {}".format(
66
+ type(sequences)
67
+ )
68
+ )
69
+
70
+ if explain:
71
+ previous_logger_level: int = logger.level
72
+ logger.addHandler(explain_handler)
73
+ logger.setLevel(TRACE)
74
+
75
+ length: int = len(sequences)
76
+
77
+ if length == 0:
78
+ logger.debug("Encoding detection on empty bytes, assuming utf_8 intention.")
79
+ if explain: # Defensive: ensure exit path clean handler
80
+ logger.removeHandler(explain_handler)
81
+ logger.setLevel(previous_logger_level or logging.WARNING)
82
+ return CharsetMatches([CharsetMatch(sequences, "utf_8", 0.0, False, [], "")])
83
+
84
+ if cp_isolation is not None:
85
+ logger.log(
86
+ TRACE,
87
+ "cp_isolation is set. use this flag for debugging purpose. "
88
+ "limited list of encoding allowed : %s.",
89
+ ", ".join(cp_isolation),
90
+ )
91
+ cp_isolation = [iana_name(cp, False) for cp in cp_isolation]
92
+ else:
93
+ cp_isolation = []
94
+
95
+ if cp_exclusion is not None:
96
+ logger.log(
97
+ TRACE,
98
+ "cp_exclusion is set. use this flag for debugging purpose. "
99
+ "limited list of encoding excluded : %s.",
100
+ ", ".join(cp_exclusion),
101
+ )
102
+ cp_exclusion = [iana_name(cp, False) for cp in cp_exclusion]
103
+ else:
104
+ cp_exclusion = []
105
+
106
+ if length <= (chunk_size * steps):
107
+ logger.log(
108
+ TRACE,
109
+ "override steps (%i) and chunk_size (%i) as content does not fit (%i byte(s) given) parameters.",
110
+ steps,
111
+ chunk_size,
112
+ length,
113
+ )
114
+ steps = 1
115
+ chunk_size = length
116
+
117
+ if steps > 1 and length / steps < chunk_size:
118
+ chunk_size = int(length / steps)
119
+
120
+ is_too_small_sequence: bool = len(sequences) < TOO_SMALL_SEQUENCE
121
+ is_too_large_sequence: bool = len(sequences) >= TOO_BIG_SEQUENCE
122
+
123
+ if is_too_small_sequence:
124
+ logger.log(
125
+ TRACE,
126
+ "Trying to detect encoding from a tiny portion of ({}) byte(s).".format(
127
+ length
128
+ ),
129
+ )
130
+ elif is_too_large_sequence:
131
+ logger.log(
132
+ TRACE,
133
+ "Using lazy str decoding because the payload is quite large, ({}) byte(s).".format(
134
+ length
135
+ ),
136
+ )
137
+
138
+ prioritized_encodings: list[str] = []
139
+
140
+ specified_encoding: str | None = (
141
+ any_specified_encoding(sequences) if preemptive_behaviour else None
142
+ )
143
+
144
+ if specified_encoding is not None:
145
+ prioritized_encodings.append(specified_encoding)
146
+ logger.log(
147
+ TRACE,
148
+ "Detected declarative mark in sequence. Priority +1 given for %s.",
149
+ specified_encoding,
150
+ )
151
+
152
+ tested: set[str] = set()
153
+ tested_but_hard_failure: list[str] = []
154
+ tested_but_soft_failure: list[str] = []
155
+
156
+ fallback_ascii: CharsetMatch | None = None
157
+ fallback_u8: CharsetMatch | None = None
158
+ fallback_specified: CharsetMatch | None = None
159
+
160
+ results: CharsetMatches = CharsetMatches()
161
+
162
+ early_stop_results: CharsetMatches = CharsetMatches()
163
+
164
+ sig_encoding, sig_payload = identify_sig_or_bom(sequences)
165
+
166
+ if sig_encoding is not None:
167
+ prioritized_encodings.append(sig_encoding)
168
+ logger.log(
169
+ TRACE,
170
+ "Detected a SIG or BOM mark on first %i byte(s). Priority +1 given for %s.",
171
+ len(sig_payload),
172
+ sig_encoding,
173
+ )
174
+
175
+ prioritized_encodings.append("ascii")
176
+
177
+ if "utf_8" not in prioritized_encodings:
178
+ prioritized_encodings.append("utf_8")
179
+
180
+ for encoding_iana in prioritized_encodings + IANA_SUPPORTED:
181
+ if cp_isolation and encoding_iana not in cp_isolation:
182
+ continue
183
+
184
+ if cp_exclusion and encoding_iana in cp_exclusion:
185
+ continue
186
+
187
+ if encoding_iana in tested:
188
+ continue
189
+
190
+ tested.add(encoding_iana)
191
+
192
+ decoded_payload: str | None = None
193
+ bom_or_sig_available: bool = sig_encoding == encoding_iana
194
+ strip_sig_or_bom: bool = bom_or_sig_available and should_strip_sig_or_bom(
195
+ encoding_iana
196
+ )
197
+
198
+ if encoding_iana in {"utf_16", "utf_32"} and not bom_or_sig_available:
199
+ logger.log(
200
+ TRACE,
201
+ "Encoding %s won't be tested as-is because it require a BOM. Will try some sub-encoder LE/BE.",
202
+ encoding_iana,
203
+ )
204
+ continue
205
+ if encoding_iana in {"utf_7"} and not bom_or_sig_available:
206
+ logger.log(
207
+ TRACE,
208
+ "Encoding %s won't be tested as-is because detection is unreliable without BOM/SIG.",
209
+ encoding_iana,
210
+ )
211
+ continue
212
+
213
+ try:
214
+ is_multi_byte_decoder: bool = is_multi_byte_encoding(encoding_iana)
215
+ except (ModuleNotFoundError, ImportError):
216
+ logger.log(
217
+ TRACE,
218
+ "Encoding %s does not provide an IncrementalDecoder",
219
+ encoding_iana,
220
+ )
221
+ continue
222
+
223
+ try:
224
+ if is_too_large_sequence and is_multi_byte_decoder is False:
225
+ str(
226
+ (
227
+ sequences[: int(50e4)]
228
+ if strip_sig_or_bom is False
229
+ else sequences[len(sig_payload) : int(50e4)]
230
+ ),
231
+ encoding=encoding_iana,
232
+ )
233
+ else:
234
+ decoded_payload = str(
235
+ (
236
+ sequences
237
+ if strip_sig_or_bom is False
238
+ else sequences[len(sig_payload) :]
239
+ ),
240
+ encoding=encoding_iana,
241
+ )
242
+ except (UnicodeDecodeError, LookupError) as e:
243
+ if not isinstance(e, LookupError):
244
+ logger.log(
245
+ TRACE,
246
+ "Code page %s does not fit given bytes sequence at ALL. %s",
247
+ encoding_iana,
248
+ str(e),
249
+ )
250
+ tested_but_hard_failure.append(encoding_iana)
251
+ continue
252
+
253
+ similar_soft_failure_test: bool = False
254
+
255
+ for encoding_soft_failed in tested_but_soft_failure:
256
+ if is_cp_similar(encoding_iana, encoding_soft_failed):
257
+ similar_soft_failure_test = True
258
+ break
259
+
260
+ if similar_soft_failure_test:
261
+ logger.log(
262
+ TRACE,
263
+ "%s is deemed too similar to code page %s and was consider unsuited already. Continuing!",
264
+ encoding_iana,
265
+ encoding_soft_failed,
266
+ )
267
+ continue
268
+
269
+ r_ = range(
270
+ 0 if not bom_or_sig_available else len(sig_payload),
271
+ length,
272
+ int(length / steps),
273
+ )
274
+
275
+ multi_byte_bonus: bool = (
276
+ is_multi_byte_decoder
277
+ and decoded_payload is not None
278
+ and len(decoded_payload) < length
279
+ )
280
+
281
+ if multi_byte_bonus:
282
+ logger.log(
283
+ TRACE,
284
+ "Code page %s is a multi byte encoding table and it appear that at least one character "
285
+ "was encoded using n-bytes.",
286
+ encoding_iana,
287
+ )
288
+
289
+ max_chunk_gave_up: int = int(len(r_) / 4)
290
+
291
+ max_chunk_gave_up = max(max_chunk_gave_up, 2)
292
+ early_stop_count: int = 0
293
+ lazy_str_hard_failure = False
294
+
295
+ md_chunks: list[str] = []
296
+ md_ratios = []
297
+
298
+ try:
299
+ for chunk in cut_sequence_chunks(
300
+ sequences,
301
+ encoding_iana,
302
+ r_,
303
+ chunk_size,
304
+ bom_or_sig_available,
305
+ strip_sig_or_bom,
306
+ sig_payload,
307
+ is_multi_byte_decoder,
308
+ decoded_payload,
309
+ ):
310
+ md_chunks.append(chunk)
311
+
312
+ md_ratios.append(
313
+ mess_ratio(
314
+ chunk,
315
+ threshold,
316
+ explain is True and 1 <= len(cp_isolation) <= 2,
317
+ )
318
+ )
319
+
320
+ if md_ratios[-1] >= threshold:
321
+ early_stop_count += 1
322
+
323
+ if (early_stop_count >= max_chunk_gave_up) or (
324
+ bom_or_sig_available and strip_sig_or_bom is False
325
+ ):
326
+ break
327
+ except (
328
+ UnicodeDecodeError
329
+ ) as e: # Lazy str loading may have missed something there
330
+ logger.log(
331
+ TRACE,
332
+ "LazyStr Loading: After MD chunk decode, code page %s does not fit given bytes sequence at ALL. %s",
333
+ encoding_iana,
334
+ str(e),
335
+ )
336
+ early_stop_count = max_chunk_gave_up
337
+ lazy_str_hard_failure = True
338
+
339
+ # We might want to check the sequence again with the whole content
340
+ # Only if initial MD tests passes
341
+ if (
342
+ not lazy_str_hard_failure
343
+ and is_too_large_sequence
344
+ and not is_multi_byte_decoder
345
+ ):
346
+ try:
347
+ sequences[int(50e3) :].decode(encoding_iana, errors="strict")
348
+ except UnicodeDecodeError as e:
349
+ logger.log(
350
+ TRACE,
351
+ "LazyStr Loading: After final lookup, code page %s does not fit given bytes sequence at ALL. %s",
352
+ encoding_iana,
353
+ str(e),
354
+ )
355
+ tested_but_hard_failure.append(encoding_iana)
356
+ continue
357
+
358
+ mean_mess_ratio: float = sum(md_ratios) / len(md_ratios) if md_ratios else 0.0
359
+ if mean_mess_ratio >= threshold or early_stop_count >= max_chunk_gave_up:
360
+ tested_but_soft_failure.append(encoding_iana)
361
+ logger.log(
362
+ TRACE,
363
+ "%s was excluded because of initial chaos probing. Gave up %i time(s). "
364
+ "Computed mean chaos is %f %%.",
365
+ encoding_iana,
366
+ early_stop_count,
367
+ round(mean_mess_ratio * 100, ndigits=3),
368
+ )
369
+ # Preparing those fallbacks in case we got nothing.
370
+ if (
371
+ enable_fallback
372
+ and encoding_iana in ["ascii", "utf_8", specified_encoding]
373
+ and not lazy_str_hard_failure
374
+ ):
375
+ fallback_entry = CharsetMatch(
376
+ sequences,
377
+ encoding_iana,
378
+ threshold,
379
+ False,
380
+ [],
381
+ decoded_payload,
382
+ preemptive_declaration=specified_encoding,
383
+ )
384
+ if encoding_iana == specified_encoding:
385
+ fallback_specified = fallback_entry
386
+ elif encoding_iana == "ascii":
387
+ fallback_ascii = fallback_entry
388
+ else:
389
+ fallback_u8 = fallback_entry
390
+ continue
391
+
392
+ logger.log(
393
+ TRACE,
394
+ "%s passed initial chaos probing. Mean measured chaos is %f %%",
395
+ encoding_iana,
396
+ round(mean_mess_ratio * 100, ndigits=3),
397
+ )
398
+
399
+ if not is_multi_byte_decoder:
400
+ target_languages: list[str] = encoding_languages(encoding_iana)
401
+ else:
402
+ target_languages = mb_encoding_languages(encoding_iana)
403
+
404
+ if target_languages:
405
+ logger.log(
406
+ TRACE,
407
+ "{} should target any language(s) of {}".format(
408
+ encoding_iana, str(target_languages)
409
+ ),
410
+ )
411
+
412
+ cd_ratios = []
413
+
414
+ # We shall skip the CD when its about ASCII
415
+ # Most of the time its not relevant to run "language-detection" on it.
416
+ if encoding_iana != "ascii":
417
+ for chunk in md_chunks:
418
+ chunk_languages = coherence_ratio(
419
+ chunk,
420
+ language_threshold,
421
+ ",".join(target_languages) if target_languages else None,
422
+ )
423
+
424
+ cd_ratios.append(chunk_languages)
425
+
426
+ cd_ratios_merged = merge_coherence_ratios(cd_ratios)
427
+
428
+ if cd_ratios_merged:
429
+ logger.log(
430
+ TRACE,
431
+ "We detected language {} using {}".format(
432
+ cd_ratios_merged, encoding_iana
433
+ ),
434
+ )
435
+
436
+ current_match = CharsetMatch(
437
+ sequences,
438
+ encoding_iana,
439
+ mean_mess_ratio,
440
+ bom_or_sig_available,
441
+ cd_ratios_merged,
442
+ (
443
+ decoded_payload
444
+ if (
445
+ is_too_large_sequence is False
446
+ or encoding_iana in [specified_encoding, "ascii", "utf_8"]
447
+ )
448
+ else None
449
+ ),
450
+ preemptive_declaration=specified_encoding,
451
+ )
452
+
453
+ results.append(current_match)
454
+
455
+ if (
456
+ encoding_iana in [specified_encoding, "ascii", "utf_8"]
457
+ and mean_mess_ratio < 0.1
458
+ ):
459
+ # If md says nothing to worry about, then... stop immediately!
460
+ if mean_mess_ratio == 0.0:
461
+ logger.debug(
462
+ "Encoding detection: %s is most likely the one.",
463
+ current_match.encoding,
464
+ )
465
+ if explain: # Defensive: ensure exit path clean handler
466
+ logger.removeHandler(explain_handler)
467
+ logger.setLevel(previous_logger_level)
468
+ return CharsetMatches([current_match])
469
+
470
+ early_stop_results.append(current_match)
471
+
472
+ if (
473
+ len(early_stop_results)
474
+ and (specified_encoding is None or specified_encoding in tested)
475
+ and "ascii" in tested
476
+ and "utf_8" in tested
477
+ ):
478
+ probable_result: CharsetMatch = early_stop_results.best() # type: ignore[assignment]
479
+ logger.debug(
480
+ "Encoding detection: %s is most likely the one.",
481
+ probable_result.encoding,
482
+ )
483
+ if explain: # Defensive: ensure exit path clean handler
484
+ logger.removeHandler(explain_handler)
485
+ logger.setLevel(previous_logger_level)
486
+
487
+ return CharsetMatches([probable_result])
488
+
489
+ if encoding_iana == sig_encoding:
490
+ logger.debug(
491
+ "Encoding detection: %s is most likely the one as we detected a BOM or SIG within "
492
+ "the beginning of the sequence.",
493
+ encoding_iana,
494
+ )
495
+ if explain: # Defensive: ensure exit path clean handler
496
+ logger.removeHandler(explain_handler)
497
+ logger.setLevel(previous_logger_level)
498
+ return CharsetMatches([results[encoding_iana]])
499
+
500
+ if len(results) == 0:
501
+ if fallback_u8 or fallback_ascii or fallback_specified:
502
+ logger.log(
503
+ TRACE,
504
+ "Nothing got out of the detection process. Using ASCII/UTF-8/Specified fallback.",
505
+ )
506
+
507
+ if fallback_specified:
508
+ logger.debug(
509
+ "Encoding detection: %s will be used as a fallback match",
510
+ fallback_specified.encoding,
511
+ )
512
+ results.append(fallback_specified)
513
+ elif (
514
+ (fallback_u8 and fallback_ascii is None)
515
+ or (
516
+ fallback_u8
517
+ and fallback_ascii
518
+ and fallback_u8.fingerprint != fallback_ascii.fingerprint
519
+ )
520
+ or (fallback_u8 is not None)
521
+ ):
522
+ logger.debug("Encoding detection: utf_8 will be used as a fallback match")
523
+ results.append(fallback_u8)
524
+ elif fallback_ascii:
525
+ logger.debug("Encoding detection: ascii will be used as a fallback match")
526
+ results.append(fallback_ascii)
527
+
528
+ if results:
529
+ logger.debug(
530
+ "Encoding detection: Found %s as plausible (best-candidate) for content. With %i alternatives.",
531
+ results.best().encoding, # type: ignore
532
+ len(results) - 1,
533
+ )
534
+ else:
535
+ logger.debug("Encoding detection: Unable to determine any suitable charset.")
536
+
537
+ if explain:
538
+ logger.removeHandler(explain_handler)
539
+ logger.setLevel(previous_logger_level)
540
+
541
+ return results
542
+
543
+
544
+ def from_fp(
545
+ fp: BinaryIO,
546
+ steps: int = 5,
547
+ chunk_size: int = 512,
548
+ threshold: float = 0.20,
549
+ cp_isolation: list[str] | None = None,
550
+ cp_exclusion: list[str] | None = None,
551
+ preemptive_behaviour: bool = True,
552
+ explain: bool = False,
553
+ language_threshold: float = 0.1,
554
+ enable_fallback: bool = True,
555
+ ) -> CharsetMatches:
556
+ """
557
+ Same thing than the function from_bytes but using a file pointer that is already ready.
558
+ Will not close the file pointer.
559
+ """
560
+ return from_bytes(
561
+ fp.read(),
562
+ steps,
563
+ chunk_size,
564
+ threshold,
565
+ cp_isolation,
566
+ cp_exclusion,
567
+ preemptive_behaviour,
568
+ explain,
569
+ language_threshold,
570
+ enable_fallback,
571
+ )
572
+
573
+
574
+ def from_path(
575
+ path: str | bytes | PathLike, # type: ignore[type-arg]
576
+ steps: int = 5,
577
+ chunk_size: int = 512,
578
+ threshold: float = 0.20,
579
+ cp_isolation: list[str] | None = None,
580
+ cp_exclusion: list[str] | None = None,
581
+ preemptive_behaviour: bool = True,
582
+ explain: bool = False,
583
+ language_threshold: float = 0.1,
584
+ enable_fallback: bool = True,
585
+ ) -> CharsetMatches:
586
+ """
587
+ Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode.
588
+ Can raise IOError.
589
+ """
590
+ with open(path, "rb") as fp:
591
+ return from_fp(
592
+ fp,
593
+ steps,
594
+ chunk_size,
595
+ threshold,
596
+ cp_isolation,
597
+ cp_exclusion,
598
+ preemptive_behaviour,
599
+ explain,
600
+ language_threshold,
601
+ enable_fallback,
602
+ )
603
+
604
+
605
+ def is_binary(
606
+ fp_or_path_or_payload: PathLike | str | BinaryIO | bytes, # type: ignore[type-arg]
607
+ steps: int = 5,
608
+ chunk_size: int = 512,
609
+ threshold: float = 0.20,
610
+ cp_isolation: list[str] | None = None,
611
+ cp_exclusion: list[str] | None = None,
612
+ preemptive_behaviour: bool = True,
613
+ explain: bool = False,
614
+ language_threshold: float = 0.1,
615
+ enable_fallback: bool = False,
616
+ ) -> bool:
617
+ """
618
+ Detect if the given input (file, bytes, or path) points to a binary file. aka. not a string.
619
+ Based on the same main heuristic algorithms and default kwargs at the sole exception that fallbacks match
620
+ are disabled to be stricter around ASCII-compatible but unlikely to be a string.
621
+ """
622
+ if isinstance(fp_or_path_or_payload, (str, PathLike)):
623
+ guesses = from_path(
624
+ fp_or_path_or_payload,
625
+ steps=steps,
626
+ chunk_size=chunk_size,
627
+ threshold=threshold,
628
+ cp_isolation=cp_isolation,
629
+ cp_exclusion=cp_exclusion,
630
+ preemptive_behaviour=preemptive_behaviour,
631
+ explain=explain,
632
+ language_threshold=language_threshold,
633
+ enable_fallback=enable_fallback,
634
+ )
635
+ elif isinstance(
636
+ fp_or_path_or_payload,
637
+ (
638
+ bytes,
639
+ bytearray,
640
+ ),
641
+ ):
642
+ guesses = from_bytes(
643
+ fp_or_path_or_payload,
644
+ steps=steps,
645
+ chunk_size=chunk_size,
646
+ threshold=threshold,
647
+ cp_isolation=cp_isolation,
648
+ cp_exclusion=cp_exclusion,
649
+ preemptive_behaviour=preemptive_behaviour,
650
+ explain=explain,
651
+ language_threshold=language_threshold,
652
+ enable_fallback=enable_fallback,
653
+ )
654
+ else:
655
+ guesses = from_fp(
656
+ fp_or_path_or_payload,
657
+ steps=steps,
658
+ chunk_size=chunk_size,
659
+ threshold=threshold,
660
+ cp_isolation=cp_isolation,
661
+ cp_exclusion=cp_exclusion,
662
+ preemptive_behaviour=preemptive_behaviour,
663
+ explain=explain,
664
+ language_threshold=language_threshold,
665
+ enable_fallback=enable_fallback,
666
+ )
667
+
668
+ return not guesses
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/cd.py ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import importlib
4
+ from codecs import IncrementalDecoder
5
+ from collections import Counter
6
+ from functools import lru_cache
7
+ from typing import Counter as TypeCounter
8
+
9
+ from .constant import (
10
+ FREQUENCIES,
11
+ KO_NAMES,
12
+ LANGUAGE_SUPPORTED_COUNT,
13
+ TOO_SMALL_SEQUENCE,
14
+ ZH_NAMES,
15
+ )
16
+ from .md import is_suspiciously_successive_range
17
+ from .models import CoherenceMatches
18
+ from .utils import (
19
+ is_accentuated,
20
+ is_latin,
21
+ is_multi_byte_encoding,
22
+ is_unicode_range_secondary,
23
+ unicode_range,
24
+ )
25
+
26
+
27
+ def encoding_unicode_range(iana_name: str) -> list[str]:
28
+ """
29
+ Return associated unicode ranges in a single byte code page.
30
+ """
31
+ if is_multi_byte_encoding(iana_name):
32
+ raise OSError("Function not supported on multi-byte code page")
33
+
34
+ decoder = importlib.import_module(f"encodings.{iana_name}").IncrementalDecoder
35
+
36
+ p: IncrementalDecoder = decoder(errors="ignore")
37
+ seen_ranges: dict[str, int] = {}
38
+ character_count: int = 0
39
+
40
+ for i in range(0x40, 0xFF):
41
+ chunk: str = p.decode(bytes([i]))
42
+
43
+ if chunk:
44
+ character_range: str | None = unicode_range(chunk)
45
+
46
+ if character_range is None:
47
+ continue
48
+
49
+ if is_unicode_range_secondary(character_range) is False:
50
+ if character_range not in seen_ranges:
51
+ seen_ranges[character_range] = 0
52
+ seen_ranges[character_range] += 1
53
+ character_count += 1
54
+
55
+ return sorted(
56
+ [
57
+ character_range
58
+ for character_range in seen_ranges
59
+ if seen_ranges[character_range] / character_count >= 0.15
60
+ ]
61
+ )
62
+
63
+
64
+ def unicode_range_languages(primary_range: str) -> list[str]:
65
+ """
66
+ Return inferred languages used with a unicode range.
67
+ """
68
+ languages: list[str] = []
69
+
70
+ for language, characters in FREQUENCIES.items():
71
+ for character in characters:
72
+ if unicode_range(character) == primary_range:
73
+ languages.append(language)
74
+ break
75
+
76
+ return languages
77
+
78
+
79
+ @lru_cache()
80
+ def encoding_languages(iana_name: str) -> list[str]:
81
+ """
82
+ Single-byte encoding language association. Some code page are heavily linked to particular language(s).
83
+ This function does the correspondence.
84
+ """
85
+ unicode_ranges: list[str] = encoding_unicode_range(iana_name)
86
+ primary_range: str | None = None
87
+
88
+ for specified_range in unicode_ranges:
89
+ if "Latin" not in specified_range:
90
+ primary_range = specified_range
91
+ break
92
+
93
+ if primary_range is None:
94
+ return ["Latin Based"]
95
+
96
+ return unicode_range_languages(primary_range)
97
+
98
+
99
+ @lru_cache()
100
+ def mb_encoding_languages(iana_name: str) -> list[str]:
101
+ """
102
+ Multi-byte encoding language association. Some code page are heavily linked to particular language(s).
103
+ This function does the correspondence.
104
+ """
105
+ if (
106
+ iana_name.startswith("shift_")
107
+ or iana_name.startswith("iso2022_jp")
108
+ or iana_name.startswith("euc_j")
109
+ or iana_name == "cp932"
110
+ ):
111
+ return ["Japanese"]
112
+ if iana_name.startswith("gb") or iana_name in ZH_NAMES:
113
+ return ["Chinese"]
114
+ if iana_name.startswith("iso2022_kr") or iana_name in KO_NAMES:
115
+ return ["Korean"]
116
+
117
+ return []
118
+
119
+
120
+ @lru_cache(maxsize=LANGUAGE_SUPPORTED_COUNT)
121
+ def get_target_features(language: str) -> tuple[bool, bool]:
122
+ """
123
+ Determine main aspects from a supported language if it contains accents and if is pure Latin.
124
+ """
125
+ target_have_accents: bool = False
126
+ target_pure_latin: bool = True
127
+
128
+ for character in FREQUENCIES[language]:
129
+ if not target_have_accents and is_accentuated(character):
130
+ target_have_accents = True
131
+ if target_pure_latin and is_latin(character) is False:
132
+ target_pure_latin = False
133
+
134
+ return target_have_accents, target_pure_latin
135
+
136
+
137
+ def alphabet_languages(
138
+ characters: list[str], ignore_non_latin: bool = False
139
+ ) -> list[str]:
140
+ """
141
+ Return associated languages associated to given characters.
142
+ """
143
+ languages: list[tuple[str, float]] = []
144
+
145
+ source_have_accents = any(is_accentuated(character) for character in characters)
146
+
147
+ for language, language_characters in FREQUENCIES.items():
148
+ target_have_accents, target_pure_latin = get_target_features(language)
149
+
150
+ if ignore_non_latin and target_pure_latin is False:
151
+ continue
152
+
153
+ if target_have_accents is False and source_have_accents:
154
+ continue
155
+
156
+ character_count: int = len(language_characters)
157
+
158
+ character_match_count: int = len(
159
+ [c for c in language_characters if c in characters]
160
+ )
161
+
162
+ ratio: float = character_match_count / character_count
163
+
164
+ if ratio >= 0.2:
165
+ languages.append((language, ratio))
166
+
167
+ languages = sorted(languages, key=lambda x: x[1], reverse=True)
168
+
169
+ return [compatible_language[0] for compatible_language in languages]
170
+
171
+
172
+ def characters_popularity_compare(
173
+ language: str, ordered_characters: list[str]
174
+ ) -> float:
175
+ """
176
+ Determine if a ordered characters list (by occurrence from most appearance to rarest) match a particular language.
177
+ The result is a ratio between 0. (absolutely no correspondence) and 1. (near perfect fit).
178
+ Beware that is function is not strict on the match in order to ease the detection. (Meaning close match is 1.)
179
+ """
180
+ if language not in FREQUENCIES:
181
+ raise ValueError(f"{language} not available")
182
+
183
+ character_approved_count: int = 0
184
+ FREQUENCIES_language_set = set(FREQUENCIES[language])
185
+
186
+ ordered_characters_count: int = len(ordered_characters)
187
+ target_language_characters_count: int = len(FREQUENCIES[language])
188
+
189
+ large_alphabet: bool = target_language_characters_count > 26
190
+
191
+ for character, character_rank in zip(
192
+ ordered_characters, range(0, ordered_characters_count)
193
+ ):
194
+ if character not in FREQUENCIES_language_set:
195
+ continue
196
+
197
+ character_rank_in_language: int = FREQUENCIES[language].index(character)
198
+ expected_projection_ratio: float = (
199
+ target_language_characters_count / ordered_characters_count
200
+ )
201
+ character_rank_projection: int = int(character_rank * expected_projection_ratio)
202
+
203
+ if (
204
+ large_alphabet is False
205
+ and abs(character_rank_projection - character_rank_in_language) > 4
206
+ ):
207
+ continue
208
+
209
+ if (
210
+ large_alphabet is True
211
+ and abs(character_rank_projection - character_rank_in_language)
212
+ < target_language_characters_count / 3
213
+ ):
214
+ character_approved_count += 1
215
+ continue
216
+
217
+ characters_before_source: list[str] = FREQUENCIES[language][
218
+ 0:character_rank_in_language
219
+ ]
220
+ characters_after_source: list[str] = FREQUENCIES[language][
221
+ character_rank_in_language:
222
+ ]
223
+ characters_before: list[str] = ordered_characters[0:character_rank]
224
+ characters_after: list[str] = ordered_characters[character_rank:]
225
+
226
+ before_match_count: int = len(
227
+ set(characters_before) & set(characters_before_source)
228
+ )
229
+
230
+ after_match_count: int = len(
231
+ set(characters_after) & set(characters_after_source)
232
+ )
233
+
234
+ if len(characters_before_source) == 0 and before_match_count <= 4:
235
+ character_approved_count += 1
236
+ continue
237
+
238
+ if len(characters_after_source) == 0 and after_match_count <= 4:
239
+ character_approved_count += 1
240
+ continue
241
+
242
+ if (
243
+ before_match_count / len(characters_before_source) >= 0.4
244
+ or after_match_count / len(characters_after_source) >= 0.4
245
+ ):
246
+ character_approved_count += 1
247
+ continue
248
+
249
+ return character_approved_count / len(ordered_characters)
250
+
251
+
252
+ def alpha_unicode_split(decoded_sequence: str) -> list[str]:
253
+ """
254
+ Given a decoded text sequence, return a list of str. Unicode range / alphabet separation.
255
+ Ex. a text containing English/Latin with a bit a Hebrew will return two items in the resulting list;
256
+ One containing the latin letters and the other hebrew.
257
+ """
258
+ layers: dict[str, str] = {}
259
+
260
+ for character in decoded_sequence:
261
+ if character.isalpha() is False:
262
+ continue
263
+
264
+ character_range: str | None = unicode_range(character)
265
+
266
+ if character_range is None:
267
+ continue
268
+
269
+ layer_target_range: str | None = None
270
+
271
+ for discovered_range in layers:
272
+ if (
273
+ is_suspiciously_successive_range(discovered_range, character_range)
274
+ is False
275
+ ):
276
+ layer_target_range = discovered_range
277
+ break
278
+
279
+ if layer_target_range is None:
280
+ layer_target_range = character_range
281
+
282
+ if layer_target_range not in layers:
283
+ layers[layer_target_range] = character.lower()
284
+ continue
285
+
286
+ layers[layer_target_range] += character.lower()
287
+
288
+ return list(layers.values())
289
+
290
+
291
+ def merge_coherence_ratios(results: list[CoherenceMatches]) -> CoherenceMatches:
292
+ """
293
+ This function merge results previously given by the function coherence_ratio.
294
+ The return type is the same as coherence_ratio.
295
+ """
296
+ per_language_ratios: dict[str, list[float]] = {}
297
+ for result in results:
298
+ for sub_result in result:
299
+ language, ratio = sub_result
300
+ if language not in per_language_ratios:
301
+ per_language_ratios[language] = [ratio]
302
+ continue
303
+ per_language_ratios[language].append(ratio)
304
+
305
+ merge = [
306
+ (
307
+ language,
308
+ round(
309
+ sum(per_language_ratios[language]) / len(per_language_ratios[language]),
310
+ 4,
311
+ ),
312
+ )
313
+ for language in per_language_ratios
314
+ ]
315
+
316
+ return sorted(merge, key=lambda x: x[1], reverse=True)
317
+
318
+
319
+ def filter_alt_coherence_matches(results: CoherenceMatches) -> CoherenceMatches:
320
+ """
321
+ We shall NOT return "English—" in CoherenceMatches because it is an alternative
322
+ of "English". This function only keeps the best match and remove the em-dash in it.
323
+ """
324
+ index_results: dict[str, list[float]] = dict()
325
+
326
+ for result in results:
327
+ language, ratio = result
328
+ no_em_name: str = language.replace("—", "")
329
+
330
+ if no_em_name not in index_results:
331
+ index_results[no_em_name] = []
332
+
333
+ index_results[no_em_name].append(ratio)
334
+
335
+ if any(len(index_results[e]) > 1 for e in index_results):
336
+ filtered_results: CoherenceMatches = []
337
+
338
+ for language in index_results:
339
+ filtered_results.append((language, max(index_results[language])))
340
+
341
+ return filtered_results
342
+
343
+ return results
344
+
345
+
346
+ @lru_cache(maxsize=2048)
347
+ def coherence_ratio(
348
+ decoded_sequence: str, threshold: float = 0.1, lg_inclusion: str | None = None
349
+ ) -> CoherenceMatches:
350
+ """
351
+ Detect ANY language that can be identified in given sequence. The sequence will be analysed by layers.
352
+ A layer = Character extraction by alphabets/ranges.
353
+ """
354
+
355
+ results: list[tuple[str, float]] = []
356
+ ignore_non_latin: bool = False
357
+
358
+ sufficient_match_count: int = 0
359
+
360
+ lg_inclusion_list = lg_inclusion.split(",") if lg_inclusion is not None else []
361
+ if "Latin Based" in lg_inclusion_list:
362
+ ignore_non_latin = True
363
+ lg_inclusion_list.remove("Latin Based")
364
+
365
+ for layer in alpha_unicode_split(decoded_sequence):
366
+ sequence_frequencies: TypeCounter[str] = Counter(layer)
367
+ most_common = sequence_frequencies.most_common()
368
+
369
+ character_count: int = sum(o for c, o in most_common)
370
+
371
+ if character_count <= TOO_SMALL_SEQUENCE:
372
+ continue
373
+
374
+ popular_character_ordered: list[str] = [c for c, o in most_common]
375
+
376
+ for language in lg_inclusion_list or alphabet_languages(
377
+ popular_character_ordered, ignore_non_latin
378
+ ):
379
+ ratio: float = characters_popularity_compare(
380
+ language, popular_character_ordered
381
+ )
382
+
383
+ if ratio < threshold:
384
+ continue
385
+ elif ratio >= 0.8:
386
+ sufficient_match_count += 1
387
+
388
+ results.append((language, round(ratio, 4)))
389
+
390
+ if sufficient_match_count >= 3:
391
+ break
392
+
393
+ return sorted(
394
+ filter_alt_coherence_matches(results), key=lambda x: x[1], reverse=True
395
+ )
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/constant.py ADDED
@@ -0,0 +1,1998 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from codecs import BOM_UTF8, BOM_UTF16_BE, BOM_UTF16_LE, BOM_UTF32_BE, BOM_UTF32_LE
4
+ from encodings.aliases import aliases
5
+ from re import IGNORECASE
6
+ from re import compile as re_compile
7
+
8
+ # Contain for each eligible encoding a list of/item bytes SIG/BOM
9
+ ENCODING_MARKS: dict[str, bytes | list[bytes]] = {
10
+ "utf_8": BOM_UTF8,
11
+ "utf_7": [
12
+ b"\x2b\x2f\x76\x38",
13
+ b"\x2b\x2f\x76\x39",
14
+ b"\x2b\x2f\x76\x2b",
15
+ b"\x2b\x2f\x76\x2f",
16
+ b"\x2b\x2f\x76\x38\x2d",
17
+ ],
18
+ "gb18030": b"\x84\x31\x95\x33",
19
+ "utf_32": [BOM_UTF32_BE, BOM_UTF32_LE],
20
+ "utf_16": [BOM_UTF16_BE, BOM_UTF16_LE],
21
+ }
22
+
23
+ TOO_SMALL_SEQUENCE: int = 32
24
+ TOO_BIG_SEQUENCE: int = int(10e6)
25
+
26
+ UTF8_MAXIMAL_ALLOCATION: int = 1_112_064
27
+
28
+ # Up-to-date Unicode ucd/15.0.0
29
+ UNICODE_RANGES_COMBINED: dict[str, range] = {
30
+ "Control character": range(32),
31
+ "Basic Latin": range(32, 128),
32
+ "Latin-1 Supplement": range(128, 256),
33
+ "Latin Extended-A": range(256, 384),
34
+ "Latin Extended-B": range(384, 592),
35
+ "IPA Extensions": range(592, 688),
36
+ "Spacing Modifier Letters": range(688, 768),
37
+ "Combining Diacritical Marks": range(768, 880),
38
+ "Greek and Coptic": range(880, 1024),
39
+ "Cyrillic": range(1024, 1280),
40
+ "Cyrillic Supplement": range(1280, 1328),
41
+ "Armenian": range(1328, 1424),
42
+ "Hebrew": range(1424, 1536),
43
+ "Arabic": range(1536, 1792),
44
+ "Syriac": range(1792, 1872),
45
+ "Arabic Supplement": range(1872, 1920),
46
+ "Thaana": range(1920, 1984),
47
+ "NKo": range(1984, 2048),
48
+ "Samaritan": range(2048, 2112),
49
+ "Mandaic": range(2112, 2144),
50
+ "Syriac Supplement": range(2144, 2160),
51
+ "Arabic Extended-B": range(2160, 2208),
52
+ "Arabic Extended-A": range(2208, 2304),
53
+ "Devanagari": range(2304, 2432),
54
+ "Bengali": range(2432, 2560),
55
+ "Gurmukhi": range(2560, 2688),
56
+ "Gujarati": range(2688, 2816),
57
+ "Oriya": range(2816, 2944),
58
+ "Tamil": range(2944, 3072),
59
+ "Telugu": range(3072, 3200),
60
+ "Kannada": range(3200, 3328),
61
+ "Malayalam": range(3328, 3456),
62
+ "Sinhala": range(3456, 3584),
63
+ "Thai": range(3584, 3712),
64
+ "Lao": range(3712, 3840),
65
+ "Tibetan": range(3840, 4096),
66
+ "Myanmar": range(4096, 4256),
67
+ "Georgian": range(4256, 4352),
68
+ "Hangul Jamo": range(4352, 4608),
69
+ "Ethiopic": range(4608, 4992),
70
+ "Ethiopic Supplement": range(4992, 5024),
71
+ "Cherokee": range(5024, 5120),
72
+ "Unified Canadian Aboriginal Syllabics": range(5120, 5760),
73
+ "Ogham": range(5760, 5792),
74
+ "Runic": range(5792, 5888),
75
+ "Tagalog": range(5888, 5920),
76
+ "Hanunoo": range(5920, 5952),
77
+ "Buhid": range(5952, 5984),
78
+ "Tagbanwa": range(5984, 6016),
79
+ "Khmer": range(6016, 6144),
80
+ "Mongolian": range(6144, 6320),
81
+ "Unified Canadian Aboriginal Syllabics Extended": range(6320, 6400),
82
+ "Limbu": range(6400, 6480),
83
+ "Tai Le": range(6480, 6528),
84
+ "New Tai Lue": range(6528, 6624),
85
+ "Khmer Symbols": range(6624, 6656),
86
+ "Buginese": range(6656, 6688),
87
+ "Tai Tham": range(6688, 6832),
88
+ "Combining Diacritical Marks Extended": range(6832, 6912),
89
+ "Balinese": range(6912, 7040),
90
+ "Sundanese": range(7040, 7104),
91
+ "Batak": range(7104, 7168),
92
+ "Lepcha": range(7168, 7248),
93
+ "Ol Chiki": range(7248, 7296),
94
+ "Cyrillic Extended-C": range(7296, 7312),
95
+ "Georgian Extended": range(7312, 7360),
96
+ "Sundanese Supplement": range(7360, 7376),
97
+ "Vedic Extensions": range(7376, 7424),
98
+ "Phonetic Extensions": range(7424, 7552),
99
+ "Phonetic Extensions Supplement": range(7552, 7616),
100
+ "Combining Diacritical Marks Supplement": range(7616, 7680),
101
+ "Latin Extended Additional": range(7680, 7936),
102
+ "Greek Extended": range(7936, 8192),
103
+ "General Punctuation": range(8192, 8304),
104
+ "Superscripts and Subscripts": range(8304, 8352),
105
+ "Currency Symbols": range(8352, 8400),
106
+ "Combining Diacritical Marks for Symbols": range(8400, 8448),
107
+ "Letterlike Symbols": range(8448, 8528),
108
+ "Number Forms": range(8528, 8592),
109
+ "Arrows": range(8592, 8704),
110
+ "Mathematical Operators": range(8704, 8960),
111
+ "Miscellaneous Technical": range(8960, 9216),
112
+ "Control Pictures": range(9216, 9280),
113
+ "Optical Character Recognition": range(9280, 9312),
114
+ "Enclosed Alphanumerics": range(9312, 9472),
115
+ "Box Drawing": range(9472, 9600),
116
+ "Block Elements": range(9600, 9632),
117
+ "Geometric Shapes": range(9632, 9728),
118
+ "Miscellaneous Symbols": range(9728, 9984),
119
+ "Dingbats": range(9984, 10176),
120
+ "Miscellaneous Mathematical Symbols-A": range(10176, 10224),
121
+ "Supplemental Arrows-A": range(10224, 10240),
122
+ "Braille Patterns": range(10240, 10496),
123
+ "Supplemental Arrows-B": range(10496, 10624),
124
+ "Miscellaneous Mathematical Symbols-B": range(10624, 10752),
125
+ "Supplemental Mathematical Operators": range(10752, 11008),
126
+ "Miscellaneous Symbols and Arrows": range(11008, 11264),
127
+ "Glagolitic": range(11264, 11360),
128
+ "Latin Extended-C": range(11360, 11392),
129
+ "Coptic": range(11392, 11520),
130
+ "Georgian Supplement": range(11520, 11568),
131
+ "Tifinagh": range(11568, 11648),
132
+ "Ethiopic Extended": range(11648, 11744),
133
+ "Cyrillic Extended-A": range(11744, 11776),
134
+ "Supplemental Punctuation": range(11776, 11904),
135
+ "CJK Radicals Supplement": range(11904, 12032),
136
+ "Kangxi Radicals": range(12032, 12256),
137
+ "Ideographic Description Characters": range(12272, 12288),
138
+ "CJK Symbols and Punctuation": range(12288, 12352),
139
+ "Hiragana": range(12352, 12448),
140
+ "Katakana": range(12448, 12544),
141
+ "Bopomofo": range(12544, 12592),
142
+ "Hangul Compatibility Jamo": range(12592, 12688),
143
+ "Kanbun": range(12688, 12704),
144
+ "Bopomofo Extended": range(12704, 12736),
145
+ "CJK Strokes": range(12736, 12784),
146
+ "Katakana Phonetic Extensions": range(12784, 12800),
147
+ "Enclosed CJK Letters and Months": range(12800, 13056),
148
+ "CJK Compatibility": range(13056, 13312),
149
+ "CJK Unified Ideographs Extension A": range(13312, 19904),
150
+ "Yijing Hexagram Symbols": range(19904, 19968),
151
+ "CJK Unified Ideographs": range(19968, 40960),
152
+ "Yi Syllables": range(40960, 42128),
153
+ "Yi Radicals": range(42128, 42192),
154
+ "Lisu": range(42192, 42240),
155
+ "Vai": range(42240, 42560),
156
+ "Cyrillic Extended-B": range(42560, 42656),
157
+ "Bamum": range(42656, 42752),
158
+ "Modifier Tone Letters": range(42752, 42784),
159
+ "Latin Extended-D": range(42784, 43008),
160
+ "Syloti Nagri": range(43008, 43056),
161
+ "Common Indic Number Forms": range(43056, 43072),
162
+ "Phags-pa": range(43072, 43136),
163
+ "Saurashtra": range(43136, 43232),
164
+ "Devanagari Extended": range(43232, 43264),
165
+ "Kayah Li": range(43264, 43312),
166
+ "Rejang": range(43312, 43360),
167
+ "Hangul Jamo Extended-A": range(43360, 43392),
168
+ "Javanese": range(43392, 43488),
169
+ "Myanmar Extended-B": range(43488, 43520),
170
+ "Cham": range(43520, 43616),
171
+ "Myanmar Extended-A": range(43616, 43648),
172
+ "Tai Viet": range(43648, 43744),
173
+ "Meetei Mayek Extensions": range(43744, 43776),
174
+ "Ethiopic Extended-A": range(43776, 43824),
175
+ "Latin Extended-E": range(43824, 43888),
176
+ "Cherokee Supplement": range(43888, 43968),
177
+ "Meetei Mayek": range(43968, 44032),
178
+ "Hangul Syllables": range(44032, 55216),
179
+ "Hangul Jamo Extended-B": range(55216, 55296),
180
+ "High Surrogates": range(55296, 56192),
181
+ "High Private Use Surrogates": range(56192, 56320),
182
+ "Low Surrogates": range(56320, 57344),
183
+ "Private Use Area": range(57344, 63744),
184
+ "CJK Compatibility Ideographs": range(63744, 64256),
185
+ "Alphabetic Presentation Forms": range(64256, 64336),
186
+ "Arabic Presentation Forms-A": range(64336, 65024),
187
+ "Variation Selectors": range(65024, 65040),
188
+ "Vertical Forms": range(65040, 65056),
189
+ "Combining Half Marks": range(65056, 65072),
190
+ "CJK Compatibility Forms": range(65072, 65104),
191
+ "Small Form Variants": range(65104, 65136),
192
+ "Arabic Presentation Forms-B": range(65136, 65280),
193
+ "Halfwidth and Fullwidth Forms": range(65280, 65520),
194
+ "Specials": range(65520, 65536),
195
+ "Linear B Syllabary": range(65536, 65664),
196
+ "Linear B Ideograms": range(65664, 65792),
197
+ "Aegean Numbers": range(65792, 65856),
198
+ "Ancient Greek Numbers": range(65856, 65936),
199
+ "Ancient Symbols": range(65936, 66000),
200
+ "Phaistos Disc": range(66000, 66048),
201
+ "Lycian": range(66176, 66208),
202
+ "Carian": range(66208, 66272),
203
+ "Coptic Epact Numbers": range(66272, 66304),
204
+ "Old Italic": range(66304, 66352),
205
+ "Gothic": range(66352, 66384),
206
+ "Old Permic": range(66384, 66432),
207
+ "Ugaritic": range(66432, 66464),
208
+ "Old Persian": range(66464, 66528),
209
+ "Deseret": range(66560, 66640),
210
+ "Shavian": range(66640, 66688),
211
+ "Osmanya": range(66688, 66736),
212
+ "Osage": range(66736, 66816),
213
+ "Elbasan": range(66816, 66864),
214
+ "Caucasian Albanian": range(66864, 66928),
215
+ "Vithkuqi": range(66928, 67008),
216
+ "Linear A": range(67072, 67456),
217
+ "Latin Extended-F": range(67456, 67520),
218
+ "Cypriot Syllabary": range(67584, 67648),
219
+ "Imperial Aramaic": range(67648, 67680),
220
+ "Palmyrene": range(67680, 67712),
221
+ "Nabataean": range(67712, 67760),
222
+ "Hatran": range(67808, 67840),
223
+ "Phoenician": range(67840, 67872),
224
+ "Lydian": range(67872, 67904),
225
+ "Meroitic Hieroglyphs": range(67968, 68000),
226
+ "Meroitic Cursive": range(68000, 68096),
227
+ "Kharoshthi": range(68096, 68192),
228
+ "Old South Arabian": range(68192, 68224),
229
+ "Old North Arabian": range(68224, 68256),
230
+ "Manichaean": range(68288, 68352),
231
+ "Avestan": range(68352, 68416),
232
+ "Inscriptional Parthian": range(68416, 68448),
233
+ "Inscriptional Pahlavi": range(68448, 68480),
234
+ "Psalter Pahlavi": range(68480, 68528),
235
+ "Old Turkic": range(68608, 68688),
236
+ "Old Hungarian": range(68736, 68864),
237
+ "Hanifi Rohingya": range(68864, 68928),
238
+ "Rumi Numeral Symbols": range(69216, 69248),
239
+ "Yezidi": range(69248, 69312),
240
+ "Arabic Extended-C": range(69312, 69376),
241
+ "Old Sogdian": range(69376, 69424),
242
+ "Sogdian": range(69424, 69488),
243
+ "Old Uyghur": range(69488, 69552),
244
+ "Chorasmian": range(69552, 69600),
245
+ "Elymaic": range(69600, 69632),
246
+ "Brahmi": range(69632, 69760),
247
+ "Kaithi": range(69760, 69840),
248
+ "Sora Sompeng": range(69840, 69888),
249
+ "Chakma": range(69888, 69968),
250
+ "Mahajani": range(69968, 70016),
251
+ "Sharada": range(70016, 70112),
252
+ "Sinhala Archaic Numbers": range(70112, 70144),
253
+ "Khojki": range(70144, 70224),
254
+ "Multani": range(70272, 70320),
255
+ "Khudawadi": range(70320, 70400),
256
+ "Grantha": range(70400, 70528),
257
+ "Newa": range(70656, 70784),
258
+ "Tirhuta": range(70784, 70880),
259
+ "Siddham": range(71040, 71168),
260
+ "Modi": range(71168, 71264),
261
+ "Mongolian Supplement": range(71264, 71296),
262
+ "Takri": range(71296, 71376),
263
+ "Ahom": range(71424, 71504),
264
+ "Dogra": range(71680, 71760),
265
+ "Warang Citi": range(71840, 71936),
266
+ "Dives Akuru": range(71936, 72032),
267
+ "Nandinagari": range(72096, 72192),
268
+ "Zanabazar Square": range(72192, 72272),
269
+ "Soyombo": range(72272, 72368),
270
+ "Unified Canadian Aboriginal Syllabics Extended-A": range(72368, 72384),
271
+ "Pau Cin Hau": range(72384, 72448),
272
+ "Devanagari Extended-A": range(72448, 72544),
273
+ "Bhaiksuki": range(72704, 72816),
274
+ "Marchen": range(72816, 72896),
275
+ "Masaram Gondi": range(72960, 73056),
276
+ "Gunjala Gondi": range(73056, 73136),
277
+ "Makasar": range(73440, 73472),
278
+ "Kawi": range(73472, 73568),
279
+ "Lisu Supplement": range(73648, 73664),
280
+ "Tamil Supplement": range(73664, 73728),
281
+ "Cuneiform": range(73728, 74752),
282
+ "Cuneiform Numbers and Punctuation": range(74752, 74880),
283
+ "Early Dynastic Cuneiform": range(74880, 75088),
284
+ "Cypro-Minoan": range(77712, 77824),
285
+ "Egyptian Hieroglyphs": range(77824, 78896),
286
+ "Egyptian Hieroglyph Format Controls": range(78896, 78944),
287
+ "Anatolian Hieroglyphs": range(82944, 83584),
288
+ "Bamum Supplement": range(92160, 92736),
289
+ "Mro": range(92736, 92784),
290
+ "Tangsa": range(92784, 92880),
291
+ "Bassa Vah": range(92880, 92928),
292
+ "Pahawh Hmong": range(92928, 93072),
293
+ "Medefaidrin": range(93760, 93856),
294
+ "Miao": range(93952, 94112),
295
+ "Ideographic Symbols and Punctuation": range(94176, 94208),
296
+ "Tangut": range(94208, 100352),
297
+ "Tangut Components": range(100352, 101120),
298
+ "Khitan Small Script": range(101120, 101632),
299
+ "Tangut Supplement": range(101632, 101760),
300
+ "Kana Extended-B": range(110576, 110592),
301
+ "Kana Supplement": range(110592, 110848),
302
+ "Kana Extended-A": range(110848, 110896),
303
+ "Small Kana Extension": range(110896, 110960),
304
+ "Nushu": range(110960, 111360),
305
+ "Duployan": range(113664, 113824),
306
+ "Shorthand Format Controls": range(113824, 113840),
307
+ "Znamenny Musical Notation": range(118528, 118736),
308
+ "Byzantine Musical Symbols": range(118784, 119040),
309
+ "Musical Symbols": range(119040, 119296),
310
+ "Ancient Greek Musical Notation": range(119296, 119376),
311
+ "Kaktovik Numerals": range(119488, 119520),
312
+ "Mayan Numerals": range(119520, 119552),
313
+ "Tai Xuan Jing Symbols": range(119552, 119648),
314
+ "Counting Rod Numerals": range(119648, 119680),
315
+ "Mathematical Alphanumeric Symbols": range(119808, 120832),
316
+ "Sutton SignWriting": range(120832, 121520),
317
+ "Latin Extended-G": range(122624, 122880),
318
+ "Glagolitic Supplement": range(122880, 122928),
319
+ "Cyrillic Extended-D": range(122928, 123024),
320
+ "Nyiakeng Puachue Hmong": range(123136, 123216),
321
+ "Toto": range(123536, 123584),
322
+ "Wancho": range(123584, 123648),
323
+ "Nag Mundari": range(124112, 124160),
324
+ "Ethiopic Extended-B": range(124896, 124928),
325
+ "Mende Kikakui": range(124928, 125152),
326
+ "Adlam": range(125184, 125280),
327
+ "Indic Siyaq Numbers": range(126064, 126144),
328
+ "Ottoman Siyaq Numbers": range(126208, 126288),
329
+ "Arabic Mathematical Alphabetic Symbols": range(126464, 126720),
330
+ "Mahjong Tiles": range(126976, 127024),
331
+ "Domino Tiles": range(127024, 127136),
332
+ "Playing Cards": range(127136, 127232),
333
+ "Enclosed Alphanumeric Supplement": range(127232, 127488),
334
+ "Enclosed Ideographic Supplement": range(127488, 127744),
335
+ "Miscellaneous Symbols and Pictographs": range(127744, 128512),
336
+ "Emoticons range(Emoji)": range(128512, 128592),
337
+ "Ornamental Dingbats": range(128592, 128640),
338
+ "Transport and Map Symbols": range(128640, 128768),
339
+ "Alchemical Symbols": range(128768, 128896),
340
+ "Geometric Shapes Extended": range(128896, 129024),
341
+ "Supplemental Arrows-C": range(129024, 129280),
342
+ "Supplemental Symbols and Pictographs": range(129280, 129536),
343
+ "Chess Symbols": range(129536, 129648),
344
+ "Symbols and Pictographs Extended-A": range(129648, 129792),
345
+ "Symbols for Legacy Computing": range(129792, 130048),
346
+ "CJK Unified Ideographs Extension B": range(131072, 173792),
347
+ "CJK Unified Ideographs Extension C": range(173824, 177984),
348
+ "CJK Unified Ideographs Extension D": range(177984, 178208),
349
+ "CJK Unified Ideographs Extension E": range(178208, 183984),
350
+ "CJK Unified Ideographs Extension F": range(183984, 191472),
351
+ "CJK Compatibility Ideographs Supplement": range(194560, 195104),
352
+ "CJK Unified Ideographs Extension G": range(196608, 201552),
353
+ "CJK Unified Ideographs Extension H": range(201552, 205744),
354
+ "Tags": range(917504, 917632),
355
+ "Variation Selectors Supplement": range(917760, 918000),
356
+ "Supplementary Private Use Area-A": range(983040, 1048576),
357
+ "Supplementary Private Use Area-B": range(1048576, 1114112),
358
+ }
359
+
360
+
361
+ UNICODE_SECONDARY_RANGE_KEYWORD: list[str] = [
362
+ "Supplement",
363
+ "Extended",
364
+ "Extensions",
365
+ "Modifier",
366
+ "Marks",
367
+ "Punctuation",
368
+ "Symbols",
369
+ "Forms",
370
+ "Operators",
371
+ "Miscellaneous",
372
+ "Drawing",
373
+ "Block",
374
+ "Shapes",
375
+ "Supplemental",
376
+ "Tags",
377
+ ]
378
+
379
+ RE_POSSIBLE_ENCODING_INDICATION = re_compile(
380
+ r"(?:(?:encoding)|(?:charset)|(?:coding))(?:[\:= ]{1,10})(?:[\"\']?)([a-zA-Z0-9\-_]+)(?:[\"\']?)",
381
+ IGNORECASE,
382
+ )
383
+
384
+ IANA_NO_ALIASES = [
385
+ "cp720",
386
+ "cp737",
387
+ "cp856",
388
+ "cp874",
389
+ "cp875",
390
+ "cp1006",
391
+ "koi8_r",
392
+ "koi8_t",
393
+ "koi8_u",
394
+ ]
395
+
396
+ IANA_SUPPORTED: list[str] = sorted(
397
+ filter(
398
+ lambda x: x.endswith("_codec") is False
399
+ and x not in {"rot_13", "tactis", "mbcs"},
400
+ list(set(aliases.values())) + IANA_NO_ALIASES,
401
+ )
402
+ )
403
+
404
+ IANA_SUPPORTED_COUNT: int = len(IANA_SUPPORTED)
405
+
406
+ # pre-computed code page that are similar using the function cp_similarity.
407
+ IANA_SUPPORTED_SIMILAR: dict[str, list[str]] = {
408
+ "cp037": ["cp1026", "cp1140", "cp273", "cp500"],
409
+ "cp1026": ["cp037", "cp1140", "cp273", "cp500"],
410
+ "cp1125": ["cp866"],
411
+ "cp1140": ["cp037", "cp1026", "cp273", "cp500"],
412
+ "cp1250": ["iso8859_2"],
413
+ "cp1251": ["kz1048", "ptcp154"],
414
+ "cp1252": ["iso8859_15", "iso8859_9", "latin_1"],
415
+ "cp1253": ["iso8859_7"],
416
+ "cp1254": ["iso8859_15", "iso8859_9", "latin_1"],
417
+ "cp1257": ["iso8859_13"],
418
+ "cp273": ["cp037", "cp1026", "cp1140", "cp500"],
419
+ "cp437": ["cp850", "cp858", "cp860", "cp861", "cp862", "cp863", "cp865"],
420
+ "cp500": ["cp037", "cp1026", "cp1140", "cp273"],
421
+ "cp850": ["cp437", "cp857", "cp858", "cp865"],
422
+ "cp857": ["cp850", "cp858", "cp865"],
423
+ "cp858": ["cp437", "cp850", "cp857", "cp865"],
424
+ "cp860": ["cp437", "cp861", "cp862", "cp863", "cp865"],
425
+ "cp861": ["cp437", "cp860", "cp862", "cp863", "cp865"],
426
+ "cp862": ["cp437", "cp860", "cp861", "cp863", "cp865"],
427
+ "cp863": ["cp437", "cp860", "cp861", "cp862", "cp865"],
428
+ "cp865": ["cp437", "cp850", "cp857", "cp858", "cp860", "cp861", "cp862", "cp863"],
429
+ "cp866": ["cp1125"],
430
+ "iso8859_10": ["iso8859_14", "iso8859_15", "iso8859_4", "iso8859_9", "latin_1"],
431
+ "iso8859_11": ["tis_620"],
432
+ "iso8859_13": ["cp1257"],
433
+ "iso8859_14": [
434
+ "iso8859_10",
435
+ "iso8859_15",
436
+ "iso8859_16",
437
+ "iso8859_3",
438
+ "iso8859_9",
439
+ "latin_1",
440
+ ],
441
+ "iso8859_15": [
442
+ "cp1252",
443
+ "cp1254",
444
+ "iso8859_10",
445
+ "iso8859_14",
446
+ "iso8859_16",
447
+ "iso8859_3",
448
+ "iso8859_9",
449
+ "latin_1",
450
+ ],
451
+ "iso8859_16": [
452
+ "iso8859_14",
453
+ "iso8859_15",
454
+ "iso8859_2",
455
+ "iso8859_3",
456
+ "iso8859_9",
457
+ "latin_1",
458
+ ],
459
+ "iso8859_2": ["cp1250", "iso8859_16", "iso8859_4"],
460
+ "iso8859_3": ["iso8859_14", "iso8859_15", "iso8859_16", "iso8859_9", "latin_1"],
461
+ "iso8859_4": ["iso8859_10", "iso8859_2", "iso8859_9", "latin_1"],
462
+ "iso8859_7": ["cp1253"],
463
+ "iso8859_9": [
464
+ "cp1252",
465
+ "cp1254",
466
+ "cp1258",
467
+ "iso8859_10",
468
+ "iso8859_14",
469
+ "iso8859_15",
470
+ "iso8859_16",
471
+ "iso8859_3",
472
+ "iso8859_4",
473
+ "latin_1",
474
+ ],
475
+ "kz1048": ["cp1251", "ptcp154"],
476
+ "latin_1": [
477
+ "cp1252",
478
+ "cp1254",
479
+ "cp1258",
480
+ "iso8859_10",
481
+ "iso8859_14",
482
+ "iso8859_15",
483
+ "iso8859_16",
484
+ "iso8859_3",
485
+ "iso8859_4",
486
+ "iso8859_9",
487
+ ],
488
+ "mac_iceland": ["mac_roman", "mac_turkish"],
489
+ "mac_roman": ["mac_iceland", "mac_turkish"],
490
+ "mac_turkish": ["mac_iceland", "mac_roman"],
491
+ "ptcp154": ["cp1251", "kz1048"],
492
+ "tis_620": ["iso8859_11"],
493
+ }
494
+
495
+
496
+ CHARDET_CORRESPONDENCE: dict[str, str] = {
497
+ "iso2022_kr": "ISO-2022-KR",
498
+ "iso2022_jp": "ISO-2022-JP",
499
+ "euc_kr": "EUC-KR",
500
+ "tis_620": "TIS-620",
501
+ "utf_32": "UTF-32",
502
+ "euc_jp": "EUC-JP",
503
+ "koi8_r": "KOI8-R",
504
+ "iso8859_1": "ISO-8859-1",
505
+ "iso8859_2": "ISO-8859-2",
506
+ "iso8859_5": "ISO-8859-5",
507
+ "iso8859_6": "ISO-8859-6",
508
+ "iso8859_7": "ISO-8859-7",
509
+ "iso8859_8": "ISO-8859-8",
510
+ "utf_16": "UTF-16",
511
+ "cp855": "IBM855",
512
+ "mac_cyrillic": "MacCyrillic",
513
+ "gb2312": "GB2312",
514
+ "gb18030": "GB18030",
515
+ "cp932": "CP932",
516
+ "cp866": "IBM866",
517
+ "utf_8": "utf-8",
518
+ "utf_8_sig": "UTF-8-SIG",
519
+ "shift_jis": "SHIFT_JIS",
520
+ "big5": "Big5",
521
+ "cp1250": "windows-1250",
522
+ "cp1251": "windows-1251",
523
+ "cp1252": "Windows-1252",
524
+ "cp1253": "windows-1253",
525
+ "cp1255": "windows-1255",
526
+ "cp1256": "windows-1256",
527
+ "cp1254": "Windows-1254",
528
+ "cp949": "CP949",
529
+ }
530
+
531
+
532
+ COMMON_SAFE_ASCII_CHARACTERS: set[str] = {
533
+ "<",
534
+ ">",
535
+ "=",
536
+ ":",
537
+ "/",
538
+ "&",
539
+ ";",
540
+ "{",
541
+ "}",
542
+ "[",
543
+ "]",
544
+ ",",
545
+ "|",
546
+ '"',
547
+ "-",
548
+ "(",
549
+ ")",
550
+ }
551
+
552
+
553
+ KO_NAMES: set[str] = {"johab", "cp949", "euc_kr"}
554
+ ZH_NAMES: set[str] = {"big5", "cp950", "big5hkscs", "hz"}
555
+
556
+ # Logging LEVEL below DEBUG
557
+ TRACE: int = 5
558
+
559
+
560
+ # Language label that contain the em dash "—"
561
+ # character are to be considered alternative seq to origin
562
+ FREQUENCIES: dict[str, list[str]] = {
563
+ "English": [
564
+ "e",
565
+ "a",
566
+ "t",
567
+ "i",
568
+ "o",
569
+ "n",
570
+ "s",
571
+ "r",
572
+ "h",
573
+ "l",
574
+ "d",
575
+ "c",
576
+ "u",
577
+ "m",
578
+ "f",
579
+ "p",
580
+ "g",
581
+ "w",
582
+ "y",
583
+ "b",
584
+ "v",
585
+ "k",
586
+ "x",
587
+ "j",
588
+ "z",
589
+ "q",
590
+ ],
591
+ "English—": [
592
+ "e",
593
+ "a",
594
+ "t",
595
+ "i",
596
+ "o",
597
+ "n",
598
+ "s",
599
+ "r",
600
+ "h",
601
+ "l",
602
+ "d",
603
+ "c",
604
+ "m",
605
+ "u",
606
+ "f",
607
+ "p",
608
+ "g",
609
+ "w",
610
+ "b",
611
+ "y",
612
+ "v",
613
+ "k",
614
+ "j",
615
+ "x",
616
+ "z",
617
+ "q",
618
+ ],
619
+ "German": [
620
+ "e",
621
+ "n",
622
+ "i",
623
+ "r",
624
+ "s",
625
+ "t",
626
+ "a",
627
+ "d",
628
+ "h",
629
+ "u",
630
+ "l",
631
+ "g",
632
+ "o",
633
+ "c",
634
+ "m",
635
+ "b",
636
+ "f",
637
+ "k",
638
+ "w",
639
+ "z",
640
+ "p",
641
+ "v",
642
+ "ü",
643
+ "ä",
644
+ "ö",
645
+ "j",
646
+ ],
647
+ "French": [
648
+ "e",
649
+ "a",
650
+ "s",
651
+ "n",
652
+ "i",
653
+ "t",
654
+ "r",
655
+ "l",
656
+ "u",
657
+ "o",
658
+ "d",
659
+ "c",
660
+ "p",
661
+ "m",
662
+ "é",
663
+ "v",
664
+ "g",
665
+ "f",
666
+ "b",
667
+ "h",
668
+ "q",
669
+ "à",
670
+ "x",
671
+ "è",
672
+ "y",
673
+ "j",
674
+ ],
675
+ "Dutch": [
676
+ "e",
677
+ "n",
678
+ "a",
679
+ "i",
680
+ "r",
681
+ "t",
682
+ "o",
683
+ "d",
684
+ "s",
685
+ "l",
686
+ "g",
687
+ "h",
688
+ "v",
689
+ "m",
690
+ "u",
691
+ "k",
692
+ "c",
693
+ "p",
694
+ "b",
695
+ "w",
696
+ "j",
697
+ "z",
698
+ "f",
699
+ "y",
700
+ "x",
701
+ "ë",
702
+ ],
703
+ "Italian": [
704
+ "e",
705
+ "i",
706
+ "a",
707
+ "o",
708
+ "n",
709
+ "l",
710
+ "t",
711
+ "r",
712
+ "s",
713
+ "c",
714
+ "d",
715
+ "u",
716
+ "p",
717
+ "m",
718
+ "g",
719
+ "v",
720
+ "f",
721
+ "b",
722
+ "z",
723
+ "h",
724
+ "q",
725
+ "è",
726
+ "à",
727
+ "k",
728
+ "y",
729
+ "ò",
730
+ ],
731
+ "Polish": [
732
+ "a",
733
+ "i",
734
+ "o",
735
+ "e",
736
+ "n",
737
+ "r",
738
+ "z",
739
+ "w",
740
+ "s",
741
+ "c",
742
+ "t",
743
+ "k",
744
+ "y",
745
+ "d",
746
+ "p",
747
+ "m",
748
+ "u",
749
+ "l",
750
+ "j",
751
+ "ł",
752
+ "g",
753
+ "b",
754
+ "h",
755
+ "ą",
756
+ "ę",
757
+ "ó",
758
+ ],
759
+ "Spanish": [
760
+ "e",
761
+ "a",
762
+ "o",
763
+ "n",
764
+ "s",
765
+ "r",
766
+ "i",
767
+ "l",
768
+ "d",
769
+ "t",
770
+ "c",
771
+ "u",
772
+ "m",
773
+ "p",
774
+ "b",
775
+ "g",
776
+ "v",
777
+ "f",
778
+ "y",
779
+ "ó",
780
+ "h",
781
+ "q",
782
+ "í",
783
+ "j",
784
+ "z",
785
+ "á",
786
+ ],
787
+ "Russian": [
788
+ "о",
789
+ "а",
790
+ "е",
791
+ "и",
792
+ "н",
793
+ "с",
794
+ "т",
795
+ "р",
796
+ "в",
797
+ "л",
798
+ "к",
799
+ "м",
800
+ "д",
801
+ "п",
802
+ "у",
803
+ "г",
804
+ "я",
805
+ "ы",
806
+ "з",
807
+ "б",
808
+ "й",
809
+ "ь",
810
+ "ч",
811
+ "х",
812
+ "ж",
813
+ "ц",
814
+ ],
815
+ # Jap-Kanji
816
+ "Japanese": [
817
+ "人",
818
+ "一",
819
+ "大",
820
+ "亅",
821
+ "丁",
822
+ "丨",
823
+ "竹",
824
+ "笑",
825
+ "口",
826
+ "日",
827
+ "今",
828
+ "二",
829
+ "彳",
830
+ "行",
831
+ "十",
832
+ "土",
833
+ "丶",
834
+ "寸",
835
+ "寺",
836
+ "時",
837
+ "乙",
838
+ "丿",
839
+ "乂",
840
+ "气",
841
+ "気",
842
+ "冂",
843
+ "巾",
844
+ "亠",
845
+ "市",
846
+ "目",
847
+ "儿",
848
+ "見",
849
+ "八",
850
+ "小",
851
+ "凵",
852
+ "県",
853
+ "月",
854
+ "彐",
855
+ "門",
856
+ "間",
857
+ "木",
858
+ "東",
859
+ "山",
860
+ "出",
861
+ "本",
862
+ "中",
863
+ "刀",
864
+ "分",
865
+ "耳",
866
+ "又",
867
+ "取",
868
+ "最",
869
+ "言",
870
+ "田",
871
+ "心",
872
+ "思",
873
+ "刂",
874
+ "前",
875
+ "京",
876
+ "尹",
877
+ "事",
878
+ "生",
879
+ "厶",
880
+ "云",
881
+ "会",
882
+ "未",
883
+ "来",
884
+ "白",
885
+ "冫",
886
+ "楽",
887
+ "灬",
888
+ "馬",
889
+ "尸",
890
+ "尺",
891
+ "駅",
892
+ "明",
893
+ "耂",
894
+ "者",
895
+ "了",
896
+ "阝",
897
+ "都",
898
+ "高",
899
+ "卜",
900
+ "占",
901
+ "厂",
902
+ "广",
903
+ "店",
904
+ "子",
905
+ "申",
906
+ "奄",
907
+ "亻",
908
+ "俺",
909
+ "上",
910
+ "方",
911
+ "冖",
912
+ "学",
913
+ "衣",
914
+ "艮",
915
+ "食",
916
+ "自",
917
+ ],
918
+ # Jap-Katakana
919
+ "Japanese—": [
920
+ "ー",
921
+ "ン",
922
+ "ス",
923
+ "・",
924
+ "ル",
925
+ "ト",
926
+ "リ",
927
+ "イ",
928
+ "ア",
929
+ "ラ",
930
+ "ッ",
931
+ "ク",
932
+ "ド",
933
+ "シ",
934
+ "レ",
935
+ "ジ",
936
+ "タ",
937
+ "フ",
938
+ "ロ",
939
+ "カ",
940
+ "テ",
941
+ "マ",
942
+ "ィ",
943
+ "グ",
944
+ "バ",
945
+ "ム",
946
+ "プ",
947
+ "オ",
948
+ "コ",
949
+ "デ",
950
+ "ニ",
951
+ "ウ",
952
+ "メ",
953
+ "サ",
954
+ "ビ",
955
+ "ナ",
956
+ "ブ",
957
+ "ャ",
958
+ "エ",
959
+ "ュ",
960
+ "チ",
961
+ "キ",
962
+ "ズ",
963
+ "ダ",
964
+ "パ",
965
+ "ミ",
966
+ "ェ",
967
+ "ョ",
968
+ "ハ",
969
+ "セ",
970
+ "ベ",
971
+ "ガ",
972
+ "モ",
973
+ "ツ",
974
+ "ネ",
975
+ "ボ",
976
+ "ソ",
977
+ "ノ",
978
+ "ァ",
979
+ "ヴ",
980
+ "ワ",
981
+ "ポ",
982
+ "ペ",
983
+ "ピ",
984
+ "ケ",
985
+ "ゴ",
986
+ "ギ",
987
+ "ザ",
988
+ "ホ",
989
+ "ゲ",
990
+ "ォ",
991
+ "ヤ",
992
+ "ヒ",
993
+ "ユ",
994
+ "ヨ",
995
+ "ヘ",
996
+ "ゼ",
997
+ "ヌ",
998
+ "ゥ",
999
+ "ゾ",
1000
+ "ヶ",
1001
+ "ヂ",
1002
+ "ヲ",
1003
+ "ヅ",
1004
+ "ヵ",
1005
+ "ヱ",
1006
+ "ヰ",
1007
+ "ヮ",
1008
+ "ヽ",
1009
+ "゠",
1010
+ "ヾ",
1011
+ "ヷ",
1012
+ "ヿ",
1013
+ "ヸ",
1014
+ "ヹ",
1015
+ "ヺ",
1016
+ ],
1017
+ # Jap-Hiragana
1018
+ "Japanese——": [
1019
+ "の",
1020
+ "に",
1021
+ "る",
1022
+ "た",
1023
+ "と",
1024
+ "は",
1025
+ "し",
1026
+ "い",
1027
+ "を",
1028
+ "で",
1029
+ "て",
1030
+ "が",
1031
+ "な",
1032
+ "れ",
1033
+ "か",
1034
+ "ら",
1035
+ "さ",
1036
+ "っ",
1037
+ "り",
1038
+ "す",
1039
+ "あ",
1040
+ "も",
1041
+ "こ",
1042
+ "ま",
1043
+ "う",
1044
+ "く",
1045
+ "よ",
1046
+ "き",
1047
+ "ん",
1048
+ "め",
1049
+ "お",
1050
+ "け",
1051
+ "そ",
1052
+ "つ",
1053
+ "だ",
1054
+ "や",
1055
+ "え",
1056
+ "ど",
1057
+ "わ",
1058
+ "ち",
1059
+ "み",
1060
+ "せ",
1061
+ "じ",
1062
+ "ば",
1063
+ "へ",
1064
+ "び",
1065
+ "ず",
1066
+ "ろ",
1067
+ "ほ",
1068
+ "げ",
1069
+ "む",
1070
+ "べ",
1071
+ "ひ",
1072
+ "ょ",
1073
+ "ゆ",
1074
+ "ぶ",
1075
+ "ご",
1076
+ "ゃ",
1077
+ "ね",
1078
+ "ふ",
1079
+ "ぐ",
1080
+ "ぎ",
1081
+ "ぼ",
1082
+ "ゅ",
1083
+ "づ",
1084
+ "ざ",
1085
+ "ぞ",
1086
+ "ぬ",
1087
+ "ぜ",
1088
+ "ぱ",
1089
+ "ぽ",
1090
+ "ぷ",
1091
+ "ぴ",
1092
+ "ぃ",
1093
+ "ぁ",
1094
+ "ぇ",
1095
+ "ぺ",
1096
+ "ゞ",
1097
+ "ぢ",
1098
+ "ぉ",
1099
+ "ぅ",
1100
+ "ゐ",
1101
+ "ゝ",
1102
+ "ゑ",
1103
+ "゛",
1104
+ "゜",
1105
+ "ゎ",
1106
+ "ゔ",
1107
+ "゚",
1108
+ "ゟ",
1109
+ "゙",
1110
+ "ゕ",
1111
+ "ゖ",
1112
+ ],
1113
+ "Portuguese": [
1114
+ "a",
1115
+ "e",
1116
+ "o",
1117
+ "s",
1118
+ "i",
1119
+ "r",
1120
+ "d",
1121
+ "n",
1122
+ "t",
1123
+ "m",
1124
+ "u",
1125
+ "c",
1126
+ "l",
1127
+ "p",
1128
+ "g",
1129
+ "v",
1130
+ "b",
1131
+ "f",
1132
+ "h",
1133
+ "ã",
1134
+ "q",
1135
+ "é",
1136
+ "ç",
1137
+ "á",
1138
+ "z",
1139
+ "í",
1140
+ ],
1141
+ "Swedish": [
1142
+ "e",
1143
+ "a",
1144
+ "n",
1145
+ "r",
1146
+ "t",
1147
+ "s",
1148
+ "i",
1149
+ "l",
1150
+ "d",
1151
+ "o",
1152
+ "m",
1153
+ "k",
1154
+ "g",
1155
+ "v",
1156
+ "h",
1157
+ "f",
1158
+ "u",
1159
+ "p",
1160
+ "ä",
1161
+ "c",
1162
+ "b",
1163
+ "ö",
1164
+ "å",
1165
+ "y",
1166
+ "j",
1167
+ "x",
1168
+ ],
1169
+ "Chinese": [
1170
+ "的",
1171
+ "一",
1172
+ "是",
1173
+ "不",
1174
+ "了",
1175
+ "在",
1176
+ "人",
1177
+ "有",
1178
+ "我",
1179
+ "他",
1180
+ "这",
1181
+ "个",
1182
+ "们",
1183
+ "中",
1184
+ "来",
1185
+ "上",
1186
+ "大",
1187
+ "为",
1188
+ "和",
1189
+ "国",
1190
+ "地",
1191
+ "到",
1192
+ "以",
1193
+ "说",
1194
+ "时",
1195
+ "要",
1196
+ "就",
1197
+ "出",
1198
+ "会",
1199
+ "可",
1200
+ "也",
1201
+ "你",
1202
+ "对",
1203
+ "生",
1204
+ "能",
1205
+ "而",
1206
+ "子",
1207
+ "那",
1208
+ "得",
1209
+ "于",
1210
+ "着",
1211
+ "下",
1212
+ "自",
1213
+ "之",
1214
+ "年",
1215
+ "过",
1216
+ "发",
1217
+ "后",
1218
+ "作",
1219
+ "里",
1220
+ "用",
1221
+ "道",
1222
+ "行",
1223
+ "所",
1224
+ "然",
1225
+ "家",
1226
+ "种",
1227
+ "事",
1228
+ "成",
1229
+ "方",
1230
+ "多",
1231
+ "经",
1232
+ "么",
1233
+ "去",
1234
+ "法",
1235
+ "学",
1236
+ "如",
1237
+ "都",
1238
+ "同",
1239
+ "现",
1240
+ "当",
1241
+ "没",
1242
+ "动",
1243
+ "面",
1244
+ "起",
1245
+ "看",
1246
+ "定",
1247
+ "天",
1248
+ "分",
1249
+ "还",
1250
+ "进",
1251
+ "好",
1252
+ "小",
1253
+ "部",
1254
+ "其",
1255
+ "些",
1256
+ "主",
1257
+ "样",
1258
+ "理",
1259
+ "心",
1260
+ "她",
1261
+ "本",
1262
+ "前",
1263
+ "开",
1264
+ "但",
1265
+ "因",
1266
+ "只",
1267
+ "从",
1268
+ "想",
1269
+ "实",
1270
+ ],
1271
+ "Ukrainian": [
1272
+ "о",
1273
+ "а",
1274
+ "н",
1275
+ "і",
1276
+ "и",
1277
+ "р",
1278
+ "в",
1279
+ "т",
1280
+ "е",
1281
+ "с",
1282
+ "к",
1283
+ "л",
1284
+ "у",
1285
+ "д",
1286
+ "м",
1287
+ "п",
1288
+ "з",
1289
+ "я",
1290
+ "ь",
1291
+ "б",
1292
+ "г",
1293
+ "й",
1294
+ "ч",
1295
+ "х",
1296
+ "ц",
1297
+ "ї",
1298
+ ],
1299
+ "Norwegian": [
1300
+ "e",
1301
+ "r",
1302
+ "n",
1303
+ "t",
1304
+ "a",
1305
+ "s",
1306
+ "i",
1307
+ "o",
1308
+ "l",
1309
+ "d",
1310
+ "g",
1311
+ "k",
1312
+ "m",
1313
+ "v",
1314
+ "f",
1315
+ "p",
1316
+ "u",
1317
+ "b",
1318
+ "h",
1319
+ "å",
1320
+ "y",
1321
+ "j",
1322
+ "ø",
1323
+ "c",
1324
+ "æ",
1325
+ "w",
1326
+ ],
1327
+ "Finnish": [
1328
+ "a",
1329
+ "i",
1330
+ "n",
1331
+ "t",
1332
+ "e",
1333
+ "s",
1334
+ "l",
1335
+ "o",
1336
+ "u",
1337
+ "k",
1338
+ "ä",
1339
+ "m",
1340
+ "r",
1341
+ "v",
1342
+ "j",
1343
+ "h",
1344
+ "p",
1345
+ "y",
1346
+ "d",
1347
+ "ö",
1348
+ "g",
1349
+ "c",
1350
+ "b",
1351
+ "f",
1352
+ "w",
1353
+ "z",
1354
+ ],
1355
+ "Vietnamese": [
1356
+ "n",
1357
+ "h",
1358
+ "t",
1359
+ "i",
1360
+ "c",
1361
+ "g",
1362
+ "a",
1363
+ "o",
1364
+ "u",
1365
+ "m",
1366
+ "l",
1367
+ "r",
1368
+ "à",
1369
+ "đ",
1370
+ "s",
1371
+ "e",
1372
+ "v",
1373
+ "p",
1374
+ "b",
1375
+ "y",
1376
+ "ư",
1377
+ "d",
1378
+ "á",
1379
+ "k",
1380
+ "ộ",
1381
+ "ế",
1382
+ ],
1383
+ "Czech": [
1384
+ "o",
1385
+ "e",
1386
+ "a",
1387
+ "n",
1388
+ "t",
1389
+ "s",
1390
+ "i",
1391
+ "l",
1392
+ "v",
1393
+ "r",
1394
+ "k",
1395
+ "d",
1396
+ "u",
1397
+ "m",
1398
+ "p",
1399
+ "í",
1400
+ "c",
1401
+ "h",
1402
+ "z",
1403
+ "á",
1404
+ "y",
1405
+ "j",
1406
+ "b",
1407
+ "ě",
1408
+ "é",
1409
+ "ř",
1410
+ ],
1411
+ "Hungarian": [
1412
+ "e",
1413
+ "a",
1414
+ "t",
1415
+ "l",
1416
+ "s",
1417
+ "n",
1418
+ "k",
1419
+ "r",
1420
+ "i",
1421
+ "o",
1422
+ "z",
1423
+ "á",
1424
+ "é",
1425
+ "g",
1426
+ "m",
1427
+ "b",
1428
+ "y",
1429
+ "v",
1430
+ "d",
1431
+ "h",
1432
+ "u",
1433
+ "p",
1434
+ "j",
1435
+ "ö",
1436
+ "f",
1437
+ "c",
1438
+ ],
1439
+ "Korean": [
1440
+ "이",
1441
+ "다",
1442
+ "에",
1443
+ "의",
1444
+ "는",
1445
+ "로",
1446
+ "하",
1447
+ "을",
1448
+ "가",
1449
+ "고",
1450
+ "지",
1451
+ "서",
1452
+ "한",
1453
+ "은",
1454
+ "기",
1455
+ "으",
1456
+ "년",
1457
+ "대",
1458
+ "사",
1459
+ "시",
1460
+ "를",
1461
+ "리",
1462
+ "도",
1463
+ "인",
1464
+ "스",
1465
+ "일",
1466
+ ],
1467
+ "Indonesian": [
1468
+ "a",
1469
+ "n",
1470
+ "e",
1471
+ "i",
1472
+ "r",
1473
+ "t",
1474
+ "u",
1475
+ "s",
1476
+ "d",
1477
+ "k",
1478
+ "m",
1479
+ "l",
1480
+ "g",
1481
+ "p",
1482
+ "b",
1483
+ "o",
1484
+ "h",
1485
+ "y",
1486
+ "j",
1487
+ "c",
1488
+ "w",
1489
+ "f",
1490
+ "v",
1491
+ "z",
1492
+ "x",
1493
+ "q",
1494
+ ],
1495
+ "Turkish": [
1496
+ "a",
1497
+ "e",
1498
+ "i",
1499
+ "n",
1500
+ "r",
1501
+ "l",
1502
+ "ı",
1503
+ "k",
1504
+ "d",
1505
+ "t",
1506
+ "s",
1507
+ "m",
1508
+ "y",
1509
+ "u",
1510
+ "o",
1511
+ "b",
1512
+ "ü",
1513
+ "ş",
1514
+ "v",
1515
+ "g",
1516
+ "z",
1517
+ "h",
1518
+ "c",
1519
+ "p",
1520
+ "ç",
1521
+ "ğ",
1522
+ ],
1523
+ "Romanian": [
1524
+ "e",
1525
+ "i",
1526
+ "a",
1527
+ "r",
1528
+ "n",
1529
+ "t",
1530
+ "u",
1531
+ "l",
1532
+ "o",
1533
+ "c",
1534
+ "s",
1535
+ "d",
1536
+ "p",
1537
+ "m",
1538
+ "ă",
1539
+ "f",
1540
+ "v",
1541
+ "î",
1542
+ "g",
1543
+ "b",
1544
+ "ș",
1545
+ "ț",
1546
+ "z",
1547
+ "h",
1548
+ "â",
1549
+ "j",
1550
+ ],
1551
+ "Farsi": [
1552
+ "ا",
1553
+ "ی",
1554
+ "ر",
1555
+ "د",
1556
+ "ن",
1557
+ "ه",
1558
+ "و",
1559
+ "م",
1560
+ "ت",
1561
+ "ب",
1562
+ "س",
1563
+ "ل",
1564
+ "ک",
1565
+ "ش",
1566
+ "ز",
1567
+ "ف",
1568
+ "گ",
1569
+ "ع",
1570
+ "خ",
1571
+ "ق",
1572
+ "ج",
1573
+ "آ",
1574
+ "پ",
1575
+ "ح",
1576
+ "ط",
1577
+ "ص",
1578
+ ],
1579
+ "Arabic": [
1580
+ "ا",
1581
+ "ل",
1582
+ "ي",
1583
+ "م",
1584
+ "و",
1585
+ "ن",
1586
+ "ر",
1587
+ "ت",
1588
+ "ب",
1589
+ "ة",
1590
+ "ع",
1591
+ "د",
1592
+ "س",
1593
+ "ف",
1594
+ "ه",
1595
+ "ك",
1596
+ "ق",
1597
+ "أ",
1598
+ "ح",
1599
+ "ج",
1600
+ "ش",
1601
+ "ط",
1602
+ "ص",
1603
+ "ى",
1604
+ "خ",
1605
+ "إ",
1606
+ ],
1607
+ "Danish": [
1608
+ "e",
1609
+ "r",
1610
+ "n",
1611
+ "t",
1612
+ "a",
1613
+ "i",
1614
+ "s",
1615
+ "d",
1616
+ "l",
1617
+ "o",
1618
+ "g",
1619
+ "m",
1620
+ "k",
1621
+ "f",
1622
+ "v",
1623
+ "u",
1624
+ "b",
1625
+ "h",
1626
+ "p",
1627
+ "å",
1628
+ "y",
1629
+ "ø",
1630
+ "æ",
1631
+ "c",
1632
+ "j",
1633
+ "w",
1634
+ ],
1635
+ "Serbian": [
1636
+ "а",
1637
+ "и",
1638
+ "о",
1639
+ "е",
1640
+ "н",
1641
+ "р",
1642
+ "с",
1643
+ "у",
1644
+ "т",
1645
+ "к",
1646
+ "ј",
1647
+ "в",
1648
+ "д",
1649
+ "м",
1650
+ "п",
1651
+ "л",
1652
+ "г",
1653
+ "з",
1654
+ "б",
1655
+ "a",
1656
+ "i",
1657
+ "e",
1658
+ "o",
1659
+ "n",
1660
+ "ц",
1661
+ "ш",
1662
+ ],
1663
+ "Lithuanian": [
1664
+ "i",
1665
+ "a",
1666
+ "s",
1667
+ "o",
1668
+ "r",
1669
+ "e",
1670
+ "t",
1671
+ "n",
1672
+ "u",
1673
+ "k",
1674
+ "m",
1675
+ "l",
1676
+ "p",
1677
+ "v",
1678
+ "d",
1679
+ "j",
1680
+ "g",
1681
+ "ė",
1682
+ "b",
1683
+ "y",
1684
+ "ų",
1685
+ "š",
1686
+ "ž",
1687
+ "c",
1688
+ "ą",
1689
+ "į",
1690
+ ],
1691
+ "Slovene": [
1692
+ "e",
1693
+ "a",
1694
+ "i",
1695
+ "o",
1696
+ "n",
1697
+ "r",
1698
+ "s",
1699
+ "l",
1700
+ "t",
1701
+ "j",
1702
+ "v",
1703
+ "k",
1704
+ "d",
1705
+ "p",
1706
+ "m",
1707
+ "u",
1708
+ "z",
1709
+ "b",
1710
+ "g",
1711
+ "h",
1712
+ "č",
1713
+ "c",
1714
+ "š",
1715
+ "ž",
1716
+ "f",
1717
+ "y",
1718
+ ],
1719
+ "Slovak": [
1720
+ "o",
1721
+ "a",
1722
+ "e",
1723
+ "n",
1724
+ "i",
1725
+ "r",
1726
+ "v",
1727
+ "t",
1728
+ "s",
1729
+ "l",
1730
+ "k",
1731
+ "d",
1732
+ "m",
1733
+ "p",
1734
+ "u",
1735
+ "c",
1736
+ "h",
1737
+ "j",
1738
+ "b",
1739
+ "z",
1740
+ "á",
1741
+ "y",
1742
+ "ý",
1743
+ "í",
1744
+ "č",
1745
+ "é",
1746
+ ],
1747
+ "Hebrew": [
1748
+ "י",
1749
+ "ו",
1750
+ "ה",
1751
+ "ל",
1752
+ "ר",
1753
+ "ב",
1754
+ "ת",
1755
+ "מ",
1756
+ "א",
1757
+ "ש",
1758
+ "נ",
1759
+ "ע",
1760
+ "ם",
1761
+ "ד",
1762
+ "ק",
1763
+ "ח",
1764
+ "פ",
1765
+ "ס",
1766
+ "כ",
1767
+ "ג",
1768
+ "ט",
1769
+ "צ",
1770
+ "ן",
1771
+ "ז",
1772
+ "ך",
1773
+ ],
1774
+ "Bulgarian": [
1775
+ "а",
1776
+ "и",
1777
+ "о",
1778
+ "е",
1779
+ "н",
1780
+ "т",
1781
+ "р",
1782
+ "с",
1783
+ "в",
1784
+ "л",
1785
+ "к",
1786
+ "д",
1787
+ "п",
1788
+ "м",
1789
+ "з",
1790
+ "г",
1791
+ "я",
1792
+ "ъ",
1793
+ "у",
1794
+ "б",
1795
+ "ч",
1796
+ "ц",
1797
+ "й",
1798
+ "ж",
1799
+ "щ",
1800
+ "х",
1801
+ ],
1802
+ "Croatian": [
1803
+ "a",
1804
+ "i",
1805
+ "o",
1806
+ "e",
1807
+ "n",
1808
+ "r",
1809
+ "j",
1810
+ "s",
1811
+ "t",
1812
+ "u",
1813
+ "k",
1814
+ "l",
1815
+ "v",
1816
+ "d",
1817
+ "m",
1818
+ "p",
1819
+ "g",
1820
+ "z",
1821
+ "b",
1822
+ "c",
1823
+ "č",
1824
+ "h",
1825
+ "š",
1826
+ "ž",
1827
+ "ć",
1828
+ "f",
1829
+ ],
1830
+ "Hindi": [
1831
+ "क",
1832
+ "र",
1833
+ "स",
1834
+ "न",
1835
+ "त",
1836
+ "म",
1837
+ "ह",
1838
+ "प",
1839
+ "य",
1840
+ "ल",
1841
+ "व",
1842
+ "ज",
1843
+ "द",
1844
+ "ग",
1845
+ "ब",
1846
+ "श",
1847
+ "ट",
1848
+ "अ",
1849
+ "ए",
1850
+ "थ",
1851
+ "भ",
1852
+ "ड",
1853
+ "च",
1854
+ "ध",
1855
+ "ष",
1856
+ "इ",
1857
+ ],
1858
+ "Estonian": [
1859
+ "a",
1860
+ "i",
1861
+ "e",
1862
+ "s",
1863
+ "t",
1864
+ "l",
1865
+ "u",
1866
+ "n",
1867
+ "o",
1868
+ "k",
1869
+ "r",
1870
+ "d",
1871
+ "m",
1872
+ "v",
1873
+ "g",
1874
+ "p",
1875
+ "j",
1876
+ "h",
1877
+ "ä",
1878
+ "b",
1879
+ "õ",
1880
+ "ü",
1881
+ "f",
1882
+ "c",
1883
+ "ö",
1884
+ "y",
1885
+ ],
1886
+ "Thai": [
1887
+ "า",
1888
+ "น",
1889
+ "ร",
1890
+ "อ",
1891
+ "ก",
1892
+ "เ",
1893
+ "ง",
1894
+ "ม",
1895
+ "ย",
1896
+ "ล",
1897
+ "ว",
1898
+ "ด",
1899
+ "ท",
1900
+ "ส",
1901
+ "ต",
1902
+ "ะ",
1903
+ "ป",
1904
+ "บ",
1905
+ "ค",
1906
+ "ห",
1907
+ "แ",
1908
+ "จ",
1909
+ "พ",
1910
+ "ช",
1911
+ "ข",
1912
+ "ใ",
1913
+ ],
1914
+ "Greek": [
1915
+ "α",
1916
+ "τ",
1917
+ "ο",
1918
+ "ι",
1919
+ "ε",
1920
+ "ν",
1921
+ "ρ",
1922
+ "σ",
1923
+ "κ",
1924
+ "η",
1925
+ "π",
1926
+ "ς",
1927
+ "υ",
1928
+ "μ",
1929
+ "λ",
1930
+ "ί",
1931
+ "ό",
1932
+ "ά",
1933
+ "γ",
1934
+ "έ",
1935
+ "δ",
1936
+ "ή",
1937
+ "ω",
1938
+ "χ",
1939
+ "θ",
1940
+ "ύ",
1941
+ ],
1942
+ "Tamil": [
1943
+ "க",
1944
+ "த",
1945
+ "ப",
1946
+ "ட",
1947
+ "ர",
1948
+ "ம",
1949
+ "ல",
1950
+ "ன",
1951
+ "வ",
1952
+ "ற",
1953
+ "ய",
1954
+ "ள",
1955
+ "ச",
1956
+ "ந",
1957
+ "இ",
1958
+ "ண",
1959
+ "அ",
1960
+ "ஆ",
1961
+ "ழ",
1962
+ "ங",
1963
+ "எ",
1964
+ "உ",
1965
+ "ஒ",
1966
+ "ஸ",
1967
+ ],
1968
+ "Kazakh": [
1969
+ "а",
1970
+ "ы",
1971
+ "е",
1972
+ "н",
1973
+ "т",
1974
+ "р",
1975
+ "л",
1976
+ "і",
1977
+ "д",
1978
+ "с",
1979
+ "м",
1980
+ "қ",
1981
+ "к",
1982
+ "о",
1983
+ "б",
1984
+ "и",
1985
+ "у",
1986
+ "ғ",
1987
+ "ж",
1988
+ "ң",
1989
+ "з",
1990
+ "ш",
1991
+ "й",
1992
+ "п",
1993
+ "г",
1994
+ "ө",
1995
+ ],
1996
+ }
1997
+
1998
+ LANGUAGE_SUPPORTED_COUNT: int = len(FREQUENCIES)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/legacy.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any
4
+ from warnings import warn
5
+
6
+ from .api import from_bytes
7
+ from .constant import CHARDET_CORRESPONDENCE
8
+
9
+ # TODO: remove this check when dropping Python 3.7 support
10
+ if TYPE_CHECKING:
11
+ from typing_extensions import TypedDict
12
+
13
+ class ResultDict(TypedDict):
14
+ encoding: str | None
15
+ language: str
16
+ confidence: float | None
17
+
18
+
19
+ def detect(
20
+ byte_str: bytes, should_rename_legacy: bool = False, **kwargs: Any
21
+ ) -> ResultDict:
22
+ """
23
+ chardet legacy method
24
+ Detect the encoding of the given byte string. It should be mostly backward-compatible.
25
+ Encoding name will match Chardet own writing whenever possible. (Not on encoding name unsupported by it)
26
+ This function is deprecated and should be used to migrate your project easily, consult the documentation for
27
+ further information. Not planned for removal.
28
+
29
+ :param byte_str: The byte sequence to examine.
30
+ :param should_rename_legacy: Should we rename legacy encodings
31
+ to their more modern equivalents?
32
+ """
33
+ if len(kwargs):
34
+ warn(
35
+ f"charset-normalizer disregard arguments '{','.join(list(kwargs.keys()))}' in legacy function detect()"
36
+ )
37
+
38
+ if not isinstance(byte_str, (bytearray, bytes)):
39
+ raise TypeError( # pragma: nocover
40
+ "Expected object of type bytes or bytearray, got: " "{}".format(
41
+ type(byte_str)
42
+ )
43
+ )
44
+
45
+ if isinstance(byte_str, bytearray):
46
+ byte_str = bytes(byte_str)
47
+
48
+ r = from_bytes(byte_str).best()
49
+
50
+ encoding = r.encoding if r is not None else None
51
+ language = r.language if r is not None and r.language != "Unknown" else ""
52
+ confidence = 1.0 - r.chaos if r is not None else None
53
+
54
+ # Note: CharsetNormalizer does not return 'UTF-8-SIG' as the sig get stripped in the detection/normalization process
55
+ # but chardet does return 'utf-8-sig' and it is a valid codec name.
56
+ if r is not None and encoding == "utf_8" and r.bom:
57
+ encoding += "_sig"
58
+
59
+ if should_rename_legacy is False and encoding in CHARDET_CORRESPONDENCE:
60
+ encoding = CHARDET_CORRESPONDENCE[encoding]
61
+
62
+ return {
63
+ "encoding": encoding,
64
+ "language": language,
65
+ "confidence": confidence,
66
+ }
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/md.cpython-312-x86_64-linux-gnu.so ADDED
Binary file (16.1 kB). View file
 
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/md.py ADDED
@@ -0,0 +1,630 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from functools import lru_cache
4
+ from logging import getLogger
5
+
6
+ from .constant import (
7
+ COMMON_SAFE_ASCII_CHARACTERS,
8
+ TRACE,
9
+ UNICODE_SECONDARY_RANGE_KEYWORD,
10
+ )
11
+ from .utils import (
12
+ is_accentuated,
13
+ is_arabic,
14
+ is_arabic_isolated_form,
15
+ is_case_variable,
16
+ is_cjk,
17
+ is_emoticon,
18
+ is_hangul,
19
+ is_hiragana,
20
+ is_katakana,
21
+ is_latin,
22
+ is_punctuation,
23
+ is_separator,
24
+ is_symbol,
25
+ is_thai,
26
+ is_unprintable,
27
+ remove_accent,
28
+ unicode_range,
29
+ )
30
+
31
+
32
+ class MessDetectorPlugin:
33
+ """
34
+ Base abstract class used for mess detection plugins.
35
+ All detectors MUST extend and implement given methods.
36
+ """
37
+
38
+ def eligible(self, character: str) -> bool:
39
+ """
40
+ Determine if given character should be fed in.
41
+ """
42
+ raise NotImplementedError # pragma: nocover
43
+
44
+ def feed(self, character: str) -> None:
45
+ """
46
+ The main routine to be executed upon character.
47
+ Insert the logic in witch the text would be considered chaotic.
48
+ """
49
+ raise NotImplementedError # pragma: nocover
50
+
51
+ def reset(self) -> None: # pragma: no cover
52
+ """
53
+ Permit to reset the plugin to the initial state.
54
+ """
55
+ raise NotImplementedError
56
+
57
+ @property
58
+ def ratio(self) -> float:
59
+ """
60
+ Compute the chaos ratio based on what your feed() has seen.
61
+ Must NOT be lower than 0.; No restriction gt 0.
62
+ """
63
+ raise NotImplementedError # pragma: nocover
64
+
65
+
66
+ class TooManySymbolOrPunctuationPlugin(MessDetectorPlugin):
67
+ def __init__(self) -> None:
68
+ self._punctuation_count: int = 0
69
+ self._symbol_count: int = 0
70
+ self._character_count: int = 0
71
+
72
+ self._last_printable_char: str | None = None
73
+ self._frenzy_symbol_in_word: bool = False
74
+
75
+ def eligible(self, character: str) -> bool:
76
+ return character.isprintable()
77
+
78
+ def feed(self, character: str) -> None:
79
+ self._character_count += 1
80
+
81
+ if (
82
+ character != self._last_printable_char
83
+ and character not in COMMON_SAFE_ASCII_CHARACTERS
84
+ ):
85
+ if is_punctuation(character):
86
+ self._punctuation_count += 1
87
+ elif (
88
+ character.isdigit() is False
89
+ and is_symbol(character)
90
+ and is_emoticon(character) is False
91
+ ):
92
+ self._symbol_count += 2
93
+
94
+ self._last_printable_char = character
95
+
96
+ def reset(self) -> None: # Abstract
97
+ self._punctuation_count = 0
98
+ self._character_count = 0
99
+ self._symbol_count = 0
100
+
101
+ @property
102
+ def ratio(self) -> float:
103
+ if self._character_count == 0:
104
+ return 0.0
105
+
106
+ ratio_of_punctuation: float = (
107
+ self._punctuation_count + self._symbol_count
108
+ ) / self._character_count
109
+
110
+ return ratio_of_punctuation if ratio_of_punctuation >= 0.3 else 0.0
111
+
112
+
113
+ class TooManyAccentuatedPlugin(MessDetectorPlugin):
114
+ def __init__(self) -> None:
115
+ self._character_count: int = 0
116
+ self._accentuated_count: int = 0
117
+
118
+ def eligible(self, character: str) -> bool:
119
+ return character.isalpha()
120
+
121
+ def feed(self, character: str) -> None:
122
+ self._character_count += 1
123
+
124
+ if is_accentuated(character):
125
+ self._accentuated_count += 1
126
+
127
+ def reset(self) -> None: # Abstract
128
+ self._character_count = 0
129
+ self._accentuated_count = 0
130
+
131
+ @property
132
+ def ratio(self) -> float:
133
+ if self._character_count < 8:
134
+ return 0.0
135
+
136
+ ratio_of_accentuation: float = self._accentuated_count / self._character_count
137
+ return ratio_of_accentuation if ratio_of_accentuation >= 0.35 else 0.0
138
+
139
+
140
+ class UnprintablePlugin(MessDetectorPlugin):
141
+ def __init__(self) -> None:
142
+ self._unprintable_count: int = 0
143
+ self._character_count: int = 0
144
+
145
+ def eligible(self, character: str) -> bool:
146
+ return True
147
+
148
+ def feed(self, character: str) -> None:
149
+ if is_unprintable(character):
150
+ self._unprintable_count += 1
151
+ self._character_count += 1
152
+
153
+ def reset(self) -> None: # Abstract
154
+ self._unprintable_count = 0
155
+
156
+ @property
157
+ def ratio(self) -> float:
158
+ if self._character_count == 0:
159
+ return 0.0
160
+
161
+ return (self._unprintable_count * 8) / self._character_count
162
+
163
+
164
+ class SuspiciousDuplicateAccentPlugin(MessDetectorPlugin):
165
+ def __init__(self) -> None:
166
+ self._successive_count: int = 0
167
+ self._character_count: int = 0
168
+
169
+ self._last_latin_character: str | None = None
170
+
171
+ def eligible(self, character: str) -> bool:
172
+ return character.isalpha() and is_latin(character)
173
+
174
+ def feed(self, character: str) -> None:
175
+ self._character_count += 1
176
+ if (
177
+ self._last_latin_character is not None
178
+ and is_accentuated(character)
179
+ and is_accentuated(self._last_latin_character)
180
+ ):
181
+ if character.isupper() and self._last_latin_character.isupper():
182
+ self._successive_count += 1
183
+ # Worse if its the same char duplicated with different accent.
184
+ if remove_accent(character) == remove_accent(self._last_latin_character):
185
+ self._successive_count += 1
186
+ self._last_latin_character = character
187
+
188
+ def reset(self) -> None: # Abstract
189
+ self._successive_count = 0
190
+ self._character_count = 0
191
+ self._last_latin_character = None
192
+
193
+ @property
194
+ def ratio(self) -> float:
195
+ if self._character_count == 0:
196
+ return 0.0
197
+
198
+ return (self._successive_count * 2) / self._character_count
199
+
200
+
201
+ class SuspiciousRange(MessDetectorPlugin):
202
+ def __init__(self) -> None:
203
+ self._suspicious_successive_range_count: int = 0
204
+ self._character_count: int = 0
205
+ self._last_printable_seen: str | None = None
206
+
207
+ def eligible(self, character: str) -> bool:
208
+ return character.isprintable()
209
+
210
+ def feed(self, character: str) -> None:
211
+ self._character_count += 1
212
+
213
+ if (
214
+ character.isspace()
215
+ or is_punctuation(character)
216
+ or character in COMMON_SAFE_ASCII_CHARACTERS
217
+ ):
218
+ self._last_printable_seen = None
219
+ return
220
+
221
+ if self._last_printable_seen is None:
222
+ self._last_printable_seen = character
223
+ return
224
+
225
+ unicode_range_a: str | None = unicode_range(self._last_printable_seen)
226
+ unicode_range_b: str | None = unicode_range(character)
227
+
228
+ if is_suspiciously_successive_range(unicode_range_a, unicode_range_b):
229
+ self._suspicious_successive_range_count += 1
230
+
231
+ self._last_printable_seen = character
232
+
233
+ def reset(self) -> None: # Abstract
234
+ self._character_count = 0
235
+ self._suspicious_successive_range_count = 0
236
+ self._last_printable_seen = None
237
+
238
+ @property
239
+ def ratio(self) -> float:
240
+ if self._character_count <= 13:
241
+ return 0.0
242
+
243
+ ratio_of_suspicious_range_usage: float = (
244
+ self._suspicious_successive_range_count * 2
245
+ ) / self._character_count
246
+
247
+ return ratio_of_suspicious_range_usage
248
+
249
+
250
+ class SuperWeirdWordPlugin(MessDetectorPlugin):
251
+ def __init__(self) -> None:
252
+ self._word_count: int = 0
253
+ self._bad_word_count: int = 0
254
+ self._foreign_long_count: int = 0
255
+
256
+ self._is_current_word_bad: bool = False
257
+ self._foreign_long_watch: bool = False
258
+
259
+ self._character_count: int = 0
260
+ self._bad_character_count: int = 0
261
+
262
+ self._buffer: str = ""
263
+ self._buffer_accent_count: int = 0
264
+ self._buffer_glyph_count: int = 0
265
+
266
+ def eligible(self, character: str) -> bool:
267
+ return True
268
+
269
+ def feed(self, character: str) -> None:
270
+ if character.isalpha():
271
+ self._buffer += character
272
+ if is_accentuated(character):
273
+ self._buffer_accent_count += 1
274
+ if (
275
+ self._foreign_long_watch is False
276
+ and (is_latin(character) is False or is_accentuated(character))
277
+ and is_cjk(character) is False
278
+ and is_hangul(character) is False
279
+ and is_katakana(character) is False
280
+ and is_hiragana(character) is False
281
+ and is_thai(character) is False
282
+ ):
283
+ self._foreign_long_watch = True
284
+ if (
285
+ is_cjk(character)
286
+ or is_hangul(character)
287
+ or is_katakana(character)
288
+ or is_hiragana(character)
289
+ or is_thai(character)
290
+ ):
291
+ self._buffer_glyph_count += 1
292
+ return
293
+ if not self._buffer:
294
+ return
295
+ if (
296
+ character.isspace() or is_punctuation(character) or is_separator(character)
297
+ ) and self._buffer:
298
+ self._word_count += 1
299
+ buffer_length: int = len(self._buffer)
300
+
301
+ self._character_count += buffer_length
302
+
303
+ if buffer_length >= 4:
304
+ if self._buffer_accent_count / buffer_length >= 0.5:
305
+ self._is_current_word_bad = True
306
+ # Word/Buffer ending with an upper case accentuated letter are so rare,
307
+ # that we will consider them all as suspicious. Same weight as foreign_long suspicious.
308
+ elif (
309
+ is_accentuated(self._buffer[-1])
310
+ and self._buffer[-1].isupper()
311
+ and all(_.isupper() for _ in self._buffer) is False
312
+ ):
313
+ self._foreign_long_count += 1
314
+ self._is_current_word_bad = True
315
+ elif self._buffer_glyph_count == 1:
316
+ self._is_current_word_bad = True
317
+ self._foreign_long_count += 1
318
+ if buffer_length >= 24 and self._foreign_long_watch:
319
+ camel_case_dst = [
320
+ i
321
+ for c, i in zip(self._buffer, range(0, buffer_length))
322
+ if c.isupper()
323
+ ]
324
+ probable_camel_cased: bool = False
325
+
326
+ if camel_case_dst and (len(camel_case_dst) / buffer_length <= 0.3):
327
+ probable_camel_cased = True
328
+
329
+ if not probable_camel_cased:
330
+ self._foreign_long_count += 1
331
+ self._is_current_word_bad = True
332
+
333
+ if self._is_current_word_bad:
334
+ self._bad_word_count += 1
335
+ self._bad_character_count += len(self._buffer)
336
+ self._is_current_word_bad = False
337
+
338
+ self._foreign_long_watch = False
339
+ self._buffer = ""
340
+ self._buffer_accent_count = 0
341
+ self._buffer_glyph_count = 0
342
+ elif (
343
+ character not in {"<", ">", "-", "=", "~", "|", "_"}
344
+ and character.isdigit() is False
345
+ and is_symbol(character)
346
+ ):
347
+ self._is_current_word_bad = True
348
+ self._buffer += character
349
+
350
+ def reset(self) -> None: # Abstract
351
+ self._buffer = ""
352
+ self._is_current_word_bad = False
353
+ self._foreign_long_watch = False
354
+ self._bad_word_count = 0
355
+ self._word_count = 0
356
+ self._character_count = 0
357
+ self._bad_character_count = 0
358
+ self._foreign_long_count = 0
359
+
360
+ @property
361
+ def ratio(self) -> float:
362
+ if self._word_count <= 10 and self._foreign_long_count == 0:
363
+ return 0.0
364
+
365
+ return self._bad_character_count / self._character_count
366
+
367
+
368
+ class CjkInvalidStopPlugin(MessDetectorPlugin):
369
+ """
370
+ GB(Chinese) based encoding often render the stop incorrectly when the content does not fit and
371
+ can be easily detected. Searching for the overuse of '丅' and '丄'.
372
+ """
373
+
374
+ def __init__(self) -> None:
375
+ self._wrong_stop_count: int = 0
376
+ self._cjk_character_count: int = 0
377
+
378
+ def eligible(self, character: str) -> bool:
379
+ return True
380
+
381
+ def feed(self, character: str) -> None:
382
+ if character in {"丅", "丄"}:
383
+ self._wrong_stop_count += 1
384
+ return
385
+ if is_cjk(character):
386
+ self._cjk_character_count += 1
387
+
388
+ def reset(self) -> None: # Abstract
389
+ self._wrong_stop_count = 0
390
+ self._cjk_character_count = 0
391
+
392
+ @property
393
+ def ratio(self) -> float:
394
+ if self._cjk_character_count < 16:
395
+ return 0.0
396
+ return self._wrong_stop_count / self._cjk_character_count
397
+
398
+
399
+ class ArchaicUpperLowerPlugin(MessDetectorPlugin):
400
+ def __init__(self) -> None:
401
+ self._buf: bool = False
402
+
403
+ self._character_count_since_last_sep: int = 0
404
+
405
+ self._successive_upper_lower_count: int = 0
406
+ self._successive_upper_lower_count_final: int = 0
407
+
408
+ self._character_count: int = 0
409
+
410
+ self._last_alpha_seen: str | None = None
411
+ self._current_ascii_only: bool = True
412
+
413
+ def eligible(self, character: str) -> bool:
414
+ return True
415
+
416
+ def feed(self, character: str) -> None:
417
+ is_concerned = character.isalpha() and is_case_variable(character)
418
+ chunk_sep = is_concerned is False
419
+
420
+ if chunk_sep and self._character_count_since_last_sep > 0:
421
+ if (
422
+ self._character_count_since_last_sep <= 64
423
+ and character.isdigit() is False
424
+ and self._current_ascii_only is False
425
+ ):
426
+ self._successive_upper_lower_count_final += (
427
+ self._successive_upper_lower_count
428
+ )
429
+
430
+ self._successive_upper_lower_count = 0
431
+ self._character_count_since_last_sep = 0
432
+ self._last_alpha_seen = None
433
+ self._buf = False
434
+ self._character_count += 1
435
+ self._current_ascii_only = True
436
+
437
+ return
438
+
439
+ if self._current_ascii_only is True and character.isascii() is False:
440
+ self._current_ascii_only = False
441
+
442
+ if self._last_alpha_seen is not None:
443
+ if (character.isupper() and self._last_alpha_seen.islower()) or (
444
+ character.islower() and self._last_alpha_seen.isupper()
445
+ ):
446
+ if self._buf is True:
447
+ self._successive_upper_lower_count += 2
448
+ self._buf = False
449
+ else:
450
+ self._buf = True
451
+ else:
452
+ self._buf = False
453
+
454
+ self._character_count += 1
455
+ self._character_count_since_last_sep += 1
456
+ self._last_alpha_seen = character
457
+
458
+ def reset(self) -> None: # Abstract
459
+ self._character_count = 0
460
+ self._character_count_since_last_sep = 0
461
+ self._successive_upper_lower_count = 0
462
+ self._successive_upper_lower_count_final = 0
463
+ self._last_alpha_seen = None
464
+ self._buf = False
465
+ self._current_ascii_only = True
466
+
467
+ @property
468
+ def ratio(self) -> float:
469
+ if self._character_count == 0:
470
+ return 0.0
471
+
472
+ return self._successive_upper_lower_count_final / self._character_count
473
+
474
+
475
+ class ArabicIsolatedFormPlugin(MessDetectorPlugin):
476
+ def __init__(self) -> None:
477
+ self._character_count: int = 0
478
+ self._isolated_form_count: int = 0
479
+
480
+ def reset(self) -> None: # Abstract
481
+ self._character_count = 0
482
+ self._isolated_form_count = 0
483
+
484
+ def eligible(self, character: str) -> bool:
485
+ return is_arabic(character)
486
+
487
+ def feed(self, character: str) -> None:
488
+ self._character_count += 1
489
+
490
+ if is_arabic_isolated_form(character):
491
+ self._isolated_form_count += 1
492
+
493
+ @property
494
+ def ratio(self) -> float:
495
+ if self._character_count < 8:
496
+ return 0.0
497
+
498
+ isolated_form_usage: float = self._isolated_form_count / self._character_count
499
+
500
+ return isolated_form_usage
501
+
502
+
503
+ @lru_cache(maxsize=1024)
504
+ def is_suspiciously_successive_range(
505
+ unicode_range_a: str | None, unicode_range_b: str | None
506
+ ) -> bool:
507
+ """
508
+ Determine if two Unicode range seen next to each other can be considered as suspicious.
509
+ """
510
+ if unicode_range_a is None or unicode_range_b is None:
511
+ return True
512
+
513
+ if unicode_range_a == unicode_range_b:
514
+ return False
515
+
516
+ if "Latin" in unicode_range_a and "Latin" in unicode_range_b:
517
+ return False
518
+
519
+ if "Emoticons" in unicode_range_a or "Emoticons" in unicode_range_b:
520
+ return False
521
+
522
+ # Latin characters can be accompanied with a combining diacritical mark
523
+ # eg. Vietnamese.
524
+ if ("Latin" in unicode_range_a or "Latin" in unicode_range_b) and (
525
+ "Combining" in unicode_range_a or "Combining" in unicode_range_b
526
+ ):
527
+ return False
528
+
529
+ keywords_range_a, keywords_range_b = (
530
+ unicode_range_a.split(" "),
531
+ unicode_range_b.split(" "),
532
+ )
533
+
534
+ for el in keywords_range_a:
535
+ if el in UNICODE_SECONDARY_RANGE_KEYWORD:
536
+ continue
537
+ if el in keywords_range_b:
538
+ return False
539
+
540
+ # Japanese Exception
541
+ range_a_jp_chars, range_b_jp_chars = (
542
+ unicode_range_a
543
+ in (
544
+ "Hiragana",
545
+ "Katakana",
546
+ ),
547
+ unicode_range_b in ("Hiragana", "Katakana"),
548
+ )
549
+ if (range_a_jp_chars or range_b_jp_chars) and (
550
+ "CJK" in unicode_range_a or "CJK" in unicode_range_b
551
+ ):
552
+ return False
553
+ if range_a_jp_chars and range_b_jp_chars:
554
+ return False
555
+
556
+ if "Hangul" in unicode_range_a or "Hangul" in unicode_range_b:
557
+ if "CJK" in unicode_range_a or "CJK" in unicode_range_b:
558
+ return False
559
+ if unicode_range_a == "Basic Latin" or unicode_range_b == "Basic Latin":
560
+ return False
561
+
562
+ # Chinese/Japanese use dedicated range for punctuation and/or separators.
563
+ if ("CJK" in unicode_range_a or "CJK" in unicode_range_b) or (
564
+ unicode_range_a in ["Katakana", "Hiragana"]
565
+ and unicode_range_b in ["Katakana", "Hiragana"]
566
+ ):
567
+ if "Punctuation" in unicode_range_a or "Punctuation" in unicode_range_b:
568
+ return False
569
+ if "Forms" in unicode_range_a or "Forms" in unicode_range_b:
570
+ return False
571
+ if unicode_range_a == "Basic Latin" or unicode_range_b == "Basic Latin":
572
+ return False
573
+
574
+ return True
575
+
576
+
577
+ @lru_cache(maxsize=2048)
578
+ def mess_ratio(
579
+ decoded_sequence: str, maximum_threshold: float = 0.2, debug: bool = False
580
+ ) -> float:
581
+ """
582
+ Compute a mess ratio given a decoded bytes sequence. The maximum threshold does stop the computation earlier.
583
+ """
584
+
585
+ detectors: list[MessDetectorPlugin] = [
586
+ md_class() for md_class in MessDetectorPlugin.__subclasses__()
587
+ ]
588
+
589
+ length: int = len(decoded_sequence) + 1
590
+
591
+ mean_mess_ratio: float = 0.0
592
+
593
+ if length < 512:
594
+ intermediary_mean_mess_ratio_calc: int = 32
595
+ elif length <= 1024:
596
+ intermediary_mean_mess_ratio_calc = 64
597
+ else:
598
+ intermediary_mean_mess_ratio_calc = 128
599
+
600
+ for character, index in zip(decoded_sequence + "\n", range(length)):
601
+ for detector in detectors:
602
+ if detector.eligible(character):
603
+ detector.feed(character)
604
+
605
+ if (
606
+ index > 0 and index % intermediary_mean_mess_ratio_calc == 0
607
+ ) or index == length - 1:
608
+ mean_mess_ratio = sum(dt.ratio for dt in detectors)
609
+
610
+ if mean_mess_ratio >= maximum_threshold:
611
+ break
612
+
613
+ if debug:
614
+ logger = getLogger("charset_normalizer")
615
+
616
+ logger.log(
617
+ TRACE,
618
+ "Mess-detector extended-analysis start. "
619
+ f"intermediary_mean_mess_ratio_calc={intermediary_mean_mess_ratio_calc} mean_mess_ratio={mean_mess_ratio} "
620
+ f"maximum_threshold={maximum_threshold}",
621
+ )
622
+
623
+ if len(decoded_sequence) > 16:
624
+ logger.log(TRACE, f"Starting with: {decoded_sequence[:16]}")
625
+ logger.log(TRACE, f"Ending with: {decoded_sequence[-16::]}")
626
+
627
+ for dt in detectors:
628
+ logger.log(TRACE, f"{dt.__class__}: {dt.ratio}")
629
+
630
+ return round(mean_mess_ratio, 3)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/models.py ADDED
@@ -0,0 +1,360 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from encodings.aliases import aliases
4
+ from hashlib import sha256
5
+ from json import dumps
6
+ from re import sub
7
+ from typing import Any, Iterator, List, Tuple
8
+
9
+ from .constant import RE_POSSIBLE_ENCODING_INDICATION, TOO_BIG_SEQUENCE
10
+ from .utils import iana_name, is_multi_byte_encoding, unicode_range
11
+
12
+
13
+ class CharsetMatch:
14
+ def __init__(
15
+ self,
16
+ payload: bytes,
17
+ guessed_encoding: str,
18
+ mean_mess_ratio: float,
19
+ has_sig_or_bom: bool,
20
+ languages: CoherenceMatches,
21
+ decoded_payload: str | None = None,
22
+ preemptive_declaration: str | None = None,
23
+ ):
24
+ self._payload: bytes = payload
25
+
26
+ self._encoding: str = guessed_encoding
27
+ self._mean_mess_ratio: float = mean_mess_ratio
28
+ self._languages: CoherenceMatches = languages
29
+ self._has_sig_or_bom: bool = has_sig_or_bom
30
+ self._unicode_ranges: list[str] | None = None
31
+
32
+ self._leaves: list[CharsetMatch] = []
33
+ self._mean_coherence_ratio: float = 0.0
34
+
35
+ self._output_payload: bytes | None = None
36
+ self._output_encoding: str | None = None
37
+
38
+ self._string: str | None = decoded_payload
39
+
40
+ self._preemptive_declaration: str | None = preemptive_declaration
41
+
42
+ def __eq__(self, other: object) -> bool:
43
+ if not isinstance(other, CharsetMatch):
44
+ if isinstance(other, str):
45
+ return iana_name(other) == self.encoding
46
+ return False
47
+ return self.encoding == other.encoding and self.fingerprint == other.fingerprint
48
+
49
+ def __lt__(self, other: object) -> bool:
50
+ """
51
+ Implemented to make sorted available upon CharsetMatches items.
52
+ """
53
+ if not isinstance(other, CharsetMatch):
54
+ raise ValueError
55
+
56
+ chaos_difference: float = abs(self.chaos - other.chaos)
57
+ coherence_difference: float = abs(self.coherence - other.coherence)
58
+
59
+ # Below 1% difference --> Use Coherence
60
+ if chaos_difference < 0.01 and coherence_difference > 0.02:
61
+ return self.coherence > other.coherence
62
+ elif chaos_difference < 0.01 and coherence_difference <= 0.02:
63
+ # When having a difficult decision, use the result that decoded as many multi-byte as possible.
64
+ # preserve RAM usage!
65
+ if len(self._payload) >= TOO_BIG_SEQUENCE:
66
+ return self.chaos < other.chaos
67
+ return self.multi_byte_usage > other.multi_byte_usage
68
+
69
+ return self.chaos < other.chaos
70
+
71
+ @property
72
+ def multi_byte_usage(self) -> float:
73
+ return 1.0 - (len(str(self)) / len(self.raw))
74
+
75
+ def __str__(self) -> str:
76
+ # Lazy Str Loading
77
+ if self._string is None:
78
+ self._string = str(self._payload, self._encoding, "strict")
79
+ return self._string
80
+
81
+ def __repr__(self) -> str:
82
+ return f"<CharsetMatch '{self.encoding}' bytes({self.fingerprint})>"
83
+
84
+ def add_submatch(self, other: CharsetMatch) -> None:
85
+ if not isinstance(other, CharsetMatch) or other == self:
86
+ raise ValueError(
87
+ "Unable to add instance <{}> as a submatch of a CharsetMatch".format(
88
+ other.__class__
89
+ )
90
+ )
91
+
92
+ other._string = None # Unload RAM usage; dirty trick.
93
+ self._leaves.append(other)
94
+
95
+ @property
96
+ def encoding(self) -> str:
97
+ return self._encoding
98
+
99
+ @property
100
+ def encoding_aliases(self) -> list[str]:
101
+ """
102
+ Encoding name are known by many name, using this could help when searching for IBM855 when it's listed as CP855.
103
+ """
104
+ also_known_as: list[str] = []
105
+ for u, p in aliases.items():
106
+ if self.encoding == u:
107
+ also_known_as.append(p)
108
+ elif self.encoding == p:
109
+ also_known_as.append(u)
110
+ return also_known_as
111
+
112
+ @property
113
+ def bom(self) -> bool:
114
+ return self._has_sig_or_bom
115
+
116
+ @property
117
+ def byte_order_mark(self) -> bool:
118
+ return self._has_sig_or_bom
119
+
120
+ @property
121
+ def languages(self) -> list[str]:
122
+ """
123
+ Return the complete list of possible languages found in decoded sequence.
124
+ Usually not really useful. Returned list may be empty even if 'language' property return something != 'Unknown'.
125
+ """
126
+ return [e[0] for e in self._languages]
127
+
128
+ @property
129
+ def language(self) -> str:
130
+ """
131
+ Most probable language found in decoded sequence. If none were detected or inferred, the property will return
132
+ "Unknown".
133
+ """
134
+ if not self._languages:
135
+ # Trying to infer the language based on the given encoding
136
+ # Its either English or we should not pronounce ourselves in certain cases.
137
+ if "ascii" in self.could_be_from_charset:
138
+ return "English"
139
+
140
+ # doing it there to avoid circular import
141
+ from charset_normalizer.cd import encoding_languages, mb_encoding_languages
142
+
143
+ languages = (
144
+ mb_encoding_languages(self.encoding)
145
+ if is_multi_byte_encoding(self.encoding)
146
+ else encoding_languages(self.encoding)
147
+ )
148
+
149
+ if len(languages) == 0 or "Latin Based" in languages:
150
+ return "Unknown"
151
+
152
+ return languages[0]
153
+
154
+ return self._languages[0][0]
155
+
156
+ @property
157
+ def chaos(self) -> float:
158
+ return self._mean_mess_ratio
159
+
160
+ @property
161
+ def coherence(self) -> float:
162
+ if not self._languages:
163
+ return 0.0
164
+ return self._languages[0][1]
165
+
166
+ @property
167
+ def percent_chaos(self) -> float:
168
+ return round(self.chaos * 100, ndigits=3)
169
+
170
+ @property
171
+ def percent_coherence(self) -> float:
172
+ return round(self.coherence * 100, ndigits=3)
173
+
174
+ @property
175
+ def raw(self) -> bytes:
176
+ """
177
+ Original untouched bytes.
178
+ """
179
+ return self._payload
180
+
181
+ @property
182
+ def submatch(self) -> list[CharsetMatch]:
183
+ return self._leaves
184
+
185
+ @property
186
+ def has_submatch(self) -> bool:
187
+ return len(self._leaves) > 0
188
+
189
+ @property
190
+ def alphabets(self) -> list[str]:
191
+ if self._unicode_ranges is not None:
192
+ return self._unicode_ranges
193
+ # list detected ranges
194
+ detected_ranges: list[str | None] = [unicode_range(char) for char in str(self)]
195
+ # filter and sort
196
+ self._unicode_ranges = sorted(list({r for r in detected_ranges if r}))
197
+ return self._unicode_ranges
198
+
199
+ @property
200
+ def could_be_from_charset(self) -> list[str]:
201
+ """
202
+ The complete list of encoding that output the exact SAME str result and therefore could be the originating
203
+ encoding.
204
+ This list does include the encoding available in property 'encoding'.
205
+ """
206
+ return [self._encoding] + [m.encoding for m in self._leaves]
207
+
208
+ def output(self, encoding: str = "utf_8") -> bytes:
209
+ """
210
+ Method to get re-encoded bytes payload using given target encoding. Default to UTF-8.
211
+ Any errors will be simply ignored by the encoder NOT replaced.
212
+ """
213
+ if self._output_encoding is None or self._output_encoding != encoding:
214
+ self._output_encoding = encoding
215
+ decoded_string = str(self)
216
+ if (
217
+ self._preemptive_declaration is not None
218
+ and self._preemptive_declaration.lower()
219
+ not in ["utf-8", "utf8", "utf_8"]
220
+ ):
221
+ patched_header = sub(
222
+ RE_POSSIBLE_ENCODING_INDICATION,
223
+ lambda m: m.string[m.span()[0] : m.span()[1]].replace(
224
+ m.groups()[0],
225
+ iana_name(self._output_encoding).replace("_", "-"), # type: ignore[arg-type]
226
+ ),
227
+ decoded_string[:8192],
228
+ count=1,
229
+ )
230
+
231
+ decoded_string = patched_header + decoded_string[8192:]
232
+
233
+ self._output_payload = decoded_string.encode(encoding, "replace")
234
+
235
+ return self._output_payload # type: ignore
236
+
237
+ @property
238
+ def fingerprint(self) -> str:
239
+ """
240
+ Retrieve the unique SHA256 computed using the transformed (re-encoded) payload. Not the original one.
241
+ """
242
+ return sha256(self.output()).hexdigest()
243
+
244
+
245
+ class CharsetMatches:
246
+ """
247
+ Container with every CharsetMatch items ordered by default from most probable to the less one.
248
+ Act like a list(iterable) but does not implements all related methods.
249
+ """
250
+
251
+ def __init__(self, results: list[CharsetMatch] | None = None):
252
+ self._results: list[CharsetMatch] = sorted(results) if results else []
253
+
254
+ def __iter__(self) -> Iterator[CharsetMatch]:
255
+ yield from self._results
256
+
257
+ def __getitem__(self, item: int | str) -> CharsetMatch:
258
+ """
259
+ Retrieve a single item either by its position or encoding name (alias may be used here).
260
+ Raise KeyError upon invalid index or encoding not present in results.
261
+ """
262
+ if isinstance(item, int):
263
+ return self._results[item]
264
+ if isinstance(item, str):
265
+ item = iana_name(item, False)
266
+ for result in self._results:
267
+ if item in result.could_be_from_charset:
268
+ return result
269
+ raise KeyError
270
+
271
+ def __len__(self) -> int:
272
+ return len(self._results)
273
+
274
+ def __bool__(self) -> bool:
275
+ return len(self._results) > 0
276
+
277
+ def append(self, item: CharsetMatch) -> None:
278
+ """
279
+ Insert a single match. Will be inserted accordingly to preserve sort.
280
+ Can be inserted as a submatch.
281
+ """
282
+ if not isinstance(item, CharsetMatch):
283
+ raise ValueError(
284
+ "Cannot append instance '{}' to CharsetMatches".format(
285
+ str(item.__class__)
286
+ )
287
+ )
288
+ # We should disable the submatch factoring when the input file is too heavy (conserve RAM usage)
289
+ if len(item.raw) < TOO_BIG_SEQUENCE:
290
+ for match in self._results:
291
+ if match.fingerprint == item.fingerprint and match.chaos == item.chaos:
292
+ match.add_submatch(item)
293
+ return
294
+ self._results.append(item)
295
+ self._results = sorted(self._results)
296
+
297
+ def best(self) -> CharsetMatch | None:
298
+ """
299
+ Simply return the first match. Strict equivalent to matches[0].
300
+ """
301
+ if not self._results:
302
+ return None
303
+ return self._results[0]
304
+
305
+ def first(self) -> CharsetMatch | None:
306
+ """
307
+ Redundant method, call the method best(). Kept for BC reasons.
308
+ """
309
+ return self.best()
310
+
311
+
312
+ CoherenceMatch = Tuple[str, float]
313
+ CoherenceMatches = List[CoherenceMatch]
314
+
315
+
316
+ class CliDetectionResult:
317
+ def __init__(
318
+ self,
319
+ path: str,
320
+ encoding: str | None,
321
+ encoding_aliases: list[str],
322
+ alternative_encodings: list[str],
323
+ language: str,
324
+ alphabets: list[str],
325
+ has_sig_or_bom: bool,
326
+ chaos: float,
327
+ coherence: float,
328
+ unicode_path: str | None,
329
+ is_preferred: bool,
330
+ ):
331
+ self.path: str = path
332
+ self.unicode_path: str | None = unicode_path
333
+ self.encoding: str | None = encoding
334
+ self.encoding_aliases: list[str] = encoding_aliases
335
+ self.alternative_encodings: list[str] = alternative_encodings
336
+ self.language: str = language
337
+ self.alphabets: list[str] = alphabets
338
+ self.has_sig_or_bom: bool = has_sig_or_bom
339
+ self.chaos: float = chaos
340
+ self.coherence: float = coherence
341
+ self.is_preferred: bool = is_preferred
342
+
343
+ @property
344
+ def __dict__(self) -> dict[str, Any]: # type: ignore
345
+ return {
346
+ "path": self.path,
347
+ "encoding": self.encoding,
348
+ "encoding_aliases": self.encoding_aliases,
349
+ "alternative_encodings": self.alternative_encodings,
350
+ "language": self.language,
351
+ "alphabets": self.alphabets,
352
+ "has_sig_or_bom": self.has_sig_or_bom,
353
+ "chaos": self.chaos,
354
+ "coherence": self.coherence,
355
+ "unicode_path": self.unicode_path,
356
+ "is_preferred": self.is_preferred,
357
+ }
358
+
359
+ def to_json(self) -> str:
360
+ return dumps(self.__dict__, ensure_ascii=True, indent=4)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/py.typed ADDED
File without changes
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/utils.py ADDED
@@ -0,0 +1,408 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import importlib
4
+ import logging
5
+ import unicodedata
6
+ from codecs import IncrementalDecoder
7
+ from encodings.aliases import aliases
8
+ from functools import lru_cache
9
+ from re import findall
10
+ from typing import Generator
11
+
12
+ from _multibytecodec import ( # type: ignore[import-not-found,import]
13
+ MultibyteIncrementalDecoder,
14
+ )
15
+
16
+ from .constant import (
17
+ ENCODING_MARKS,
18
+ IANA_SUPPORTED_SIMILAR,
19
+ RE_POSSIBLE_ENCODING_INDICATION,
20
+ UNICODE_RANGES_COMBINED,
21
+ UNICODE_SECONDARY_RANGE_KEYWORD,
22
+ UTF8_MAXIMAL_ALLOCATION,
23
+ )
24
+
25
+
26
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
27
+ def is_accentuated(character: str) -> bool:
28
+ try:
29
+ description: str = unicodedata.name(character)
30
+ except ValueError: # Defensive: unicode database outdated?
31
+ return False
32
+ return (
33
+ "WITH GRAVE" in description
34
+ or "WITH ACUTE" in description
35
+ or "WITH CEDILLA" in description
36
+ or "WITH DIAERESIS" in description
37
+ or "WITH CIRCUMFLEX" in description
38
+ or "WITH TILDE" in description
39
+ or "WITH MACRON" in description
40
+ or "WITH RING ABOVE" in description
41
+ )
42
+
43
+
44
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
45
+ def remove_accent(character: str) -> str:
46
+ decomposed: str = unicodedata.decomposition(character)
47
+ if not decomposed:
48
+ return character
49
+
50
+ codes: list[str] = decomposed.split(" ")
51
+
52
+ return chr(int(codes[0], 16))
53
+
54
+
55
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
56
+ def unicode_range(character: str) -> str | None:
57
+ """
58
+ Retrieve the Unicode range official name from a single character.
59
+ """
60
+ character_ord: int = ord(character)
61
+
62
+ for range_name, ord_range in UNICODE_RANGES_COMBINED.items():
63
+ if character_ord in ord_range:
64
+ return range_name
65
+
66
+ return None
67
+
68
+
69
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
70
+ def is_latin(character: str) -> bool:
71
+ try:
72
+ description: str = unicodedata.name(character)
73
+ except ValueError: # Defensive: unicode database outdated?
74
+ return False
75
+ return "LATIN" in description
76
+
77
+
78
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
79
+ def is_punctuation(character: str) -> bool:
80
+ character_category: str = unicodedata.category(character)
81
+
82
+ if "P" in character_category:
83
+ return True
84
+
85
+ character_range: str | None = unicode_range(character)
86
+
87
+ if character_range is None:
88
+ return False
89
+
90
+ return "Punctuation" in character_range
91
+
92
+
93
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
94
+ def is_symbol(character: str) -> bool:
95
+ character_category: str = unicodedata.category(character)
96
+
97
+ if "S" in character_category or "N" in character_category:
98
+ return True
99
+
100
+ character_range: str | None = unicode_range(character)
101
+
102
+ if character_range is None:
103
+ return False
104
+
105
+ return "Forms" in character_range and character_category != "Lo"
106
+
107
+
108
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
109
+ def is_emoticon(character: str) -> bool:
110
+ character_range: str | None = unicode_range(character)
111
+
112
+ if character_range is None:
113
+ return False
114
+
115
+ return "Emoticons" in character_range or "Pictographs" in character_range
116
+
117
+
118
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
119
+ def is_separator(character: str) -> bool:
120
+ if character.isspace() or character in {"|", "+", "<", ">"}:
121
+ return True
122
+
123
+ character_category: str = unicodedata.category(character)
124
+
125
+ return "Z" in character_category or character_category in {"Po", "Pd", "Pc"}
126
+
127
+
128
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
129
+ def is_case_variable(character: str) -> bool:
130
+ return character.islower() != character.isupper()
131
+
132
+
133
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
134
+ def is_cjk(character: str) -> bool:
135
+ try:
136
+ character_name = unicodedata.name(character)
137
+ except ValueError: # Defensive: unicode database outdated?
138
+ return False
139
+
140
+ return "CJK" in character_name
141
+
142
+
143
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
144
+ def is_hiragana(character: str) -> bool:
145
+ try:
146
+ character_name = unicodedata.name(character)
147
+ except ValueError: # Defensive: unicode database outdated?
148
+ return False
149
+
150
+ return "HIRAGANA" in character_name
151
+
152
+
153
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
154
+ def is_katakana(character: str) -> bool:
155
+ try:
156
+ character_name = unicodedata.name(character)
157
+ except ValueError: # Defensive: unicode database outdated?
158
+ return False
159
+
160
+ return "KATAKANA" in character_name
161
+
162
+
163
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
164
+ def is_hangul(character: str) -> bool:
165
+ try:
166
+ character_name = unicodedata.name(character)
167
+ except ValueError: # Defensive: unicode database outdated?
168
+ return False
169
+
170
+ return "HANGUL" in character_name
171
+
172
+
173
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
174
+ def is_thai(character: str) -> bool:
175
+ try:
176
+ character_name = unicodedata.name(character)
177
+ except ValueError: # Defensive: unicode database outdated?
178
+ return False
179
+
180
+ return "THAI" in character_name
181
+
182
+
183
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
184
+ def is_arabic(character: str) -> bool:
185
+ try:
186
+ character_name = unicodedata.name(character)
187
+ except ValueError: # Defensive: unicode database outdated?
188
+ return False
189
+
190
+ return "ARABIC" in character_name
191
+
192
+
193
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
194
+ def is_arabic_isolated_form(character: str) -> bool:
195
+ try:
196
+ character_name = unicodedata.name(character)
197
+ except ValueError: # Defensive: unicode database outdated?
198
+ return False
199
+
200
+ return "ARABIC" in character_name and "ISOLATED FORM" in character_name
201
+
202
+
203
+ @lru_cache(maxsize=len(UNICODE_RANGES_COMBINED))
204
+ def is_unicode_range_secondary(range_name: str) -> bool:
205
+ return any(keyword in range_name for keyword in UNICODE_SECONDARY_RANGE_KEYWORD)
206
+
207
+
208
+ @lru_cache(maxsize=UTF8_MAXIMAL_ALLOCATION)
209
+ def is_unprintable(character: str) -> bool:
210
+ return (
211
+ character.isspace() is False # includes \n \t \r \v
212
+ and character.isprintable() is False
213
+ and character != "\x1a" # Why? Its the ASCII substitute character.
214
+ and character != "\ufeff" # bug discovered in Python,
215
+ # Zero Width No-Break Space located in Arabic Presentation Forms-B, Unicode 1.1 not acknowledged as space.
216
+ )
217
+
218
+
219
+ def any_specified_encoding(sequence: bytes, search_zone: int = 8192) -> str | None:
220
+ """
221
+ Extract using ASCII-only decoder any specified encoding in the first n-bytes.
222
+ """
223
+ if not isinstance(sequence, bytes):
224
+ raise TypeError
225
+
226
+ seq_len: int = len(sequence)
227
+
228
+ results: list[str] = findall(
229
+ RE_POSSIBLE_ENCODING_INDICATION,
230
+ sequence[: min(seq_len, search_zone)].decode("ascii", errors="ignore"),
231
+ )
232
+
233
+ if len(results) == 0:
234
+ return None
235
+
236
+ for specified_encoding in results:
237
+ specified_encoding = specified_encoding.lower().replace("-", "_")
238
+
239
+ encoding_alias: str
240
+ encoding_iana: str
241
+
242
+ for encoding_alias, encoding_iana in aliases.items():
243
+ if encoding_alias == specified_encoding:
244
+ return encoding_iana
245
+ if encoding_iana == specified_encoding:
246
+ return encoding_iana
247
+
248
+ return None
249
+
250
+
251
+ @lru_cache(maxsize=128)
252
+ def is_multi_byte_encoding(name: str) -> bool:
253
+ """
254
+ Verify is a specific encoding is a multi byte one based on it IANA name
255
+ """
256
+ return name in {
257
+ "utf_8",
258
+ "utf_8_sig",
259
+ "utf_16",
260
+ "utf_16_be",
261
+ "utf_16_le",
262
+ "utf_32",
263
+ "utf_32_le",
264
+ "utf_32_be",
265
+ "utf_7",
266
+ } or issubclass(
267
+ importlib.import_module(f"encodings.{name}").IncrementalDecoder,
268
+ MultibyteIncrementalDecoder,
269
+ )
270
+
271
+
272
+ def identify_sig_or_bom(sequence: bytes) -> tuple[str | None, bytes]:
273
+ """
274
+ Identify and extract SIG/BOM in given sequence.
275
+ """
276
+
277
+ for iana_encoding in ENCODING_MARKS:
278
+ marks: bytes | list[bytes] = ENCODING_MARKS[iana_encoding]
279
+
280
+ if isinstance(marks, bytes):
281
+ marks = [marks]
282
+
283
+ for mark in marks:
284
+ if sequence.startswith(mark):
285
+ return iana_encoding, mark
286
+
287
+ return None, b""
288
+
289
+
290
+ def should_strip_sig_or_bom(iana_encoding: str) -> bool:
291
+ return iana_encoding not in {"utf_16", "utf_32"}
292
+
293
+
294
+ def iana_name(cp_name: str, strict: bool = True) -> str:
295
+ """Returns the Python normalized encoding name (Not the IANA official name)."""
296
+ cp_name = cp_name.lower().replace("-", "_")
297
+
298
+ encoding_alias: str
299
+ encoding_iana: str
300
+
301
+ for encoding_alias, encoding_iana in aliases.items():
302
+ if cp_name in [encoding_alias, encoding_iana]:
303
+ return encoding_iana
304
+
305
+ if strict:
306
+ raise ValueError(f"Unable to retrieve IANA for '{cp_name}'")
307
+
308
+ return cp_name
309
+
310
+
311
+ def cp_similarity(iana_name_a: str, iana_name_b: str) -> float:
312
+ if is_multi_byte_encoding(iana_name_a) or is_multi_byte_encoding(iana_name_b):
313
+ return 0.0
314
+
315
+ decoder_a = importlib.import_module(f"encodings.{iana_name_a}").IncrementalDecoder
316
+ decoder_b = importlib.import_module(f"encodings.{iana_name_b}").IncrementalDecoder
317
+
318
+ id_a: IncrementalDecoder = decoder_a(errors="ignore")
319
+ id_b: IncrementalDecoder = decoder_b(errors="ignore")
320
+
321
+ character_match_count: int = 0
322
+
323
+ for i in range(255):
324
+ to_be_decoded: bytes = bytes([i])
325
+ if id_a.decode(to_be_decoded) == id_b.decode(to_be_decoded):
326
+ character_match_count += 1
327
+
328
+ return character_match_count / 254
329
+
330
+
331
+ def is_cp_similar(iana_name_a: str, iana_name_b: str) -> bool:
332
+ """
333
+ Determine if two code page are at least 80% similar. IANA_SUPPORTED_SIMILAR dict was generated using
334
+ the function cp_similarity.
335
+ """
336
+ return (
337
+ iana_name_a in IANA_SUPPORTED_SIMILAR
338
+ and iana_name_b in IANA_SUPPORTED_SIMILAR[iana_name_a]
339
+ )
340
+
341
+
342
+ def set_logging_handler(
343
+ name: str = "charset_normalizer",
344
+ level: int = logging.INFO,
345
+ format_string: str = "%(asctime)s | %(levelname)s | %(message)s",
346
+ ) -> None:
347
+ logger = logging.getLogger(name)
348
+ logger.setLevel(level)
349
+
350
+ handler = logging.StreamHandler()
351
+ handler.setFormatter(logging.Formatter(format_string))
352
+ logger.addHandler(handler)
353
+
354
+
355
+ def cut_sequence_chunks(
356
+ sequences: bytes,
357
+ encoding_iana: str,
358
+ offsets: range,
359
+ chunk_size: int,
360
+ bom_or_sig_available: bool,
361
+ strip_sig_or_bom: bool,
362
+ sig_payload: bytes,
363
+ is_multi_byte_decoder: bool,
364
+ decoded_payload: str | None = None,
365
+ ) -> Generator[str, None, None]:
366
+ if decoded_payload and is_multi_byte_decoder is False:
367
+ for i in offsets:
368
+ chunk = decoded_payload[i : i + chunk_size]
369
+ if not chunk:
370
+ break
371
+ yield chunk
372
+ else:
373
+ for i in offsets:
374
+ chunk_end = i + chunk_size
375
+ if chunk_end > len(sequences) + 8:
376
+ continue
377
+
378
+ cut_sequence = sequences[i : i + chunk_size]
379
+
380
+ if bom_or_sig_available and strip_sig_or_bom is False:
381
+ cut_sequence = sig_payload + cut_sequence
382
+
383
+ chunk = cut_sequence.decode(
384
+ encoding_iana,
385
+ errors="ignore" if is_multi_byte_decoder else "strict",
386
+ )
387
+
388
+ # multi-byte bad cutting detector and adjustment
389
+ # not the cleanest way to perform that fix but clever enough for now.
390
+ if is_multi_byte_decoder and i > 0:
391
+ chunk_partial_size_chk: int = min(chunk_size, 16)
392
+
393
+ if (
394
+ decoded_payload
395
+ and chunk[:chunk_partial_size_chk] not in decoded_payload
396
+ ):
397
+ for j in range(i, i - 4, -1):
398
+ cut_sequence = sequences[j:chunk_end]
399
+
400
+ if bom_or_sig_available and strip_sig_or_bom is False:
401
+ cut_sequence = sig_payload + cut_sequence
402
+
403
+ chunk = cut_sequence.decode(encoding_iana, errors="ignore")
404
+
405
+ if chunk[:chunk_partial_size_chk] in decoded_payload:
406
+ break
407
+
408
+ yield chunk
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/charset_normalizer/version.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Expose version
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ __version__ = "3.4.1"
8
+ VERSION = __version__.split(".")
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/METADATA ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.4
2
+ Name: filelock
3
+ Version: 3.17.0
4
+ Summary: A platform independent file lock.
5
+ Project-URL: Documentation, https://py-filelock.readthedocs.io
6
+ Project-URL: Homepage, https://github.com/tox-dev/py-filelock
7
+ Project-URL: Source, https://github.com/tox-dev/py-filelock
8
+ Project-URL: Tracker, https://github.com/tox-dev/py-filelock/issues
9
+ Maintainer-email: Bernát Gábor <gaborjbernat@gmail.com>
10
+ License-Expression: Unlicense
11
+ License-File: LICENSE
12
+ Keywords: application,cache,directory,log,user
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Internet
25
+ Classifier: Topic :: Software Development :: Libraries
26
+ Classifier: Topic :: System
27
+ Requires-Python: >=3.9
28
+ Provides-Extra: docs
29
+ Requires-Dist: furo>=2024.8.6; extra == 'docs'
30
+ Requires-Dist: sphinx-autodoc-typehints>=3; extra == 'docs'
31
+ Requires-Dist: sphinx>=8.1.3; extra == 'docs'
32
+ Provides-Extra: testing
33
+ Requires-Dist: covdefaults>=2.3; extra == 'testing'
34
+ Requires-Dist: coverage>=7.6.10; extra == 'testing'
35
+ Requires-Dist: diff-cover>=9.2.1; extra == 'testing'
36
+ Requires-Dist: pytest-asyncio>=0.25.2; extra == 'testing'
37
+ Requires-Dist: pytest-cov>=6; extra == 'testing'
38
+ Requires-Dist: pytest-mock>=3.14; extra == 'testing'
39
+ Requires-Dist: pytest-timeout>=2.3.1; extra == 'testing'
40
+ Requires-Dist: pytest>=8.3.4; extra == 'testing'
41
+ Requires-Dist: virtualenv>=20.28.1; extra == 'testing'
42
+ Provides-Extra: typing
43
+ Requires-Dist: typing-extensions>=4.12.2; (python_version < '3.11') and extra == 'typing'
44
+ Description-Content-Type: text/markdown
45
+
46
+ # filelock
47
+
48
+ [![PyPI](https://img.shields.io/pypi/v/filelock)](https://pypi.org/project/filelock/)
49
+ [![Supported Python
50
+ versions](https://img.shields.io/pypi/pyversions/filelock.svg)](https://pypi.org/project/filelock/)
51
+ [![Documentation
52
+ status](https://readthedocs.org/projects/py-filelock/badge/?version=latest)](https://py-filelock.readthedocs.io/en/latest/?badge=latest)
53
+ [![Code style:
54
+ black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
55
+ [![Downloads](https://static.pepy.tech/badge/filelock/month)](https://pepy.tech/project/filelock)
56
+ [![check](https://github.com/tox-dev/py-filelock/actions/workflows/check.yaml/badge.svg)](https://github.com/tox-dev/py-filelock/actions/workflows/check.yaml)
57
+
58
+ For more information checkout the [official documentation](https://py-filelock.readthedocs.io/en/latest/index.html).
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/RECORD ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ filelock-3.17.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ filelock-3.17.0.dist-info/METADATA,sha256=gQqzfk2JJpzrBAdeo31F6ZOm_BPZANfa7AgwMPKlXdM,2897
3
+ filelock-3.17.0.dist-info/RECORD,,
4
+ filelock-3.17.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
5
+ filelock-3.17.0.dist-info/licenses/LICENSE,sha256=iNm062BXnBkew5HKBMFhMFctfu3EqG2qWL8oxuFMm80,1210
6
+ filelock/__init__.py,sha256=_t_-OAGXo_qyPa9lNQ1YnzVYEvSW3I0onPqzpomsVVg,1769
7
+ filelock/__pycache__/__init__.cpython-312.pyc,,
8
+ filelock/__pycache__/_api.cpython-312.pyc,,
9
+ filelock/__pycache__/_error.cpython-312.pyc,,
10
+ filelock/__pycache__/_soft.cpython-312.pyc,,
11
+ filelock/__pycache__/_unix.cpython-312.pyc,,
12
+ filelock/__pycache__/_util.cpython-312.pyc,,
13
+ filelock/__pycache__/_windows.cpython-312.pyc,,
14
+ filelock/__pycache__/asyncio.cpython-312.pyc,,
15
+ filelock/__pycache__/version.cpython-312.pyc,,
16
+ filelock/_api.py,sha256=2aATBeJ3-jtMj5OSm7EE539iNaTBsf13KXtcBMoi8oM,14545
17
+ filelock/_error.py,sha256=-5jMcjTu60YAvAO1UbqDD1GIEjVkwr8xCFwDBtMeYDg,787
18
+ filelock/_soft.py,sha256=haqtc_TB_KJbYv2a8iuEAclKuM4fMG1vTcp28sK919c,1711
19
+ filelock/_unix.py,sha256=w9H8dHeJlVFJMxV9LDUx3MYTnfovPmAHKPiZFQ6va8A,2261
20
+ filelock/_util.py,sha256=QHBoNFIYfbAThhotH3Q8E2acFc84wpG49-T-uu017ZE,1715
21
+ filelock/_windows.py,sha256=8k4XIBl_zZVfGC2gz0kEr8DZBvpNa8wdU9qeM1YrBb8,2179
22
+ filelock/asyncio.py,sha256=xjaIxFAjUI7XTlj58Lx7qnqEG9n3PTHjNr5H7EocogU,12465
23
+ filelock/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ filelock/version.py,sha256=KdbrTz1mygb-tPODYZu2E4Sk2KYmeTUCHVpQLRpXAXo,413
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/filelock-3.17.0.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/INSTALLER ADDED
@@ -0,0 +1 @@
 
 
1
+ pip
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/LICENSE ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Copyright (c) 2015 Vitaly Puzrin, Alex Kocharin.
2
+ Copyright (c) 2021 Taneli Hukkinen
3
+
4
+ Permission is hereby granted, free of charge, to any person
5
+ obtaining a copy of this software and associated documentation
6
+ files (the "Software"), to deal in the Software without
7
+ restriction, including without limitation the rights to use,
8
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following
11
+ conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
+ OTHER DEALINGS IN THE SOFTWARE.
24
+
25
+ --------------------------------------------------------------------------------
26
+
27
+ .parse() is based on Joyent's node.js `url` code:
28
+
29
+ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
30
+ Permission is hereby granted, free of charge, to any person obtaining a copy
31
+ of this software and associated documentation files (the "Software"), to
32
+ deal in the Software without restriction, including without limitation the
33
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
34
+ sell copies of the Software, and to permit persons to whom the Software is
35
+ furnished to do so, subject to the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be included in
38
+ all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
41
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
42
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
43
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
44
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
45
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
46
+ IN THE SOFTWARE.
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/METADATA ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Metadata-Version: 2.1
2
+ Name: mdurl
3
+ Version: 0.1.2
4
+ Summary: Markdown URL utilities
5
+ Keywords: markdown,commonmark
6
+ Author-email: Taneli Hukkinen <hukkin@users.noreply.github.com>
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Operating System :: Microsoft :: Windows
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.7
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Typing :: Typed
22
+ Project-URL: Homepage, https://github.com/executablebooks/mdurl
23
+
24
+ # mdurl
25
+
26
+ [![Build Status](https://github.com/executablebooks/mdurl/workflows/Tests/badge.svg?branch=master)](https://github.com/executablebooks/mdurl/actions?query=workflow%3ATests+branch%3Amaster+event%3Apush)
27
+ [![codecov.io](https://codecov.io/gh/executablebooks/mdurl/branch/master/graph/badge.svg)](https://codecov.io/gh/executablebooks/mdurl)
28
+ [![PyPI version](https://img.shields.io/pypi/v/mdurl)](https://pypi.org/project/mdurl)
29
+
30
+ This is a Python port of the JavaScript [mdurl](https://www.npmjs.com/package/mdurl) package.
31
+ See the [upstream README.md file](https://github.com/markdown-it/mdurl/blob/master/README.md) for API documentation.
32
+
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/RECORD ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ mdurl-0.1.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
2
+ mdurl-0.1.2.dist-info/LICENSE,sha256=fGBd9uKGZ6lgMRjpgnT2SknOPu0NJvzM6VNKNF4O-VU,2338
3
+ mdurl-0.1.2.dist-info/METADATA,sha256=tTsp1I9Jk2cFP9o8gefOJ9JVg4Drv4PmYCOwLrfd0l0,1638
4
+ mdurl-0.1.2.dist-info/RECORD,,
5
+ mdurl-0.1.2.dist-info/WHEEL,sha256=4TfKIB_xu-04bc2iKz6_zFt-gEFEEDU_31HGhqzOCE8,81
6
+ mdurl/__init__.py,sha256=1vpE89NyXniIRZNC_4f6BPm3Ub4bPntjfyyhLRR7opU,547
7
+ mdurl/__pycache__/__init__.cpython-312.pyc,,
8
+ mdurl/__pycache__/_decode.cpython-312.pyc,,
9
+ mdurl/__pycache__/_encode.cpython-312.pyc,,
10
+ mdurl/__pycache__/_format.cpython-312.pyc,,
11
+ mdurl/__pycache__/_parse.cpython-312.pyc,,
12
+ mdurl/__pycache__/_url.cpython-312.pyc,,
13
+ mdurl/_decode.py,sha256=3Q_gDQqU__TvDbu7x-b9LjbVl4QWy5g_qFwljcuvN_Y,3004
14
+ mdurl/_encode.py,sha256=goJLUFt1h4rVZNqqm9t15Nw2W-bFXYQEy3aR01ImWvs,2602
15
+ mdurl/_format.py,sha256=xZct0mdePXA0H3kAqxjGtlB5O86G35DAYMGkA44CmB4,626
16
+ mdurl/_parse.py,sha256=ezZSkM2_4NQ2Zx047sEdcJG7NYQRFHiZK7Y8INHFzwY,11374
17
+ mdurl/_url.py,sha256=5kQnRQN2A_G4svLnRzZcG0bfoD9AbBrYDXousDHZ3z0,284
18
+ mdurl/py.typed,sha256=8PjyZ1aVoQpRVvt71muvuq5qE-jTFZkK-GLHkhdebmc,26
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/mdurl-0.1.2.dist-info/WHEEL ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Wheel-Version: 1.0
2
+ Generator: flit 3.7.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/__init__.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Multidict implementation.
2
+
3
+ HTTP Headers and URL query string require specific data structure:
4
+ multidict. It behaves mostly like a dict but it can have
5
+ several values for the same key.
6
+ """
7
+
8
+ from ._abc import MultiMapping, MutableMultiMapping
9
+ from ._compat import USE_EXTENSIONS
10
+
11
+ __all__ = (
12
+ "MultiMapping",
13
+ "MutableMultiMapping",
14
+ "MultiDictProxy",
15
+ "CIMultiDictProxy",
16
+ "MultiDict",
17
+ "CIMultiDict",
18
+ "upstr",
19
+ "istr",
20
+ "getversion",
21
+ )
22
+
23
+ __version__ = "6.1.0"
24
+
25
+
26
+ try:
27
+ if not USE_EXTENSIONS:
28
+ raise ImportError
29
+ from ._multidict import (
30
+ CIMultiDict,
31
+ CIMultiDictProxy,
32
+ MultiDict,
33
+ MultiDictProxy,
34
+ getversion,
35
+ istr,
36
+ )
37
+ except ImportError: # pragma: no cover
38
+ from ._multidict_py import (
39
+ CIMultiDict,
40
+ CIMultiDictProxy,
41
+ MultiDict,
42
+ MultiDictProxy,
43
+ getversion,
44
+ istr,
45
+ )
46
+
47
+
48
+ upstr = istr
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/__init__.pyi ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import abc
2
+ from typing import (
3
+ Generic,
4
+ Iterable,
5
+ Iterator,
6
+ Mapping,
7
+ MutableMapping,
8
+ TypeVar,
9
+ overload,
10
+ )
11
+
12
+ class istr(str): ...
13
+
14
+ upstr = istr
15
+
16
+ _S = str | istr
17
+
18
+ _T = TypeVar("_T")
19
+
20
+ _T_co = TypeVar("_T_co", covariant=True)
21
+
22
+ _D = TypeVar("_D")
23
+
24
+ class MultiMapping(Mapping[_S, _T_co]):
25
+ @overload
26
+ @abc.abstractmethod
27
+ def getall(self, key: _S) -> list[_T_co]: ...
28
+ @overload
29
+ @abc.abstractmethod
30
+ def getall(self, key: _S, default: _D) -> list[_T_co] | _D: ...
31
+ @overload
32
+ @abc.abstractmethod
33
+ def getone(self, key: _S) -> _T_co: ...
34
+ @overload
35
+ @abc.abstractmethod
36
+ def getone(self, key: _S, default: _D) -> _T_co | _D: ...
37
+
38
+ _Arg = (
39
+ Mapping[str, _T]
40
+ | Mapping[istr, _T]
41
+ | dict[str, _T]
42
+ | dict[istr, _T]
43
+ | MultiMapping[_T]
44
+ | Iterable[tuple[str, _T]]
45
+ | Iterable[tuple[istr, _T]]
46
+ )
47
+
48
+ class MutableMultiMapping(MultiMapping[_T], MutableMapping[_S, _T], Generic[_T]):
49
+ @abc.abstractmethod
50
+ def add(self, key: _S, value: _T) -> None: ...
51
+ @abc.abstractmethod
52
+ def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
53
+ @overload
54
+ @abc.abstractmethod
55
+ def popone(self, key: _S) -> _T: ...
56
+ @overload
57
+ @abc.abstractmethod
58
+ def popone(self, key: _S, default: _D) -> _T | _D: ...
59
+ @overload
60
+ @abc.abstractmethod
61
+ def popall(self, key: _S) -> list[_T]: ...
62
+ @overload
63
+ @abc.abstractmethod
64
+ def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
65
+
66
+ class MultiDict(MutableMultiMapping[_T], Generic[_T]):
67
+ def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
68
+ def copy(self) -> MultiDict[_T]: ...
69
+ def __getitem__(self, k: _S) -> _T: ...
70
+ def __setitem__(self, k: _S, v: _T) -> None: ...
71
+ def __delitem__(self, v: _S) -> None: ...
72
+ def __iter__(self) -> Iterator[_S]: ...
73
+ def __len__(self) -> int: ...
74
+ @overload
75
+ def getall(self, key: _S) -> list[_T]: ...
76
+ @overload
77
+ def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
78
+ @overload
79
+ def getone(self, key: _S) -> _T: ...
80
+ @overload
81
+ def getone(self, key: _S, default: _D) -> _T | _D: ...
82
+ def add(self, key: _S, value: _T) -> None: ...
83
+ def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
84
+ @overload
85
+ def popone(self, key: _S) -> _T: ...
86
+ @overload
87
+ def popone(self, key: _S, default: _D) -> _T | _D: ...
88
+ @overload
89
+ def popall(self, key: _S) -> list[_T]: ...
90
+ @overload
91
+ def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
92
+
93
+ class CIMultiDict(MutableMultiMapping[_T], Generic[_T]):
94
+ def __init__(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
95
+ def copy(self) -> CIMultiDict[_T]: ...
96
+ def __getitem__(self, k: _S) -> _T: ...
97
+ def __setitem__(self, k: _S, v: _T) -> None: ...
98
+ def __delitem__(self, v: _S) -> None: ...
99
+ def __iter__(self) -> Iterator[_S]: ...
100
+ def __len__(self) -> int: ...
101
+ @overload
102
+ def getall(self, key: _S) -> list[_T]: ...
103
+ @overload
104
+ def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
105
+ @overload
106
+ def getone(self, key: _S) -> _T: ...
107
+ @overload
108
+ def getone(self, key: _S, default: _D) -> _T | _D: ...
109
+ def add(self, key: _S, value: _T) -> None: ...
110
+ def extend(self, arg: _Arg[_T] = ..., **kwargs: _T) -> None: ...
111
+ @overload
112
+ def popone(self, key: _S) -> _T: ...
113
+ @overload
114
+ def popone(self, key: _S, default: _D) -> _T | _D: ...
115
+ @overload
116
+ def popall(self, key: _S) -> list[_T]: ...
117
+ @overload
118
+ def popall(self, key: _S, default: _D) -> list[_T] | _D: ...
119
+
120
+ class MultiDictProxy(MultiMapping[_T], Generic[_T]):
121
+ def __init__(self, arg: MultiMapping[_T] | MutableMultiMapping[_T]) -> None: ...
122
+ def copy(self) -> MultiDict[_T]: ...
123
+ def __getitem__(self, k: _S) -> _T: ...
124
+ def __iter__(self) -> Iterator[_S]: ...
125
+ def __len__(self) -> int: ...
126
+ @overload
127
+ def getall(self, key: _S) -> list[_T]: ...
128
+ @overload
129
+ def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
130
+ @overload
131
+ def getone(self, key: _S) -> _T: ...
132
+ @overload
133
+ def getone(self, key: _S, default: _D) -> _T | _D: ...
134
+
135
+ class CIMultiDictProxy(MultiMapping[_T], Generic[_T]):
136
+ def __init__(self, arg: MultiMapping[_T] | MutableMultiMapping[_T]) -> None: ...
137
+ def __getitem__(self, k: _S) -> _T: ...
138
+ def __iter__(self) -> Iterator[_S]: ...
139
+ def __len__(self) -> int: ...
140
+ @overload
141
+ def getall(self, key: _S) -> list[_T]: ...
142
+ @overload
143
+ def getall(self, key: _S, default: _D) -> list[_T] | _D: ...
144
+ @overload
145
+ def getone(self, key: _S) -> _T: ...
146
+ @overload
147
+ def getone(self, key: _S, default: _D) -> _T | _D: ...
148
+ def copy(self) -> CIMultiDict[_T]: ...
149
+
150
+ def getversion(
151
+ md: MultiDict[_T] | CIMultiDict[_T] | MultiDictProxy[_T] | CIMultiDictProxy[_T],
152
+ ) -> int: ...
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_abc.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import abc
2
+ import sys
3
+ import types
4
+ from collections.abc import Mapping, MutableMapping
5
+
6
+
7
+ class _TypingMeta(abc.ABCMeta):
8
+ # A fake metaclass to satisfy typing deps in runtime
9
+ # basically MultiMapping[str] and other generic-like type instantiations
10
+ # are emulated.
11
+ # Note: real type hints are provided by __init__.pyi stub file
12
+ if sys.version_info >= (3, 9):
13
+
14
+ def __getitem__(self, key):
15
+ return types.GenericAlias(self, key)
16
+
17
+ else:
18
+
19
+ def __getitem__(self, key):
20
+ return self
21
+
22
+
23
+ class MultiMapping(Mapping, metaclass=_TypingMeta):
24
+ @abc.abstractmethod
25
+ def getall(self, key, default=None):
26
+ raise KeyError
27
+
28
+ @abc.abstractmethod
29
+ def getone(self, key, default=None):
30
+ raise KeyError
31
+
32
+
33
+ class MutableMultiMapping(MultiMapping, MutableMapping):
34
+ @abc.abstractmethod
35
+ def add(self, key, value):
36
+ raise NotImplementedError
37
+
38
+ @abc.abstractmethod
39
+ def extend(self, *args, **kwargs):
40
+ raise NotImplementedError
41
+
42
+ @abc.abstractmethod
43
+ def popone(self, key, default=None):
44
+ raise KeyError
45
+
46
+ @abc.abstractmethod
47
+ def popall(self, key, default=None):
48
+ raise KeyError
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_compat.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import platform
3
+
4
+ NO_EXTENSIONS = bool(os.environ.get("MULTIDICT_NO_EXTENSIONS"))
5
+
6
+ PYPY = platform.python_implementation() == "PyPy"
7
+
8
+ USE_EXTENSIONS = not NO_EXTENSIONS and not PYPY
9
+
10
+ if USE_EXTENSIONS:
11
+ try:
12
+ from . import _multidict # type: ignore[attr-defined] # noqa: F401
13
+ except ImportError:
14
+ USE_EXTENSIONS = False
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_multidict_base.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ from collections.abc import ItemsView, Iterable, KeysView, Set, ValuesView
3
+
4
+ if sys.version_info >= (3, 11):
5
+ from typing import assert_never
6
+ else:
7
+ from typing_extensions import assert_never
8
+
9
+
10
+ def _abc_itemsview_register(view_cls):
11
+ ItemsView.register(view_cls)
12
+
13
+
14
+ def _abc_keysview_register(view_cls):
15
+ KeysView.register(view_cls)
16
+
17
+
18
+ def _abc_valuesview_register(view_cls):
19
+ ValuesView.register(view_cls)
20
+
21
+
22
+ def _viewbaseset_richcmp(view, other, op):
23
+ if op == 0: # <
24
+ if not isinstance(other, Set):
25
+ return NotImplemented
26
+ return len(view) < len(other) and view <= other
27
+ elif op == 1: # <=
28
+ if not isinstance(other, Set):
29
+ return NotImplemented
30
+ if len(view) > len(other):
31
+ return False
32
+ for elem in view:
33
+ if elem not in other:
34
+ return False
35
+ return True
36
+ elif op == 2: # ==
37
+ if not isinstance(other, Set):
38
+ return NotImplemented
39
+ return len(view) == len(other) and view <= other
40
+ elif op == 3: # !=
41
+ return not view == other
42
+ elif op == 4: # >
43
+ if not isinstance(other, Set):
44
+ return NotImplemented
45
+ return len(view) > len(other) and view >= other
46
+ elif op == 5: # >=
47
+ if not isinstance(other, Set):
48
+ return NotImplemented
49
+ if len(view) < len(other):
50
+ return False
51
+ for elem in other:
52
+ if elem not in view:
53
+ return False
54
+ return True
55
+ else: # pragma: no cover
56
+ assert_never(op)
57
+
58
+
59
+ def _viewbaseset_and(view, other):
60
+ if not isinstance(other, Iterable):
61
+ return NotImplemented
62
+ if isinstance(view, Set):
63
+ view = set(iter(view))
64
+ if isinstance(other, Set):
65
+ other = set(iter(other))
66
+ if not isinstance(other, Set):
67
+ other = set(iter(other))
68
+ return view & other
69
+
70
+
71
+ def _viewbaseset_or(view, other):
72
+ if not isinstance(other, Iterable):
73
+ return NotImplemented
74
+ if isinstance(view, Set):
75
+ view = set(iter(view))
76
+ if isinstance(other, Set):
77
+ other = set(iter(other))
78
+ if not isinstance(other, Set):
79
+ other = set(iter(other))
80
+ return view | other
81
+
82
+
83
+ def _viewbaseset_sub(view, other):
84
+ if not isinstance(other, Iterable):
85
+ return NotImplemented
86
+ if isinstance(view, Set):
87
+ view = set(iter(view))
88
+ if isinstance(other, Set):
89
+ other = set(iter(other))
90
+ if not isinstance(other, Set):
91
+ other = set(iter(other))
92
+ return view - other
93
+
94
+
95
+ def _viewbaseset_xor(view, other):
96
+ if not isinstance(other, Iterable):
97
+ return NotImplemented
98
+ if isinstance(view, Set):
99
+ view = set(iter(view))
100
+ if isinstance(other, Set):
101
+ other = set(iter(other))
102
+ if not isinstance(other, Set):
103
+ other = set(iter(other))
104
+ return view ^ other
105
+
106
+
107
+ def _itemsview_isdisjoint(view, other):
108
+ "Return True if two sets have a null intersection."
109
+ for v in other:
110
+ if v in view:
111
+ return False
112
+ return True
113
+
114
+
115
+ def _itemsview_repr(view):
116
+ lst = []
117
+ for k, v in view:
118
+ lst.append("{!r}: {!r}".format(k, v))
119
+ body = ", ".join(lst)
120
+ return "{}({})".format(view.__class__.__name__, body)
121
+
122
+
123
+ def _keysview_isdisjoint(view, other):
124
+ "Return True if two sets have a null intersection."
125
+ for k in other:
126
+ if k in view:
127
+ return False
128
+ return True
129
+
130
+
131
+ def _keysview_repr(view):
132
+ lst = []
133
+ for k in view:
134
+ lst.append("{!r}".format(k))
135
+ body = ", ".join(lst)
136
+ return "{}({})".format(view.__class__.__name__, body)
137
+
138
+
139
+ def _valuesview_repr(view):
140
+ lst = []
141
+ for v in view:
142
+ lst.append("{!r}".format(v))
143
+ body = ", ".join(lst)
144
+ return "{}({})".format(view.__class__.__name__, body)
145
+
146
+
147
+ def _mdrepr(md):
148
+ lst = []
149
+ for k, v in md.items():
150
+ lst.append("'{}': {!r}".format(k, v))
151
+ body = ", ".join(lst)
152
+ return "<{}({})>".format(md.__class__.__name__, body)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/_multidict_py.py ADDED
@@ -0,0 +1,527 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys
2
+ import types
3
+ from array import array
4
+ from collections import abc
5
+
6
+ from ._abc import MultiMapping, MutableMultiMapping
7
+
8
+ _marker = object()
9
+
10
+ if sys.version_info >= (3, 9):
11
+ GenericAlias = types.GenericAlias
12
+ else:
13
+
14
+ def GenericAlias(cls):
15
+ return cls
16
+
17
+
18
+ class istr(str):
19
+
20
+ """Case insensitive str."""
21
+
22
+ __is_istr__ = True
23
+
24
+
25
+ upstr = istr # for relaxing backward compatibility problems
26
+
27
+
28
+ def getversion(md):
29
+ if not isinstance(md, _Base):
30
+ raise TypeError("Parameter should be multidict or proxy")
31
+ return md._impl._version
32
+
33
+
34
+ _version = array("Q", [0])
35
+
36
+
37
+ class _Impl:
38
+ __slots__ = ("_items", "_version")
39
+
40
+ def __init__(self):
41
+ self._items = []
42
+ self.incr_version()
43
+
44
+ def incr_version(self):
45
+ global _version
46
+ v = _version
47
+ v[0] += 1
48
+ self._version = v[0]
49
+
50
+ if sys.implementation.name != "pypy":
51
+
52
+ def __sizeof__(self):
53
+ return object.__sizeof__(self) + sys.getsizeof(self._items)
54
+
55
+
56
+ class _Base:
57
+ def _title(self, key):
58
+ return key
59
+
60
+ def getall(self, key, default=_marker):
61
+ """Return a list of all values matching the key."""
62
+ identity = self._title(key)
63
+ res = [v for i, k, v in self._impl._items if i == identity]
64
+ if res:
65
+ return res
66
+ if not res and default is not _marker:
67
+ return default
68
+ raise KeyError("Key not found: %r" % key)
69
+
70
+ def getone(self, key, default=_marker):
71
+ """Get first value matching the key.
72
+
73
+ Raises KeyError if the key is not found and no default is provided.
74
+ """
75
+ identity = self._title(key)
76
+ for i, k, v in self._impl._items:
77
+ if i == identity:
78
+ return v
79
+ if default is not _marker:
80
+ return default
81
+ raise KeyError("Key not found: %r" % key)
82
+
83
+ # Mapping interface #
84
+
85
+ def __getitem__(self, key):
86
+ return self.getone(key)
87
+
88
+ def get(self, key, default=None):
89
+ """Get first value matching the key.
90
+
91
+ If the key is not found, returns the default (or None if no default is provided)
92
+ """
93
+ return self.getone(key, default)
94
+
95
+ def __iter__(self):
96
+ return iter(self.keys())
97
+
98
+ def __len__(self):
99
+ return len(self._impl._items)
100
+
101
+ def keys(self):
102
+ """Return a new view of the dictionary's keys."""
103
+ return _KeysView(self._impl)
104
+
105
+ def items(self):
106
+ """Return a new view of the dictionary's items *(key, value) pairs)."""
107
+ return _ItemsView(self._impl)
108
+
109
+ def values(self):
110
+ """Return a new view of the dictionary's values."""
111
+ return _ValuesView(self._impl)
112
+
113
+ def __eq__(self, other):
114
+ if not isinstance(other, abc.Mapping):
115
+ return NotImplemented
116
+ if isinstance(other, _Base):
117
+ lft = self._impl._items
118
+ rht = other._impl._items
119
+ if len(lft) != len(rht):
120
+ return False
121
+ for (i1, k2, v1), (i2, k2, v2) in zip(lft, rht):
122
+ if i1 != i2 or v1 != v2:
123
+ return False
124
+ return True
125
+ if len(self._impl._items) != len(other):
126
+ return False
127
+ for k, v in self.items():
128
+ nv = other.get(k, _marker)
129
+ if v != nv:
130
+ return False
131
+ return True
132
+
133
+ def __contains__(self, key):
134
+ identity = self._title(key)
135
+ for i, k, v in self._impl._items:
136
+ if i == identity:
137
+ return True
138
+ return False
139
+
140
+ def __repr__(self):
141
+ body = ", ".join("'{}': {!r}".format(k, v) for k, v in self.items())
142
+ return "<{}({})>".format(self.__class__.__name__, body)
143
+
144
+ __class_getitem__ = classmethod(GenericAlias)
145
+
146
+
147
+ class MultiDictProxy(_Base, MultiMapping):
148
+ """Read-only proxy for MultiDict instance."""
149
+
150
+ def __init__(self, arg):
151
+ if not isinstance(arg, (MultiDict, MultiDictProxy)):
152
+ raise TypeError(
153
+ "ctor requires MultiDict or MultiDictProxy instance"
154
+ ", not {}".format(type(arg))
155
+ )
156
+
157
+ self._impl = arg._impl
158
+
159
+ def __reduce__(self):
160
+ raise TypeError("can't pickle {} objects".format(self.__class__.__name__))
161
+
162
+ def copy(self):
163
+ """Return a copy of itself."""
164
+ return MultiDict(self.items())
165
+
166
+
167
+ class CIMultiDictProxy(MultiDictProxy):
168
+ """Read-only proxy for CIMultiDict instance."""
169
+
170
+ def __init__(self, arg):
171
+ if not isinstance(arg, (CIMultiDict, CIMultiDictProxy)):
172
+ raise TypeError(
173
+ "ctor requires CIMultiDict or CIMultiDictProxy instance"
174
+ ", not {}".format(type(arg))
175
+ )
176
+
177
+ self._impl = arg._impl
178
+
179
+ def _title(self, key):
180
+ return key.title()
181
+
182
+ def copy(self):
183
+ """Return a copy of itself."""
184
+ return CIMultiDict(self.items())
185
+
186
+
187
+ class MultiDict(_Base, MutableMultiMapping):
188
+ """Dictionary with the support for duplicate keys."""
189
+
190
+ def __init__(self, *args, **kwargs):
191
+ self._impl = _Impl()
192
+
193
+ self._extend(args, kwargs, self.__class__.__name__, self._extend_items)
194
+
195
+ if sys.implementation.name != "pypy":
196
+
197
+ def __sizeof__(self):
198
+ return object.__sizeof__(self) + sys.getsizeof(self._impl)
199
+
200
+ def __reduce__(self):
201
+ return (self.__class__, (list(self.items()),))
202
+
203
+ def _title(self, key):
204
+ return key
205
+
206
+ def _key(self, key):
207
+ if isinstance(key, str):
208
+ return key
209
+ else:
210
+ raise TypeError(
211
+ "MultiDict keys should be either str " "or subclasses of str"
212
+ )
213
+
214
+ def add(self, key, value):
215
+ identity = self._title(key)
216
+ self._impl._items.append((identity, self._key(key), value))
217
+ self._impl.incr_version()
218
+
219
+ def copy(self):
220
+ """Return a copy of itself."""
221
+ cls = self.__class__
222
+ return cls(self.items())
223
+
224
+ __copy__ = copy
225
+
226
+ def extend(self, *args, **kwargs):
227
+ """Extend current MultiDict with more values.
228
+
229
+ This method must be used instead of update.
230
+ """
231
+ self._extend(args, kwargs, "extend", self._extend_items)
232
+
233
+ def _extend(self, args, kwargs, name, method):
234
+ if len(args) > 1:
235
+ raise TypeError(
236
+ "{} takes at most 1 positional argument"
237
+ " ({} given)".format(name, len(args))
238
+ )
239
+ if args:
240
+ arg = args[0]
241
+ if isinstance(args[0], (MultiDict, MultiDictProxy)) and not kwargs:
242
+ items = arg._impl._items
243
+ else:
244
+ if hasattr(arg, "items"):
245
+ arg = arg.items()
246
+ if kwargs:
247
+ arg = list(arg)
248
+ arg.extend(list(kwargs.items()))
249
+ items = []
250
+ for item in arg:
251
+ if not len(item) == 2:
252
+ raise TypeError(
253
+ "{} takes either dict or list of (key, value) "
254
+ "tuples".format(name)
255
+ )
256
+ items.append((self._title(item[0]), self._key(item[0]), item[1]))
257
+
258
+ method(items)
259
+ else:
260
+ method(
261
+ [
262
+ (self._title(key), self._key(key), value)
263
+ for key, value in kwargs.items()
264
+ ]
265
+ )
266
+
267
+ def _extend_items(self, items):
268
+ for identity, key, value in items:
269
+ self.add(key, value)
270
+
271
+ def clear(self):
272
+ """Remove all items from MultiDict."""
273
+ self._impl._items.clear()
274
+ self._impl.incr_version()
275
+
276
+ # Mapping interface #
277
+
278
+ def __setitem__(self, key, value):
279
+ self._replace(key, value)
280
+
281
+ def __delitem__(self, key):
282
+ identity = self._title(key)
283
+ items = self._impl._items
284
+ found = False
285
+ for i in range(len(items) - 1, -1, -1):
286
+ if items[i][0] == identity:
287
+ del items[i]
288
+ found = True
289
+ if not found:
290
+ raise KeyError(key)
291
+ else:
292
+ self._impl.incr_version()
293
+
294
+ def setdefault(self, key, default=None):
295
+ """Return value for key, set value to default if key is not present."""
296
+ identity = self._title(key)
297
+ for i, k, v in self._impl._items:
298
+ if i == identity:
299
+ return v
300
+ self.add(key, default)
301
+ return default
302
+
303
+ def popone(self, key, default=_marker):
304
+ """Remove specified key and return the corresponding value.
305
+
306
+ If key is not found, d is returned if given, otherwise
307
+ KeyError is raised.
308
+
309
+ """
310
+ identity = self._title(key)
311
+ for i in range(len(self._impl._items)):
312
+ if self._impl._items[i][0] == identity:
313
+ value = self._impl._items[i][2]
314
+ del self._impl._items[i]
315
+ self._impl.incr_version()
316
+ return value
317
+ if default is _marker:
318
+ raise KeyError(key)
319
+ else:
320
+ return default
321
+
322
+ pop = popone # type: ignore
323
+
324
+ def popall(self, key, default=_marker):
325
+ """Remove all occurrences of key and return the list of corresponding
326
+ values.
327
+
328
+ If key is not found, default is returned if given, otherwise
329
+ KeyError is raised.
330
+
331
+ """
332
+ found = False
333
+ identity = self._title(key)
334
+ ret = []
335
+ for i in range(len(self._impl._items) - 1, -1, -1):
336
+ item = self._impl._items[i]
337
+ if item[0] == identity:
338
+ ret.append(item[2])
339
+ del self._impl._items[i]
340
+ self._impl.incr_version()
341
+ found = True
342
+ if not found:
343
+ if default is _marker:
344
+ raise KeyError(key)
345
+ else:
346
+ return default
347
+ else:
348
+ ret.reverse()
349
+ return ret
350
+
351
+ def popitem(self):
352
+ """Remove and return an arbitrary (key, value) pair."""
353
+ if self._impl._items:
354
+ i = self._impl._items.pop(0)
355
+ self._impl.incr_version()
356
+ return i[1], i[2]
357
+ else:
358
+ raise KeyError("empty multidict")
359
+
360
+ def update(self, *args, **kwargs):
361
+ """Update the dictionary from *other*, overwriting existing keys."""
362
+ self._extend(args, kwargs, "update", self._update_items)
363
+
364
+ def _update_items(self, items):
365
+ if not items:
366
+ return
367
+ used_keys = {}
368
+ for identity, key, value in items:
369
+ start = used_keys.get(identity, 0)
370
+ for i in range(start, len(self._impl._items)):
371
+ item = self._impl._items[i]
372
+ if item[0] == identity:
373
+ used_keys[identity] = i + 1
374
+ self._impl._items[i] = (identity, key, value)
375
+ break
376
+ else:
377
+ self._impl._items.append((identity, key, value))
378
+ used_keys[identity] = len(self._impl._items)
379
+
380
+ # drop tails
381
+ i = 0
382
+ while i < len(self._impl._items):
383
+ item = self._impl._items[i]
384
+ identity = item[0]
385
+ pos = used_keys.get(identity)
386
+ if pos is None:
387
+ i += 1
388
+ continue
389
+ if i >= pos:
390
+ del self._impl._items[i]
391
+ else:
392
+ i += 1
393
+
394
+ self._impl.incr_version()
395
+
396
+ def _replace(self, key, value):
397
+ key = self._key(key)
398
+ identity = self._title(key)
399
+ items = self._impl._items
400
+
401
+ for i in range(len(items)):
402
+ item = items[i]
403
+ if item[0] == identity:
404
+ items[i] = (identity, key, value)
405
+ # i points to last found item
406
+ rgt = i
407
+ self._impl.incr_version()
408
+ break
409
+ else:
410
+ self._impl._items.append((identity, key, value))
411
+ self._impl.incr_version()
412
+ return
413
+
414
+ # remove all tail items
415
+ i = rgt + 1
416
+ while i < len(items):
417
+ item = items[i]
418
+ if item[0] == identity:
419
+ del items[i]
420
+ else:
421
+ i += 1
422
+
423
+
424
+ class CIMultiDict(MultiDict):
425
+ """Dictionary with the support for duplicate case-insensitive keys."""
426
+
427
+ def _title(self, key):
428
+ return key.title()
429
+
430
+
431
+ class _Iter:
432
+ __slots__ = ("_size", "_iter")
433
+
434
+ def __init__(self, size, iterator):
435
+ self._size = size
436
+ self._iter = iterator
437
+
438
+ def __iter__(self):
439
+ return self
440
+
441
+ def __next__(self):
442
+ return next(self._iter)
443
+
444
+ def __length_hint__(self):
445
+ return self._size
446
+
447
+
448
+ class _ViewBase:
449
+ def __init__(self, impl):
450
+ self._impl = impl
451
+
452
+ def __len__(self):
453
+ return len(self._impl._items)
454
+
455
+
456
+ class _ItemsView(_ViewBase, abc.ItemsView):
457
+ def __contains__(self, item):
458
+ assert isinstance(item, tuple) or isinstance(item, list)
459
+ assert len(item) == 2
460
+ for i, k, v in self._impl._items:
461
+ if item[0] == k and item[1] == v:
462
+ return True
463
+ return False
464
+
465
+ def __iter__(self):
466
+ return _Iter(len(self), self._iter(self._impl._version))
467
+
468
+ def _iter(self, version):
469
+ for i, k, v in self._impl._items:
470
+ if version != self._impl._version:
471
+ raise RuntimeError("Dictionary changed during iteration")
472
+ yield k, v
473
+
474
+ def __repr__(self):
475
+ lst = []
476
+ for item in self._impl._items:
477
+ lst.append("{!r}: {!r}".format(item[1], item[2]))
478
+ body = ", ".join(lst)
479
+ return "{}({})".format(self.__class__.__name__, body)
480
+
481
+
482
+ class _ValuesView(_ViewBase, abc.ValuesView):
483
+ def __contains__(self, value):
484
+ for item in self._impl._items:
485
+ if item[2] == value:
486
+ return True
487
+ return False
488
+
489
+ def __iter__(self):
490
+ return _Iter(len(self), self._iter(self._impl._version))
491
+
492
+ def _iter(self, version):
493
+ for item in self._impl._items:
494
+ if version != self._impl._version:
495
+ raise RuntimeError("Dictionary changed during iteration")
496
+ yield item[2]
497
+
498
+ def __repr__(self):
499
+ lst = []
500
+ for item in self._impl._items:
501
+ lst.append("{!r}".format(item[2]))
502
+ body = ", ".join(lst)
503
+ return "{}({})".format(self.__class__.__name__, body)
504
+
505
+
506
+ class _KeysView(_ViewBase, abc.KeysView):
507
+ def __contains__(self, key):
508
+ for item in self._impl._items:
509
+ if item[1] == key:
510
+ return True
511
+ return False
512
+
513
+ def __iter__(self):
514
+ return _Iter(len(self), self._iter(self._impl._version))
515
+
516
+ def _iter(self, version):
517
+ for item in self._impl._items:
518
+ if version != self._impl._version:
519
+ raise RuntimeError("Dictionary changed during iteration")
520
+ yield item[1]
521
+
522
+ def __repr__(self):
523
+ lst = []
524
+ for item in self._impl._items:
525
+ lst.append("{!r}".format(item[1]))
526
+ body = ", ".join(lst)
527
+ return "{}({})".format(self.__class__.__name__, body)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/multidict/py.typed ADDED
@@ -0,0 +1 @@
 
 
1
+ PEP-561 marker.
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__config__.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"]
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": "10.2.1",
37
+ "commands": r"cc",
38
+ "args": r"-fno-strict-aliasing",
39
+ "linker args": r"-Wl,--strip-debug, -fno-strict-aliasing",
40
+ },
41
+ "cython": {
42
+ "name": "cython",
43
+ "linker": r"cython",
44
+ "version": "3.0.8",
45
+ "commands": r"cython",
46
+ "args": r"",
47
+ "linker args": r"",
48
+ },
49
+ "c++": {
50
+ "name": "gcc",
51
+ "linker": r"ld.bfd",
52
+ "version": "10.2.1",
53
+ "commands": r"c++",
54
+ "args": r"",
55
+ "linker args": r"-Wl,--strip-debug",
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": bool("False".lower().replace("false", "")),
72
+ },
73
+ "Build Dependencies": {
74
+ "blas": {
75
+ "name": "openblas64",
76
+ "found": bool("True".lower().replace("false", "")),
77
+ "version": "0.3.23.dev",
78
+ "detection method": "pkgconfig",
79
+ "include directory": r"/usr/local/include",
80
+ "lib directory": r"/usr/local/lib",
81
+ "openblas configuration": r"USE_64BITINT=1 DYNAMIC_ARCH=1 DYNAMIC_OLDER= NO_CBLAS= NO_LAPACK= NO_LAPACKE= NO_AFFINITY=1 USE_OPENMP= HASWELL MAX_THREADS=2",
82
+ "pc file directory": r"/usr/local/lib/pkgconfig",
83
+ },
84
+ "lapack": {
85
+ "name": "dep140551260102944",
86
+ "found": bool("True".lower().replace("false", "")),
87
+ "version": "1.26.4",
88
+ "detection method": "internal",
89
+ "include directory": r"unknown",
90
+ "lib directory": r"unknown",
91
+ "openblas configuration": r"unknown",
92
+ "pc file directory": r"unknown",
93
+ },
94
+ },
95
+ "Python Information": {
96
+ "path": r"/opt/python/cp312-cp312/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
+ )
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.cython-30.pxd ADDED
@@ -0,0 +1,1050 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 "Python.h":
24
+ ctypedef int Py_intptr_t
25
+
26
+ cdef extern from "numpy/arrayobject.h":
27
+ ctypedef Py_intptr_t npy_intp
28
+ ctypedef size_t npy_uintp
29
+
30
+ cdef enum NPY_TYPES:
31
+ NPY_BOOL
32
+ NPY_BYTE
33
+ NPY_UBYTE
34
+ NPY_SHORT
35
+ NPY_USHORT
36
+ NPY_INT
37
+ NPY_UINT
38
+ NPY_LONG
39
+ NPY_ULONG
40
+ NPY_LONGLONG
41
+ NPY_ULONGLONG
42
+ NPY_FLOAT
43
+ NPY_DOUBLE
44
+ NPY_LONGDOUBLE
45
+ NPY_CFLOAT
46
+ NPY_CDOUBLE
47
+ NPY_CLONGDOUBLE
48
+ NPY_OBJECT
49
+ NPY_STRING
50
+ NPY_UNICODE
51
+ NPY_VOID
52
+ NPY_DATETIME
53
+ NPY_TIMEDELTA
54
+ NPY_NTYPES
55
+ NPY_NOTYPE
56
+
57
+ NPY_INT8
58
+ NPY_INT16
59
+ NPY_INT32
60
+ NPY_INT64
61
+ NPY_INT128
62
+ NPY_INT256
63
+ NPY_UINT8
64
+ NPY_UINT16
65
+ NPY_UINT32
66
+ NPY_UINT64
67
+ NPY_UINT128
68
+ NPY_UINT256
69
+ NPY_FLOAT16
70
+ NPY_FLOAT32
71
+ NPY_FLOAT64
72
+ NPY_FLOAT80
73
+ NPY_FLOAT96
74
+ NPY_FLOAT128
75
+ NPY_FLOAT256
76
+ NPY_COMPLEX32
77
+ NPY_COMPLEX64
78
+ NPY_COMPLEX128
79
+ NPY_COMPLEX160
80
+ NPY_COMPLEX192
81
+ NPY_COMPLEX256
82
+ NPY_COMPLEX512
83
+
84
+ NPY_INTP
85
+
86
+ ctypedef enum NPY_ORDER:
87
+ NPY_ANYORDER
88
+ NPY_CORDER
89
+ NPY_FORTRANORDER
90
+ NPY_KEEPORDER
91
+
92
+ ctypedef enum NPY_CASTING:
93
+ NPY_NO_CASTING
94
+ NPY_EQUIV_CASTING
95
+ NPY_SAFE_CASTING
96
+ NPY_SAME_KIND_CASTING
97
+ NPY_UNSAFE_CASTING
98
+
99
+ ctypedef enum NPY_CLIPMODE:
100
+ NPY_CLIP
101
+ NPY_WRAP
102
+ NPY_RAISE
103
+
104
+ ctypedef enum NPY_SCALARKIND:
105
+ NPY_NOSCALAR,
106
+ NPY_BOOL_SCALAR,
107
+ NPY_INTPOS_SCALAR,
108
+ NPY_INTNEG_SCALAR,
109
+ NPY_FLOAT_SCALAR,
110
+ NPY_COMPLEX_SCALAR,
111
+ NPY_OBJECT_SCALAR
112
+
113
+ ctypedef enum NPY_SORTKIND:
114
+ NPY_QUICKSORT
115
+ NPY_HEAPSORT
116
+ NPY_MERGESORT
117
+
118
+ ctypedef enum NPY_SEARCHSIDE:
119
+ NPY_SEARCHLEFT
120
+ NPY_SEARCHRIGHT
121
+
122
+ enum:
123
+ # DEPRECATED since NumPy 1.7 ! Do not use in new code!
124
+ NPY_C_CONTIGUOUS
125
+ NPY_F_CONTIGUOUS
126
+ NPY_CONTIGUOUS
127
+ NPY_FORTRAN
128
+ NPY_OWNDATA
129
+ NPY_FORCECAST
130
+ NPY_ENSURECOPY
131
+ NPY_ENSUREARRAY
132
+ NPY_ELEMENTSTRIDES
133
+ NPY_ALIGNED
134
+ NPY_NOTSWAPPED
135
+ NPY_WRITEABLE
136
+ NPY_ARR_HAS_DESCR
137
+
138
+ NPY_BEHAVED
139
+ NPY_BEHAVED_NS
140
+ NPY_CARRAY
141
+ NPY_CARRAY_RO
142
+ NPY_FARRAY
143
+ NPY_FARRAY_RO
144
+ NPY_DEFAULT
145
+
146
+ NPY_IN_ARRAY
147
+ NPY_OUT_ARRAY
148
+ NPY_INOUT_ARRAY
149
+ NPY_IN_FARRAY
150
+ NPY_OUT_FARRAY
151
+ NPY_INOUT_FARRAY
152
+
153
+ NPY_UPDATE_ALL
154
+
155
+ enum:
156
+ # Added in NumPy 1.7 to replace the deprecated enums above.
157
+ NPY_ARRAY_C_CONTIGUOUS
158
+ NPY_ARRAY_F_CONTIGUOUS
159
+ NPY_ARRAY_OWNDATA
160
+ NPY_ARRAY_FORCECAST
161
+ NPY_ARRAY_ENSURECOPY
162
+ NPY_ARRAY_ENSUREARRAY
163
+ NPY_ARRAY_ELEMENTSTRIDES
164
+ NPY_ARRAY_ALIGNED
165
+ NPY_ARRAY_NOTSWAPPED
166
+ NPY_ARRAY_WRITEABLE
167
+ NPY_ARRAY_WRITEBACKIFCOPY
168
+
169
+ NPY_ARRAY_BEHAVED
170
+ NPY_ARRAY_BEHAVED_NS
171
+ NPY_ARRAY_CARRAY
172
+ NPY_ARRAY_CARRAY_RO
173
+ NPY_ARRAY_FARRAY
174
+ NPY_ARRAY_FARRAY_RO
175
+ NPY_ARRAY_DEFAULT
176
+
177
+ NPY_ARRAY_IN_ARRAY
178
+ NPY_ARRAY_OUT_ARRAY
179
+ NPY_ARRAY_INOUT_ARRAY
180
+ NPY_ARRAY_IN_FARRAY
181
+ NPY_ARRAY_OUT_FARRAY
182
+ NPY_ARRAY_INOUT_FARRAY
183
+
184
+ NPY_ARRAY_UPDATE_ALL
185
+
186
+ cdef enum:
187
+ NPY_MAXDIMS
188
+
189
+ npy_intp NPY_MAX_ELSIZE
190
+
191
+ ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
192
+
193
+ ctypedef struct PyArray_ArrayDescr:
194
+ # shape is a tuple, but Cython doesn't support "tuple shape"
195
+ # inside a non-PyObject declaration, so we have to declare it
196
+ # as just a PyObject*.
197
+ PyObject* shape
198
+
199
+ ctypedef struct PyArray_Descr:
200
+ pass
201
+
202
+ ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]:
203
+ # Use PyDataType_* macros when possible, however there are no macros
204
+ # for accessing some of the fields, so some are defined.
205
+ cdef PyTypeObject* typeobj
206
+ cdef char kind
207
+ cdef char type
208
+ # Numpy sometimes mutates this without warning (e.g. it'll
209
+ # sometimes change "|" to "<" in shared dtype objects on
210
+ # little-endian machines). If this matters to you, use
211
+ # PyArray_IsNativeByteOrder(dtype.byteorder) instead of
212
+ # directly accessing this field.
213
+ cdef char byteorder
214
+ cdef char flags
215
+ cdef int type_num
216
+ cdef int itemsize "elsize"
217
+ cdef int alignment
218
+ cdef object fields
219
+ cdef tuple names
220
+ # Use PyDataType_HASSUBARRAY to test whether this field is
221
+ # valid (the pointer can be NULL). Most users should access
222
+ # this field via the inline helper method PyDataType_SHAPE.
223
+ cdef PyArray_ArrayDescr* subarray
224
+
225
+ ctypedef class numpy.flatiter [object PyArrayIterObject, check_size ignore]:
226
+ # Use through macros
227
+ pass
228
+
229
+ ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]:
230
+ # Use through macros
231
+ pass
232
+
233
+ ctypedef struct PyArrayObject:
234
+ # For use in situations where ndarray can't replace PyArrayObject*,
235
+ # like PyArrayObject**.
236
+ pass
237
+
238
+ ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]:
239
+ cdef __cythonbufferdefaults__ = {"mode": "strided"}
240
+
241
+ # NOTE: no field declarations since direct access is deprecated since NumPy 1.7
242
+ # Instead, we use properties that map to the corresponding C-API functions.
243
+
244
+ @property
245
+ cdef inline PyObject* base(self) nogil:
246
+ """Returns a borrowed reference to the object owning the data/memory.
247
+ """
248
+ return PyArray_BASE(self)
249
+
250
+ @property
251
+ cdef inline dtype descr(self):
252
+ """Returns an owned reference to the dtype of the array.
253
+ """
254
+ return <dtype>PyArray_DESCR(self)
255
+
256
+ @property
257
+ cdef inline int ndim(self) nogil:
258
+ """Returns the number of dimensions in the array.
259
+ """
260
+ return PyArray_NDIM(self)
261
+
262
+ @property
263
+ cdef inline npy_intp *shape(self) nogil:
264
+ """Returns a pointer to the dimensions/shape of the array.
265
+ The number of elements matches the number of dimensions of the array (ndim).
266
+ Can return NULL for 0-dimensional arrays.
267
+ """
268
+ return PyArray_DIMS(self)
269
+
270
+ @property
271
+ cdef inline npy_intp *strides(self) nogil:
272
+ """Returns a pointer to the strides of the array.
273
+ The number of elements matches the number of dimensions of the array (ndim).
274
+ """
275
+ return PyArray_STRIDES(self)
276
+
277
+ @property
278
+ cdef inline npy_intp size(self) nogil:
279
+ """Returns the total size (in number of elements) of the array.
280
+ """
281
+ return PyArray_SIZE(self)
282
+
283
+ @property
284
+ cdef inline char* data(self) nogil:
285
+ """The pointer to the data buffer as a char*.
286
+ This is provided for legacy reasons to avoid direct struct field access.
287
+ For new code that needs this access, you probably want to cast the result
288
+ of `PyArray_DATA()` instead, which returns a 'void*'.
289
+ """
290
+ return PyArray_BYTES(self)
291
+
292
+ ctypedef unsigned char npy_bool
293
+
294
+ ctypedef signed char npy_byte
295
+ ctypedef signed short npy_short
296
+ ctypedef signed int npy_int
297
+ ctypedef signed long npy_long
298
+ ctypedef signed long long npy_longlong
299
+
300
+ ctypedef unsigned char npy_ubyte
301
+ ctypedef unsigned short npy_ushort
302
+ ctypedef unsigned int npy_uint
303
+ ctypedef unsigned long npy_ulong
304
+ ctypedef unsigned long long npy_ulonglong
305
+
306
+ ctypedef float npy_float
307
+ ctypedef double npy_double
308
+ ctypedef long double npy_longdouble
309
+
310
+ ctypedef signed char npy_int8
311
+ ctypedef signed short npy_int16
312
+ ctypedef signed int npy_int32
313
+ ctypedef signed long long npy_int64
314
+ ctypedef signed long long npy_int96
315
+ ctypedef signed long long npy_int128
316
+
317
+ ctypedef unsigned char npy_uint8
318
+ ctypedef unsigned short npy_uint16
319
+ ctypedef unsigned int npy_uint32
320
+ ctypedef unsigned long long npy_uint64
321
+ ctypedef unsigned long long npy_uint96
322
+ ctypedef unsigned long long npy_uint128
323
+
324
+ ctypedef float npy_float32
325
+ ctypedef double npy_float64
326
+ ctypedef long double npy_float80
327
+ ctypedef long double npy_float96
328
+ ctypedef long double npy_float128
329
+
330
+ ctypedef struct npy_cfloat:
331
+ float real
332
+ float imag
333
+
334
+ ctypedef struct npy_cdouble:
335
+ double real
336
+ double imag
337
+
338
+ ctypedef struct npy_clongdouble:
339
+ long double real
340
+ long double imag
341
+
342
+ ctypedef struct npy_complex64:
343
+ float real
344
+ float imag
345
+
346
+ ctypedef struct npy_complex128:
347
+ double real
348
+ double imag
349
+
350
+ ctypedef struct npy_complex160:
351
+ long double real
352
+ long double imag
353
+
354
+ ctypedef struct npy_complex192:
355
+ long double real
356
+ long double imag
357
+
358
+ ctypedef struct npy_complex256:
359
+ long double real
360
+ long double imag
361
+
362
+ ctypedef struct PyArray_Dims:
363
+ npy_intp *ptr
364
+ int len
365
+
366
+ int _import_array() except -1
367
+ # A second definition so _import_array isn't marked as used when we use it here.
368
+ # Do not use - subject to change any time.
369
+ int __pyx_import_array "_import_array"() except -1
370
+
371
+ #
372
+ # Macros from ndarrayobject.h
373
+ #
374
+ bint PyArray_CHKFLAGS(ndarray m, int flags) nogil
375
+ bint PyArray_IS_C_CONTIGUOUS(ndarray arr) nogil
376
+ bint PyArray_IS_F_CONTIGUOUS(ndarray arr) nogil
377
+ bint PyArray_ISCONTIGUOUS(ndarray m) nogil
378
+ bint PyArray_ISWRITEABLE(ndarray m) nogil
379
+ bint PyArray_ISALIGNED(ndarray m) nogil
380
+
381
+ int PyArray_NDIM(ndarray) nogil
382
+ bint PyArray_ISONESEGMENT(ndarray) nogil
383
+ bint PyArray_ISFORTRAN(ndarray) nogil
384
+ int PyArray_FORTRANIF(ndarray) nogil
385
+
386
+ void* PyArray_DATA(ndarray) nogil
387
+ char* PyArray_BYTES(ndarray) nogil
388
+
389
+ npy_intp* PyArray_DIMS(ndarray) nogil
390
+ npy_intp* PyArray_STRIDES(ndarray) nogil
391
+ npy_intp PyArray_DIM(ndarray, size_t) nogil
392
+ npy_intp PyArray_STRIDE(ndarray, size_t) nogil
393
+
394
+ PyObject *PyArray_BASE(ndarray) nogil # returns borrowed reference!
395
+ PyArray_Descr *PyArray_DESCR(ndarray) nogil # returns borrowed reference to dtype!
396
+ PyArray_Descr *PyArray_DTYPE(ndarray) nogil # returns borrowed reference to dtype! NP 1.7+ alias for descr.
397
+ int PyArray_FLAGS(ndarray) nogil
398
+ void PyArray_CLEARFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7
399
+ void PyArray_ENABLEFLAGS(ndarray, int flags) nogil # Added in NumPy 1.7
400
+ npy_intp PyArray_ITEMSIZE(ndarray) nogil
401
+ int PyArray_TYPE(ndarray arr) nogil
402
+
403
+ object PyArray_GETITEM(ndarray arr, void *itemptr)
404
+ int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) except -1
405
+
406
+ bint PyTypeNum_ISBOOL(int) nogil
407
+ bint PyTypeNum_ISUNSIGNED(int) nogil
408
+ bint PyTypeNum_ISSIGNED(int) nogil
409
+ bint PyTypeNum_ISINTEGER(int) nogil
410
+ bint PyTypeNum_ISFLOAT(int) nogil
411
+ bint PyTypeNum_ISNUMBER(int) nogil
412
+ bint PyTypeNum_ISSTRING(int) nogil
413
+ bint PyTypeNum_ISCOMPLEX(int) nogil
414
+ bint PyTypeNum_ISPYTHON(int) nogil
415
+ bint PyTypeNum_ISFLEXIBLE(int) nogil
416
+ bint PyTypeNum_ISUSERDEF(int) nogil
417
+ bint PyTypeNum_ISEXTENDED(int) nogil
418
+ bint PyTypeNum_ISOBJECT(int) nogil
419
+
420
+ bint PyDataType_ISBOOL(dtype) nogil
421
+ bint PyDataType_ISUNSIGNED(dtype) nogil
422
+ bint PyDataType_ISSIGNED(dtype) nogil
423
+ bint PyDataType_ISINTEGER(dtype) nogil
424
+ bint PyDataType_ISFLOAT(dtype) nogil
425
+ bint PyDataType_ISNUMBER(dtype) nogil
426
+ bint PyDataType_ISSTRING(dtype) nogil
427
+ bint PyDataType_ISCOMPLEX(dtype) nogil
428
+ bint PyDataType_ISPYTHON(dtype) nogil
429
+ bint PyDataType_ISFLEXIBLE(dtype) nogil
430
+ bint PyDataType_ISUSERDEF(dtype) nogil
431
+ bint PyDataType_ISEXTENDED(dtype) nogil
432
+ bint PyDataType_ISOBJECT(dtype) nogil
433
+ bint PyDataType_HASFIELDS(dtype) nogil
434
+ bint PyDataType_HASSUBARRAY(dtype) nogil
435
+
436
+ bint PyArray_ISBOOL(ndarray) nogil
437
+ bint PyArray_ISUNSIGNED(ndarray) nogil
438
+ bint PyArray_ISSIGNED(ndarray) nogil
439
+ bint PyArray_ISINTEGER(ndarray) nogil
440
+ bint PyArray_ISFLOAT(ndarray) nogil
441
+ bint PyArray_ISNUMBER(ndarray) nogil
442
+ bint PyArray_ISSTRING(ndarray) nogil
443
+ bint PyArray_ISCOMPLEX(ndarray) nogil
444
+ bint PyArray_ISPYTHON(ndarray) nogil
445
+ bint PyArray_ISFLEXIBLE(ndarray) nogil
446
+ bint PyArray_ISUSERDEF(ndarray) nogil
447
+ bint PyArray_ISEXTENDED(ndarray) nogil
448
+ bint PyArray_ISOBJECT(ndarray) nogil
449
+ bint PyArray_HASFIELDS(ndarray) nogil
450
+
451
+ bint PyArray_ISVARIABLE(ndarray) nogil
452
+
453
+ bint PyArray_SAFEALIGNEDCOPY(ndarray) nogil
454
+ bint PyArray_ISNBO(char) nogil # works on ndarray.byteorder
455
+ bint PyArray_IsNativeByteOrder(char) nogil # works on ndarray.byteorder
456
+ bint PyArray_ISNOTSWAPPED(ndarray) nogil
457
+ bint PyArray_ISBYTESWAPPED(ndarray) nogil
458
+
459
+ bint PyArray_FLAGSWAP(ndarray, int) nogil
460
+
461
+ bint PyArray_ISCARRAY(ndarray) nogil
462
+ bint PyArray_ISCARRAY_RO(ndarray) nogil
463
+ bint PyArray_ISFARRAY(ndarray) nogil
464
+ bint PyArray_ISFARRAY_RO(ndarray) nogil
465
+ bint PyArray_ISBEHAVED(ndarray) nogil
466
+ bint PyArray_ISBEHAVED_RO(ndarray) nogil
467
+
468
+
469
+ bint PyDataType_ISNOTSWAPPED(dtype) nogil
470
+ bint PyDataType_ISBYTESWAPPED(dtype) nogil
471
+
472
+ bint PyArray_DescrCheck(object)
473
+
474
+ bint PyArray_Check(object)
475
+ bint PyArray_CheckExact(object)
476
+
477
+ # Cannot be supported due to out arg:
478
+ # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
479
+ # bint PyArray_HasArrayInterface(op, out)
480
+
481
+
482
+ bint PyArray_IsZeroDim(object)
483
+ # Cannot be supported due to ## ## in macro:
484
+ # bint PyArray_IsScalar(object, verbatim work)
485
+ bint PyArray_CheckScalar(object)
486
+ bint PyArray_IsPythonNumber(object)
487
+ bint PyArray_IsPythonScalar(object)
488
+ bint PyArray_IsAnyScalar(object)
489
+ bint PyArray_CheckAnyScalar(object)
490
+
491
+ ndarray PyArray_GETCONTIGUOUS(ndarray)
492
+ bint PyArray_SAMESHAPE(ndarray, ndarray) nogil
493
+ npy_intp PyArray_SIZE(ndarray) nogil
494
+ npy_intp PyArray_NBYTES(ndarray) nogil
495
+
496
+ object PyArray_FROM_O(object)
497
+ object PyArray_FROM_OF(object m, int flags)
498
+ object PyArray_FROM_OT(object m, int type)
499
+ object PyArray_FROM_OTF(object m, int type, int flags)
500
+ object PyArray_FROMANY(object m, int type, int min, int max, int flags)
501
+ object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran)
502
+ object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran)
503
+ void PyArray_FILLWBYTE(object, int val)
504
+ npy_intp PyArray_REFCOUNT(object)
505
+ object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth)
506
+ unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2)
507
+ bint PyArray_EquivByteorders(int b1, int b2) nogil
508
+ object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum)
509
+ object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data)
510
+ #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr)
511
+ object PyArray_ToScalar(void* data, ndarray arr)
512
+
513
+ void* PyArray_GETPTR1(ndarray m, npy_intp i) nogil
514
+ void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) nogil
515
+ void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) nogil
516
+ void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) nogil
517
+
518
+ # Cannot be supported due to out arg
519
+ # void PyArray_DESCR_REPLACE(descr)
520
+
521
+
522
+ object PyArray_Copy(ndarray)
523
+ object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
524
+ object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
525
+ object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
526
+
527
+ object PyArray_Cast(ndarray mp, int type_num)
528
+ object PyArray_Take(ndarray ap, object items, int axis)
529
+ object PyArray_Put(ndarray ap, object items, object values)
530
+
531
+ void PyArray_ITER_RESET(flatiter it) nogil
532
+ void PyArray_ITER_NEXT(flatiter it) nogil
533
+ void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
534
+ void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
535
+ void* PyArray_ITER_DATA(flatiter it) nogil
536
+ bint PyArray_ITER_NOTDONE(flatiter it) nogil
537
+
538
+ void PyArray_MultiIter_RESET(broadcast multi) nogil
539
+ void PyArray_MultiIter_NEXT(broadcast multi) nogil
540
+ void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
541
+ void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil
542
+ void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil
543
+ void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil
544
+ bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil
545
+
546
+ # Functions from __multiarray_api.h
547
+
548
+ # Functions taking dtype and returning object/ndarray are disabled
549
+ # for now as they steal dtype references. I'm conservative and disable
550
+ # more than is probably needed until it can be checked further.
551
+ int PyArray_SetNumericOps (object) except -1
552
+ object PyArray_GetNumericOps ()
553
+ int PyArray_INCREF (ndarray) except * # uses PyArray_Item_INCREF...
554
+ int PyArray_XDECREF (ndarray) except * # uses PyArray_Item_DECREF...
555
+ void PyArray_SetStringFunction (object, int)
556
+ dtype PyArray_DescrFromType (int)
557
+ object PyArray_TypeObjectFromType (int)
558
+ char * PyArray_Zero (ndarray)
559
+ char * PyArray_One (ndarray)
560
+ #object PyArray_CastToType (ndarray, dtype, int)
561
+ int PyArray_CastTo (ndarray, ndarray) except -1
562
+ int PyArray_CastAnyTo (ndarray, ndarray) except -1
563
+ int PyArray_CanCastSafely (int, int) # writes errors
564
+ npy_bool PyArray_CanCastTo (dtype, dtype) # writes errors
565
+ int PyArray_ObjectType (object, int) except 0
566
+ dtype PyArray_DescrFromObject (object, dtype)
567
+ #ndarray* PyArray_ConvertToCommonType (object, int *)
568
+ dtype PyArray_DescrFromScalar (object)
569
+ dtype PyArray_DescrFromTypeObject (object)
570
+ npy_intp PyArray_Size (object)
571
+ #object PyArray_Scalar (void *, dtype, object)
572
+ #object PyArray_FromScalar (object, dtype)
573
+ void PyArray_ScalarAsCtype (object, void *)
574
+ #int PyArray_CastScalarToCtype (object, void *, dtype)
575
+ #int PyArray_CastScalarDirect (object, dtype, void *, int)
576
+ object PyArray_ScalarFromObject (object)
577
+ #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int)
578
+ object PyArray_FromDims (int, int *, int)
579
+ #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *)
580
+ #object PyArray_FromAny (object, dtype, int, int, int, object)
581
+ object PyArray_EnsureArray (object)
582
+ object PyArray_EnsureAnyArray (object)
583
+ #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *)
584
+ #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *)
585
+ #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp)
586
+ #object PyArray_FromIter (object, dtype, npy_intp)
587
+ object PyArray_Return (ndarray)
588
+ #object PyArray_GetField (ndarray, dtype, int)
589
+ #int PyArray_SetField (ndarray, dtype, int, object) except -1
590
+ object PyArray_Byteswap (ndarray, npy_bool)
591
+ object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER)
592
+ int PyArray_MoveInto (ndarray, ndarray) except -1
593
+ int PyArray_CopyInto (ndarray, ndarray) except -1
594
+ int PyArray_CopyAnyInto (ndarray, ndarray) except -1
595
+ int PyArray_CopyObject (ndarray, object) except -1
596
+ object PyArray_NewCopy (ndarray, NPY_ORDER)
597
+ object PyArray_ToList (ndarray)
598
+ object PyArray_ToString (ndarray, NPY_ORDER)
599
+ int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *) except -1
600
+ int PyArray_Dump (object, object, int) except -1
601
+ object PyArray_Dumps (object, int)
602
+ int PyArray_ValidType (int) # Cannot error
603
+ void PyArray_UpdateFlags (ndarray, int)
604
+ object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
605
+ #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
606
+ #dtype PyArray_DescrNew (dtype)
607
+ dtype PyArray_DescrNewFromType (int)
608
+ double PyArray_GetPriority (object, double) # clears errors as of 1.25
609
+ object PyArray_IterNew (object)
610
+ object PyArray_MultiIterNew (int, ...)
611
+
612
+ int PyArray_PyIntAsInt (object) except? -1
613
+ npy_intp PyArray_PyIntAsIntp (object)
614
+ int PyArray_Broadcast (broadcast) except -1
615
+ void PyArray_FillObjectArray (ndarray, object) except *
616
+ int PyArray_FillWithScalar (ndarray, object) except -1
617
+ npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
618
+ dtype PyArray_DescrNewByteorder (dtype, char)
619
+ object PyArray_IterAllButAxis (object, int *)
620
+ #object PyArray_CheckFromAny (object, dtype, int, int, int, object)
621
+ #object PyArray_FromArray (ndarray, dtype, int)
622
+ object PyArray_FromInterface (object)
623
+ object PyArray_FromStructInterface (object)
624
+ #object PyArray_FromArrayAttr (object, dtype, object)
625
+ #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*)
626
+ int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND)
627
+ object PyArray_NewFlagsObject (object)
628
+ npy_bool PyArray_CanCastScalar (type, type)
629
+ #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t)
630
+ int PyArray_RemoveSmallest (broadcast) except -1
631
+ int PyArray_ElementStrides (object)
632
+ void PyArray_Item_INCREF (char *, dtype) except *
633
+ void PyArray_Item_XDECREF (char *, dtype) except *
634
+ object PyArray_FieldNames (object)
635
+ object PyArray_Transpose (ndarray, PyArray_Dims *)
636
+ object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE)
637
+ object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE)
638
+ object PyArray_PutMask (ndarray, object, object)
639
+ object PyArray_Repeat (ndarray, object, int)
640
+ object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE)
641
+ int PyArray_Sort (ndarray, int, NPY_SORTKIND) except -1
642
+ object PyArray_ArgSort (ndarray, int, NPY_SORTKIND)
643
+ object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject *)
644
+ object PyArray_ArgMax (ndarray, int, ndarray)
645
+ object PyArray_ArgMin (ndarray, int, ndarray)
646
+ object PyArray_Reshape (ndarray, object)
647
+ object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER)
648
+ object PyArray_Squeeze (ndarray)
649
+ #object PyArray_View (ndarray, dtype, type)
650
+ object PyArray_SwapAxes (ndarray, int, int)
651
+ object PyArray_Max (ndarray, int, ndarray)
652
+ object PyArray_Min (ndarray, int, ndarray)
653
+ object PyArray_Ptp (ndarray, int, ndarray)
654
+ object PyArray_Mean (ndarray, int, int, ndarray)
655
+ object PyArray_Trace (ndarray, int, int, int, int, ndarray)
656
+ object PyArray_Diagonal (ndarray, int, int, int)
657
+ object PyArray_Clip (ndarray, object, object, ndarray)
658
+ object PyArray_Conjugate (ndarray, ndarray)
659
+ object PyArray_Nonzero (ndarray)
660
+ object PyArray_Std (ndarray, int, int, ndarray, int)
661
+ object PyArray_Sum (ndarray, int, int, ndarray)
662
+ object PyArray_CumSum (ndarray, int, int, ndarray)
663
+ object PyArray_Prod (ndarray, int, int, ndarray)
664
+ object PyArray_CumProd (ndarray, int, int, ndarray)
665
+ object PyArray_All (ndarray, int, ndarray)
666
+ object PyArray_Any (ndarray, int, ndarray)
667
+ object PyArray_Compress (ndarray, object, int, ndarray)
668
+ object PyArray_Flatten (ndarray, NPY_ORDER)
669
+ object PyArray_Ravel (ndarray, NPY_ORDER)
670
+ npy_intp PyArray_MultiplyList (npy_intp *, int)
671
+ int PyArray_MultiplyIntList (int *, int)
672
+ void * PyArray_GetPtr (ndarray, npy_intp*)
673
+ int PyArray_CompareLists (npy_intp *, npy_intp *, int)
674
+ #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype)
675
+ #int PyArray_As1D (object*, char **, int *, int)
676
+ #int PyArray_As2D (object*, char ***, int *, int *, int)
677
+ int PyArray_Free (object, void *)
678
+ #int PyArray_Converter (object, object*)
679
+ int PyArray_IntpFromSequence (object, npy_intp *, int) except -1
680
+ object PyArray_Concatenate (object, int)
681
+ object PyArray_InnerProduct (object, object)
682
+ object PyArray_MatrixProduct (object, object)
683
+ object PyArray_CopyAndTranspose (object)
684
+ object PyArray_Correlate (object, object, int)
685
+ int PyArray_TypestrConvert (int, int)
686
+ #int PyArray_DescrConverter (object, dtype*) except 0
687
+ #int PyArray_DescrConverter2 (object, dtype*) except 0
688
+ int PyArray_IntpConverter (object, PyArray_Dims *) except 0
689
+ #int PyArray_BufferConverter (object, chunk) except 0
690
+ int PyArray_AxisConverter (object, int *) except 0
691
+ int PyArray_BoolConverter (object, npy_bool *) except 0
692
+ int PyArray_ByteorderConverter (object, char *) except 0
693
+ int PyArray_OrderConverter (object, NPY_ORDER *) except 0
694
+ unsigned char PyArray_EquivTypes (dtype, dtype) # clears errors
695
+ #object PyArray_Zeros (int, npy_intp *, dtype, int)
696
+ #object PyArray_Empty (int, npy_intp *, dtype, int)
697
+ object PyArray_Where (object, object, object)
698
+ object PyArray_Arange (double, double, double, int)
699
+ #object PyArray_ArangeObj (object, object, object, dtype)
700
+ int PyArray_SortkindConverter (object, NPY_SORTKIND *) except 0
701
+ object PyArray_LexSort (object, int)
702
+ object PyArray_Round (ndarray, int, ndarray)
703
+ unsigned char PyArray_EquivTypenums (int, int)
704
+ int PyArray_RegisterDataType (dtype) except -1
705
+ int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *) except -1
706
+ int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND) except -1
707
+ #void PyArray_InitArrFuncs (PyArray_ArrFuncs *)
708
+ object PyArray_IntTupleFromIntp (int, npy_intp *)
709
+ int PyArray_TypeNumFromName (char *)
710
+ int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *) except 0
711
+ #int PyArray_OutputConverter (object, ndarray*) except 0
712
+ object PyArray_BroadcastToShape (object, npy_intp *, int)
713
+ void _PyArray_SigintHandler (int)
714
+ void* _PyArray_GetSigintBuf ()
715
+ #int PyArray_DescrAlignConverter (object, dtype*) except 0
716
+ #int PyArray_DescrAlignConverter2 (object, dtype*) except 0
717
+ int PyArray_SearchsideConverter (object, void *) except 0
718
+ object PyArray_CheckAxis (ndarray, int *, int)
719
+ npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
720
+ int PyArray_CompareString (char *, char *, size_t)
721
+ int PyArray_SetBaseObject(ndarray, base) except -1 # NOTE: steals a reference to base! Use "set_array_base()" instead.
722
+
723
+
724
+ # Typedefs that matches the runtime dtype objects in
725
+ # the numpy module.
726
+
727
+ # The ones that are commented out needs an IFDEF function
728
+ # in Cython to enable them only on the right systems.
729
+
730
+ ctypedef npy_int8 int8_t
731
+ ctypedef npy_int16 int16_t
732
+ ctypedef npy_int32 int32_t
733
+ ctypedef npy_int64 int64_t
734
+ #ctypedef npy_int96 int96_t
735
+ #ctypedef npy_int128 int128_t
736
+
737
+ ctypedef npy_uint8 uint8_t
738
+ ctypedef npy_uint16 uint16_t
739
+ ctypedef npy_uint32 uint32_t
740
+ ctypedef npy_uint64 uint64_t
741
+ #ctypedef npy_uint96 uint96_t
742
+ #ctypedef npy_uint128 uint128_t
743
+
744
+ ctypedef npy_float32 float32_t
745
+ ctypedef npy_float64 float64_t
746
+ #ctypedef npy_float80 float80_t
747
+ #ctypedef npy_float128 float128_t
748
+
749
+ ctypedef float complex complex64_t
750
+ ctypedef double complex complex128_t
751
+
752
+ # The int types are mapped a bit surprising --
753
+ # numpy.int corresponds to 'l' and numpy.long to 'q'
754
+ ctypedef npy_long int_t
755
+ ctypedef npy_longlong longlong_t
756
+
757
+ ctypedef npy_ulong uint_t
758
+ ctypedef npy_ulonglong ulonglong_t
759
+
760
+ ctypedef npy_intp intp_t
761
+ ctypedef npy_uintp uintp_t
762
+
763
+ ctypedef npy_double float_t
764
+ ctypedef npy_double double_t
765
+ ctypedef npy_longdouble longdouble_t
766
+
767
+ ctypedef npy_cfloat cfloat_t
768
+ ctypedef npy_cdouble cdouble_t
769
+ ctypedef npy_clongdouble clongdouble_t
770
+
771
+ ctypedef npy_cdouble complex_t
772
+
773
+ cdef inline object PyArray_MultiIterNew1(a):
774
+ return PyArray_MultiIterNew(1, <void*>a)
775
+
776
+ cdef inline object PyArray_MultiIterNew2(a, b):
777
+ return PyArray_MultiIterNew(2, <void*>a, <void*>b)
778
+
779
+ cdef inline object PyArray_MultiIterNew3(a, b, c):
780
+ return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
781
+
782
+ cdef inline object PyArray_MultiIterNew4(a, b, c, d):
783
+ return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
784
+
785
+ cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
786
+ return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
787
+
788
+ cdef inline tuple PyDataType_SHAPE(dtype d):
789
+ if PyDataType_HASSUBARRAY(d):
790
+ return <tuple>d.subarray.shape
791
+ else:
792
+ return ()
793
+
794
+
795
+ cdef extern from "numpy/ndarrayobject.h":
796
+ PyTypeObject PyTimedeltaArrType_Type
797
+ PyTypeObject PyDatetimeArrType_Type
798
+ ctypedef int64_t npy_timedelta
799
+ ctypedef int64_t npy_datetime
800
+
801
+ cdef extern from "numpy/ndarraytypes.h":
802
+ ctypedef struct PyArray_DatetimeMetaData:
803
+ NPY_DATETIMEUNIT base
804
+ int64_t num
805
+
806
+ cdef extern from "numpy/arrayscalars.h":
807
+
808
+ # abstract types
809
+ ctypedef class numpy.generic [object PyObject]:
810
+ pass
811
+ ctypedef class numpy.number [object PyObject]:
812
+ pass
813
+ ctypedef class numpy.integer [object PyObject]:
814
+ pass
815
+ ctypedef class numpy.signedinteger [object PyObject]:
816
+ pass
817
+ ctypedef class numpy.unsignedinteger [object PyObject]:
818
+ pass
819
+ ctypedef class numpy.inexact [object PyObject]:
820
+ pass
821
+ ctypedef class numpy.floating [object PyObject]:
822
+ pass
823
+ ctypedef class numpy.complexfloating [object PyObject]:
824
+ pass
825
+ ctypedef class numpy.flexible [object PyObject]:
826
+ pass
827
+ ctypedef class numpy.character [object PyObject]:
828
+ pass
829
+
830
+ ctypedef struct PyDatetimeScalarObject:
831
+ # PyObject_HEAD
832
+ npy_datetime obval
833
+ PyArray_DatetimeMetaData obmeta
834
+
835
+ ctypedef struct PyTimedeltaScalarObject:
836
+ # PyObject_HEAD
837
+ npy_timedelta obval
838
+ PyArray_DatetimeMetaData obmeta
839
+
840
+ ctypedef enum NPY_DATETIMEUNIT:
841
+ NPY_FR_Y
842
+ NPY_FR_M
843
+ NPY_FR_W
844
+ NPY_FR_D
845
+ NPY_FR_B
846
+ NPY_FR_h
847
+ NPY_FR_m
848
+ NPY_FR_s
849
+ NPY_FR_ms
850
+ NPY_FR_us
851
+ NPY_FR_ns
852
+ NPY_FR_ps
853
+ NPY_FR_fs
854
+ NPY_FR_as
855
+ NPY_FR_GENERIC
856
+
857
+
858
+ #
859
+ # ufunc API
860
+ #
861
+
862
+ cdef extern from "numpy/ufuncobject.h":
863
+
864
+ ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
865
+
866
+ ctypedef class numpy.ufunc [object PyUFuncObject, check_size ignore]:
867
+ cdef:
868
+ int nin, nout, nargs
869
+ int identity
870
+ PyUFuncGenericFunction *functions
871
+ void **data
872
+ int ntypes
873
+ int check_return
874
+ char *name
875
+ char *types
876
+ char *doc
877
+ void *ptr
878
+ PyObject *obj
879
+ PyObject *userloops
880
+
881
+ cdef enum:
882
+ PyUFunc_Zero
883
+ PyUFunc_One
884
+ PyUFunc_None
885
+ UFUNC_ERR_IGNORE
886
+ UFUNC_ERR_WARN
887
+ UFUNC_ERR_RAISE
888
+ UFUNC_ERR_CALL
889
+ UFUNC_ERR_PRINT
890
+ UFUNC_ERR_LOG
891
+ UFUNC_MASK_DIVIDEBYZERO
892
+ UFUNC_MASK_OVERFLOW
893
+ UFUNC_MASK_UNDERFLOW
894
+ UFUNC_MASK_INVALID
895
+ UFUNC_SHIFT_DIVIDEBYZERO
896
+ UFUNC_SHIFT_OVERFLOW
897
+ UFUNC_SHIFT_UNDERFLOW
898
+ UFUNC_SHIFT_INVALID
899
+ UFUNC_FPE_DIVIDEBYZERO
900
+ UFUNC_FPE_OVERFLOW
901
+ UFUNC_FPE_UNDERFLOW
902
+ UFUNC_FPE_INVALID
903
+ UFUNC_ERR_DEFAULT
904
+ UFUNC_ERR_DEFAULT2
905
+
906
+ object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
907
+ void **, char *, int, int, int, int, char *, char *, int)
908
+ int PyUFunc_RegisterLoopForType(ufunc, int,
909
+ PyUFuncGenericFunction, int *, void *) except -1
910
+ void PyUFunc_f_f_As_d_d \
911
+ (char **, npy_intp *, npy_intp *, void *)
912
+ void PyUFunc_d_d \
913
+ (char **, npy_intp *, npy_intp *, void *)
914
+ void PyUFunc_f_f \
915
+ (char **, npy_intp *, npy_intp *, void *)
916
+ void PyUFunc_g_g \
917
+ (char **, npy_intp *, npy_intp *, void *)
918
+ void PyUFunc_F_F_As_D_D \
919
+ (char **, npy_intp *, npy_intp *, void *)
920
+ void PyUFunc_F_F \
921
+ (char **, npy_intp *, npy_intp *, void *)
922
+ void PyUFunc_D_D \
923
+ (char **, npy_intp *, npy_intp *, void *)
924
+ void PyUFunc_G_G \
925
+ (char **, npy_intp *, npy_intp *, void *)
926
+ void PyUFunc_O_O \
927
+ (char **, npy_intp *, npy_intp *, void *)
928
+ void PyUFunc_ff_f_As_dd_d \
929
+ (char **, npy_intp *, npy_intp *, void *)
930
+ void PyUFunc_ff_f \
931
+ (char **, npy_intp *, npy_intp *, void *)
932
+ void PyUFunc_dd_d \
933
+ (char **, npy_intp *, npy_intp *, void *)
934
+ void PyUFunc_gg_g \
935
+ (char **, npy_intp *, npy_intp *, void *)
936
+ void PyUFunc_FF_F_As_DD_D \
937
+ (char **, npy_intp *, npy_intp *, void *)
938
+ void PyUFunc_DD_D \
939
+ (char **, npy_intp *, npy_intp *, void *)
940
+ void PyUFunc_FF_F \
941
+ (char **, npy_intp *, npy_intp *, void *)
942
+ void PyUFunc_GG_G \
943
+ (char **, npy_intp *, npy_intp *, void *)
944
+ void PyUFunc_OO_O \
945
+ (char **, npy_intp *, npy_intp *, void *)
946
+ void PyUFunc_O_O_method \
947
+ (char **, npy_intp *, npy_intp *, void *)
948
+ void PyUFunc_OO_O_method \
949
+ (char **, npy_intp *, npy_intp *, void *)
950
+ void PyUFunc_On_Om \
951
+ (char **, npy_intp *, npy_intp *, void *)
952
+ int PyUFunc_GetPyValues \
953
+ (char *, int *, int *, PyObject **)
954
+ int PyUFunc_checkfperr \
955
+ (int, PyObject *, int *)
956
+ void PyUFunc_clearfperr()
957
+ int PyUFunc_getfperr()
958
+ int PyUFunc_handlefperr \
959
+ (int, PyObject *, int, int *) except -1
960
+ int PyUFunc_ReplaceLoopBySignature \
961
+ (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)
962
+ object PyUFunc_FromFuncAndDataAndSignature \
963
+ (PyUFuncGenericFunction *, void **, char *, int, int, int,
964
+ int, char *, char *, int, char *)
965
+
966
+ int _import_umath() except -1
967
+
968
+ cdef inline void set_array_base(ndarray arr, object base):
969
+ Py_INCREF(base) # important to do this before stealing the reference below!
970
+ PyArray_SetBaseObject(arr, base)
971
+
972
+ cdef inline object get_array_base(ndarray arr):
973
+ base = PyArray_BASE(arr)
974
+ if base is NULL:
975
+ return None
976
+ return <object>base
977
+
978
+ # Versions of the import_* functions which are more suitable for
979
+ # Cython code.
980
+ cdef inline int import_array() except -1:
981
+ try:
982
+ __pyx_import_array()
983
+ except Exception:
984
+ raise ImportError("numpy.core.multiarray failed to import")
985
+
986
+ cdef inline int import_umath() except -1:
987
+ try:
988
+ _import_umath()
989
+ except Exception:
990
+ raise ImportError("numpy.core.umath failed to import")
991
+
992
+ cdef inline int import_ufunc() except -1:
993
+ try:
994
+ _import_umath()
995
+ except Exception:
996
+ raise ImportError("numpy.core.umath failed to import")
997
+
998
+
999
+ cdef inline bint is_timedelta64_object(object obj):
1000
+ """
1001
+ Cython equivalent of `isinstance(obj, np.timedelta64)`
1002
+
1003
+ Parameters
1004
+ ----------
1005
+ obj : object
1006
+
1007
+ Returns
1008
+ -------
1009
+ bool
1010
+ """
1011
+ return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)
1012
+
1013
+
1014
+ cdef inline bint is_datetime64_object(object obj):
1015
+ """
1016
+ Cython equivalent of `isinstance(obj, np.datetime64)`
1017
+
1018
+ Parameters
1019
+ ----------
1020
+ obj : object
1021
+
1022
+ Returns
1023
+ -------
1024
+ bool
1025
+ """
1026
+ return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)
1027
+
1028
+
1029
+ cdef inline npy_datetime get_datetime64_value(object obj) nogil:
1030
+ """
1031
+ returns the int64 value underlying scalar numpy datetime64 object
1032
+
1033
+ Note that to interpret this as a datetime, the corresponding unit is
1034
+ also needed. That can be found using `get_datetime64_unit`.
1035
+ """
1036
+ return (<PyDatetimeScalarObject*>obj).obval
1037
+
1038
+
1039
+ cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:
1040
+ """
1041
+ returns the int64 value underlying scalar numpy timedelta64 object
1042
+ """
1043
+ return (<PyTimedeltaScalarObject*>obj).obval
1044
+
1045
+
1046
+ cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:
1047
+ """
1048
+ returns the unit part of the dtype for a numpy datetime64 object.
1049
+ """
1050
+ return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.pxd ADDED
@@ -0,0 +1,1015 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.
5
+ #
6
+ # Author: Dag Sverre Seljebotn
7
+ #
8
+
9
+ DEF _buffer_format_string_len = 255
10
+
11
+ cimport cpython.buffer as pybuf
12
+ from cpython.ref cimport Py_INCREF
13
+ from cpython.mem cimport PyObject_Malloc, PyObject_Free
14
+ from cpython.object cimport PyObject, PyTypeObject
15
+ from cpython.buffer cimport PyObject_GetBuffer
16
+ from cpython.type cimport type
17
+ cimport libc.stdio as stdio
18
+
19
+ cdef extern from "Python.h":
20
+ ctypedef int Py_intptr_t
21
+ bint PyObject_TypeCheck(object obj, PyTypeObject* type)
22
+
23
+ cdef extern from "numpy/arrayobject.h":
24
+ ctypedef Py_intptr_t npy_intp
25
+ ctypedef size_t npy_uintp
26
+
27
+ cdef enum NPY_TYPES:
28
+ NPY_BOOL
29
+ NPY_BYTE
30
+ NPY_UBYTE
31
+ NPY_SHORT
32
+ NPY_USHORT
33
+ NPY_INT
34
+ NPY_UINT
35
+ NPY_LONG
36
+ NPY_ULONG
37
+ NPY_LONGLONG
38
+ NPY_ULONGLONG
39
+ NPY_FLOAT
40
+ NPY_DOUBLE
41
+ NPY_LONGDOUBLE
42
+ NPY_CFLOAT
43
+ NPY_CDOUBLE
44
+ NPY_CLONGDOUBLE
45
+ NPY_OBJECT
46
+ NPY_STRING
47
+ NPY_UNICODE
48
+ NPY_VOID
49
+ NPY_DATETIME
50
+ NPY_TIMEDELTA
51
+ NPY_NTYPES
52
+ NPY_NOTYPE
53
+
54
+ NPY_INT8
55
+ NPY_INT16
56
+ NPY_INT32
57
+ NPY_INT64
58
+ NPY_INT128
59
+ NPY_INT256
60
+ NPY_UINT8
61
+ NPY_UINT16
62
+ NPY_UINT32
63
+ NPY_UINT64
64
+ NPY_UINT128
65
+ NPY_UINT256
66
+ NPY_FLOAT16
67
+ NPY_FLOAT32
68
+ NPY_FLOAT64
69
+ NPY_FLOAT80
70
+ NPY_FLOAT96
71
+ NPY_FLOAT128
72
+ NPY_FLOAT256
73
+ NPY_COMPLEX32
74
+ NPY_COMPLEX64
75
+ NPY_COMPLEX128
76
+ NPY_COMPLEX160
77
+ NPY_COMPLEX192
78
+ NPY_COMPLEX256
79
+ NPY_COMPLEX512
80
+
81
+ NPY_INTP
82
+
83
+ ctypedef enum NPY_ORDER:
84
+ NPY_ANYORDER
85
+ NPY_CORDER
86
+ NPY_FORTRANORDER
87
+ NPY_KEEPORDER
88
+
89
+ ctypedef enum NPY_CASTING:
90
+ NPY_NO_CASTING
91
+ NPY_EQUIV_CASTING
92
+ NPY_SAFE_CASTING
93
+ NPY_SAME_KIND_CASTING
94
+ NPY_UNSAFE_CASTING
95
+
96
+ ctypedef enum NPY_CLIPMODE:
97
+ NPY_CLIP
98
+ NPY_WRAP
99
+ NPY_RAISE
100
+
101
+ ctypedef enum NPY_SCALARKIND:
102
+ NPY_NOSCALAR,
103
+ NPY_BOOL_SCALAR,
104
+ NPY_INTPOS_SCALAR,
105
+ NPY_INTNEG_SCALAR,
106
+ NPY_FLOAT_SCALAR,
107
+ NPY_COMPLEX_SCALAR,
108
+ NPY_OBJECT_SCALAR
109
+
110
+ ctypedef enum NPY_SORTKIND:
111
+ NPY_QUICKSORT
112
+ NPY_HEAPSORT
113
+ NPY_MERGESORT
114
+
115
+ ctypedef enum NPY_SEARCHSIDE:
116
+ NPY_SEARCHLEFT
117
+ NPY_SEARCHRIGHT
118
+
119
+ enum:
120
+ # DEPRECATED since NumPy 1.7 ! Do not use in new code!
121
+ NPY_C_CONTIGUOUS
122
+ NPY_F_CONTIGUOUS
123
+ NPY_CONTIGUOUS
124
+ NPY_FORTRAN
125
+ NPY_OWNDATA
126
+ NPY_FORCECAST
127
+ NPY_ENSURECOPY
128
+ NPY_ENSUREARRAY
129
+ NPY_ELEMENTSTRIDES
130
+ NPY_ALIGNED
131
+ NPY_NOTSWAPPED
132
+ NPY_WRITEABLE
133
+ NPY_ARR_HAS_DESCR
134
+
135
+ NPY_BEHAVED
136
+ NPY_BEHAVED_NS
137
+ NPY_CARRAY
138
+ NPY_CARRAY_RO
139
+ NPY_FARRAY
140
+ NPY_FARRAY_RO
141
+ NPY_DEFAULT
142
+
143
+ NPY_IN_ARRAY
144
+ NPY_OUT_ARRAY
145
+ NPY_INOUT_ARRAY
146
+ NPY_IN_FARRAY
147
+ NPY_OUT_FARRAY
148
+ NPY_INOUT_FARRAY
149
+
150
+ NPY_UPDATE_ALL
151
+
152
+ enum:
153
+ # Added in NumPy 1.7 to replace the deprecated enums above.
154
+ NPY_ARRAY_C_CONTIGUOUS
155
+ NPY_ARRAY_F_CONTIGUOUS
156
+ NPY_ARRAY_OWNDATA
157
+ NPY_ARRAY_FORCECAST
158
+ NPY_ARRAY_ENSURECOPY
159
+ NPY_ARRAY_ENSUREARRAY
160
+ NPY_ARRAY_ELEMENTSTRIDES
161
+ NPY_ARRAY_ALIGNED
162
+ NPY_ARRAY_NOTSWAPPED
163
+ NPY_ARRAY_WRITEABLE
164
+ NPY_ARRAY_WRITEBACKIFCOPY
165
+
166
+ NPY_ARRAY_BEHAVED
167
+ NPY_ARRAY_BEHAVED_NS
168
+ NPY_ARRAY_CARRAY
169
+ NPY_ARRAY_CARRAY_RO
170
+ NPY_ARRAY_FARRAY
171
+ NPY_ARRAY_FARRAY_RO
172
+ NPY_ARRAY_DEFAULT
173
+
174
+ NPY_ARRAY_IN_ARRAY
175
+ NPY_ARRAY_OUT_ARRAY
176
+ NPY_ARRAY_INOUT_ARRAY
177
+ NPY_ARRAY_IN_FARRAY
178
+ NPY_ARRAY_OUT_FARRAY
179
+ NPY_ARRAY_INOUT_FARRAY
180
+
181
+ NPY_ARRAY_UPDATE_ALL
182
+
183
+ cdef enum:
184
+ NPY_MAXDIMS
185
+
186
+ npy_intp NPY_MAX_ELSIZE
187
+
188
+ ctypedef void (*PyArray_VectorUnaryFunc)(void *, void *, npy_intp, void *, void *)
189
+
190
+ ctypedef struct PyArray_ArrayDescr:
191
+ # shape is a tuple, but Cython doesn't support "tuple shape"
192
+ # inside a non-PyObject declaration, so we have to declare it
193
+ # as just a PyObject*.
194
+ PyObject* shape
195
+
196
+ ctypedef struct PyArray_Descr:
197
+ pass
198
+
199
+ ctypedef class numpy.dtype [object PyArray_Descr, check_size ignore]:
200
+ # Use PyDataType_* macros when possible, however there are no macros
201
+ # for accessing some of the fields, so some are defined.
202
+ cdef PyTypeObject* typeobj
203
+ cdef char kind
204
+ cdef char type
205
+ # Numpy sometimes mutates this without warning (e.g. it'll
206
+ # sometimes change "|" to "<" in shared dtype objects on
207
+ # little-endian machines). If this matters to you, use
208
+ # PyArray_IsNativeByteOrder(dtype.byteorder) instead of
209
+ # directly accessing this field.
210
+ cdef char byteorder
211
+ cdef char flags
212
+ cdef int type_num
213
+ cdef int itemsize "elsize"
214
+ cdef int alignment
215
+ cdef object fields
216
+ cdef tuple names
217
+ # Use PyDataType_HASSUBARRAY to test whether this field is
218
+ # valid (the pointer can be NULL). Most users should access
219
+ # this field via the inline helper method PyDataType_SHAPE.
220
+ cdef PyArray_ArrayDescr* subarray
221
+
222
+ ctypedef class numpy.flatiter [object PyArrayIterObject, check_size ignore]:
223
+ # Use through macros
224
+ pass
225
+
226
+ ctypedef class numpy.broadcast [object PyArrayMultiIterObject, check_size ignore]:
227
+ cdef int numiter
228
+ cdef npy_intp size, index
229
+ cdef int nd
230
+ cdef npy_intp *dimensions
231
+ cdef void **iters
232
+
233
+ ctypedef struct PyArrayObject:
234
+ # For use in situations where ndarray can't replace PyArrayObject*,
235
+ # like PyArrayObject**.
236
+ pass
237
+
238
+ ctypedef class numpy.ndarray [object PyArrayObject, check_size ignore]:
239
+ cdef __cythonbufferdefaults__ = {"mode": "strided"}
240
+
241
+ cdef:
242
+ # Only taking a few of the most commonly used and stable fields.
243
+ # One should use PyArray_* macros instead to access the C fields.
244
+ char *data
245
+ int ndim "nd"
246
+ npy_intp *shape "dimensions"
247
+ npy_intp *strides
248
+ dtype descr # deprecated since NumPy 1.7 !
249
+ PyObject* base # NOT PUBLIC, DO NOT USE !
250
+
251
+
252
+
253
+ ctypedef unsigned char npy_bool
254
+
255
+ ctypedef signed char npy_byte
256
+ ctypedef signed short npy_short
257
+ ctypedef signed int npy_int
258
+ ctypedef signed long npy_long
259
+ ctypedef signed long long npy_longlong
260
+
261
+ ctypedef unsigned char npy_ubyte
262
+ ctypedef unsigned short npy_ushort
263
+ ctypedef unsigned int npy_uint
264
+ ctypedef unsigned long npy_ulong
265
+ ctypedef unsigned long long npy_ulonglong
266
+
267
+ ctypedef float npy_float
268
+ ctypedef double npy_double
269
+ ctypedef long double npy_longdouble
270
+
271
+ ctypedef signed char npy_int8
272
+ ctypedef signed short npy_int16
273
+ ctypedef signed int npy_int32
274
+ ctypedef signed long long npy_int64
275
+ ctypedef signed long long npy_int96
276
+ ctypedef signed long long npy_int128
277
+
278
+ ctypedef unsigned char npy_uint8
279
+ ctypedef unsigned short npy_uint16
280
+ ctypedef unsigned int npy_uint32
281
+ ctypedef unsigned long long npy_uint64
282
+ ctypedef unsigned long long npy_uint96
283
+ ctypedef unsigned long long npy_uint128
284
+
285
+ ctypedef float npy_float32
286
+ ctypedef double npy_float64
287
+ ctypedef long double npy_float80
288
+ ctypedef long double npy_float96
289
+ ctypedef long double npy_float128
290
+
291
+ ctypedef struct npy_cfloat:
292
+ float real
293
+ float imag
294
+
295
+ ctypedef struct npy_cdouble:
296
+ double real
297
+ double imag
298
+
299
+ ctypedef struct npy_clongdouble:
300
+ long double real
301
+ long double imag
302
+
303
+ ctypedef struct npy_complex64:
304
+ float real
305
+ float imag
306
+
307
+ ctypedef struct npy_complex128:
308
+ double real
309
+ double imag
310
+
311
+ ctypedef struct npy_complex160:
312
+ long double real
313
+ long double imag
314
+
315
+ ctypedef struct npy_complex192:
316
+ long double real
317
+ long double imag
318
+
319
+ ctypedef struct npy_complex256:
320
+ long double real
321
+ long double imag
322
+
323
+ ctypedef struct PyArray_Dims:
324
+ npy_intp *ptr
325
+ int len
326
+
327
+ int _import_array() except -1
328
+ # A second definition so _import_array isn't marked as used when we use it here.
329
+ # Do not use - subject to change any time.
330
+ int __pyx_import_array "_import_array"() except -1
331
+
332
+ #
333
+ # Macros from ndarrayobject.h
334
+ #
335
+ bint PyArray_CHKFLAGS(ndarray m, int flags) nogil
336
+ bint PyArray_IS_C_CONTIGUOUS(ndarray arr) nogil
337
+ bint PyArray_IS_F_CONTIGUOUS(ndarray arr) nogil
338
+ bint PyArray_ISCONTIGUOUS(ndarray m) nogil
339
+ bint PyArray_ISWRITEABLE(ndarray m) nogil
340
+ bint PyArray_ISALIGNED(ndarray m) nogil
341
+
342
+ int PyArray_NDIM(ndarray) nogil
343
+ bint PyArray_ISONESEGMENT(ndarray) nogil
344
+ bint PyArray_ISFORTRAN(ndarray) nogil
345
+ int PyArray_FORTRANIF(ndarray) nogil
346
+
347
+ void* PyArray_DATA(ndarray) nogil
348
+ char* PyArray_BYTES(ndarray) nogil
349
+
350
+ npy_intp* PyArray_DIMS(ndarray) nogil
351
+ npy_intp* PyArray_STRIDES(ndarray) nogil
352
+ npy_intp PyArray_DIM(ndarray, size_t) nogil
353
+ npy_intp PyArray_STRIDE(ndarray, size_t) nogil
354
+
355
+ PyObject *PyArray_BASE(ndarray) nogil # returns borrowed reference!
356
+ PyArray_Descr *PyArray_DESCR(ndarray) nogil # returns borrowed reference to dtype!
357
+ int PyArray_FLAGS(ndarray) nogil
358
+ npy_intp PyArray_ITEMSIZE(ndarray) nogil
359
+ int PyArray_TYPE(ndarray arr) nogil
360
+
361
+ object PyArray_GETITEM(ndarray arr, void *itemptr)
362
+ int PyArray_SETITEM(ndarray arr, void *itemptr, object obj) except -1
363
+
364
+ bint PyTypeNum_ISBOOL(int) nogil
365
+ bint PyTypeNum_ISUNSIGNED(int) nogil
366
+ bint PyTypeNum_ISSIGNED(int) nogil
367
+ bint PyTypeNum_ISINTEGER(int) nogil
368
+ bint PyTypeNum_ISFLOAT(int) nogil
369
+ bint PyTypeNum_ISNUMBER(int) nogil
370
+ bint PyTypeNum_ISSTRING(int) nogil
371
+ bint PyTypeNum_ISCOMPLEX(int) nogil
372
+ bint PyTypeNum_ISPYTHON(int) nogil
373
+ bint PyTypeNum_ISFLEXIBLE(int) nogil
374
+ bint PyTypeNum_ISUSERDEF(int) nogil
375
+ bint PyTypeNum_ISEXTENDED(int) nogil
376
+ bint PyTypeNum_ISOBJECT(int) nogil
377
+
378
+ bint PyDataType_ISBOOL(dtype) nogil
379
+ bint PyDataType_ISUNSIGNED(dtype) nogil
380
+ bint PyDataType_ISSIGNED(dtype) nogil
381
+ bint PyDataType_ISINTEGER(dtype) nogil
382
+ bint PyDataType_ISFLOAT(dtype) nogil
383
+ bint PyDataType_ISNUMBER(dtype) nogil
384
+ bint PyDataType_ISSTRING(dtype) nogil
385
+ bint PyDataType_ISCOMPLEX(dtype) nogil
386
+ bint PyDataType_ISPYTHON(dtype) nogil
387
+ bint PyDataType_ISFLEXIBLE(dtype) nogil
388
+ bint PyDataType_ISUSERDEF(dtype) nogil
389
+ bint PyDataType_ISEXTENDED(dtype) nogil
390
+ bint PyDataType_ISOBJECT(dtype) nogil
391
+ bint PyDataType_HASFIELDS(dtype) nogil
392
+ bint PyDataType_HASSUBARRAY(dtype) nogil
393
+
394
+ bint PyArray_ISBOOL(ndarray) nogil
395
+ bint PyArray_ISUNSIGNED(ndarray) nogil
396
+ bint PyArray_ISSIGNED(ndarray) nogil
397
+ bint PyArray_ISINTEGER(ndarray) nogil
398
+ bint PyArray_ISFLOAT(ndarray) nogil
399
+ bint PyArray_ISNUMBER(ndarray) nogil
400
+ bint PyArray_ISSTRING(ndarray) nogil
401
+ bint PyArray_ISCOMPLEX(ndarray) nogil
402
+ bint PyArray_ISPYTHON(ndarray) nogil
403
+ bint PyArray_ISFLEXIBLE(ndarray) nogil
404
+ bint PyArray_ISUSERDEF(ndarray) nogil
405
+ bint PyArray_ISEXTENDED(ndarray) nogil
406
+ bint PyArray_ISOBJECT(ndarray) nogil
407
+ bint PyArray_HASFIELDS(ndarray) nogil
408
+
409
+ bint PyArray_ISVARIABLE(ndarray) nogil
410
+
411
+ bint PyArray_SAFEALIGNEDCOPY(ndarray) nogil
412
+ bint PyArray_ISNBO(char) nogil # works on ndarray.byteorder
413
+ bint PyArray_IsNativeByteOrder(char) nogil # works on ndarray.byteorder
414
+ bint PyArray_ISNOTSWAPPED(ndarray) nogil
415
+ bint PyArray_ISBYTESWAPPED(ndarray) nogil
416
+
417
+ bint PyArray_FLAGSWAP(ndarray, int) nogil
418
+
419
+ bint PyArray_ISCARRAY(ndarray) nogil
420
+ bint PyArray_ISCARRAY_RO(ndarray) nogil
421
+ bint PyArray_ISFARRAY(ndarray) nogil
422
+ bint PyArray_ISFARRAY_RO(ndarray) nogil
423
+ bint PyArray_ISBEHAVED(ndarray) nogil
424
+ bint PyArray_ISBEHAVED_RO(ndarray) nogil
425
+
426
+
427
+ bint PyDataType_ISNOTSWAPPED(dtype) nogil
428
+ bint PyDataType_ISBYTESWAPPED(dtype) nogil
429
+
430
+ bint PyArray_DescrCheck(object)
431
+
432
+ bint PyArray_Check(object)
433
+ bint PyArray_CheckExact(object)
434
+
435
+ # Cannot be supported due to out arg:
436
+ # bint PyArray_HasArrayInterfaceType(object, dtype, object, object&)
437
+ # bint PyArray_HasArrayInterface(op, out)
438
+
439
+
440
+ bint PyArray_IsZeroDim(object)
441
+ # Cannot be supported due to ## ## in macro:
442
+ # bint PyArray_IsScalar(object, verbatim work)
443
+ bint PyArray_CheckScalar(object)
444
+ bint PyArray_IsPythonNumber(object)
445
+ bint PyArray_IsPythonScalar(object)
446
+ bint PyArray_IsAnyScalar(object)
447
+ bint PyArray_CheckAnyScalar(object)
448
+
449
+ ndarray PyArray_GETCONTIGUOUS(ndarray)
450
+ bint PyArray_SAMESHAPE(ndarray, ndarray) nogil
451
+ npy_intp PyArray_SIZE(ndarray) nogil
452
+ npy_intp PyArray_NBYTES(ndarray) nogil
453
+
454
+ object PyArray_FROM_O(object)
455
+ object PyArray_FROM_OF(object m, int flags)
456
+ object PyArray_FROM_OT(object m, int type)
457
+ object PyArray_FROM_OTF(object m, int type, int flags)
458
+ object PyArray_FROMANY(object m, int type, int min, int max, int flags)
459
+ object PyArray_ZEROS(int nd, npy_intp* dims, int type, int fortran)
460
+ object PyArray_EMPTY(int nd, npy_intp* dims, int type, int fortran)
461
+ void PyArray_FILLWBYTE(object, int val)
462
+ npy_intp PyArray_REFCOUNT(object)
463
+ object PyArray_ContiguousFromAny(op, int, int min_depth, int max_depth)
464
+ unsigned char PyArray_EquivArrTypes(ndarray a1, ndarray a2)
465
+ bint PyArray_EquivByteorders(int b1, int b2) nogil
466
+ object PyArray_SimpleNew(int nd, npy_intp* dims, int typenum)
467
+ object PyArray_SimpleNewFromData(int nd, npy_intp* dims, int typenum, void* data)
468
+ #object PyArray_SimpleNewFromDescr(int nd, npy_intp* dims, dtype descr)
469
+ object PyArray_ToScalar(void* data, ndarray arr)
470
+
471
+ void* PyArray_GETPTR1(ndarray m, npy_intp i) nogil
472
+ void* PyArray_GETPTR2(ndarray m, npy_intp i, npy_intp j) nogil
473
+ void* PyArray_GETPTR3(ndarray m, npy_intp i, npy_intp j, npy_intp k) nogil
474
+ void* PyArray_GETPTR4(ndarray m, npy_intp i, npy_intp j, npy_intp k, npy_intp l) nogil
475
+
476
+ # Cannot be supported due to out arg
477
+ # void PyArray_DESCR_REPLACE(descr)
478
+
479
+
480
+ object PyArray_Copy(ndarray)
481
+ object PyArray_FromObject(object op, int type, int min_depth, int max_depth)
482
+ object PyArray_ContiguousFromObject(object op, int type, int min_depth, int max_depth)
483
+ object PyArray_CopyFromObject(object op, int type, int min_depth, int max_depth)
484
+
485
+ object PyArray_Cast(ndarray mp, int type_num)
486
+ object PyArray_Take(ndarray ap, object items, int axis)
487
+ object PyArray_Put(ndarray ap, object items, object values)
488
+
489
+ void PyArray_ITER_RESET(flatiter it) nogil
490
+ void PyArray_ITER_NEXT(flatiter it) nogil
491
+ void PyArray_ITER_GOTO(flatiter it, npy_intp* destination) nogil
492
+ void PyArray_ITER_GOTO1D(flatiter it, npy_intp ind) nogil
493
+ void* PyArray_ITER_DATA(flatiter it) nogil
494
+ bint PyArray_ITER_NOTDONE(flatiter it) nogil
495
+
496
+ void PyArray_MultiIter_RESET(broadcast multi) nogil
497
+ void PyArray_MultiIter_NEXT(broadcast multi) nogil
498
+ void PyArray_MultiIter_GOTO(broadcast multi, npy_intp dest) nogil
499
+ void PyArray_MultiIter_GOTO1D(broadcast multi, npy_intp ind) nogil
500
+ void* PyArray_MultiIter_DATA(broadcast multi, npy_intp i) nogil
501
+ void PyArray_MultiIter_NEXTi(broadcast multi, npy_intp i) nogil
502
+ bint PyArray_MultiIter_NOTDONE(broadcast multi) nogil
503
+
504
+ # Functions from __multiarray_api.h
505
+
506
+ # Functions taking dtype and returning object/ndarray are disabled
507
+ # for now as they steal dtype references. I'm conservative and disable
508
+ # more than is probably needed until it can be checked further.
509
+ int PyArray_SetNumericOps (object) except -1
510
+ object PyArray_GetNumericOps ()
511
+ int PyArray_INCREF (ndarray) except * # uses PyArray_Item_INCREF...
512
+ int PyArray_XDECREF (ndarray) except * # uses PyArray_Item_DECREF...
513
+ void PyArray_SetStringFunction (object, int)
514
+ dtype PyArray_DescrFromType (int)
515
+ object PyArray_TypeObjectFromType (int)
516
+ char * PyArray_Zero (ndarray)
517
+ char * PyArray_One (ndarray)
518
+ #object PyArray_CastToType (ndarray, dtype, int)
519
+ int PyArray_CastTo (ndarray, ndarray) except -1
520
+ int PyArray_CastAnyTo (ndarray, ndarray) except -1
521
+ int PyArray_CanCastSafely (int, int) # writes errors
522
+ npy_bool PyArray_CanCastTo (dtype, dtype) # writes errors
523
+ int PyArray_ObjectType (object, int) except 0
524
+ dtype PyArray_DescrFromObject (object, dtype)
525
+ #ndarray* PyArray_ConvertToCommonType (object, int *)
526
+ dtype PyArray_DescrFromScalar (object)
527
+ dtype PyArray_DescrFromTypeObject (object)
528
+ npy_intp PyArray_Size (object)
529
+ #object PyArray_Scalar (void *, dtype, object)
530
+ #object PyArray_FromScalar (object, dtype)
531
+ void PyArray_ScalarAsCtype (object, void *)
532
+ #int PyArray_CastScalarToCtype (object, void *, dtype)
533
+ #int PyArray_CastScalarDirect (object, dtype, void *, int)
534
+ object PyArray_ScalarFromObject (object)
535
+ #PyArray_VectorUnaryFunc * PyArray_GetCastFunc (dtype, int)
536
+ object PyArray_FromDims (int, int *, int)
537
+ #object PyArray_FromDimsAndDataAndDescr (int, int *, dtype, char *)
538
+ #object PyArray_FromAny (object, dtype, int, int, int, object)
539
+ object PyArray_EnsureArray (object)
540
+ object PyArray_EnsureAnyArray (object)
541
+ #object PyArray_FromFile (stdio.FILE *, dtype, npy_intp, char *)
542
+ #object PyArray_FromString (char *, npy_intp, dtype, npy_intp, char *)
543
+ #object PyArray_FromBuffer (object, dtype, npy_intp, npy_intp)
544
+ #object PyArray_FromIter (object, dtype, npy_intp)
545
+ object PyArray_Return (ndarray)
546
+ #object PyArray_GetField (ndarray, dtype, int)
547
+ #int PyArray_SetField (ndarray, dtype, int, object) except -1
548
+ object PyArray_Byteswap (ndarray, npy_bool)
549
+ object PyArray_Resize (ndarray, PyArray_Dims *, int, NPY_ORDER)
550
+ int PyArray_MoveInto (ndarray, ndarray) except -1
551
+ int PyArray_CopyInto (ndarray, ndarray) except -1
552
+ int PyArray_CopyAnyInto (ndarray, ndarray) except -1
553
+ int PyArray_CopyObject (ndarray, object) except -1
554
+ object PyArray_NewCopy (ndarray, NPY_ORDER)
555
+ object PyArray_ToList (ndarray)
556
+ object PyArray_ToString (ndarray, NPY_ORDER)
557
+ int PyArray_ToFile (ndarray, stdio.FILE *, char *, char *) except -1
558
+ int PyArray_Dump (object, object, int) except -1
559
+ object PyArray_Dumps (object, int)
560
+ int PyArray_ValidType (int) # Cannot error
561
+ void PyArray_UpdateFlags (ndarray, int)
562
+ object PyArray_New (type, int, npy_intp *, int, npy_intp *, void *, int, int, object)
563
+ #object PyArray_NewFromDescr (type, dtype, int, npy_intp *, npy_intp *, void *, int, object)
564
+ #dtype PyArray_DescrNew (dtype)
565
+ dtype PyArray_DescrNewFromType (int)
566
+ double PyArray_GetPriority (object, double) # clears errors as of 1.25
567
+ object PyArray_IterNew (object)
568
+ object PyArray_MultiIterNew (int, ...)
569
+
570
+ int PyArray_PyIntAsInt (object) except? -1
571
+ npy_intp PyArray_PyIntAsIntp (object)
572
+ int PyArray_Broadcast (broadcast) except -1
573
+ void PyArray_FillObjectArray (ndarray, object) except *
574
+ int PyArray_FillWithScalar (ndarray, object) except -1
575
+ npy_bool PyArray_CheckStrides (int, int, npy_intp, npy_intp, npy_intp *, npy_intp *)
576
+ dtype PyArray_DescrNewByteorder (dtype, char)
577
+ object PyArray_IterAllButAxis (object, int *)
578
+ #object PyArray_CheckFromAny (object, dtype, int, int, int, object)
579
+ #object PyArray_FromArray (ndarray, dtype, int)
580
+ object PyArray_FromInterface (object)
581
+ object PyArray_FromStructInterface (object)
582
+ #object PyArray_FromArrayAttr (object, dtype, object)
583
+ #NPY_SCALARKIND PyArray_ScalarKind (int, ndarray*)
584
+ int PyArray_CanCoerceScalar (int, int, NPY_SCALARKIND)
585
+ object PyArray_NewFlagsObject (object)
586
+ npy_bool PyArray_CanCastScalar (type, type)
587
+ #int PyArray_CompareUCS4 (npy_ucs4 *, npy_ucs4 *, register size_t)
588
+ int PyArray_RemoveSmallest (broadcast) except -1
589
+ int PyArray_ElementStrides (object)
590
+ void PyArray_Item_INCREF (char *, dtype) except *
591
+ void PyArray_Item_XDECREF (char *, dtype) except *
592
+ object PyArray_FieldNames (object)
593
+ object PyArray_Transpose (ndarray, PyArray_Dims *)
594
+ object PyArray_TakeFrom (ndarray, object, int, ndarray, NPY_CLIPMODE)
595
+ object PyArray_PutTo (ndarray, object, object, NPY_CLIPMODE)
596
+ object PyArray_PutMask (ndarray, object, object)
597
+ object PyArray_Repeat (ndarray, object, int)
598
+ object PyArray_Choose (ndarray, object, ndarray, NPY_CLIPMODE)
599
+ int PyArray_Sort (ndarray, int, NPY_SORTKIND) except -1
600
+ object PyArray_ArgSort (ndarray, int, NPY_SORTKIND)
601
+ object PyArray_SearchSorted (ndarray, object, NPY_SEARCHSIDE, PyObject *)
602
+ object PyArray_ArgMax (ndarray, int, ndarray)
603
+ object PyArray_ArgMin (ndarray, int, ndarray)
604
+ object PyArray_Reshape (ndarray, object)
605
+ object PyArray_Newshape (ndarray, PyArray_Dims *, NPY_ORDER)
606
+ object PyArray_Squeeze (ndarray)
607
+ #object PyArray_View (ndarray, dtype, type)
608
+ object PyArray_SwapAxes (ndarray, int, int)
609
+ object PyArray_Max (ndarray, int, ndarray)
610
+ object PyArray_Min (ndarray, int, ndarray)
611
+ object PyArray_Ptp (ndarray, int, ndarray)
612
+ object PyArray_Mean (ndarray, int, int, ndarray)
613
+ object PyArray_Trace (ndarray, int, int, int, int, ndarray)
614
+ object PyArray_Diagonal (ndarray, int, int, int)
615
+ object PyArray_Clip (ndarray, object, object, ndarray)
616
+ object PyArray_Conjugate (ndarray, ndarray)
617
+ object PyArray_Nonzero (ndarray)
618
+ object PyArray_Std (ndarray, int, int, ndarray, int)
619
+ object PyArray_Sum (ndarray, int, int, ndarray)
620
+ object PyArray_CumSum (ndarray, int, int, ndarray)
621
+ object PyArray_Prod (ndarray, int, int, ndarray)
622
+ object PyArray_CumProd (ndarray, int, int, ndarray)
623
+ object PyArray_All (ndarray, int, ndarray)
624
+ object PyArray_Any (ndarray, int, ndarray)
625
+ object PyArray_Compress (ndarray, object, int, ndarray)
626
+ object PyArray_Flatten (ndarray, NPY_ORDER)
627
+ object PyArray_Ravel (ndarray, NPY_ORDER)
628
+ npy_intp PyArray_MultiplyList (npy_intp *, int)
629
+ int PyArray_MultiplyIntList (int *, int)
630
+ void * PyArray_GetPtr (ndarray, npy_intp*)
631
+ int PyArray_CompareLists (npy_intp *, npy_intp *, int)
632
+ #int PyArray_AsCArray (object*, void *, npy_intp *, int, dtype)
633
+ #int PyArray_As1D (object*, char **, int *, int)
634
+ #int PyArray_As2D (object*, char ***, int *, int *, int)
635
+ int PyArray_Free (object, void *)
636
+ #int PyArray_Converter (object, object*)
637
+ int PyArray_IntpFromSequence (object, npy_intp *, int) except -1
638
+ object PyArray_Concatenate (object, int)
639
+ object PyArray_InnerProduct (object, object)
640
+ object PyArray_MatrixProduct (object, object)
641
+ object PyArray_CopyAndTranspose (object)
642
+ object PyArray_Correlate (object, object, int)
643
+ int PyArray_TypestrConvert (int, int)
644
+ #int PyArray_DescrConverter (object, dtype*) except 0
645
+ #int PyArray_DescrConverter2 (object, dtype*) except 0
646
+ int PyArray_IntpConverter (object, PyArray_Dims *) except 0
647
+ #int PyArray_BufferConverter (object, chunk) except 0
648
+ int PyArray_AxisConverter (object, int *) except 0
649
+ int PyArray_BoolConverter (object, npy_bool *) except 0
650
+ int PyArray_ByteorderConverter (object, char *) except 0
651
+ int PyArray_OrderConverter (object, NPY_ORDER *) except 0
652
+ unsigned char PyArray_EquivTypes (dtype, dtype) # clears errors
653
+ #object PyArray_Zeros (int, npy_intp *, dtype, int)
654
+ #object PyArray_Empty (int, npy_intp *, dtype, int)
655
+ object PyArray_Where (object, object, object)
656
+ object PyArray_Arange (double, double, double, int)
657
+ #object PyArray_ArangeObj (object, object, object, dtype)
658
+ int PyArray_SortkindConverter (object, NPY_SORTKIND *) except 0
659
+ object PyArray_LexSort (object, int)
660
+ object PyArray_Round (ndarray, int, ndarray)
661
+ unsigned char PyArray_EquivTypenums (int, int)
662
+ int PyArray_RegisterDataType (dtype) except -1
663
+ int PyArray_RegisterCastFunc (dtype, int, PyArray_VectorUnaryFunc *) except -1
664
+ int PyArray_RegisterCanCast (dtype, int, NPY_SCALARKIND) except -1
665
+ #void PyArray_InitArrFuncs (PyArray_ArrFuncs *)
666
+ object PyArray_IntTupleFromIntp (int, npy_intp *)
667
+ int PyArray_TypeNumFromName (char *)
668
+ int PyArray_ClipmodeConverter (object, NPY_CLIPMODE *) except 0
669
+ #int PyArray_OutputConverter (object, ndarray*) except 0
670
+ object PyArray_BroadcastToShape (object, npy_intp *, int)
671
+ void _PyArray_SigintHandler (int)
672
+ void* _PyArray_GetSigintBuf ()
673
+ #int PyArray_DescrAlignConverter (object, dtype*) except 0
674
+ #int PyArray_DescrAlignConverter2 (object, dtype*) except 0
675
+ int PyArray_SearchsideConverter (object, void *) except 0
676
+ object PyArray_CheckAxis (ndarray, int *, int)
677
+ npy_intp PyArray_OverflowMultiplyList (npy_intp *, int)
678
+ int PyArray_CompareString (char *, char *, size_t)
679
+ int PyArray_SetBaseObject(ndarray, base) except -1 # NOTE: steals a reference to base! Use "set_array_base()" instead.
680
+
681
+
682
+ # Typedefs that matches the runtime dtype objects in
683
+ # the numpy module.
684
+
685
+ # The ones that are commented out needs an IFDEF function
686
+ # in Cython to enable them only on the right systems.
687
+
688
+ ctypedef npy_int8 int8_t
689
+ ctypedef npy_int16 int16_t
690
+ ctypedef npy_int32 int32_t
691
+ ctypedef npy_int64 int64_t
692
+ #ctypedef npy_int96 int96_t
693
+ #ctypedef npy_int128 int128_t
694
+
695
+ ctypedef npy_uint8 uint8_t
696
+ ctypedef npy_uint16 uint16_t
697
+ ctypedef npy_uint32 uint32_t
698
+ ctypedef npy_uint64 uint64_t
699
+ #ctypedef npy_uint96 uint96_t
700
+ #ctypedef npy_uint128 uint128_t
701
+
702
+ ctypedef npy_float32 float32_t
703
+ ctypedef npy_float64 float64_t
704
+ #ctypedef npy_float80 float80_t
705
+ #ctypedef npy_float128 float128_t
706
+
707
+ ctypedef float complex complex64_t
708
+ ctypedef double complex complex128_t
709
+
710
+ # The int types are mapped a bit surprising --
711
+ # numpy.int corresponds to 'l' and numpy.long to 'q'
712
+ ctypedef npy_long int_t
713
+ ctypedef npy_longlong longlong_t
714
+
715
+ ctypedef npy_ulong uint_t
716
+ ctypedef npy_ulonglong ulonglong_t
717
+
718
+ ctypedef npy_intp intp_t
719
+ ctypedef npy_uintp uintp_t
720
+
721
+ ctypedef npy_double float_t
722
+ ctypedef npy_double double_t
723
+ ctypedef npy_longdouble longdouble_t
724
+
725
+ ctypedef npy_cfloat cfloat_t
726
+ ctypedef npy_cdouble cdouble_t
727
+ ctypedef npy_clongdouble clongdouble_t
728
+
729
+ ctypedef npy_cdouble complex_t
730
+
731
+ cdef inline object PyArray_MultiIterNew1(a):
732
+ return PyArray_MultiIterNew(1, <void*>a)
733
+
734
+ cdef inline object PyArray_MultiIterNew2(a, b):
735
+ return PyArray_MultiIterNew(2, <void*>a, <void*>b)
736
+
737
+ cdef inline object PyArray_MultiIterNew3(a, b, c):
738
+ return PyArray_MultiIterNew(3, <void*>a, <void*>b, <void*> c)
739
+
740
+ cdef inline object PyArray_MultiIterNew4(a, b, c, d):
741
+ return PyArray_MultiIterNew(4, <void*>a, <void*>b, <void*>c, <void*> d)
742
+
743
+ cdef inline object PyArray_MultiIterNew5(a, b, c, d, e):
744
+ return PyArray_MultiIterNew(5, <void*>a, <void*>b, <void*>c, <void*> d, <void*> e)
745
+
746
+ cdef inline tuple PyDataType_SHAPE(dtype d):
747
+ if PyDataType_HASSUBARRAY(d):
748
+ return <tuple>d.subarray.shape
749
+ else:
750
+ return ()
751
+
752
+
753
+ cdef extern from "numpy/ndarrayobject.h":
754
+ PyTypeObject PyTimedeltaArrType_Type
755
+ PyTypeObject PyDatetimeArrType_Type
756
+ ctypedef int64_t npy_timedelta
757
+ ctypedef int64_t npy_datetime
758
+
759
+ cdef extern from "numpy/ndarraytypes.h":
760
+ ctypedef struct PyArray_DatetimeMetaData:
761
+ NPY_DATETIMEUNIT base
762
+ int64_t num
763
+
764
+ cdef extern from "numpy/arrayscalars.h":
765
+
766
+ # abstract types
767
+ ctypedef class numpy.generic [object PyObject]:
768
+ pass
769
+ ctypedef class numpy.number [object PyObject]:
770
+ pass
771
+ ctypedef class numpy.integer [object PyObject]:
772
+ pass
773
+ ctypedef class numpy.signedinteger [object PyObject]:
774
+ pass
775
+ ctypedef class numpy.unsignedinteger [object PyObject]:
776
+ pass
777
+ ctypedef class numpy.inexact [object PyObject]:
778
+ pass
779
+ ctypedef class numpy.floating [object PyObject]:
780
+ pass
781
+ ctypedef class numpy.complexfloating [object PyObject]:
782
+ pass
783
+ ctypedef class numpy.flexible [object PyObject]:
784
+ pass
785
+ ctypedef class numpy.character [object PyObject]:
786
+ pass
787
+
788
+ ctypedef struct PyDatetimeScalarObject:
789
+ # PyObject_HEAD
790
+ npy_datetime obval
791
+ PyArray_DatetimeMetaData obmeta
792
+
793
+ ctypedef struct PyTimedeltaScalarObject:
794
+ # PyObject_HEAD
795
+ npy_timedelta obval
796
+ PyArray_DatetimeMetaData obmeta
797
+
798
+ ctypedef enum NPY_DATETIMEUNIT:
799
+ NPY_FR_Y
800
+ NPY_FR_M
801
+ NPY_FR_W
802
+ NPY_FR_D
803
+ NPY_FR_B
804
+ NPY_FR_h
805
+ NPY_FR_m
806
+ NPY_FR_s
807
+ NPY_FR_ms
808
+ NPY_FR_us
809
+ NPY_FR_ns
810
+ NPY_FR_ps
811
+ NPY_FR_fs
812
+ NPY_FR_as
813
+ NPY_FR_GENERIC
814
+
815
+
816
+ #
817
+ # ufunc API
818
+ #
819
+
820
+ cdef extern from "numpy/ufuncobject.h":
821
+
822
+ ctypedef void (*PyUFuncGenericFunction) (char **, npy_intp *, npy_intp *, void *)
823
+
824
+ ctypedef class numpy.ufunc [object PyUFuncObject, check_size ignore]:
825
+ cdef:
826
+ int nin, nout, nargs
827
+ int identity
828
+ PyUFuncGenericFunction *functions
829
+ void **data
830
+ int ntypes
831
+ int check_return
832
+ char *name
833
+ char *types
834
+ char *doc
835
+ void *ptr
836
+ PyObject *obj
837
+ PyObject *userloops
838
+
839
+ cdef enum:
840
+ PyUFunc_Zero
841
+ PyUFunc_One
842
+ PyUFunc_None
843
+ UFUNC_ERR_IGNORE
844
+ UFUNC_ERR_WARN
845
+ UFUNC_ERR_RAISE
846
+ UFUNC_ERR_CALL
847
+ UFUNC_ERR_PRINT
848
+ UFUNC_ERR_LOG
849
+ UFUNC_MASK_DIVIDEBYZERO
850
+ UFUNC_MASK_OVERFLOW
851
+ UFUNC_MASK_UNDERFLOW
852
+ UFUNC_MASK_INVALID
853
+ UFUNC_SHIFT_DIVIDEBYZERO
854
+ UFUNC_SHIFT_OVERFLOW
855
+ UFUNC_SHIFT_UNDERFLOW
856
+ UFUNC_SHIFT_INVALID
857
+ UFUNC_FPE_DIVIDEBYZERO
858
+ UFUNC_FPE_OVERFLOW
859
+ UFUNC_FPE_UNDERFLOW
860
+ UFUNC_FPE_INVALID
861
+ UFUNC_ERR_DEFAULT
862
+ UFUNC_ERR_DEFAULT2
863
+
864
+ object PyUFunc_FromFuncAndData(PyUFuncGenericFunction *,
865
+ void **, char *, int, int, int, int, char *, char *, int)
866
+ int PyUFunc_RegisterLoopForType(ufunc, int,
867
+ PyUFuncGenericFunction, int *, void *) except -1
868
+ void PyUFunc_f_f_As_d_d \
869
+ (char **, npy_intp *, npy_intp *, void *)
870
+ void PyUFunc_d_d \
871
+ (char **, npy_intp *, npy_intp *, void *)
872
+ void PyUFunc_f_f \
873
+ (char **, npy_intp *, npy_intp *, void *)
874
+ void PyUFunc_g_g \
875
+ (char **, npy_intp *, npy_intp *, void *)
876
+ void PyUFunc_F_F_As_D_D \
877
+ (char **, npy_intp *, npy_intp *, void *)
878
+ void PyUFunc_F_F \
879
+ (char **, npy_intp *, npy_intp *, void *)
880
+ void PyUFunc_D_D \
881
+ (char **, npy_intp *, npy_intp *, void *)
882
+ void PyUFunc_G_G \
883
+ (char **, npy_intp *, npy_intp *, void *)
884
+ void PyUFunc_O_O \
885
+ (char **, npy_intp *, npy_intp *, void *)
886
+ void PyUFunc_ff_f_As_dd_d \
887
+ (char **, npy_intp *, npy_intp *, void *)
888
+ void PyUFunc_ff_f \
889
+ (char **, npy_intp *, npy_intp *, void *)
890
+ void PyUFunc_dd_d \
891
+ (char **, npy_intp *, npy_intp *, void *)
892
+ void PyUFunc_gg_g \
893
+ (char **, npy_intp *, npy_intp *, void *)
894
+ void PyUFunc_FF_F_As_DD_D \
895
+ (char **, npy_intp *, npy_intp *, void *)
896
+ void PyUFunc_DD_D \
897
+ (char **, npy_intp *, npy_intp *, void *)
898
+ void PyUFunc_FF_F \
899
+ (char **, npy_intp *, npy_intp *, void *)
900
+ void PyUFunc_GG_G \
901
+ (char **, npy_intp *, npy_intp *, void *)
902
+ void PyUFunc_OO_O \
903
+ (char **, npy_intp *, npy_intp *, void *)
904
+ void PyUFunc_O_O_method \
905
+ (char **, npy_intp *, npy_intp *, void *)
906
+ void PyUFunc_OO_O_method \
907
+ (char **, npy_intp *, npy_intp *, void *)
908
+ void PyUFunc_On_Om \
909
+ (char **, npy_intp *, npy_intp *, void *)
910
+ int PyUFunc_GetPyValues \
911
+ (char *, int *, int *, PyObject **)
912
+ int PyUFunc_checkfperr \
913
+ (int, PyObject *, int *)
914
+ void PyUFunc_clearfperr()
915
+ int PyUFunc_getfperr()
916
+ int PyUFunc_handlefperr \
917
+ (int, PyObject *, int, int *) except -1
918
+ int PyUFunc_ReplaceLoopBySignature \
919
+ (ufunc, PyUFuncGenericFunction, int *, PyUFuncGenericFunction *)
920
+ object PyUFunc_FromFuncAndDataAndSignature \
921
+ (PyUFuncGenericFunction *, void **, char *, int, int, int,
922
+ int, char *, char *, int, char *)
923
+
924
+ int _import_umath() except -1
925
+
926
+ cdef inline void set_array_base(ndarray arr, object base):
927
+ Py_INCREF(base) # important to do this before stealing the reference below!
928
+ PyArray_SetBaseObject(arr, base)
929
+
930
+ cdef inline object get_array_base(ndarray arr):
931
+ base = PyArray_BASE(arr)
932
+ if base is NULL:
933
+ return None
934
+ return <object>base
935
+
936
+ # Versions of the import_* functions which are more suitable for
937
+ # Cython code.
938
+ cdef inline int import_array() except -1:
939
+ try:
940
+ __pyx_import_array()
941
+ except Exception:
942
+ raise ImportError("numpy.core.multiarray failed to import")
943
+
944
+ cdef inline int import_umath() except -1:
945
+ try:
946
+ _import_umath()
947
+ except Exception:
948
+ raise ImportError("numpy.core.umath failed to import")
949
+
950
+ cdef inline int import_ufunc() except -1:
951
+ try:
952
+ _import_umath()
953
+ except Exception:
954
+ raise ImportError("numpy.core.umath failed to import")
955
+
956
+ cdef extern from *:
957
+ # Leave a marker that the NumPy declarations came from this file
958
+ # See https://github.com/cython/cython/issues/3573
959
+ """
960
+ /* NumPy API declarations from "numpy/__init__.pxd" */
961
+ """
962
+
963
+
964
+ cdef inline bint is_timedelta64_object(object obj):
965
+ """
966
+ Cython equivalent of `isinstance(obj, np.timedelta64)`
967
+
968
+ Parameters
969
+ ----------
970
+ obj : object
971
+
972
+ Returns
973
+ -------
974
+ bool
975
+ """
976
+ return PyObject_TypeCheck(obj, &PyTimedeltaArrType_Type)
977
+
978
+
979
+ cdef inline bint is_datetime64_object(object obj):
980
+ """
981
+ Cython equivalent of `isinstance(obj, np.datetime64)`
982
+
983
+ Parameters
984
+ ----------
985
+ obj : object
986
+
987
+ Returns
988
+ -------
989
+ bool
990
+ """
991
+ return PyObject_TypeCheck(obj, &PyDatetimeArrType_Type)
992
+
993
+
994
+ cdef inline npy_datetime get_datetime64_value(object obj) nogil:
995
+ """
996
+ returns the int64 value underlying scalar numpy datetime64 object
997
+
998
+ Note that to interpret this as a datetime, the corresponding unit is
999
+ also needed. That can be found using `get_datetime64_unit`.
1000
+ """
1001
+ return (<PyDatetimeScalarObject*>obj).obval
1002
+
1003
+
1004
+ cdef inline npy_timedelta get_timedelta64_value(object obj) nogil:
1005
+ """
1006
+ returns the int64 value underlying scalar numpy timedelta64 object
1007
+ """
1008
+ return (<PyTimedeltaScalarObject*>obj).obval
1009
+
1010
+
1011
+ cdef inline NPY_DATETIMEUNIT get_datetime64_unit(object obj) nogil:
1012
+ """
1013
+ returns the unit part of the dtype for a numpy datetime64 object.
1014
+ """
1015
+ return <NPY_DATETIMEUNIT>(<PyDatetimeScalarObject*>obj).obmeta.base
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.py ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ To search for documents containing a keyword, do::
42
+
43
+ >>> np.lookfor('keyword')
44
+ ... # doctest: +SKIP
45
+
46
+ General-purpose documents like a glossary and help on the basic concepts
47
+ of numpy are available under the ``doc`` sub-module::
48
+
49
+ >>> from numpy import doc
50
+ >>> help(doc)
51
+ ... # doctest: +SKIP
52
+
53
+ Available subpackages
54
+ ---------------------
55
+ lib
56
+ Basic functions used by several sub-packages.
57
+ random
58
+ Core Random Tools
59
+ linalg
60
+ Core Linear Algebra Tools
61
+ fft
62
+ Core FFT routines
63
+ polynomial
64
+ Polynomial tools
65
+ testing
66
+ NumPy testing tools
67
+ distutils
68
+ Enhancements to distutils with support for
69
+ Fortran compilers support and more (for Python <= 3.11).
70
+
71
+ Utilities
72
+ ---------
73
+ test
74
+ Run numpy unittests
75
+ show_config
76
+ Show numpy build configuration
77
+ matlib
78
+ Make everything matrices.
79
+ __version__
80
+ NumPy version string
81
+
82
+ Viewing documentation using IPython
83
+ -----------------------------------
84
+
85
+ Start IPython and import `numpy` usually under the alias ``np``: `import
86
+ numpy as np`. Then, directly past or use the ``%cpaste`` magic to paste
87
+ examples into the shell. To see which functions are available in `numpy`,
88
+ type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
89
+ ``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
90
+ down the list. To view the docstring for a function, use
91
+ ``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
92
+ the source code).
93
+
94
+ Copies vs. in-place operation
95
+ -----------------------------
96
+ Most of the functions in `numpy` return a copy of the array argument
97
+ (e.g., `np.sort`). In-place versions of these functions are often
98
+ available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
99
+ Exceptions to this rule are documented.
100
+
101
+ """
102
+ import sys
103
+ import warnings
104
+
105
+ from ._globals import _NoValue, _CopyMode
106
+ # These exceptions were moved in 1.25 and are hidden from __dir__()
107
+ from .exceptions import (
108
+ ComplexWarning, ModuleDeprecationWarning, VisibleDeprecationWarning,
109
+ TooHardError, AxisError)
110
+
111
+
112
+ # If a version with git hash was stored, use that instead
113
+ from . import version
114
+ from .version import __version__
115
+
116
+ # We first need to detect if we're being called as part of the numpy setup
117
+ # procedure itself in a reliable manner.
118
+ try:
119
+ __NUMPY_SETUP__
120
+ except NameError:
121
+ __NUMPY_SETUP__ = False
122
+
123
+ if __NUMPY_SETUP__:
124
+ sys.stderr.write('Running from numpy source directory.\n')
125
+ else:
126
+ # Allow distributors to run custom init code before importing numpy.core
127
+ from . import _distributor_init
128
+
129
+ try:
130
+ from numpy.__config__ import show as show_config
131
+ except ImportError as e:
132
+ msg = """Error importing numpy: you should not try to import numpy from
133
+ its source directory; please exit the numpy source tree, and relaunch
134
+ your python interpreter from there."""
135
+ raise ImportError(msg) from e
136
+
137
+ __all__ = [
138
+ 'exceptions', 'ModuleDeprecationWarning', 'VisibleDeprecationWarning',
139
+ 'ComplexWarning', 'TooHardError', 'AxisError']
140
+
141
+ # mapping of {name: (value, deprecation_msg)}
142
+ __deprecated_attrs__ = {}
143
+
144
+ from . import core
145
+ from .core import *
146
+ from . import compat
147
+ from . import exceptions
148
+ from . import dtypes
149
+ from . import lib
150
+ # NOTE: to be revisited following future namespace cleanup.
151
+ # See gh-14454 and gh-15672 for discussion.
152
+ from .lib import *
153
+
154
+ from . import linalg
155
+ from . import fft
156
+ from . import polynomial
157
+ from . import random
158
+ from . import ctypeslib
159
+ from . import ma
160
+ from . import matrixlib as _mat
161
+ from .matrixlib import *
162
+
163
+ # Deprecations introduced in NumPy 1.20.0, 2020-06-06
164
+ import builtins as _builtins
165
+
166
+ _msg = (
167
+ "module 'numpy' has no attribute '{n}'.\n"
168
+ "`np.{n}` was a deprecated alias for the builtin `{n}`. "
169
+ "To avoid this error in existing code, use `{n}` by itself. "
170
+ "Doing this will not modify any behavior and is safe. {extended_msg}\n"
171
+ "The aliases was originally deprecated in NumPy 1.20; for more "
172
+ "details and guidance see the original release note at:\n"
173
+ " https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations")
174
+
175
+ _specific_msg = (
176
+ "If you specifically wanted the numpy scalar type, use `np.{}` here.")
177
+
178
+ _int_extended_msg = (
179
+ "When replacing `np.{}`, you may wish to use e.g. `np.int64` "
180
+ "or `np.int32` to specify the precision. If you wish to review "
181
+ "your current use, check the release note link for "
182
+ "additional information.")
183
+
184
+ _type_info = [
185
+ ("object", ""), # The NumPy scalar only exists by name.
186
+ ("bool", _specific_msg.format("bool_")),
187
+ ("float", _specific_msg.format("float64")),
188
+ ("complex", _specific_msg.format("complex128")),
189
+ ("str", _specific_msg.format("str_")),
190
+ ("int", _int_extended_msg.format("int"))]
191
+
192
+ __former_attrs__ = {
193
+ n: _msg.format(n=n, extended_msg=extended_msg)
194
+ for n, extended_msg in _type_info
195
+ }
196
+
197
+ # Future warning introduced in NumPy 1.24.0, 2022-11-17
198
+ _msg = (
199
+ "`np.{n}` is a deprecated alias for `{an}`. (Deprecated NumPy 1.24)")
200
+
201
+ # Some of these are awkward (since `np.str` may be preferable in the long
202
+ # term), but overall the names ending in 0 seem undesirable
203
+ _type_info = [
204
+ ("bool8", bool_, "np.bool_"),
205
+ ("int0", intp, "np.intp"),
206
+ ("uint0", uintp, "np.uintp"),
207
+ ("str0", str_, "np.str_"),
208
+ ("bytes0", bytes_, "np.bytes_"),
209
+ ("void0", void, "np.void"),
210
+ ("object0", object_,
211
+ "`np.object0` is a deprecated alias for `np.object_`. "
212
+ "`object` can be used instead. (Deprecated NumPy 1.24)")]
213
+
214
+ # Some of these could be defined right away, but most were aliases to
215
+ # the Python objects and only removed in NumPy 1.24. Defining them should
216
+ # probably wait for NumPy 1.26 or 2.0.
217
+ # When defined, these should possibly not be added to `__all__` to avoid
218
+ # import with `from numpy import *`.
219
+ __future_scalars__ = {"bool", "long", "ulong", "str", "bytes", "object"}
220
+
221
+ __deprecated_attrs__.update({
222
+ n: (alias, _msg.format(n=n, an=an)) for n, alias, an in _type_info})
223
+
224
+ import math
225
+
226
+ __deprecated_attrs__['math'] = (math,
227
+ "`np.math` is a deprecated alias for the standard library `math` "
228
+ "module (Deprecated Numpy 1.25). Replace usages of `np.math` with "
229
+ "`math`")
230
+
231
+ del math, _msg, _type_info
232
+
233
+ from .core import abs
234
+ # now that numpy modules are imported, can initialize limits
235
+ core.getlimits._register_known_types()
236
+
237
+ __all__.extend(['__version__', 'show_config'])
238
+ __all__.extend(core.__all__)
239
+ __all__.extend(_mat.__all__)
240
+ __all__.extend(lib.__all__)
241
+ __all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
242
+
243
+ # Remove min and max from __all__ to avoid `from numpy import *` override
244
+ # the builtins min/max. Temporary fix for 1.25.x/1.26.x, see gh-24229.
245
+ __all__.remove('min')
246
+ __all__.remove('max')
247
+ __all__.remove('round')
248
+
249
+ # Remove one of the two occurrences of `issubdtype`, which is exposed as
250
+ # both `numpy.core.issubdtype` and `numpy.lib.issubdtype`.
251
+ __all__.remove('issubdtype')
252
+
253
+ # These are exported by np.core, but are replaced by the builtins below
254
+ # remove them to ensure that we don't end up with `np.long == np.int_`,
255
+ # which would be a breaking change.
256
+ del long, unicode
257
+ __all__.remove('long')
258
+ __all__.remove('unicode')
259
+
260
+ # Remove things that are in the numpy.lib but not in the numpy namespace
261
+ # Note that there is a test (numpy/tests/test_public_api.py:test_numpy_namespace)
262
+ # that prevents adding more things to the main namespace by accident.
263
+ # The list below will grow until the `from .lib import *` fixme above is
264
+ # taken care of
265
+ __all__.remove('Arrayterator')
266
+ del Arrayterator
267
+
268
+ # These names were removed in NumPy 1.20. For at least one release,
269
+ # attempts to access these names in the numpy namespace will trigger
270
+ # a warning, and calling the function will raise an exception.
271
+ _financial_names = ['fv', 'ipmt', 'irr', 'mirr', 'nper', 'npv', 'pmt',
272
+ 'ppmt', 'pv', 'rate']
273
+ __expired_functions__ = {
274
+ name: (f'In accordance with NEP 32, the function {name} was removed '
275
+ 'from NumPy version 1.20. A replacement for this function '
276
+ 'is available in the numpy_financial library: '
277
+ 'https://pypi.org/project/numpy-financial')
278
+ for name in _financial_names}
279
+
280
+ # Filter out Cython harmless warnings
281
+ warnings.filterwarnings("ignore", message="numpy.dtype size changed")
282
+ warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
283
+ warnings.filterwarnings("ignore", message="numpy.ndarray size changed")
284
+
285
+ # oldnumeric and numarray were removed in 1.9. In case some packages import
286
+ # but do not use them, we define them here for backward compatibility.
287
+ oldnumeric = 'removed'
288
+ numarray = 'removed'
289
+
290
+ def __getattr__(attr):
291
+ # Warn for expired attributes, and return a dummy function
292
+ # that always raises an exception.
293
+ import warnings
294
+ import math
295
+ try:
296
+ msg = __expired_functions__[attr]
297
+ except KeyError:
298
+ pass
299
+ else:
300
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
301
+
302
+ def _expired(*args, **kwds):
303
+ raise RuntimeError(msg)
304
+
305
+ return _expired
306
+
307
+ # Emit warnings for deprecated attributes
308
+ try:
309
+ val, msg = __deprecated_attrs__[attr]
310
+ except KeyError:
311
+ pass
312
+ else:
313
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
314
+ return val
315
+
316
+ if attr in __future_scalars__:
317
+ # And future warnings for those that will change, but also give
318
+ # the AttributeError
319
+ warnings.warn(
320
+ f"In the future `np.{attr}` will be defined as the "
321
+ "corresponding NumPy scalar.", FutureWarning, stacklevel=2)
322
+
323
+ if attr in __former_attrs__:
324
+ raise AttributeError(__former_attrs__[attr])
325
+
326
+ if attr == 'testing':
327
+ import numpy.testing as testing
328
+ return testing
329
+ elif attr == 'Tester':
330
+ "Removed in NumPy 1.25.0"
331
+ raise RuntimeError("Tester was removed in NumPy 1.25.")
332
+
333
+ raise AttributeError("module {!r} has no attribute "
334
+ "{!r}".format(__name__, attr))
335
+
336
+ def __dir__():
337
+ public_symbols = globals().keys() | {'testing'}
338
+ public_symbols -= {
339
+ "core", "matrixlib",
340
+ # These were moved in 1.25 and may be deprecated eventually:
341
+ "ModuleDeprecationWarning", "VisibleDeprecationWarning",
342
+ "ComplexWarning", "TooHardError", "AxisError"
343
+ }
344
+ return list(public_symbols)
345
+
346
+ # Pytest testing
347
+ from numpy._pytesttester import PytestTester
348
+ test = PytestTester(__name__)
349
+ del PytestTester
350
+
351
+ def _sanity_check():
352
+ """
353
+ Quick sanity checks for common bugs caused by environment.
354
+ There are some cases e.g. with wrong BLAS ABI that cause wrong
355
+ results under specific runtime conditions that are not necessarily
356
+ achieved during test suite runs, and it is useful to catch those early.
357
+
358
+ See https://github.com/numpy/numpy/issues/8577 and other
359
+ similar bug reports.
360
+
361
+ """
362
+ try:
363
+ x = ones(2, dtype=float32)
364
+ if not abs(x.dot(x) - float32(2.0)) < 1e-5:
365
+ raise AssertionError()
366
+ except AssertionError:
367
+ msg = ("The current Numpy installation ({!r}) fails to "
368
+ "pass simple sanity checks. This can be caused for example "
369
+ "by incorrect BLAS library being linked in, or by mixing "
370
+ "package managers (pip, conda, apt, ...). Search closed "
371
+ "numpy issues for similar problems.")
372
+ raise RuntimeError(msg.format(__file__)) from None
373
+
374
+ _sanity_check()
375
+ del _sanity_check
376
+
377
+ def _mac_os_check():
378
+ """
379
+ Quick Sanity check for Mac OS look for accelerate build bugs.
380
+ Testing numpy polyfit calls init_dgelsd(LAPACK)
381
+ """
382
+ try:
383
+ c = array([3., 2., 1.])
384
+ x = linspace(0, 2, 5)
385
+ y = polyval(c, x)
386
+ _ = polyfit(x, y, 2, cov=True)
387
+ except ValueError:
388
+ pass
389
+
390
+ if sys.platform == "darwin":
391
+ from . import exceptions
392
+ with warnings.catch_warnings(record=True) as w:
393
+ _mac_os_check()
394
+ # Throw runtime error, if the test failed Check for warning and error_message
395
+ if len(w) > 0:
396
+ for _wn in w:
397
+ if _wn.category is exceptions.RankWarning:
398
+ # Ignore other warnings, they may not be relevant (see gh-25433).
399
+ error_message = f"{_wn.category.__name__}: {str(_wn.message)}"
400
+ msg = (
401
+ "Polyfit sanity test emitted a warning, most likely due "
402
+ "to using a buggy Accelerate backend."
403
+ "\nIf you compiled yourself, more information is available at:"
404
+ "\nhttps://numpy.org/devdocs/building/index.html"
405
+ "\nOtherwise report this to the vendor "
406
+ "that provided NumPy.\n\n{}\n".format(error_message))
407
+ raise RuntimeError(msg)
408
+ del _wn
409
+ del w
410
+ del _mac_os_check
411
+
412
+ # We usually use madvise hugepages support, but on some old kernels it
413
+ # is slow and thus better avoided.
414
+ # Specifically kernel version 4.6 had a bug fix which probably fixed this:
415
+ # https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff
416
+ import os
417
+ use_hugepage = os.environ.get("NUMPY_MADVISE_HUGEPAGE", None)
418
+ if sys.platform == "linux" and use_hugepage is None:
419
+ # If there is an issue with parsing the kernel version,
420
+ # set use_hugepages to 0. Usage of LooseVersion will handle
421
+ # the kernel version parsing better, but avoided since it
422
+ # will increase the import time. See: #16679 for related discussion.
423
+ try:
424
+ use_hugepage = 1
425
+ kernel_version = os.uname().release.split(".")[:2]
426
+ kernel_version = tuple(int(v) for v in kernel_version)
427
+ if kernel_version < (4, 6):
428
+ use_hugepage = 0
429
+ except ValueError:
430
+ use_hugepages = 0
431
+ elif use_hugepage is None:
432
+ # This is not Linux, so it should not matter, just enable anyway
433
+ use_hugepage = 1
434
+ else:
435
+ use_hugepage = int(use_hugepage)
436
+
437
+ # Note that this will currently only make a difference on Linux
438
+ core.multiarray._set_madvise_hugepage(use_hugepage)
439
+ del use_hugepage
440
+
441
+ # Give a warning if NumPy is reloaded or imported on a sub-interpreter
442
+ # We do this from python, since the C-module may not be reloaded and
443
+ # it is tidier organized.
444
+ core.multiarray._multiarray_umath._reload_guard()
445
+
446
+ # default to "weak" promotion for "NumPy 2".
447
+ core._set_promotion_state(
448
+ os.environ.get("NPY_PROMOTION_STATE",
449
+ "weak" if _using_numpy2_behavior() else "legacy"))
450
+
451
+ # Tell PyInstaller where to find hook-numpy.py
452
+ def _pyinstaller_hooks_dir():
453
+ from pathlib import Path
454
+ return [str(Path(__file__).with_name("_pyinstaller").resolve())]
455
+
456
+ # Remove symbols imported for internal use
457
+ del os
458
+
459
+
460
+ # Remove symbols imported for internal use
461
+ del sys, warnings
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/__init__.pyi ADDED
The diff for this file is too large to render. See raw diff
 
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/_distributor_init.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Distributor init file
2
+
3
+ Distributors: you can add custom code here to support particular distributions
4
+ of numpy.
5
+
6
+ For example, this is a good place to put any BLAS/LAPACK initialization code.
7
+
8
+ The numpy standard source distribution will not put code in this file, so you
9
+ can safely replace this file with your own version.
10
+ """
11
+
12
+ try:
13
+ from . import _distributor_init_local
14
+ except ImportError:
15
+ pass
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/conftest.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Pytest configuration and fixtures for the Numpy test suite.
3
+ """
4
+ import os
5
+ import tempfile
6
+
7
+ import hypothesis
8
+ import pytest
9
+ import numpy
10
+
11
+ from numpy.core._multiarray_tests import get_fpu_mode
12
+
13
+
14
+ _old_fpu_mode = None
15
+ _collect_results = {}
16
+
17
+ # Use a known and persistent tmpdir for hypothesis' caches, which
18
+ # can be automatically cleared by the OS or user.
19
+ hypothesis.configuration.set_hypothesis_home_dir(
20
+ os.path.join(tempfile.gettempdir(), ".hypothesis")
21
+ )
22
+
23
+ # We register two custom profiles for Numpy - for details see
24
+ # https://hypothesis.readthedocs.io/en/latest/settings.html
25
+ # The first is designed for our own CI runs; the latter also
26
+ # forces determinism and is designed for use via np.test()
27
+ hypothesis.settings.register_profile(
28
+ name="numpy-profile", deadline=None, print_blob=True,
29
+ )
30
+ hypothesis.settings.register_profile(
31
+ name="np.test() profile",
32
+ deadline=None, print_blob=True, database=None, derandomize=True,
33
+ suppress_health_check=list(hypothesis.HealthCheck),
34
+ )
35
+ # Note that the default profile is chosen based on the presence
36
+ # of pytest.ini, but can be overridden by passing the
37
+ # --hypothesis-profile=NAME argument to pytest.
38
+ _pytest_ini = os.path.join(os.path.dirname(__file__), "..", "pytest.ini")
39
+ hypothesis.settings.load_profile(
40
+ "numpy-profile" if os.path.isfile(_pytest_ini) else "np.test() profile"
41
+ )
42
+
43
+ # The experimentalAPI is used in _umath_tests
44
+ os.environ["NUMPY_EXPERIMENTAL_DTYPE_API"] = "1"
45
+
46
+ def pytest_configure(config):
47
+ config.addinivalue_line("markers",
48
+ "valgrind_error: Tests that are known to error under valgrind.")
49
+ config.addinivalue_line("markers",
50
+ "leaks_references: Tests that are known to leak references.")
51
+ config.addinivalue_line("markers",
52
+ "slow: Tests that are very slow.")
53
+ config.addinivalue_line("markers",
54
+ "slow_pypy: Tests that are very slow on pypy.")
55
+
56
+
57
+ def pytest_addoption(parser):
58
+ parser.addoption("--available-memory", action="store", default=None,
59
+ help=("Set amount of memory available for running the "
60
+ "test suite. This can result to tests requiring "
61
+ "especially large amounts of memory to be skipped. "
62
+ "Equivalent to setting environment variable "
63
+ "NPY_AVAILABLE_MEM. Default: determined"
64
+ "automatically."))
65
+
66
+
67
+ def pytest_sessionstart(session):
68
+ available_mem = session.config.getoption('available_memory')
69
+ if available_mem is not None:
70
+ os.environ['NPY_AVAILABLE_MEM'] = available_mem
71
+
72
+
73
+ #FIXME when yield tests are gone.
74
+ @pytest.hookimpl()
75
+ def pytest_itemcollected(item):
76
+ """
77
+ Check FPU precision mode was not changed during test collection.
78
+
79
+ The clumsy way we do it here is mainly necessary because numpy
80
+ still uses yield tests, which can execute code at test collection
81
+ time.
82
+ """
83
+ global _old_fpu_mode
84
+
85
+ mode = get_fpu_mode()
86
+
87
+ if _old_fpu_mode is None:
88
+ _old_fpu_mode = mode
89
+ elif mode != _old_fpu_mode:
90
+ _collect_results[item] = (_old_fpu_mode, mode)
91
+ _old_fpu_mode = mode
92
+
93
+
94
+ @pytest.fixture(scope="function", autouse=True)
95
+ def check_fpu_mode(request):
96
+ """
97
+ Check FPU precision mode was not changed during the test.
98
+ """
99
+ old_mode = get_fpu_mode()
100
+ yield
101
+ new_mode = get_fpu_mode()
102
+
103
+ if old_mode != new_mode:
104
+ raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
105
+ " during the test".format(old_mode, new_mode))
106
+
107
+ collect_result = _collect_results.get(request.node)
108
+ if collect_result is not None:
109
+ old_mode, new_mode = collect_result
110
+ raise AssertionError("FPU precision mode changed from {0:#x} to {1:#x}"
111
+ " when collecting the test".format(old_mode,
112
+ new_mode))
113
+
114
+
115
+ @pytest.fixture(autouse=True)
116
+ def add_np(doctest_namespace):
117
+ doctest_namespace['np'] = numpy
118
+
119
+ @pytest.fixture(autouse=True)
120
+ def env_setup(monkeypatch):
121
+ monkeypatch.setenv('PYTHONHASHSEED', '0')
122
+
123
+
124
+ @pytest.fixture(params=[True, False])
125
+ def weak_promotion(request):
126
+ """
127
+ Fixture to ensure "legacy" promotion state or change it to use the new
128
+ weak promotion (plus warning). `old_promotion` should be used as a
129
+ parameter in the function.
130
+ """
131
+ state = numpy._get_promotion_state()
132
+ if request.param:
133
+ numpy._set_promotion_state("weak_and_warn")
134
+ else:
135
+ numpy._set_promotion_state("legacy")
136
+
137
+ yield request.param
138
+ numpy._set_promotion_state(state)
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/ctypeslib.py ADDED
@@ -0,0 +1,545 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ============================
3
+ ``ctypes`` Utility Functions
4
+ ============================
5
+
6
+ See Also
7
+ --------
8
+ load_library : Load a C library.
9
+ ndpointer : Array restype/argtype with verification.
10
+ as_ctypes : Create a ctypes array from an ndarray.
11
+ as_array : Create an ndarray from a ctypes array.
12
+
13
+ References
14
+ ----------
15
+ .. [1] "SciPy Cookbook: ctypes", https://scipy-cookbook.readthedocs.io/items/Ctypes.html
16
+
17
+ Examples
18
+ --------
19
+ Load the C library:
20
+
21
+ >>> _lib = np.ctypeslib.load_library('libmystuff', '.') #doctest: +SKIP
22
+
23
+ Our result type, an ndarray that must be of type double, be 1-dimensional
24
+ and is C-contiguous in memory:
25
+
26
+ >>> array_1d_double = np.ctypeslib.ndpointer(
27
+ ... dtype=np.double,
28
+ ... ndim=1, flags='CONTIGUOUS') #doctest: +SKIP
29
+
30
+ Our C-function typically takes an array and updates its values
31
+ in-place. For example::
32
+
33
+ void foo_func(double* x, int length)
34
+ {
35
+ int i;
36
+ for (i = 0; i < length; i++) {
37
+ x[i] = i*i;
38
+ }
39
+ }
40
+
41
+ We wrap it using:
42
+
43
+ >>> _lib.foo_func.restype = None #doctest: +SKIP
44
+ >>> _lib.foo_func.argtypes = [array_1d_double, c_int] #doctest: +SKIP
45
+
46
+ Then, we're ready to call ``foo_func``:
47
+
48
+ >>> out = np.empty(15, dtype=np.double)
49
+ >>> _lib.foo_func(out, len(out)) #doctest: +SKIP
50
+
51
+ """
52
+ __all__ = ['load_library', 'ndpointer', 'c_intp', 'as_ctypes', 'as_array',
53
+ 'as_ctypes_type']
54
+
55
+ import os
56
+ from numpy import (
57
+ integer, ndarray, dtype as _dtype, asarray, frombuffer
58
+ )
59
+ from numpy.core.multiarray import _flagdict, flagsobj
60
+
61
+ try:
62
+ import ctypes
63
+ except ImportError:
64
+ ctypes = None
65
+
66
+ if ctypes is None:
67
+ def _dummy(*args, **kwds):
68
+ """
69
+ Dummy object that raises an ImportError if ctypes is not available.
70
+
71
+ Raises
72
+ ------
73
+ ImportError
74
+ If ctypes is not available.
75
+
76
+ """
77
+ raise ImportError("ctypes is not available.")
78
+ load_library = _dummy
79
+ as_ctypes = _dummy
80
+ as_array = _dummy
81
+ from numpy import intp as c_intp
82
+ _ndptr_base = object
83
+ else:
84
+ import numpy.core._internal as nic
85
+ c_intp = nic._getintp_ctype()
86
+ del nic
87
+ _ndptr_base = ctypes.c_void_p
88
+
89
+ # Adapted from Albert Strasheim
90
+ def load_library(libname, loader_path):
91
+ """
92
+ It is possible to load a library using
93
+
94
+ >>> lib = ctypes.cdll[<full_path_name>] # doctest: +SKIP
95
+
96
+ But there are cross-platform considerations, such as library file extensions,
97
+ plus the fact Windows will just load the first library it finds with that name.
98
+ NumPy supplies the load_library function as a convenience.
99
+
100
+ .. versionchanged:: 1.20.0
101
+ Allow libname and loader_path to take any
102
+ :term:`python:path-like object`.
103
+
104
+ Parameters
105
+ ----------
106
+ libname : path-like
107
+ Name of the library, which can have 'lib' as a prefix,
108
+ but without an extension.
109
+ loader_path : path-like
110
+ Where the library can be found.
111
+
112
+ Returns
113
+ -------
114
+ ctypes.cdll[libpath] : library object
115
+ A ctypes library object
116
+
117
+ Raises
118
+ ------
119
+ OSError
120
+ If there is no library with the expected extension, or the
121
+ library is defective and cannot be loaded.
122
+ """
123
+ # Convert path-like objects into strings
124
+ libname = os.fsdecode(libname)
125
+ loader_path = os.fsdecode(loader_path)
126
+
127
+ ext = os.path.splitext(libname)[1]
128
+ if not ext:
129
+ import sys
130
+ import sysconfig
131
+ # Try to load library with platform-specific name, otherwise
132
+ # default to libname.[so|dll|dylib]. Sometimes, these files are
133
+ # built erroneously on non-linux platforms.
134
+ base_ext = ".so"
135
+ if sys.platform.startswith("darwin"):
136
+ base_ext = ".dylib"
137
+ elif sys.platform.startswith("win"):
138
+ base_ext = ".dll"
139
+ libname_ext = [libname + base_ext]
140
+ so_ext = sysconfig.get_config_var("EXT_SUFFIX")
141
+ if not so_ext == base_ext:
142
+ libname_ext.insert(0, libname + so_ext)
143
+ else:
144
+ libname_ext = [libname]
145
+
146
+ loader_path = os.path.abspath(loader_path)
147
+ if not os.path.isdir(loader_path):
148
+ libdir = os.path.dirname(loader_path)
149
+ else:
150
+ libdir = loader_path
151
+
152
+ for ln in libname_ext:
153
+ libpath = os.path.join(libdir, ln)
154
+ if os.path.exists(libpath):
155
+ try:
156
+ return ctypes.cdll[libpath]
157
+ except OSError:
158
+ ## defective lib file
159
+ raise
160
+ ## if no successful return in the libname_ext loop:
161
+ raise OSError("no file with expected extension")
162
+
163
+
164
+ def _num_fromflags(flaglist):
165
+ num = 0
166
+ for val in flaglist:
167
+ num += _flagdict[val]
168
+ return num
169
+
170
+ _flagnames = ['C_CONTIGUOUS', 'F_CONTIGUOUS', 'ALIGNED', 'WRITEABLE',
171
+ 'OWNDATA', 'WRITEBACKIFCOPY']
172
+ def _flags_fromnum(num):
173
+ res = []
174
+ for key in _flagnames:
175
+ value = _flagdict[key]
176
+ if (num & value):
177
+ res.append(key)
178
+ return res
179
+
180
+
181
+ class _ndptr(_ndptr_base):
182
+ @classmethod
183
+ def from_param(cls, obj):
184
+ if not isinstance(obj, ndarray):
185
+ raise TypeError("argument must be an ndarray")
186
+ if cls._dtype_ is not None \
187
+ and obj.dtype != cls._dtype_:
188
+ raise TypeError("array must have data type %s" % cls._dtype_)
189
+ if cls._ndim_ is not None \
190
+ and obj.ndim != cls._ndim_:
191
+ raise TypeError("array must have %d dimension(s)" % cls._ndim_)
192
+ if cls._shape_ is not None \
193
+ and obj.shape != cls._shape_:
194
+ raise TypeError("array must have shape %s" % str(cls._shape_))
195
+ if cls._flags_ is not None \
196
+ and ((obj.flags.num & cls._flags_) != cls._flags_):
197
+ raise TypeError("array must have flags %s" %
198
+ _flags_fromnum(cls._flags_))
199
+ return obj.ctypes
200
+
201
+
202
+ class _concrete_ndptr(_ndptr):
203
+ """
204
+ Like _ndptr, but with `_shape_` and `_dtype_` specified.
205
+
206
+ Notably, this means the pointer has enough information to reconstruct
207
+ the array, which is not generally true.
208
+ """
209
+ def _check_retval_(self):
210
+ """
211
+ This method is called when this class is used as the .restype
212
+ attribute for a shared-library function, to automatically wrap the
213
+ pointer into an array.
214
+ """
215
+ return self.contents
216
+
217
+ @property
218
+ def contents(self):
219
+ """
220
+ Get an ndarray viewing the data pointed to by this pointer.
221
+
222
+ This mirrors the `contents` attribute of a normal ctypes pointer
223
+ """
224
+ full_dtype = _dtype((self._dtype_, self._shape_))
225
+ full_ctype = ctypes.c_char * full_dtype.itemsize
226
+ buffer = ctypes.cast(self, ctypes.POINTER(full_ctype)).contents
227
+ return frombuffer(buffer, dtype=full_dtype).squeeze(axis=0)
228
+
229
+
230
+ # Factory for an array-checking class with from_param defined for
231
+ # use with ctypes argtypes mechanism
232
+ _pointer_type_cache = {}
233
+ def ndpointer(dtype=None, ndim=None, shape=None, flags=None):
234
+ """
235
+ Array-checking restype/argtypes.
236
+
237
+ An ndpointer instance is used to describe an ndarray in restypes
238
+ and argtypes specifications. This approach is more flexible than
239
+ using, for example, ``POINTER(c_double)``, since several restrictions
240
+ can be specified, which are verified upon calling the ctypes function.
241
+ These include data type, number of dimensions, shape and flags. If a
242
+ given array does not satisfy the specified restrictions,
243
+ a ``TypeError`` is raised.
244
+
245
+ Parameters
246
+ ----------
247
+ dtype : data-type, optional
248
+ Array data-type.
249
+ ndim : int, optional
250
+ Number of array dimensions.
251
+ shape : tuple of ints, optional
252
+ Array shape.
253
+ flags : str or tuple of str
254
+ Array flags; may be one or more of:
255
+
256
+ - C_CONTIGUOUS / C / CONTIGUOUS
257
+ - F_CONTIGUOUS / F / FORTRAN
258
+ - OWNDATA / O
259
+ - WRITEABLE / W
260
+ - ALIGNED / A
261
+ - WRITEBACKIFCOPY / X
262
+
263
+ Returns
264
+ -------
265
+ klass : ndpointer type object
266
+ A type object, which is an ``_ndtpr`` instance containing
267
+ dtype, ndim, shape and flags information.
268
+
269
+ Raises
270
+ ------
271
+ TypeError
272
+ If a given array does not satisfy the specified restrictions.
273
+
274
+ Examples
275
+ --------
276
+ >>> clib.somefunc.argtypes = [np.ctypeslib.ndpointer(dtype=np.float64,
277
+ ... ndim=1,
278
+ ... flags='C_CONTIGUOUS')]
279
+ ... #doctest: +SKIP
280
+ >>> clib.somefunc(np.array([1, 2, 3], dtype=np.float64))
281
+ ... #doctest: +SKIP
282
+
283
+ """
284
+
285
+ # normalize dtype to an Optional[dtype]
286
+ if dtype is not None:
287
+ dtype = _dtype(dtype)
288
+
289
+ # normalize flags to an Optional[int]
290
+ num = None
291
+ if flags is not None:
292
+ if isinstance(flags, str):
293
+ flags = flags.split(',')
294
+ elif isinstance(flags, (int, integer)):
295
+ num = flags
296
+ flags = _flags_fromnum(num)
297
+ elif isinstance(flags, flagsobj):
298
+ num = flags.num
299
+ flags = _flags_fromnum(num)
300
+ if num is None:
301
+ try:
302
+ flags = [x.strip().upper() for x in flags]
303
+ except Exception as e:
304
+ raise TypeError("invalid flags specification") from e
305
+ num = _num_fromflags(flags)
306
+
307
+ # normalize shape to an Optional[tuple]
308
+ if shape is not None:
309
+ try:
310
+ shape = tuple(shape)
311
+ except TypeError:
312
+ # single integer -> 1-tuple
313
+ shape = (shape,)
314
+
315
+ cache_key = (dtype, ndim, shape, num)
316
+
317
+ try:
318
+ return _pointer_type_cache[cache_key]
319
+ except KeyError:
320
+ pass
321
+
322
+ # produce a name for the new type
323
+ if dtype is None:
324
+ name = 'any'
325
+ elif dtype.names is not None:
326
+ name = str(id(dtype))
327
+ else:
328
+ name = dtype.str
329
+ if ndim is not None:
330
+ name += "_%dd" % ndim
331
+ if shape is not None:
332
+ name += "_"+"x".join(str(x) for x in shape)
333
+ if flags is not None:
334
+ name += "_"+"_".join(flags)
335
+
336
+ if dtype is not None and shape is not None:
337
+ base = _concrete_ndptr
338
+ else:
339
+ base = _ndptr
340
+
341
+ klass = type("ndpointer_%s"%name, (base,),
342
+ {"_dtype_": dtype,
343
+ "_shape_" : shape,
344
+ "_ndim_" : ndim,
345
+ "_flags_" : num})
346
+ _pointer_type_cache[cache_key] = klass
347
+ return klass
348
+
349
+
350
+ if ctypes is not None:
351
+ def _ctype_ndarray(element_type, shape):
352
+ """ Create an ndarray of the given element type and shape """
353
+ for dim in shape[::-1]:
354
+ element_type = dim * element_type
355
+ # prevent the type name include np.ctypeslib
356
+ element_type.__module__ = None
357
+ return element_type
358
+
359
+
360
+ def _get_scalar_type_map():
361
+ """
362
+ Return a dictionary mapping native endian scalar dtype to ctypes types
363
+ """
364
+ ct = ctypes
365
+ simple_types = [
366
+ ct.c_byte, ct.c_short, ct.c_int, ct.c_long, ct.c_longlong,
367
+ ct.c_ubyte, ct.c_ushort, ct.c_uint, ct.c_ulong, ct.c_ulonglong,
368
+ ct.c_float, ct.c_double,
369
+ ct.c_bool,
370
+ ]
371
+ return {_dtype(ctype): ctype for ctype in simple_types}
372
+
373
+
374
+ _scalar_type_map = _get_scalar_type_map()
375
+
376
+
377
+ def _ctype_from_dtype_scalar(dtype):
378
+ # swapping twice ensure that `=` is promoted to <, >, or |
379
+ dtype_with_endian = dtype.newbyteorder('S').newbyteorder('S')
380
+ dtype_native = dtype.newbyteorder('=')
381
+ try:
382
+ ctype = _scalar_type_map[dtype_native]
383
+ except KeyError as e:
384
+ raise NotImplementedError(
385
+ "Converting {!r} to a ctypes type".format(dtype)
386
+ ) from None
387
+
388
+ if dtype_with_endian.byteorder == '>':
389
+ ctype = ctype.__ctype_be__
390
+ elif dtype_with_endian.byteorder == '<':
391
+ ctype = ctype.__ctype_le__
392
+
393
+ return ctype
394
+
395
+
396
+ def _ctype_from_dtype_subarray(dtype):
397
+ element_dtype, shape = dtype.subdtype
398
+ ctype = _ctype_from_dtype(element_dtype)
399
+ return _ctype_ndarray(ctype, shape)
400
+
401
+
402
+ def _ctype_from_dtype_structured(dtype):
403
+ # extract offsets of each field
404
+ field_data = []
405
+ for name in dtype.names:
406
+ field_dtype, offset = dtype.fields[name][:2]
407
+ field_data.append((offset, name, _ctype_from_dtype(field_dtype)))
408
+
409
+ # ctypes doesn't care about field order
410
+ field_data = sorted(field_data, key=lambda f: f[0])
411
+
412
+ if len(field_data) > 1 and all(offset == 0 for offset, name, ctype in field_data):
413
+ # union, if multiple fields all at address 0
414
+ size = 0
415
+ _fields_ = []
416
+ for offset, name, ctype in field_data:
417
+ _fields_.append((name, ctype))
418
+ size = max(size, ctypes.sizeof(ctype))
419
+
420
+ # pad to the right size
421
+ if dtype.itemsize != size:
422
+ _fields_.append(('', ctypes.c_char * dtype.itemsize))
423
+
424
+ # we inserted manual padding, so always `_pack_`
425
+ return type('union', (ctypes.Union,), dict(
426
+ _fields_=_fields_,
427
+ _pack_=1,
428
+ __module__=None,
429
+ ))
430
+ else:
431
+ last_offset = 0
432
+ _fields_ = []
433
+ for offset, name, ctype in field_data:
434
+ padding = offset - last_offset
435
+ if padding < 0:
436
+ raise NotImplementedError("Overlapping fields")
437
+ if padding > 0:
438
+ _fields_.append(('', ctypes.c_char * padding))
439
+
440
+ _fields_.append((name, ctype))
441
+ last_offset = offset + ctypes.sizeof(ctype)
442
+
443
+
444
+ padding = dtype.itemsize - last_offset
445
+ if padding > 0:
446
+ _fields_.append(('', ctypes.c_char * padding))
447
+
448
+ # we inserted manual padding, so always `_pack_`
449
+ return type('struct', (ctypes.Structure,), dict(
450
+ _fields_=_fields_,
451
+ _pack_=1,
452
+ __module__=None,
453
+ ))
454
+
455
+
456
+ def _ctype_from_dtype(dtype):
457
+ if dtype.fields is not None:
458
+ return _ctype_from_dtype_structured(dtype)
459
+ elif dtype.subdtype is not None:
460
+ return _ctype_from_dtype_subarray(dtype)
461
+ else:
462
+ return _ctype_from_dtype_scalar(dtype)
463
+
464
+
465
+ def as_ctypes_type(dtype):
466
+ r"""
467
+ Convert a dtype into a ctypes type.
468
+
469
+ Parameters
470
+ ----------
471
+ dtype : dtype
472
+ The dtype to convert
473
+
474
+ Returns
475
+ -------
476
+ ctype
477
+ A ctype scalar, union, array, or struct
478
+
479
+ Raises
480
+ ------
481
+ NotImplementedError
482
+ If the conversion is not possible
483
+
484
+ Notes
485
+ -----
486
+ This function does not losslessly round-trip in either direction.
487
+
488
+ ``np.dtype(as_ctypes_type(dt))`` will:
489
+
490
+ - insert padding fields
491
+ - reorder fields to be sorted by offset
492
+ - discard field titles
493
+
494
+ ``as_ctypes_type(np.dtype(ctype))`` will:
495
+
496
+ - discard the class names of `ctypes.Structure`\ s and
497
+ `ctypes.Union`\ s
498
+ - convert single-element `ctypes.Union`\ s into single-element
499
+ `ctypes.Structure`\ s
500
+ - insert padding fields
501
+
502
+ """
503
+ return _ctype_from_dtype(_dtype(dtype))
504
+
505
+
506
+ def as_array(obj, shape=None):
507
+ """
508
+ Create a numpy array from a ctypes array or POINTER.
509
+
510
+ The numpy array shares the memory with the ctypes object.
511
+
512
+ The shape parameter must be given if converting from a ctypes POINTER.
513
+ The shape parameter is ignored if converting from a ctypes array
514
+ """
515
+ if isinstance(obj, ctypes._Pointer):
516
+ # convert pointers to an array of the desired shape
517
+ if shape is None:
518
+ raise TypeError(
519
+ 'as_array() requires a shape argument when called on a '
520
+ 'pointer')
521
+ p_arr_type = ctypes.POINTER(_ctype_ndarray(obj._type_, shape))
522
+ obj = ctypes.cast(obj, p_arr_type).contents
523
+
524
+ return asarray(obj)
525
+
526
+
527
+ def as_ctypes(obj):
528
+ """Create and return a ctypes object from a numpy array. Actually
529
+ anything that exposes the __array_interface__ is accepted."""
530
+ ai = obj.__array_interface__
531
+ if ai["strides"]:
532
+ raise TypeError("strided arrays not supported")
533
+ if ai["version"] != 3:
534
+ raise TypeError("only __array_interface__ version 3 supported")
535
+ addr, readonly = ai["data"]
536
+ if readonly:
537
+ raise TypeError("readonly arrays unsupported")
538
+
539
+ # can't use `_dtype((ai["typestr"], ai["shape"]))` here, as it overflows
540
+ # dtype.itemsize (gh-14214)
541
+ ctype_scalar = as_ctypes_type(ai["typestr"])
542
+ result_type = _ctype_ndarray(ctype_scalar, ai["shape"])
543
+ result = result_type.from_address(addr)
544
+ result.__keep = obj
545
+ return result
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/ctypeslib.pyi ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # NOTE: Numpy's mypy plugin is used for importing the correct
2
+ # platform-specific `ctypes._SimpleCData[int]` sub-type
3
+ from ctypes import c_int64 as _c_intp
4
+
5
+ import os
6
+ import sys
7
+ import ctypes
8
+ from collections.abc import Iterable, Sequence
9
+ from typing import (
10
+ Literal as L,
11
+ Any,
12
+ Union,
13
+ TypeVar,
14
+ Generic,
15
+ overload,
16
+ ClassVar,
17
+ )
18
+
19
+ from numpy import (
20
+ ndarray,
21
+ dtype,
22
+ generic,
23
+ bool_,
24
+ byte,
25
+ short,
26
+ intc,
27
+ int_,
28
+ longlong,
29
+ ubyte,
30
+ ushort,
31
+ uintc,
32
+ uint,
33
+ ulonglong,
34
+ single,
35
+ double,
36
+ longdouble,
37
+ void,
38
+ )
39
+ from numpy.core._internal import _ctypes
40
+ from numpy.core.multiarray import flagsobj
41
+ from numpy._typing import (
42
+ # Arrays
43
+ NDArray,
44
+ _ArrayLike,
45
+
46
+ # Shapes
47
+ _ShapeLike,
48
+
49
+ # DTypes
50
+ DTypeLike,
51
+ _DTypeLike,
52
+ _VoidDTypeLike,
53
+ _BoolCodes,
54
+ _UByteCodes,
55
+ _UShortCodes,
56
+ _UIntCCodes,
57
+ _UIntCodes,
58
+ _ULongLongCodes,
59
+ _ByteCodes,
60
+ _ShortCodes,
61
+ _IntCCodes,
62
+ _IntCodes,
63
+ _LongLongCodes,
64
+ _SingleCodes,
65
+ _DoubleCodes,
66
+ _LongDoubleCodes,
67
+ )
68
+
69
+ # TODO: Add a proper `_Shape` bound once we've got variadic typevars
70
+ _DType = TypeVar("_DType", bound=dtype[Any])
71
+ _DTypeOptional = TypeVar("_DTypeOptional", bound=None | dtype[Any])
72
+ _SCT = TypeVar("_SCT", bound=generic)
73
+
74
+ _FlagsKind = L[
75
+ 'C_CONTIGUOUS', 'CONTIGUOUS', 'C',
76
+ 'F_CONTIGUOUS', 'FORTRAN', 'F',
77
+ 'ALIGNED', 'A',
78
+ 'WRITEABLE', 'W',
79
+ 'OWNDATA', 'O',
80
+ 'WRITEBACKIFCOPY', 'X',
81
+ ]
82
+
83
+ # TODO: Add a shape typevar once we have variadic typevars (PEP 646)
84
+ class _ndptr(ctypes.c_void_p, Generic[_DTypeOptional]):
85
+ # In practice these 4 classvars are defined in the dynamic class
86
+ # returned by `ndpointer`
87
+ _dtype_: ClassVar[_DTypeOptional]
88
+ _shape_: ClassVar[None]
89
+ _ndim_: ClassVar[None | int]
90
+ _flags_: ClassVar[None | list[_FlagsKind]]
91
+
92
+ @overload
93
+ @classmethod
94
+ def from_param(cls: type[_ndptr[None]], obj: ndarray[Any, Any]) -> _ctypes[Any]: ...
95
+ @overload
96
+ @classmethod
97
+ def from_param(cls: type[_ndptr[_DType]], obj: ndarray[Any, _DType]) -> _ctypes[Any]: ...
98
+
99
+ class _concrete_ndptr(_ndptr[_DType]):
100
+ _dtype_: ClassVar[_DType]
101
+ _shape_: ClassVar[tuple[int, ...]]
102
+ @property
103
+ def contents(self) -> ndarray[Any, _DType]: ...
104
+
105
+ def load_library(
106
+ libname: str | bytes | os.PathLike[str] | os.PathLike[bytes],
107
+ loader_path: str | bytes | os.PathLike[str] | os.PathLike[bytes],
108
+ ) -> ctypes.CDLL: ...
109
+
110
+ __all__: list[str]
111
+
112
+ c_intp = _c_intp
113
+
114
+ @overload
115
+ def ndpointer(
116
+ dtype: None = ...,
117
+ ndim: int = ...,
118
+ shape: None | _ShapeLike = ...,
119
+ flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
120
+ ) -> type[_ndptr[None]]: ...
121
+ @overload
122
+ def ndpointer(
123
+ dtype: _DTypeLike[_SCT],
124
+ ndim: int = ...,
125
+ *,
126
+ shape: _ShapeLike,
127
+ flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
128
+ ) -> type[_concrete_ndptr[dtype[_SCT]]]: ...
129
+ @overload
130
+ def ndpointer(
131
+ dtype: DTypeLike,
132
+ ndim: int = ...,
133
+ *,
134
+ shape: _ShapeLike,
135
+ flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
136
+ ) -> type[_concrete_ndptr[dtype[Any]]]: ...
137
+ @overload
138
+ def ndpointer(
139
+ dtype: _DTypeLike[_SCT],
140
+ ndim: int = ...,
141
+ shape: None = ...,
142
+ flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
143
+ ) -> type[_ndptr[dtype[_SCT]]]: ...
144
+ @overload
145
+ def ndpointer(
146
+ dtype: DTypeLike,
147
+ ndim: int = ...,
148
+ shape: None = ...,
149
+ flags: None | _FlagsKind | Iterable[_FlagsKind] | int | flagsobj = ...,
150
+ ) -> type[_ndptr[dtype[Any]]]: ...
151
+
152
+ @overload
153
+ def as_ctypes_type(dtype: _BoolCodes | _DTypeLike[bool_] | type[ctypes.c_bool]) -> type[ctypes.c_bool]: ...
154
+ @overload
155
+ def as_ctypes_type(dtype: _ByteCodes | _DTypeLike[byte] | type[ctypes.c_byte]) -> type[ctypes.c_byte]: ...
156
+ @overload
157
+ def as_ctypes_type(dtype: _ShortCodes | _DTypeLike[short] | type[ctypes.c_short]) -> type[ctypes.c_short]: ...
158
+ @overload
159
+ def as_ctypes_type(dtype: _IntCCodes | _DTypeLike[intc] | type[ctypes.c_int]) -> type[ctypes.c_int]: ...
160
+ @overload
161
+ def as_ctypes_type(dtype: _IntCodes | _DTypeLike[int_] | type[int | ctypes.c_long]) -> type[ctypes.c_long]: ...
162
+ @overload
163
+ def as_ctypes_type(dtype: _LongLongCodes | _DTypeLike[longlong] | type[ctypes.c_longlong]) -> type[ctypes.c_longlong]: ...
164
+ @overload
165
+ def as_ctypes_type(dtype: _UByteCodes | _DTypeLike[ubyte] | type[ctypes.c_ubyte]) -> type[ctypes.c_ubyte]: ...
166
+ @overload
167
+ def as_ctypes_type(dtype: _UShortCodes | _DTypeLike[ushort] | type[ctypes.c_ushort]) -> type[ctypes.c_ushort]: ...
168
+ @overload
169
+ def as_ctypes_type(dtype: _UIntCCodes | _DTypeLike[uintc] | type[ctypes.c_uint]) -> type[ctypes.c_uint]: ...
170
+ @overload
171
+ def as_ctypes_type(dtype: _UIntCodes | _DTypeLike[uint] | type[ctypes.c_ulong]) -> type[ctypes.c_ulong]: ...
172
+ @overload
173
+ def as_ctypes_type(dtype: _ULongLongCodes | _DTypeLike[ulonglong] | type[ctypes.c_ulonglong]) -> type[ctypes.c_ulonglong]: ...
174
+ @overload
175
+ def as_ctypes_type(dtype: _SingleCodes | _DTypeLike[single] | type[ctypes.c_float]) -> type[ctypes.c_float]: ...
176
+ @overload
177
+ def as_ctypes_type(dtype: _DoubleCodes | _DTypeLike[double] | type[float | ctypes.c_double]) -> type[ctypes.c_double]: ...
178
+ @overload
179
+ def as_ctypes_type(dtype: _LongDoubleCodes | _DTypeLike[longdouble] | type[ctypes.c_longdouble]) -> type[ctypes.c_longdouble]: ...
180
+ @overload
181
+ def as_ctypes_type(dtype: _VoidDTypeLike) -> type[Any]: ... # `ctypes.Union` or `ctypes.Structure`
182
+ @overload
183
+ def as_ctypes_type(dtype: str) -> type[Any]: ...
184
+
185
+ @overload
186
+ def as_array(obj: ctypes._PointerLike, shape: Sequence[int]) -> NDArray[Any]: ...
187
+ @overload
188
+ def as_array(obj: _ArrayLike[_SCT], shape: None | _ShapeLike = ...) -> NDArray[_SCT]: ...
189
+ @overload
190
+ def as_array(obj: object, shape: None | _ShapeLike = ...) -> NDArray[Any]: ...
191
+
192
+ @overload
193
+ def as_ctypes(obj: bool_) -> ctypes.c_bool: ...
194
+ @overload
195
+ def as_ctypes(obj: byte) -> ctypes.c_byte: ...
196
+ @overload
197
+ def as_ctypes(obj: short) -> ctypes.c_short: ...
198
+ @overload
199
+ def as_ctypes(obj: intc) -> ctypes.c_int: ...
200
+ @overload
201
+ def as_ctypes(obj: int_) -> ctypes.c_long: ...
202
+ @overload
203
+ def as_ctypes(obj: longlong) -> ctypes.c_longlong: ...
204
+ @overload
205
+ def as_ctypes(obj: ubyte) -> ctypes.c_ubyte: ...
206
+ @overload
207
+ def as_ctypes(obj: ushort) -> ctypes.c_ushort: ...
208
+ @overload
209
+ def as_ctypes(obj: uintc) -> ctypes.c_uint: ...
210
+ @overload
211
+ def as_ctypes(obj: uint) -> ctypes.c_ulong: ...
212
+ @overload
213
+ def as_ctypes(obj: ulonglong) -> ctypes.c_ulonglong: ...
214
+ @overload
215
+ def as_ctypes(obj: single) -> ctypes.c_float: ...
216
+ @overload
217
+ def as_ctypes(obj: double) -> ctypes.c_double: ...
218
+ @overload
219
+ def as_ctypes(obj: longdouble) -> ctypes.c_longdouble: ...
220
+ @overload
221
+ def as_ctypes(obj: void) -> Any: ... # `ctypes.Union` or `ctypes.Structure`
222
+ @overload
223
+ def as_ctypes(obj: NDArray[bool_]) -> ctypes.Array[ctypes.c_bool]: ...
224
+ @overload
225
+ def as_ctypes(obj: NDArray[byte]) -> ctypes.Array[ctypes.c_byte]: ...
226
+ @overload
227
+ def as_ctypes(obj: NDArray[short]) -> ctypes.Array[ctypes.c_short]: ...
228
+ @overload
229
+ def as_ctypes(obj: NDArray[intc]) -> ctypes.Array[ctypes.c_int]: ...
230
+ @overload
231
+ def as_ctypes(obj: NDArray[int_]) -> ctypes.Array[ctypes.c_long]: ...
232
+ @overload
233
+ def as_ctypes(obj: NDArray[longlong]) -> ctypes.Array[ctypes.c_longlong]: ...
234
+ @overload
235
+ def as_ctypes(obj: NDArray[ubyte]) -> ctypes.Array[ctypes.c_ubyte]: ...
236
+ @overload
237
+ def as_ctypes(obj: NDArray[ushort]) -> ctypes.Array[ctypes.c_ushort]: ...
238
+ @overload
239
+ def as_ctypes(obj: NDArray[uintc]) -> ctypes.Array[ctypes.c_uint]: ...
240
+ @overload
241
+ def as_ctypes(obj: NDArray[uint]) -> ctypes.Array[ctypes.c_ulong]: ...
242
+ @overload
243
+ def as_ctypes(obj: NDArray[ulonglong]) -> ctypes.Array[ctypes.c_ulonglong]: ...
244
+ @overload
245
+ def as_ctypes(obj: NDArray[single]) -> ctypes.Array[ctypes.c_float]: ...
246
+ @overload
247
+ def as_ctypes(obj: NDArray[double]) -> ctypes.Array[ctypes.c_double]: ...
248
+ @overload
249
+ def as_ctypes(obj: NDArray[longdouble]) -> ctypes.Array[ctypes.c_longdouble]: ...
250
+ @overload
251
+ def as_ctypes(obj: NDArray[void]) -> ctypes.Array[Any]: ... # `ctypes.Union` or `ctypes.Structure`
Prism/LLaDA/LLaDA_Prism/.venv/lib/python3.12/site-packages/numpy/dtypes.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ DType classes and utility (:mod:`numpy.dtypes`)
3
+ ===============================================
4
+
5
+ This module is home to specific dtypes related functionality and their classes.
6
+ For more general information about dtypes, also see `numpy.dtype` and
7
+ :ref:`arrays.dtypes`.
8
+
9
+ Similar to the builtin ``types`` module, this submodule defines types (classes)
10
+ that are not widely used directly.
11
+
12
+ .. versionadded:: NumPy 1.25
13
+
14
+ The dtypes module is new in NumPy 1.25. Previously DType classes were
15
+ only accessible indirectly.
16
+
17
+
18
+ DType classes
19
+ -------------
20
+
21
+ The following are the classes of the corresponding NumPy dtype instances and
22
+ NumPy scalar types. The classes can be used in ``isinstance`` checks and can
23
+ also be instantiated or used directly. Direct use of these classes is not
24
+ typical, since their scalar counterparts (e.g. ``np.float64``) or strings
25
+ like ``"float64"`` can be used.
26
+
27
+ .. list-table::
28
+ :header-rows: 1
29
+
30
+ * - Group
31
+ - DType class
32
+
33
+ * - Boolean
34
+ - ``BoolDType``
35
+
36
+ * - Bit-sized integers
37
+ - ``Int8DType``, ``UInt8DType``, ``Int16DType``, ``UInt16DType``,
38
+ ``Int32DType``, ``UInt32DType``, ``Int64DType``, ``UInt64DType``
39
+
40
+ * - C-named integers (may be aliases)
41
+ - ``ByteDType``, ``UByteDType``, ``ShortDType``, ``UShortDType``,
42
+ ``IntDType``, ``UIntDType``, ``LongDType``, ``ULongDType``,
43
+ ``LongLongDType``, ``ULongLongDType``
44
+
45
+ * - Floating point
46
+ - ``Float16DType``, ``Float32DType``, ``Float64DType``,
47
+ ``LongDoubleDType``
48
+
49
+ * - Complex
50
+ - ``Complex64DType``, ``Complex128DType``, ``CLongDoubleDType``
51
+
52
+ * - Strings
53
+ - ``BytesDType``, ``BytesDType``
54
+
55
+ * - Times
56
+ - ``DateTime64DType``, ``TimeDelta64DType``
57
+
58
+ * - Others
59
+ - ``ObjectDType``, ``VoidDType``
60
+
61
+ """
62
+
63
+ __all__ = []
64
+
65
+
66
+ def _add_dtype_helper(DType, alias):
67
+ # Function to add DTypes a bit more conveniently without channeling them
68
+ # through `numpy.core._multiarray_umath` namespace or similar.
69
+ from numpy import dtypes
70
+
71
+ setattr(dtypes, DType.__name__, DType)
72
+ __all__.append(DType.__name__)
73
+
74
+ if alias:
75
+ alias = alias.removeprefix("numpy.dtypes.")
76
+ setattr(dtypes, alias, DType)
77
+ __all__.append(alias)