Upload folder using huggingface_hub (part 9)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +14 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/INSTALLER +1 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/METADATA +89 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/RECORD +814 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/REQUESTED +0 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/WHEEL +6 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/licenses/LICENSE +24 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/licenses/LICENSES.third-party +569 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/sboms/auditwheel.cdx.json +1 -0
- .venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/top_level.txt +1 -0
- .venv/lib/python3.11/site-packages/numba/pycc/modulemixin.c +221 -0
- .venv/lib/python3.11/site-packages/numba/pycc/platform.py +218 -0
- .venv/lib/python3.11/site-packages/numba/pythoncapi_compat.h +1696 -0
- .venv/lib/python3.11/site-packages/numba/runtests.py +9 -0
- .venv/lib/python3.11/site-packages/numba/scripts/__init__.py +0 -0
- .venv/lib/python3.11/site-packages/numba/scripts/generate_lower_listing.py +169 -0
- .venv/lib/python3.11/site-packages/numba/stencils/__init__.py +0 -0
- .venv/lib/python3.11/site-packages/numba/stencils/stencil.py +836 -0
- .venv/lib/python3.11/site-packages/numba/stencils/stencilparfor.py +957 -0
- .venv/lib/python3.11/site-packages/numba/testing/__init__.py +61 -0
- .venv/lib/python3.11/site-packages/numba/testing/__main__.py +4 -0
- .venv/lib/python3.11/site-packages/numba/testing/_runtests.py +114 -0
- .venv/lib/python3.11/site-packages/numba/testing/loader.py +26 -0
- .venv/lib/python3.11/site-packages/numba/testing/main.py +871 -0
- .venv/lib/python3.11/site-packages/numba/testing/notebook.py +171 -0
- .venv/lib/python3.11/site-packages/numba/tests/__init__.py +33 -0
- .venv/lib/python3.11/site-packages/numba/tests/annotation_usecases.py +16 -0
- .venv/lib/python3.11/site-packages/numba/tests/cache_usecases.py +172 -0
- .venv/lib/python3.11/site-packages/numba/tests/cffi_usecases.py +197 -0
- .venv/lib/python3.11/site-packages/numba/tests/cfunc_cache_usecases.py +70 -0
- .venv/lib/python3.11/site-packages/numba/tests/chained_assign_usecases.py +69 -0
- .venv/lib/python3.11/site-packages/numba/tests/cloudpickle_main_class.py +6 -0
- .venv/lib/python3.11/site-packages/numba/tests/compile_with_pycc.py +147 -0
- .venv/lib/python3.11/site-packages/numba/tests/complex_usecases.py +93 -0
- .venv/lib/python3.11/site-packages/numba/tests/ctypes_usecases.py +114 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/__init__.py +10 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_examples.py +660 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_interval_example.py +242 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_jitclass.py +97 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_literal_container_usage.py +161 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_literally_usage.py +59 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_llvm_pass_timings.py +31 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_numpy_generators.py +38 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_parallel_chunksize.py +122 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_rec_array.py +46 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_structref_usage.py +149 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_dict_usage.py +111 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_list_usage.py +95 -0
- .venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_set_usage.py +45 -0
- .venv/lib/python3.11/site-packages/numba/tests/doctest_usecase.py +31 -0
.gitattributes
CHANGED
|
@@ -114,3 +114,17 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 114 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/omppool.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 115 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/tbbpool.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 116 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/workqueue.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/omppool.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 115 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/tbbpool.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 116 |
.venv/lib/python3.11/site-packages/numba/np/ufunc/workqueue.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 117 |
+
.venv/lib/python3.11/site-packages/numcodecs/_shuffle.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 118 |
+
.venv/lib/python3.11/site-packages/numcodecs/blosc.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 119 |
+
.venv/lib/python3.11/site-packages/numcodecs/compat_ext.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 120 |
+
.venv/lib/python3.11/site-packages/numcodecs/fletcher32.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 121 |
+
.venv/lib/python3.11/site-packages/numcodecs/jenkins.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 122 |
+
.venv/lib/python3.11/site-packages/numcodecs/lz4.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 123 |
+
.venv/lib/python3.11/site-packages/numcodecs/vlen.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 124 |
+
.venv/lib/python3.11/site-packages/numcodecs/zstd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 125 |
+
.venv/lib/python3.11/site-packages/numpy/_core/__pycache__/_add_newdocs.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 126 |
+
.venv/lib/python3.11/site-packages/numpy/_core/__pycache__/fromnumeric.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
| 127 |
+
.venv/lib/python3.11/site-packages/numpy/_core/_multiarray_tests.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 128 |
+
.venv/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 129 |
+
.venv/lib/python3.11/site-packages/numpy/_core/_simd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
| 130 |
+
.venv/lib/python3.11/site-packages/numpy/f2py/__pycache__/crackfortran.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/INSTALLER
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
uv
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/METADATA
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Metadata-Version: 2.4
|
| 2 |
+
Name: numba
|
| 3 |
+
Version: 0.66.0
|
| 4 |
+
Summary: compiling Python code using LLVM
|
| 5 |
+
Home-page: https://numba.pydata.org
|
| 6 |
+
License: BSD
|
| 7 |
+
Classifier: Development Status :: 4 - Beta
|
| 8 |
+
Classifier: Intended Audience :: Developers
|
| 9 |
+
Classifier: License :: OSI Approved :: BSD License
|
| 10 |
+
Classifier: Operating System :: OS Independent
|
| 11 |
+
Classifier: Programming Language :: Python
|
| 12 |
+
Classifier: Programming Language :: Python :: 3
|
| 13 |
+
Classifier: Programming Language :: Python :: 3.10
|
| 14 |
+
Classifier: Programming Language :: Python :: 3.11
|
| 15 |
+
Classifier: Programming Language :: Python :: 3.12
|
| 16 |
+
Classifier: Programming Language :: Python :: 3.13
|
| 17 |
+
Classifier: Programming Language :: Python :: 3.14
|
| 18 |
+
Classifier: Topic :: Software Development :: Compilers
|
| 19 |
+
Requires-Python: >=3.10
|
| 20 |
+
License-File: LICENSE
|
| 21 |
+
License-File: LICENSES.third-party
|
| 22 |
+
Requires-Dist: llvmlite<0.49,>=0.48.0dev0
|
| 23 |
+
Requires-Dist: numpy<2.5,>=1.22
|
| 24 |
+
Dynamic: classifier
|
| 25 |
+
Dynamic: description
|
| 26 |
+
Dynamic: home-page
|
| 27 |
+
Dynamic: license
|
| 28 |
+
Dynamic: license-file
|
| 29 |
+
Dynamic: requires-dist
|
| 30 |
+
Dynamic: requires-python
|
| 31 |
+
Dynamic: summary
|
| 32 |
+
|
| 33 |
+
*****
|
| 34 |
+
Numba
|
| 35 |
+
*****
|
| 36 |
+
|
| 37 |
+
.. image:: https://img.shields.io/badge/discuss-on%20discourse-blue
|
| 38 |
+
:target: https://numba.discourse.group/
|
| 39 |
+
:alt: Discourse
|
| 40 |
+
|
| 41 |
+
.. image:: https://zenodo.org/badge/doi/10.5281/zenodo.4343230.svg
|
| 42 |
+
:target: https://doi.org/10.5281/zenodo.4343230
|
| 43 |
+
:alt: Zenodo
|
| 44 |
+
|
| 45 |
+
.. image:: https://img.shields.io/pypi/v/numba.svg
|
| 46 |
+
:target: https://pypi.python.org/pypi/numba/
|
| 47 |
+
:alt: PyPI
|
| 48 |
+
|
| 49 |
+
.. image:: https://dev.azure.com/numba/numba/_apis/build/status/numba.numba?branchName=main
|
| 50 |
+
:target: https://dev.azure.com/numba/numba/_build/latest?definitionId=1?branchName=main
|
| 51 |
+
:alt: Azure Pipelines
|
| 52 |
+
|
| 53 |
+
A Just-In-Time Compiler for Numerical Functions in Python
|
| 54 |
+
#########################################################
|
| 55 |
+
|
| 56 |
+
Numba is an open source, NumPy-aware optimizing compiler for Python sponsored
|
| 57 |
+
by Anaconda, Inc. It uses the LLVM compiler project to generate machine code
|
| 58 |
+
from Python syntax.
|
| 59 |
+
|
| 60 |
+
Numba can compile a large subset of numerically-focused Python, including many
|
| 61 |
+
NumPy functions. Additionally, Numba has support for automatic
|
| 62 |
+
parallelization of loops, generation of GPU-accelerated code, and creation of
|
| 63 |
+
ufuncs and C callbacks.
|
| 64 |
+
|
| 65 |
+
For more information about Numba, see the Numba homepage:
|
| 66 |
+
https://numba.pydata.org and the online documentation:
|
| 67 |
+
https://numba.readthedocs.io/en/stable/index.html
|
| 68 |
+
|
| 69 |
+
Installation
|
| 70 |
+
============
|
| 71 |
+
|
| 72 |
+
Please follow the instructions:
|
| 73 |
+
|
| 74 |
+
https://numba.readthedocs.io/en/stable/user/installing.html
|
| 75 |
+
|
| 76 |
+
Demo
|
| 77 |
+
====
|
| 78 |
+
|
| 79 |
+
Please have a look and the demo notebooks via the mybinder service:
|
| 80 |
+
|
| 81 |
+
https://mybinder.org/v2/gh/numba/numba-examples/master?filepath=notebooks
|
| 82 |
+
|
| 83 |
+
Contact
|
| 84 |
+
=======
|
| 85 |
+
|
| 86 |
+
Numba has a discourse forum for discussions:
|
| 87 |
+
|
| 88 |
+
* https://numba.discourse.group
|
| 89 |
+
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/RECORD
ADDED
|
@@ -0,0 +1,814 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
../../../bin/numba,sha256=oSXddtzzcSW1Wd1-_HIyF2LKZovTFrinztGANaYgWIg,237
|
| 2 |
+
numba-0.66.0.dist-info/INSTALLER,sha256=5hhM4Q4mYTT9z6QB6PGpUAW81PGNFrYrdXMj4oM_6ak,2
|
| 3 |
+
numba-0.66.0.dist-info/METADATA,sha256=lXx4AG6WM5JgemDUY7PkhK90Xdxr3vEvDbtxIDiy5pk,2733
|
| 4 |
+
numba-0.66.0.dist-info/RECORD,,
|
| 5 |
+
numba-0.66.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 6 |
+
numba-0.66.0.dist-info/WHEEL,sha256=LzEbpIS1rN6HUKgX_HYQou3zndu2RacYEOrIqPjDwB0,151
|
| 7 |
+
numba-0.66.0.dist-info/licenses/LICENSE,sha256=OnDgohytAxRyRvY2PQe_dvriFscneXB_SuXbBrys8Gc,1286
|
| 8 |
+
numba-0.66.0.dist-info/licenses/LICENSES.third-party,sha256=_cYMoh2Ce-s4Nf_Gt6mb2hSlz8s3nQyCwF48H_SkgvI,26322
|
| 9 |
+
numba-0.66.0.dist-info/sboms/auditwheel.cdx.json,sha256=1vDV3a0Yg1A9oa06fU_x5TubYa457LqAwIDiSj7yGDQ,1339
|
| 10 |
+
numba-0.66.0.dist-info/top_level.txt,sha256=lAjxwBJKjiuhWb3Oxtg12KVAHFHBvynjw2CXL-a00Ig,6
|
| 11 |
+
numba/__init__.py,sha256=PPSYnQ3kvcwmJ_xL4H5Zia3nKsrUfmVRdxsBa7iBmwU,8674
|
| 12 |
+
numba/__main__.py,sha256=Mr67cF_MTaSs9gZGD7paaQFE8dq62dXt6ixEI0Fo7dM,152
|
| 13 |
+
numba/_arraystruct.h,sha256=SgoBWBXJODhp6giCY6b4joNSoF8TPQW_YB9-jsmkm-k,499
|
| 14 |
+
numba/_devicearray.cpython-311-x86_64-linux-gnu.so,sha256=JLkrjOXBtviHMB2S-JKkVDGjre3mU_U_ezHraKPFTeM,45808
|
| 15 |
+
numba/_devicearray.h,sha256=fnyiPxdF47Um9uiMEJL-1e8qg2ZdYMy6NHFifelktg4,666
|
| 16 |
+
numba/_dispatcher.cpython-311-x86_64-linux-gnu.so,sha256=T1bj_VNDdEAYLUw-kiq2fIh_IgiSAvE9qTgw5SD0r3U,403480
|
| 17 |
+
numba/_dispatcher.pyi,sha256=9sw_pA7RRgsg7QxcJt2v2zNRhDgfvMZKhLKuPfghaaQ,1887
|
| 18 |
+
numba/_dynfunc.c,sha256=iRTgvlZ85iutFsabXEN0plsxzGt-5XO2kvLIKxgWFh8,20302
|
| 19 |
+
numba/_dynfunc.cpython-311-x86_64-linux-gnu.so,sha256=PkiO-0wiqwnpc-GXyKfZS0LrlvXBeu15MFs4AkC5Nsg,49664
|
| 20 |
+
numba/_dynfuncmod.c,sha256=xFiXbTRxFkU17_QPyOL2ybgDbMix5hKXM9Bic76BgSg,2635
|
| 21 |
+
numba/_hashtable.h,sha256=74Dqe0BcBgs7X9R1Msv5BJhbC4LCi_34mNoUiBP5nlo,4499
|
| 22 |
+
numba/_helperlib.c,sha256=BTZ_6uWbbRFHGApXAZhzH036fEqeNRG6HQmEZ6TY_hE,34823
|
| 23 |
+
numba/_helperlib.cpython-311-x86_64-linux-gnu.so,sha256=mZnxZCoT25CTUSDCZnpi55Xcn-CyUfrrYh0f9eEHoqM,835320
|
| 24 |
+
numba/_helperlib.pyi,sha256=PjsAh7ug-MenYDHWCX0s5nx3X2yGVHtFgsTkHoVpwFg,75
|
| 25 |
+
numba/_helpermod.c,sha256=ehpOrcaa1yk5akXgOpLZs0WKjJCjt3GSfBEpfJYlRVk,7862
|
| 26 |
+
numba/_lapack.c,sha256=Xn8uUHFgWJk8eVilo1byHazu7fGTm7AqILxApoAlsNY,55086
|
| 27 |
+
numba/_numba_common.h,sha256=qcZMEJFdEH4y2BJ4f-FVV-gzoSV4BW-5xC-RaB_5e-w,1667
|
| 28 |
+
numba/_pymodule.h,sha256=HqN4oZ7pXAxkKFoEn-fUTlrWj30Rp2p0DejJKovZqJc,1710
|
| 29 |
+
numba/_random.c,sha256=xplDgTp5b_XC8SYgKSSdqx6HEdxfTJNv4f_EpSRcNOc,13152
|
| 30 |
+
numba/_typeof.h,sha256=TL7gz-3EUTlq5YAzNxpHFMNCXglo1witOJTIlr520s4,344
|
| 31 |
+
numba/_unicodetype_db.h,sha256=BK_cQfuPjJVk5hB8AZr7o0geNkHA7R1yDJvLw6HQtuI,248614
|
| 32 |
+
numba/_version.py,sha256=Sv9tk0sHV99jd63fOlT4kuoS2k2hLD49SoERGRlBUnQ,498
|
| 33 |
+
numba/cext/__init__.py,sha256=ZGFuefIViSAZpwX2PlttNOSKuubZ9afqDDN_35SYE28,507
|
| 34 |
+
numba/cext/cext.h,sha256=BcSDh4LjinnWcIe1T5vm-iahaVu4Cph89rfdvDK5PtU,661
|
| 35 |
+
numba/cext/dictobject.c,sha256=zI0HZ1VhCwiqvYVLqso3xILVUEWQV3kqFeQDH0LwKhM,38175
|
| 36 |
+
numba/cext/dictobject.h,sha256=AEY_44GaiJsTyTHkZqG2JGiVoFOpNpMB94ZSD2nJ8fA,5980
|
| 37 |
+
numba/cext/listobject.c,sha256=h1v1VGs4td4-1XQL7pb5TNAo9-tEntYgAjrFKIG6WHY,31928
|
| 38 |
+
numba/cext/listobject.h,sha256=S2605_HlvaK03buI-SFTjEl4OqZvd93-kvOVxudrZxE,4125
|
| 39 |
+
numba/cext/setobject.c,sha256=JvEpvP3Tk5sF--tYoU2d995zOjjyxJKozOD8vVjqP8k,29205
|
| 40 |
+
numba/cext/setobject.h,sha256=2Ga48iRRjylMQTKaTgPaToK9WvOIidFNV8mqHUAHgcE,4339
|
| 41 |
+
numba/cext/utils.c,sha256=FW9zwCwlZIQcge2d7KQlsFU2k6EcfcrY-rhn9x71vx0,201
|
| 42 |
+
numba/cloudpickle/__init__.py,sha256=IzKm9MzljfhH-QmN_o-zP5QimTwbtgJeRja8nrGFanQ,308
|
| 43 |
+
numba/cloudpickle/cloudpickle.py,sha256=AV4MEacCVSLzfQu1ldcxMM5egfS3BYQeIUZuFew0CjY,59103
|
| 44 |
+
numba/cloudpickle/cloudpickle_fast.py,sha256=AI5ZKf2AbLNxD8lXyLDpKZyzeZ2ofFtdK1ZWFq_ec1c,323
|
| 45 |
+
numba/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 46 |
+
numba/core/analysis.py,sha256=WUuo8Fez3856YxXhNophQYlegY1tHAi74GLYcr7FcW0,28317
|
| 47 |
+
numba/core/annotations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 48 |
+
numba/core/annotations/pretty_annotate.py,sha256=_RiqUaNuc7cQwYit7z5NpvdxzYe5mPzNVjybXyhqVfM,9540
|
| 49 |
+
numba/core/annotations/template.html,sha256=nU0wqR4YNRTGVTc-9JgpQvwMW9IFb4F-0GS17vvfdiQ,3464
|
| 50 |
+
numba/core/annotations/type_annotations.py,sha256=O5j1DM5JZ-2BpTOP8CqI-D3O5tY0naog3-Xl7xBG4vE,11184
|
| 51 |
+
numba/core/base.py,sha256=6Ij_GmY9wnzOhouL-iSMrvqoNnGLeqV0CWY8vHFwvG4,46144
|
| 52 |
+
numba/core/boxing.py,sha256=3eOH-z0S3cKFpcj9X8eT1v9FCIDMbt53O4De8h4E_0w,46653
|
| 53 |
+
numba/core/bytecode.py,sha256=J34EAuKyityUDQsb5JFvyP1jtSBrzWIg-ZT8KZ0cQpI,25041
|
| 54 |
+
numba/core/byteflow.py,sha256=4J-mSKXVlVj4IPChGUsIsR8tEOECbvPQhicFewm0bfM,82552
|
| 55 |
+
numba/core/caching.py,sha256=Am9G2GgXEf99T_mBxUIHU2Yw44y22PuGuE9BkWdGNcY,26855
|
| 56 |
+
numba/core/callconv.py,sha256=gkLr-gEBpJHXdLPQDw0Y1A5HpjyBEcuumBnNQaPAZIM,36799
|
| 57 |
+
numba/core/callwrapper.py,sha256=RxaV-p8315st3H5TfaAGidjvo8H04Lf1PSgtZlOSRAw,8450
|
| 58 |
+
numba/core/ccallback.py,sha256=jfxSEbMKmbKVZfz3DC5S7p2oPnV3y3Oj8svwlP9SElQ,4312
|
| 59 |
+
numba/core/ccallback.pyi,sha256=gOat0Gd7PMQkWjBhV87NHNbzWaWelBhSDzSqE2S9uX4,1488
|
| 60 |
+
numba/core/cgutils.py,sha256=Z1fN3gcpVnhknzuv9TKwxyxMByiERJnrfqjA9UbbOYs,39216
|
| 61 |
+
numba/core/codegen.py,sha256=gDYhiMiiYz4ezI4t-0VYh_5xdFAl7ufp9bvG4LEOm18,55456
|
| 62 |
+
numba/core/compiler.py,sha256=qC867N-qi3iaeCI-CEkdxzrsOrjwD_TP-dN3bkzzEpQ,27864
|
| 63 |
+
numba/core/compiler_lock.py,sha256=CM8ONwrW9UGLT_uQ3xpG5huU-M3XRAYA32hCLNnuTTQ,1521
|
| 64 |
+
numba/core/compiler_machinery.py,sha256=-UuuVPV0-TSa3_xDDRRY4EI__qefNU0VJ96xjDcqpLM,14391
|
| 65 |
+
numba/core/config.py,sha256=DaPamtpY_XEnMXu99L7j0iRSIikFFKvu6wPjtW71XIE,23052
|
| 66 |
+
numba/core/consts.py,sha256=lkwM0wNPw9rjv9rcFsDufZESSo4fC0yeszec92O96ys,4501
|
| 67 |
+
numba/core/controlflow.py,sha256=Teg-8v6GrmPGuWodMqGTfzvyJZWa_jzBxvv-iWTjkyU,32358
|
| 68 |
+
numba/core/cpu.py,sha256=TDvZYI2pv_trn4pNe7EBLnRlqUCo_xfQVwZTihYWFwA,14189
|
| 69 |
+
numba/core/cpu_options.py,sha256=FRc3PTrVcpf4UXpScsKZd_4XxLO_4Lb8SKCDRGPH_3o,5484
|
| 70 |
+
numba/core/datamodel/__init__.py,sha256=uEqJC_eaDkBhrb1NZzU76hn5Zv5vtsPNxxic-wLd05E,225
|
| 71 |
+
numba/core/datamodel/manager.py,sha256=OFSk3zpXbt0rOTHCEudW30cwn90uqhAIShd65n8Wa2M,2155
|
| 72 |
+
numba/core/datamodel/models.py,sha256=xsgTKns0M7OsRD2Jctn81mmhYfY9hueczJEndpMGXyM,44199
|
| 73 |
+
numba/core/datamodel/packer.py,sha256=PK-fWl1nBm2BpJwd7PMswTYACgWm41bHhkVh9CNTgBw,6645
|
| 74 |
+
numba/core/datamodel/registry.py,sha256=uEJyukeEvGfyIovLfBO3Rr6maqLWhgK9msD1hg7fKmg,416
|
| 75 |
+
numba/core/datamodel/testing.py,sha256=f31La03lzPAPGPF-OE-VaV-rLv0h-BT9rmRFElEDIco,5346
|
| 76 |
+
numba/core/debuginfo.py,sha256=7UGcm8gFOMbO5wXWQjL9aWNdx-6_XPaxk_ANFhsKElg,17525
|
| 77 |
+
numba/core/decorators.py,sha256=yan8ldffqh0aAZHIfqNmzCxr4PlOwJ0atYD2XdO9yso,11360
|
| 78 |
+
numba/core/decorators.pyi,sha256=WWoH-rZK_xZFn4Xu6F7D5rgJvUgtQBa5Z1pezC6SR8Q,3446
|
| 79 |
+
numba/core/descriptors.py,sha256=pYBrPowcj7MJob32fdZZ2WrmL4NWr69GPBsl0_QaqIA,345
|
| 80 |
+
numba/core/dispatcher.py,sha256=n9BQsQlc1qn--QdyqgZdUTKFg7FntSOT975rYVuZlTs,51622
|
| 81 |
+
numba/core/dispatcher.pyi,sha256=n4MyBtHs1Ngy0ZA-Im-7IYHHtM2cjpoDXZbyf5qFs78,7877
|
| 82 |
+
numba/core/entrypoints.py,sha256=eZkSqheZj4WuTVy0cjApQCQXs9rOxoNGXZ3PcuxDiGU,1615
|
| 83 |
+
numba/core/environment.py,sha256=wCydbj-gUqqy0Ql_RFmHBazk7Wb722qa71SIQRRve1c,1639
|
| 84 |
+
numba/core/errors.py,sha256=J-05z7xOTkDKKMy8twJk3uSV6pLLgxToUsAXUkD1cCs,26257
|
| 85 |
+
numba/core/event.py,sha256=q4eNSV-FMnlL_jbzm51sTiVqu2acj6e74qiPBtC0ong,12095
|
| 86 |
+
numba/core/extending.py,sha256=aoNvWN7H6ectEJWXmsDfrrh4jhI2OnlTNwiKXhrv26c,19779
|
| 87 |
+
numba/core/extending.pyi,sha256=y4HA8eLcgptr34pjWr5AaJVY1ATCGXe0GIAPbGAYK9A,6097
|
| 88 |
+
numba/core/externals.py,sha256=Dwxc71cCdcizy-_TZRR849eDMzNOXa1Y_KSZ8tUoCVI,4851
|
| 89 |
+
numba/core/fastmathpass.py,sha256=0HQfDhMmdjKG-tTiqeoYoUtDDP6CZIEPF7pGZnbDIRc,1211
|
| 90 |
+
numba/core/funcdesc.py,sha256=1VX9EhGiUTxD8ixQhC6GlXOzj9HxEpsYhf_RxLyeOR8,8273
|
| 91 |
+
numba/core/generators.py,sha256=KsHYH7fC6mKrYNMFHZ4hekK8gQN0W_442QECsIOe3lU,14176
|
| 92 |
+
numba/core/imputils.py,sha256=YocYwlXMYTkQqJLYcEj10v-nzIj4Dn9sMiCWBcM3dmU,15895
|
| 93 |
+
numba/core/inline_closurecall.py,sha256=QDm1np0ZsyhkNQu8nrVR2eY31xFkVgSLejOHylBWSfw,72191
|
| 94 |
+
numba/core/interpreter.py,sha256=HhJuPFXOa1WQ6Sf-KeZZYm_JFDjBQdAtE-Y-UPwFGx4,143235
|
| 95 |
+
numba/core/intrinsics.py,sha256=IZqjKTPQ_74XdNGt3-WurTKTfgEhGVkfhPSwdv0EpSA,2008
|
| 96 |
+
numba/core/ir.py,sha256=5sgGHOy2XmgWjT7xPNLARsiTnee3Hy5xbPhUyHV_Gmk,52254
|
| 97 |
+
numba/core/ir_utils.py,sha256=bTZjmTDwUd0qHC1Xr-bVntuXKEkaE1TQX_6j-scmM3Q,89748
|
| 98 |
+
numba/core/itanium_mangler.py,sha256=ljbaWNE21eKYVnaQovhxP_mjsM1xVLilu7CdjVYTDyw,6110
|
| 99 |
+
numba/core/llvm_bindings.py,sha256=5gZWzIsJZMWNuZZYUDrOU-Y8_3ZxYe2Rddd26uaAOho,1245
|
| 100 |
+
numba/core/lowering.py,sha256=OokX2m346J_C0L43jhNxQ8SYKpIpzTYjygl-J_bFLmA,67046
|
| 101 |
+
numba/core/object_mode_passes.py,sha256=XeRInu0p6iWhfthmFd40wDcqjvM9AGcd6SpE-dzS6Vw,5869
|
| 102 |
+
numba/core/optional.py,sha256=5g0Bgn4pB09yyVOP5X973f-RpVrKA1Y3l40PlJX6gd4,4182
|
| 103 |
+
numba/core/options.py,sha256=QISFK5LSWEBZkl6EpOa7rWStaKrChgZx39xtskvHoEQ,2999
|
| 104 |
+
numba/core/postproc.py,sha256=2DWTz4PvcPQQTj7y_L30ij1sII3OKt0l0K_azsFGLFM,9318
|
| 105 |
+
numba/core/pylowering.py,sha256=OJMzHwCusj0Fa-qIR94bNVSuIJTcL5youagB6yRl8a4,24891
|
| 106 |
+
numba/core/pythonapi.py,sha256=6Nx5g3NXfyxW9jY7puVd-83z-up0MOmT3p5DJ1tOvBM,69573
|
| 107 |
+
numba/core/registry.py,sha256=H0eAEHnO392xVxYpJ65gnmWsppVC_L8aCV_aDnDYl10,2625
|
| 108 |
+
numba/core/rewrites/__init__.py,sha256=nYQr5fLoOWzeeWbP8AeQnWij9nAoAMkFG-B6gjJ7d7E,284
|
| 109 |
+
numba/core/rewrites/ir_print.py,sha256=TXGMw9NziDSAYxc3SguhdIU7Pn6NQP9X5umlAvlm14U,2969
|
| 110 |
+
numba/core/rewrites/registry.py,sha256=0vubYnbutEygNYiNEbvm-Mf9mP977giP83QHBiSeKBA,3651
|
| 111 |
+
numba/core/rewrites/static_binop.py,sha256=beLhF0A5FyoDKKS84jsNvMOgQAFeEWckm6z-rrI-8Bw,1146
|
| 112 |
+
numba/core/rewrites/static_getitem.py,sha256=OmYFspFKSSk63fVwV2Oj8Wu4ZhVRt0rQR_E-rg_V3ZM,6624
|
| 113 |
+
numba/core/rewrites/static_raise.py,sha256=aBHSyB_Djac-T2gN44aiTwBKCIDVb9h_Mv12qQF62zY,3576
|
| 114 |
+
numba/core/runtime/__init__.py,sha256=g0oEnSA15s0XLF7kuPp_U7pw5KUcnZjcDdF0gD51rIM,23
|
| 115 |
+
numba/core/runtime/_nrt_python.c,sha256=UzNLXbDiLxsA_AtzQmF2Vht0a7jDoHeaIQxEAiWDWo4,15158
|
| 116 |
+
numba/core/runtime/_nrt_python.cpython-311-x86_64-linux-gnu.so,sha256=tLpDebMZfb3Or83OVbz4hkyMWPLLCIj5vEo5xdT4hAo,189304
|
| 117 |
+
numba/core/runtime/_nrt_pythonmod.c,sha256=Gk3pLk3R96W5gHumuJ1eg2N-eXeNOlrsWPNbtQMBht0,6095
|
| 118 |
+
numba/core/runtime/context.py,sha256=JP80DuPKWT9P0qsXay6ueHYuqtv4ChyeyDRBbMJuqLA,17206
|
| 119 |
+
numba/core/runtime/nrt.cpp,sha256=6HoAZuhcuagbBJXvZP2A8o522kYZGhwcG8NZfI2CP_0,18525
|
| 120 |
+
numba/core/runtime/nrt.h,sha256=JJzmIotXg2otcSudPYPud6Wsl6fbJdSX_7M2rGJ0rH0,6453
|
| 121 |
+
numba/core/runtime/nrt.py,sha256=vwfYk5NSKCqbTDX7ylE5_6P53Zjo7Zl7R_i2v1JVMCY,4071
|
| 122 |
+
numba/core/runtime/nrt_external.h,sha256=q2IkdHTFlV34qrQlkOL1BJrosG-4a10vxBDcyQR_iHg,1865
|
| 123 |
+
numba/core/runtime/nrtdynmod.py,sha256=Fi8E1Wqu05fc_oUtXXqbPQk_xepLoq1ydGFQrb1-a6U,8002
|
| 124 |
+
numba/core/runtime/nrtopt.py,sha256=OUuVG7DznCbJI6Xhwn3fLCucEbZ6nhimogNzduEQYho,5834
|
| 125 |
+
numba/core/serialize.py,sha256=9iKgtD-widcUcCzAT745hF7hka2vq9R5mheuysOAGAY,6284
|
| 126 |
+
numba/core/sigutils.py,sha256=KpoyuVJ5RGgtyMK2cgzmN0P3pU39zU1M-NbxSai90d4,1613
|
| 127 |
+
numba/core/ssa.py,sha256=0grM2SdX_vZjpD540O6I_gHZMzN57aRjyeFfDneF5JA,16546
|
| 128 |
+
numba/core/target_extension.py,sha256=CJlJ3nb3YlIYybujExLTEFT2cO5kItqIay5Qgc6Sm3s,4606
|
| 129 |
+
numba/core/targetconfig.py,sha256=TOH0CFU0XkiPuhEoVRrXTPTPnTi9FCSC-3wYurVjB18,9817
|
| 130 |
+
numba/core/tracing.py,sha256=C4HYOC8IgIq7tNReI3jnkfFZhA6WQbVVrG8HcYpNNXM,6900
|
| 131 |
+
numba/core/transforms.py,sha256=TVea3D-BmGPdokZUqv3_IGZxLkAbi8JEezNP5hCbpC0,31846
|
| 132 |
+
numba/core/typeconv/__init__.py,sha256=KrF14DtWGRNjGJwRsBVGcsCNWEBQ6PqLg5o_6sJSTEM,34
|
| 133 |
+
numba/core/typeconv/_typeconv.cpython-311-x86_64-linux-gnu.so,sha256=H5j_3UkKnvx8b8cYR9AUkwBVxztfvyE6vZq4cTbqJuc,139624
|
| 134 |
+
numba/core/typeconv/castgraph.py,sha256=jSG30D_rPtiUZuQFFnlCG4N3VG-7pmMwmrtNVI0NS2A,4075
|
| 135 |
+
numba/core/typeconv/rules.py,sha256=gEPmSvxvqeewigyxwVvYZMowBA5zeYKaThJs_1IiHaU,1933
|
| 136 |
+
numba/core/typeconv/typeconv.py,sha256=vcRNg8FkcWb_xdJ6IprQ_Hv8ANjArgNBrAOJCaEzTfs,4365
|
| 137 |
+
numba/core/typed_passes.py,sha256=8ojaLRXuimDQICdb1xhzL838jHwofB3Cm2dKFUyuyVU,38835
|
| 138 |
+
numba/core/typeinfer.py,sha256=0s7oZtUcs_xLk8q18c53d_e6BIUQ4pWi5tXnrKqpxdU,71738
|
| 139 |
+
numba/core/types/__init__.py,sha256=RWlAXx11IVxf5_z1sgbdcNIPTVxrU6sACfxv8Bo2ewA,5467
|
| 140 |
+
numba/core/types/__init__.pyi,sha256=Xx4pSubyfPnxLn9QfiIFGbiLCcKPQGUgqyq3aEK2PBo,5195
|
| 141 |
+
numba/core/types/abstract.py,sha256=IzJsLCR6zXOr0_smA9sLk51MKdj5d2K9BwVASjDiw5g,15202
|
| 142 |
+
numba/core/types/abstract.pyi,sha256=7ALq8oQU7_fkiVSPEv0BuGAfEo0JR6PFkgQ7aUAaYK4,5199
|
| 143 |
+
numba/core/types/common.py,sha256=lcBWBAXAxtVs81G4cLzjNoXnSuvhd5newMwrJLuKxQw,3022
|
| 144 |
+
numba/core/types/containers.py,sha256=5sXX8gT749zChqy1exBKSP-nePK3pqGLLrsAGkLWe1U,30661
|
| 145 |
+
numba/core/types/function_type.py,sha256=wWskEdTuvm287ZZwRdvff7dQ4yZAGVDBmANPIlWnf3Y,6551
|
| 146 |
+
numba/core/types/function_type.pyi,sha256=5LNq8bmO7QEXqFi49iFNv78dxzwOVXirYq7DNR02Nt8,2928
|
| 147 |
+
numba/core/types/functions.py,sha256=HUeUR4vtMcKcNQ3SuTkXEqVdE1qbPFKYLgWd2foovgM,27070
|
| 148 |
+
numba/core/types/functions.pyi,sha256=BWSY9ZlFAmIPNlJnYkazwlOVSlStVHK4Lzm4Z3TRmUs,6576
|
| 149 |
+
numba/core/types/iterators.py,sha256=Byq2QyPRSTL_Z-xeUJKljd3anzDny8CN1TEp-YmqISw,3534
|
| 150 |
+
numba/core/types/misc.py,sha256=NcljFVerH2tvV-o2n0uWM0d53Tp91Wp3BWXmBPGgISk,14609
|
| 151 |
+
numba/core/types/npytypes.py,sha256=Dko5LsKPeqyD-AXg0yKj_unnBOPPCDjaCf1DtOZPMsA,20597
|
| 152 |
+
numba/core/types/scalars.py,sha256=BMdujcaS37ZPx_i-5TIeMimtem_cZAygWQu0sG26uBk,6155
|
| 153 |
+
numba/core/typing/__init__.py,sha256=FD8n9EBp1Dd65qpibBRAYoGMkRy-U1snNitmaSceyLE,152
|
| 154 |
+
numba/core/typing/arraydecl.py,sha256=okPFJ_b4VR_ZbPAHkAAoTql4Bt6ypQMYaHhLVmUCI1M,30984
|
| 155 |
+
numba/core/typing/asnumbatype.py,sha256=ypov7bYOta9bEyhSgL-wQSV_30_1QWYyo_3VnvGKVn8,6487
|
| 156 |
+
numba/core/typing/bufproto.py,sha256=f3aQVsiwmjTrhHkdviQB781AAhWbhTpuY7wCWK1VqyI,1719
|
| 157 |
+
numba/core/typing/builtins.py,sha256=zhzkOZqX38byPrsk7WmkR9kZdB_tPeDe95yfNomywlM,32960
|
| 158 |
+
numba/core/typing/cffi_utils.py,sha256=L8cafV2eHiNyi9m9EaFUzzb0rLy_R65NuEjAovFuE_I,7959
|
| 159 |
+
numba/core/typing/cmathdecl.py,sha256=J7F_fnavUrRcuwgVNt4XrsoojCBZ_K-CNryk_3JY5eo,1202
|
| 160 |
+
numba/core/typing/collections.py,sha256=WDhsPKYV7QUd5ACfEd8zJphvCyPLSj8eb66EhFGFNbg,4025
|
| 161 |
+
numba/core/typing/context.py,sha256=LS4UvICvjQiMvKiZ82PISAlrJOHaxRKsBq6VvMEM2mM,28633
|
| 162 |
+
numba/core/typing/ctypes_utils.py,sha256=053rG2hVZ4jMYxiaUkIi0jFuZLdqO3N2MM8NsbeLCLc,3623
|
| 163 |
+
numba/core/typing/dictdecl.py,sha256=-rFhnPbP140Sy_iaJufIP5gtE8Hd61rzoHNb5lKbDZk,1872
|
| 164 |
+
numba/core/typing/enumdecl.py,sha256=W9ugyhgCumA6WLM8HG9nKndU55sYal6KB28Afa47O-A,1503
|
| 165 |
+
numba/core/typing/listdecl.py,sha256=mYRdzNLhAXScEj8-ldr8xSzA1rsmmY27-SonQOJTH3Y,4494
|
| 166 |
+
numba/core/typing/mathdecl.py,sha256=JSeZ-PFZf0JWWWttmDidTE7HJ3PkvTCrYOH7mRtxgVY,4488
|
| 167 |
+
numba/core/typing/npydecl.py,sha256=FtNGf-kGNgKZUVYLHNERjTS7bT6B9eubaMkq7huufjQ,25202
|
| 168 |
+
numba/core/typing/setdecl.py,sha256=YugeSIfastKRzE5N098jUBDeEscYiKxCrr69_cDYd9g,3209
|
| 169 |
+
numba/core/typing/templates.py,sha256=dhpwzt2Iq1CxbWF0Ig_1HLq4VGLxWb_VlbL77DzNSvE,49841
|
| 170 |
+
numba/core/typing/typeof.py,sha256=RPXZ4K35ddFpfL-DBQ13d1WN2ZshLcwtvk5pMxlD3DQ,7743
|
| 171 |
+
numba/core/unsafe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 172 |
+
numba/core/unsafe/bytes.py,sha256=2X-_9etm5LeGkKOgOR9T5CezCydxZtDstHNookgOfoA,1720
|
| 173 |
+
numba/core/unsafe/eh.py,sha256=fDSxnbGv5xTjGk8dj0M4hiJoySxbUNdKEhIVCOUiK5c,1621
|
| 174 |
+
numba/core/unsafe/nrt.py,sha256=3voPFKB8jZdLq8bm05_USvS6xhBerF6G7sz8uC3CHxE,468
|
| 175 |
+
numba/core/unsafe/refcount.py,sha256=hYVRt3Aw2iaXX_rvB1a1tYMW-9YtFi3G5Dvx3SN2n3s,2704
|
| 176 |
+
numba/core/untyped_passes.py,sha256=nvkhsDKRCuTcdiB1XabPGXRcObttdqrpGuq0l7Ugxr4,74871
|
| 177 |
+
numba/core/utils.py,sha256=8IMf2nypU7i5m_5ddZdMiaupReAWpBvTSTc4TXd-ehs,22535
|
| 178 |
+
numba/core/withcontexts.py,sha256=Y1AFOz5CqPXShFOdN2iRWNH9QgXbBpHRkKi8oC9rMds,19133
|
| 179 |
+
numba/cpython/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 180 |
+
numba/cpython/builtins.py,sha256=tQCfXFcTqyWIl5qZjW1pBHVsaectH_1ji4Tbec7QmEU,36688
|
| 181 |
+
numba/cpython/charseq.py,sha256=cZD8YpJNq_YWL2g7irQQW456oTDfMUowmQbHlbvw7bU,34401
|
| 182 |
+
numba/cpython/cmathimpl.py,sha256=FtDWq6PtOUTZMZ4k0K0JOgmEpUZk0wM2G0-aRBTL2ME,17607
|
| 183 |
+
numba/cpython/enumimpl.py,sha256=nGDz9MdYT0Zmy2En_VoyT5Aq_9-0mV1qNl1MdzbNwIw,2906
|
| 184 |
+
numba/cpython/hashing.py,sha256=Jf0uvGv3-envazAV96ury6Rv1l2jKppX4ZGlpHlWrM4,27042
|
| 185 |
+
numba/cpython/heapq.py,sha256=v4AIbYVfPkAcqjcxN1r9RyIOIyqeek4UzOiOJftUYqw,6185
|
| 186 |
+
numba/cpython/iterators.py,sha256=WexsScJ2DuWoTe4qlbflra8ICYXWo4umsbFzawubBuw,4897
|
| 187 |
+
numba/cpython/listobj.py,sha256=NPAzbz-0WQd3hxR26Rb6wxBSK3JvVhDz-U5KFiuUwy0,42815
|
| 188 |
+
numba/cpython/mathimpl.py,sha256=OcVY2A2T6voRxPG7Efl5DZ2_aa_OFTavsUs2UjbomGY,16199
|
| 189 |
+
numba/cpython/numbers.py,sha256=ceZamnqV20XTjSUk-L2YjwJlP2ZL8nIlP73Tgu1bxA4,50161
|
| 190 |
+
numba/cpython/printimpl.py,sha256=-cL-3akbIhdtSVW2dW6p3mjDvLBzCHc6NxRoKR07ETg,2494
|
| 191 |
+
numba/cpython/randomimpl.py,sha256=yojNOBBjnieh1aek1aR0JD5x1AizY-ngNlF9uN9kUvI,81555
|
| 192 |
+
numba/cpython/rangeobj.py,sha256=ZK8ng2sPsLhnrNRwYbdOzbFEkP6LAxfWaztQJn1DgQA,8653
|
| 193 |
+
numba/cpython/setobj.py,sha256=Wo4TmkOfyaV2NfBYMMxhAGK3L4ZWTMMjYKEf_Xmo1BE,57246
|
| 194 |
+
numba/cpython/slicing.py,sha256=BJIh9WSWE5hksbkjpNJFclfofEXSkvB_kLYNGcrWk0g,9435
|
| 195 |
+
numba/cpython/tupleobj.py,sha256=t2O4PHan-zGDBxT7fnlta9BIrYSpewbkrA6v6z8SN_I,16855
|
| 196 |
+
numba/cpython/unicode.py,sha256=0iZMElB5Kx2jufw1423lhBfY8vPHxBCeUT4SQ47hSUY,89951
|
| 197 |
+
numba/cpython/unicode_support.py,sha256=2SpAMVq25CdxHX2E8tbkFbCEQs9-9Rsw4T91BuvWHz8,27323
|
| 198 |
+
numba/cpython/unsafe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 199 |
+
numba/cpython/unsafe/numbers.py,sha256=99pqDh2kEopxjAX8H0GZ3RFNV0eFMnMWjp7g6qwM7mQ,1719
|
| 200 |
+
numba/cpython/unsafe/tuple.py,sha256=t2IJz9N3DzBbgE5cy6g5dWAZ17a3Td9PDNWWHsp5aWY,2883
|
| 201 |
+
numba/cuda/__init__.py,sha256=dVzRg7REcZRsrS8h6DSsMjij418I281Mha1tYhwO5uo,620
|
| 202 |
+
numba/cuda/api.py,sha256=e9Y7RQWh8mEl3Eie3xzgniSgjHC_nlLrjBCiYx5pNs8,17601
|
| 203 |
+
numba/cuda/api_util.py,sha256=aQfUV2-4RM_oGVvckMjbMr5e3effOQNX04v1T0O2EfQ,861
|
| 204 |
+
numba/cuda/args.py,sha256=HloHkw_PQal2DT-I70Xf_XbnGObS1jiUgcRrQ85Gq28,1978
|
| 205 |
+
numba/cuda/cg.py,sha256=9V1uZqyGOJX1aFd9c6GAPbLSqq83lE8LoP-vxxrKENY,1490
|
| 206 |
+
numba/cuda/codegen.py,sha256=raBoCDNt_qkDgB12yU0tbJQlA5_eTlUMemgcRHen1Vk,12174
|
| 207 |
+
numba/cuda/compiler.py,sha256=seanDEVVsiBqGmHUivIxcYf6mPWEgPYam1rects5-vs,15886
|
| 208 |
+
numba/cuda/cpp_function_wrappers.cu,sha256=iv84_F6Q9kFjV_kclrQz1msh6Dud8mI3qNkswTid7Qc,953
|
| 209 |
+
numba/cuda/cuda_fp16.h,sha256=1IC0mdNdkvKbvAe0-f4uYVS7WFrVqOyI1nRUbBiqr6A,126844
|
| 210 |
+
numba/cuda/cuda_fp16.hpp,sha256=vJ7NUr2X2tKhAP7ojydAiCoOjVO6n4QGoXD6m9Srrlw,89130
|
| 211 |
+
numba/cuda/cuda_paths.py,sha256=_fPrwCysDSoxwUvU_2xyGe9KSDxtHzunkxVqQNLtTBg,7723
|
| 212 |
+
numba/cuda/cudadecl.py,sha256=ynUidit8oPGjedc6p1miMGtS20DOji3DiQHzwmx6m0s,23192
|
| 213 |
+
numba/cuda/cudadrv/__init__.py,sha256=0TL4MZcJXUoo9qA7uu0vLv7eHrXRerVmyfi7O149ITw,199
|
| 214 |
+
numba/cuda/cudadrv/_extras.cpython-311-x86_64-linux-gnu.so,sha256=UodF7nO0p1mvsVCUiX4YYjmeyt4VKfDPqDxS6Mperm4,25856
|
| 215 |
+
numba/cuda/cudadrv/devicearray.py,sha256=B3ItYQywTnwTWjltxVRx6oaKRq7rxTtvOaiqTWsMQ2w,31123
|
| 216 |
+
numba/cuda/cudadrv/devices.py,sha256=6SneNmoq83gue0txFWWx4A65vViAa8xA06FzkApoqAk,7992
|
| 217 |
+
numba/cuda/cudadrv/driver.py,sha256=vX3ayUtG0iHgZJRdIWfY5GvPGnskRBVMJvDyo4s1Hgg,107039
|
| 218 |
+
numba/cuda/cudadrv/drvapi.py,sha256=gDalZLaZBRQIDU-LUXgV7MwPJlgKuiu8h0YEcTA6_SM,17129
|
| 219 |
+
numba/cuda/cudadrv/dummyarray.py,sha256=nXRngdr-k3h_BNGQuJUxmp89yGNWxqEDJedpwDPEZ44,14209
|
| 220 |
+
numba/cuda/cudadrv/enums.py,sha256=E0lnh17jO4EvZ_hSIq3ZtfsE5bObmINtKb_lbK7rmMg,23708
|
| 221 |
+
numba/cuda/cudadrv/error.py,sha256=zEIryW6aIy8GG4ypmTliB6RgY4Gy2n8ckz7I6W99LUM,524
|
| 222 |
+
numba/cuda/cudadrv/libs.py,sha256=PRyxal4bz9jVZmuLpKiYw-VaR59LekfwJgWKo7R5uRY,6005
|
| 223 |
+
numba/cuda/cudadrv/ndarray.py,sha256=HtULWWFyDlgqvrH5459yyPTvU4UbUo2DSdtcNfvbH00,473
|
| 224 |
+
numba/cuda/cudadrv/nvrtc.py,sha256=CLpuD9VzPcYoXj8dZ2meSoqbWXHOOC5V5D6dFNdXqmg,9693
|
| 225 |
+
numba/cuda/cudadrv/nvvm.py,sha256=v2hJJTAQeRmoG59-hnhgMEp5BSVA73QHtEoy636VKao,24107
|
| 226 |
+
numba/cuda/cudadrv/rtapi.py,sha256=WdeUoWzsYNYodx8kMRLVIjnNs0QzwpCihd2Q0AaqItE,226
|
| 227 |
+
numba/cuda/cudadrv/runtime.py,sha256=Tj9ACrzQqNmDSO6xfpzw12EsQknSywQ-ZGuWMbDdHnQ,4255
|
| 228 |
+
numba/cuda/cudaimpl.py,sha256=3YMxQSCv2KClBrpuXGchrTNICV1F6NIjjL2rie5fDZ4,38628
|
| 229 |
+
numba/cuda/cudamath.py,sha256=EFNtdzEytAZuwijdRoFGzVKCeal76UzzaNy7wUFQx8I,3978
|
| 230 |
+
numba/cuda/decorators.py,sha256=3iN9e38Qt4v7P_TfN_G9AR4m-YBWooHsdX_TcJz1ToY,7854
|
| 231 |
+
numba/cuda/descriptor.py,sha256=rNMaurJkjNjIBmHPozDoLC35DMURE0fn_LtnXRmaG_w,985
|
| 232 |
+
numba/cuda/device_init.py,sha256=orQK7anhnmEkYPRjHEs5I9uhdBwaHeXbaSD4ViX2_14,3460
|
| 233 |
+
numba/cuda/deviceufunc.py,sha256=Avu9hTiUqXrgzltNocZecvFtVxjtSP2GtG03N82BIk8,30955
|
| 234 |
+
numba/cuda/dispatcher.py,sha256=wCq4i86OPMOD5-dFbUYsQhmka7toJ6Rqh8jD0PtAPQg,40241
|
| 235 |
+
numba/cuda/errors.py,sha256=XwWHzCllx0DXU6BQdoRH0m3pznGxnTFOBTVYXMmCfqg,1724
|
| 236 |
+
numba/cuda/extending.py,sha256=URsyBYls2te-mgE0yvDY6akvawYCA0blBFfD7Lf9DO4,142
|
| 237 |
+
numba/cuda/initialize.py,sha256=TQGHGLQoq4ch4J6CLDcJdGsZzXM-g2kDgdyO1u-Rbhg,546
|
| 238 |
+
numba/cuda/intrinsic_wrapper.py,sha256=zbcUbegbfF3GdnC2Rl-z26-gozE8xBtaMxpS8LpOhfo,2239
|
| 239 |
+
numba/cuda/intrinsics.py,sha256=zk7KCyzRyXlBpxwEJLg_3oGRXOA7bODX4RPEsMKns9A,5983
|
| 240 |
+
numba/cuda/kernels/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 241 |
+
numba/cuda/kernels/reduction.py,sha256=fQnaWtoNB2yp143MNbE1DujqFIYy0KV_2moQVvbaROU,9362
|
| 242 |
+
numba/cuda/kernels/transpose.py,sha256=5FSu-nbTfhintxwfU-bjT2px2otQF5QkKH-JPDDWq_k,2061
|
| 243 |
+
numba/cuda/libdevice.py,sha256=476LeIEaAth409m-0OO1SMMmY5AHzN2AotXI__k_yYE,60065
|
| 244 |
+
numba/cuda/libdevicedecl.py,sha256=xdZbb_rCaftMf8Pbw63g_Lr230N-1QoaYzBxq8udKTg,532
|
| 245 |
+
numba/cuda/libdevicefuncs.py,sha256=c80lGpGoFIYkAdgr4fzbxzdNCyJYrLdss64bwa0Mc6w,37471
|
| 246 |
+
numba/cuda/libdeviceimpl.py,sha256=a9BmJ5kRtZ_mB7KjbDWW-PEpRuNiO_SMOxQTyy0abqs,2806
|
| 247 |
+
numba/cuda/mathimpl.py,sha256=d_gCoQ4hJzNBFNc2hvRON5h1F052epgQ8zh_RKTlLlI,14416
|
| 248 |
+
numba/cuda/models.py,sha256=2c_seT-cWX-VyWYmcapaqOEl1M4FX6_kdIOusj4s5aE,1328
|
| 249 |
+
numba/cuda/nvvmutils.py,sha256=W1zr1TpnmFjTkHF0qeu5wnBHub6gzrnpzsvgmu2OLcU,8295
|
| 250 |
+
numba/cuda/printimpl.py,sha256=Eg_RvmOcmFeL6s2RlTD-oOxebGdYLN9VZM1gcY3YMms,2789
|
| 251 |
+
numba/cuda/random.py,sha256=khX8iDdde_RTUPWhAqrxZacHRQAorFr7BokPuxRWzrg,10456
|
| 252 |
+
numba/cuda/simulator/__init__.py,sha256=crW0VQ_8e7DMRSHKoAIziZ37ea5mpbh_49tR9M3d5YY,1610
|
| 253 |
+
numba/cuda/simulator/api.py,sha256=_O9lox-obYn2j4843uZ2hZjIWgu7PXSqQGy3EiSwnnc,2620
|
| 254 |
+
numba/cuda/simulator/compiler.py,sha256=eXnvmzSKzIZZzBz6ZFJ-vMNyRAgqbCiB-AO5IJXuUyM,232
|
| 255 |
+
numba/cuda/simulator/cudadrv/__init__.py,sha256=MC6WHlTloHxGen9kIpH1Hp2p1PPyCNmoK5f3K9f7jXA,135
|
| 256 |
+
numba/cuda/simulator/cudadrv/devicearray.py,sha256=brhVnaKiJFIvZbNlE-3yft_YXTmNm4S8s95VXWT_nMc,13789
|
| 257 |
+
numba/cuda/simulator/cudadrv/devices.py,sha256=RYvLHarMNeHNrCYFokxXtg1nBIDRMu3ZohQ82hLQXN0,2689
|
| 258 |
+
numba/cuda/simulator/cudadrv/driver.py,sha256=mRz-PV4lqc-Mg3w5yUJWdrj0XS_d-3CM93uI2ZR1MTY,1124
|
| 259 |
+
numba/cuda/simulator/cudadrv/drvapi.py,sha256=76gXxRAQgr8bU-m8XizvqyXyXAZWp6QhUnS6rI-6E6Q,111
|
| 260 |
+
numba/cuda/simulator/cudadrv/dummyarray.py,sha256=DYIpIehz3cZSane651UYdJP5fehDuJkxyCg_90A1heU,163
|
| 261 |
+
numba/cuda/simulator/cudadrv/error.py,sha256=ACSQ7ZvhuCHnvV4GmvRuKWZ5bBLVzq7ncZ75oiWyLdM,87
|
| 262 |
+
numba/cuda/simulator/cudadrv/libs.py,sha256=ry5rerpZrnAy70LU_YBa1KNaqKBGLHE9cMxljdSzaik,101
|
| 263 |
+
numba/cuda/simulator/cudadrv/nvvm.py,sha256=vIFQi4ewYXyzUYssfw78QLfoZmoVgloFCLTk55Gg1tw,474
|
| 264 |
+
numba/cuda/simulator/cudadrv/runtime.py,sha256=K63p7puZJZD3BQ6ZT0qoII_Z3xJiUckp2dhozFjrnEs,358
|
| 265 |
+
numba/cuda/simulator/kernel.py,sha256=KzGURMAjrADWHE-1gUSfrKxWtwJGlH_pp9a1yxiPeBI,10668
|
| 266 |
+
numba/cuda/simulator/kernelapi.py,sha256=ZYC_XQqnA51TJCPlAjVHHkOjXeww0yUP6JZeibXw3T8,12397
|
| 267 |
+
numba/cuda/simulator/reduction.py,sha256=jVo9YiWv8W2CN5_oQ-xdS3nuxv1HZmWh9O-Vck8hsQc,300
|
| 268 |
+
numba/cuda/simulator/vector_types.py,sha256=I18mACvWYjmCiEhcRuBfX4yDbN4XhmkDfXj3HRa303Y,1672
|
| 269 |
+
numba/cuda/simulator_init.py,sha256=W_bPRtmPGOQVuiprbgt7ENnnnELv_LPCeLDIsfsvFZ8,460
|
| 270 |
+
numba/cuda/stubs.py,sha256=a9smsDwbimTKy0YnV88OkcbYqldMgkx-WiV8LB4-MGs,22280
|
| 271 |
+
numba/cuda/target.py,sha256=EI6XuKQeqvng0uSx_V9jDoxbgFivqSz-4jczFzAbs5o,16837
|
| 272 |
+
numba/cuda/testing.py,sha256=E0wP2vfno1yWsl0v1zg31kpbU8FrKxTF-5y9Iv4WjA4,6412
|
| 273 |
+
numba/cuda/tests/__init__.py,sha256=lvnEpX0TruMCga3PnDpryR3oVxLwOMyTyZKgMINCerg,984
|
| 274 |
+
numba/cuda/tests/cudadrv/__init__.py,sha256=KeAvH3QOb-KXXkFtzwvYkQp2ZrQmzgfKDkBCVIOKXXE,257
|
| 275 |
+
numba/cuda/tests/cudadrv/test_array_attr.py,sha256=cjHQ0J6F8APrLm23ZCFr0S7dtQmLqwq9vxMoI5lyn68,5300
|
| 276 |
+
numba/cuda/tests/cudadrv/test_context_stack.py,sha256=lSEuEM7x-x95m_lS_wSIBKnBxOhzn-AJ3WjYw8bW0y4,4492
|
| 277 |
+
numba/cuda/tests/cudadrv/test_cuda_array_slicing.py,sha256=RVFiuTx5wTFBECzEolJqquhfWCD6BlrK49IPyDPdmY0,14112
|
| 278 |
+
numba/cuda/tests/cudadrv/test_cuda_auto_context.py,sha256=Bhut5gxKb8H-RNu8LKp0nEmyQT5FZVRA-aOrV6X8h3E,564
|
| 279 |
+
numba/cuda/tests/cudadrv/test_cuda_devicerecord.py,sha256=rikIJQ266l_yiSMoncEeKJZizYdoVOiTg1R0gD_1nZY,5766
|
| 280 |
+
numba/cuda/tests/cudadrv/test_cuda_driver.py,sha256=y--0AZFVpp2nmbeI1jbgZsWbBP-iVEmG8WKgR9XrxKE,7663
|
| 281 |
+
numba/cuda/tests/cudadrv/test_cuda_libraries.py,sha256=sqNbo8pk4Zl5ptuGXrXFndia4IyttbuGnqjVTOtGuuw,801
|
| 282 |
+
numba/cuda/tests/cudadrv/test_cuda_memory.py,sha256=MDJMIWm1jCsBOcuwdshzqwaE__uqX0562uSjxFhud3M,6627
|
| 283 |
+
numba/cuda/tests/cudadrv/test_cuda_ndarray.py,sha256=67dmVO6v5gzp89pgb4wpxqDrWAx1UjX4vhdDQH4mebQ,20403
|
| 284 |
+
numba/cuda/tests/cudadrv/test_deallocations.py,sha256=BR1ccEj_TCVToHoHS8KwwCfKLMUl6KGb92Cx6nX-XPg,8404
|
| 285 |
+
numba/cuda/tests/cudadrv/test_detect.py,sha256=lCt2E8gxnd8O-fRobDEwgX4jBZ15W7cImQcZc8_u2Sg,2774
|
| 286 |
+
numba/cuda/tests/cudadrv/test_emm_plugins.py,sha256=ah82yaWFvBfUTTSfbkZBKLsUf2tTSSJNvlSxrk1RI1E,7094
|
| 287 |
+
numba/cuda/tests/cudadrv/test_events.py,sha256=rjBrFDxZUpfwRkAGMvMEcdjOQ7sKB_94Spv1ccxTCjQ,1075
|
| 288 |
+
numba/cuda/tests/cudadrv/test_host_alloc.py,sha256=1zGjcSFSym-LZ7XQwlOPalU-GjTOYUOEPTeSG4iNQhI,2181
|
| 289 |
+
numba/cuda/tests/cudadrv/test_init.py,sha256=kPbjDhLJr1Rl18UJZoGpT3E0l9Cm-HcyPRbKr-BD7L0,4493
|
| 290 |
+
numba/cuda/tests/cudadrv/test_inline_ptx.py,sha256=eMImGlfYRQM5esoFhWHOwDGYK3RuXdrNvStURwcFDlc,1287
|
| 291 |
+
numba/cuda/tests/cudadrv/test_is_fp16.py,sha256=0KPe4E9wOZsSV_0QI0LmjUeMTjWpYT8BXExUUsmUCDI,394
|
| 292 |
+
numba/cuda/tests/cudadrv/test_linker.py,sha256=_l2_EQEko2Jet5ooj4XMT0L4BjOuqLjbONGj1_MVI50,10161
|
| 293 |
+
numba/cuda/tests/cudadrv/test_managed_alloc.py,sha256=kYXYMkx_3GPAITKp4reLeM8KSzKkpxiC8nxnBvXpaTA,4979
|
| 294 |
+
numba/cuda/tests/cudadrv/test_mvc.py,sha256=984jATSa01SRoSrVqxPeO6ujJ7w2jsnZa39ABInFLVI,1529
|
| 295 |
+
numba/cuda/tests/cudadrv/test_nvvm_driver.py,sha256=VTw8-TZ7DvjNEqsrzZ-RKKzLRiSKEyAAZ3pRDYEQiVk,7252
|
| 296 |
+
numba/cuda/tests/cudadrv/test_pinned.py,sha256=u_TthSS2N-2J4eBIuF4PGg33AjD-wxly7MKpz0vRAKc,944
|
| 297 |
+
numba/cuda/tests/cudadrv/test_profiler.py,sha256=MQWZx1j3lbEpWmIpQ1bV9szrGOV3VHN0QrEnJRjAhW4,508
|
| 298 |
+
numba/cuda/tests/cudadrv/test_ptds.py,sha256=S8y-j_ZB4Y_r2S5GGtfFxfracnJflQAhHYfhybKIcUE,4949
|
| 299 |
+
numba/cuda/tests/cudadrv/test_reset_device.py,sha256=tPDkdkqNZEix2dLqe4UBcsejhauAc1oEQlrZDtPKWFE,1073
|
| 300 |
+
numba/cuda/tests/cudadrv/test_runtime.py,sha256=h4ZIHkZbDjoZhgvFUWVfwWcktkgkoHMuDJq6SWn6hXc,3071
|
| 301 |
+
numba/cuda/tests/cudadrv/test_select_device.py,sha256=DjfS3hGTDRFAQsk7QiH-v6-_1HEdaLeSyTiquwUPCTM,987
|
| 302 |
+
numba/cuda/tests/cudadrv/test_streams.py,sha256=Yyzj1riNWRKM4FX3CtbMOQ_LWp92M5HXW6g_aq2r9Oc,4195
|
| 303 |
+
numba/cuda/tests/cudapy/__init__.py,sha256=KeAvH3QOb-KXXkFtzwvYkQp2ZrQmzgfKDkBCVIOKXXE,257
|
| 304 |
+
numba/cuda/tests/cudapy/cache_usecases.py,sha256=Cm2YupAQE7IFsiHp4TnC9kb_CLXGFMEK4zMaELrktIk,5834
|
| 305 |
+
numba/cuda/tests/cudapy/cache_with_cpu_usecases.py,sha256=xm035XOas_2AXORGEQHz7hcDuXwL-bdpy3gL5AKp6ik,1142
|
| 306 |
+
numba/cuda/tests/cudapy/extensions_usecases.py,sha256=l-tW4F935zxOvKb1erFiGf9R1iJXjMbvWInrdzJLub0,1604
|
| 307 |
+
numba/cuda/tests/cudapy/recursion_usecases.py,sha256=7Wz7i_6VVq5EeZuqkcg1dVfW9DbfC1rp44H7pe4voqI,1781
|
| 308 |
+
numba/cuda/tests/cudapy/test_alignment.py,sha256=dik8i4fG6MPlxVilW4l9pM5o_vBMAsRGItldeE9hvvU,1218
|
| 309 |
+
numba/cuda/tests/cudapy/test_array.py,sha256=bS6rzvp6BKVLFyW8mFRbVoZbxIbc2WCl5SzQ6XG0s8c,10515
|
| 310 |
+
numba/cuda/tests/cudapy/test_array_args.py,sha256=JooZO3bODAMszWwecGT3LpBd3nJxHp7dASG3f7xyVVg,5750
|
| 311 |
+
numba/cuda/tests/cudapy/test_array_methods.py,sha256=shdeSAOKaoZbrvC8hXhETWH8FhyZPTmHg_TMw2DcdUA,969
|
| 312 |
+
numba/cuda/tests/cudapy/test_atomics.py,sha256=IVkvPf0CU2N6NNzPDURk4-JG_3cLU3E0FmRxTVjW0jE,58456
|
| 313 |
+
numba/cuda/tests/cudapy/test_blackscholes.py,sha256=dpPWyCnxRUThaK6npGvN5_fhU-KT1b1GifU5Tj3AHMI,4023
|
| 314 |
+
numba/cuda/tests/cudapy/test_boolean.py,sha256=S8fNBS4gVEZyKk6PpeF5GfG0TLEu_0NvTgybyPNNGLU,547
|
| 315 |
+
numba/cuda/tests/cudapy/test_caching.py,sha256=5o1VcVbir1Lro6yFCerbfbjsxH9xNsYFl7N4Rud6ntw,19082
|
| 316 |
+
numba/cuda/tests/cudapy/test_casting.py,sha256=XrMWIMhGwUGRzh6gocw1Ogj8RORyZZrcFWOuc1ABUtU,8802
|
| 317 |
+
numba/cuda/tests/cudapy/test_cffi.py,sha256=FFbFBA8xJrTfwmlt5LRsRt4xXC93P0aa-bxgzaItwKU,938
|
| 318 |
+
numba/cuda/tests/cudapy/test_compiler.py,sha256=fQ1tLxahLrawlIe1VJlDHciKkrTVutirmOzjp2fEiRo,10821
|
| 319 |
+
numba/cuda/tests/cudapy/test_complex.py,sha256=PO1ySqBsttB9lFnQ1psWDss_JEMbqiHye0c2QBRRVU8,10290
|
| 320 |
+
numba/cuda/tests/cudapy/test_complex_kernel.py,sha256=G08aM81rARqojCKnsunVG7vJB9ggon7H8S8xFaZoK_o,497
|
| 321 |
+
numba/cuda/tests/cudapy/test_const_string.py,sha256=er2ANBSHGby_QxcsZvOKgo9znjKZfcPxKAAT1DoLGhI,4279
|
| 322 |
+
numba/cuda/tests/cudapy/test_constmem.py,sha256=rdnGaRKWqjks3rug1stx5gC0w7Md20_15U8xnj-N3LE,5166
|
| 323 |
+
numba/cuda/tests/cudapy/test_cooperative_groups.py,sha256=ZQuct24GEZnb2JBDvo7ZrUbtTHchysVGoY2BGnSXsfk,5039
|
| 324 |
+
numba/cuda/tests/cudapy/test_cuda_array_interface.py,sha256=73FCQbNaAKpuybAwMOt4eW_dL_K6ZjrRgQw09ojkSbY,15844
|
| 325 |
+
numba/cuda/tests/cudapy/test_cuda_jit_no_types.py,sha256=iqYs48wLh6kR2RwGuuBmuSFUBaOyBdV1BNhxZghJcrM,2126
|
| 326 |
+
numba/cuda/tests/cudapy/test_datetime.py,sha256=2in1Cq8y9zAFoka7H72wF1D0awEd3n7bv56sUPgoNAQ,3508
|
| 327 |
+
numba/cuda/tests/cudapy/test_debug.py,sha256=0H_c9Cm4kNJCem0CkSeL8EQY1IhJ43ho1wDXGEds2Ic,3557
|
| 328 |
+
numba/cuda/tests/cudapy/test_debuginfo.py,sha256=jDPgxSe0G0nAib3wgbfrOg6uvnwmCcuB9GhrzXEvlc0,7875
|
| 329 |
+
numba/cuda/tests/cudapy/test_device_func.py,sha256=aTRyZSOJB3sAShw0YAEgHILrR-TCuowW9KYjtlRErKM,6892
|
| 330 |
+
numba/cuda/tests/cudapy/test_dispatcher.py,sha256=oX-l_L4H8rME1IolwhAyordSGJ152nnuqGAFdWjfgas,26587
|
| 331 |
+
numba/cuda/tests/cudapy/test_enums.py,sha256=0GWiwvZ1FTzSl1FfMxttkWaWrowASfXrSDT8XAR4ZHw,3560
|
| 332 |
+
numba/cuda/tests/cudapy/test_errors.py,sha256=jwHbNb2Ro5pbGOPFetmUhI-vG4s36OKCqMJ-lgWxHMY,2620
|
| 333 |
+
numba/cuda/tests/cudapy/test_exception.py,sha256=Y7VF25tzz2w5MIZjYD3vG1eTfmowFO-RBea2HiJilag,5501
|
| 334 |
+
numba/cuda/tests/cudapy/test_extending.py,sha256=jcu7BXC0wwpnxZd25gbREukjiEMk7YXmIhc-nev5Mvs,4118
|
| 335 |
+
numba/cuda/tests/cudapy/test_fastmath.py,sha256=eZ9KowHlnNByZfUU-8ZB2NhlGBlZhG-5N_sipXhVGgE,8401
|
| 336 |
+
numba/cuda/tests/cudapy/test_forall.py,sha256=rcSiGr_RAqPbc9o4-wrBuH3ucMMlsNdf2ZjjbVUUwvY,1457
|
| 337 |
+
numba/cuda/tests/cudapy/test_freevar.py,sha256=e8KMNFxJYLXcFv2V4OIh7YmI1cwo-NdCaamVmKWnANw,745
|
| 338 |
+
numba/cuda/tests/cudapy/test_frexp_ldexp.py,sha256=82y4vgKIwHTJnA9nqvHOyvLgkdLezqWstge2tChDytI,2024
|
| 339 |
+
numba/cuda/tests/cudapy/test_globals.py,sha256=b_i_JZ6ijBXuxTq5QBqzfCg9c48tOuGhRw1_fc72NBs,1384
|
| 340 |
+
numba/cuda/tests/cudapy/test_gufunc.py,sha256=0NWfQqHmx7tFh6vdS7QtxT86uB9-GmYYfg2ldFlFQLU,15603
|
| 341 |
+
numba/cuda/tests/cudapy/test_gufunc_scalar.py,sha256=Uhe8Q0u42jySrpwAZh8vCf4GMYkiy9NOMolyzEBuri0,5382
|
| 342 |
+
numba/cuda/tests/cudapy/test_gufunc_scheduling.py,sha256=luDtBxFS_5ZbVemXe1Z7gfqMliaU_EAOR4SuLsU5rhw,2677
|
| 343 |
+
numba/cuda/tests/cudapy/test_idiv.py,sha256=HLJ_f2lX8m_NNJjUbl_8zZ0-8GsBlRdBP2CUo_yWb0Y,1056
|
| 344 |
+
numba/cuda/tests/cudapy/test_inspect.py,sha256=lP9-8SbWFn2Xc-qmF6UNhcY6LreKTnveaK5CGW2pu8E,5196
|
| 345 |
+
numba/cuda/tests/cudapy/test_intrinsics.py,sha256=e6lABWy8YBgYheYYGfD75_y8vMbPP71GHb95A4hlLmA,34931
|
| 346 |
+
numba/cuda/tests/cudapy/test_ipc.py,sha256=Ky9d9BnndVgqRFFEcvEX-mn9ai7q1oBpkHykx6ChGM4,10441
|
| 347 |
+
numba/cuda/tests/cudapy/test_iterators.py,sha256=daQW3kSkp7icCmlTn9pCvnaauz60k_eBf4x1UQF-XVY,2344
|
| 348 |
+
numba/cuda/tests/cudapy/test_lang.py,sha256=U1BCVZMjU1AZ4wDSmjsRIPPcAReiq4dB77Cz7GmrdmA,1691
|
| 349 |
+
numba/cuda/tests/cudapy/test_laplace.py,sha256=yD--H5p_NrBHklFNCnxuQ0S8yUIBYScBkvn7hBlZ5ZM,3211
|
| 350 |
+
numba/cuda/tests/cudapy/test_libdevice.py,sha256=4NsZBXweDPQpqfgo6T7eQHaWDVBof1CZDTpI1QTkV74,6545
|
| 351 |
+
numba/cuda/tests/cudapy/test_lineinfo.py,sha256=sKPF5l1cDTyA4UT0IO8Yeq6pYPGt9pIBQtrMAJMJHCM,6855
|
| 352 |
+
numba/cuda/tests/cudapy/test_localmem.py,sha256=uv9UYuytIXQgzHpPgEoWVVVq5-a7-6Io_mWMiNsZ45I,5376
|
| 353 |
+
numba/cuda/tests/cudapy/test_mandel.py,sha256=crVQBw46l4iyAv8_pu7v1eBy9ZJG7OkigB5zsyi6s3A,1085
|
| 354 |
+
numba/cuda/tests/cudapy/test_math.py,sha256=T-KRh9qzwOL3usl_6Cly3FVlvauzGhGnedfAG1hBQy8,27615
|
| 355 |
+
numba/cuda/tests/cudapy/test_matmul.py,sha256=cZpJZ66UFmszLBQ4m1GdPyi27YHFkA6jo29cgQHjozQ,2084
|
| 356 |
+
numba/cuda/tests/cudapy/test_minmax.py,sha256=Lgd9OSELTwOeOI7JwbOf2E15mxv_XkgIrhC0mkoHTvg,2409
|
| 357 |
+
numba/cuda/tests/cudapy/test_montecarlo.py,sha256=jH_LxlcoA8Vb3C3YXg93XQw8J8O8WGCWoLRPg1mmxDg,603
|
| 358 |
+
numba/cuda/tests/cudapy/test_multigpu.py,sha256=4lC9G6LI0MRBDQEkRyTPb019NUFoU9cGrDWV4quomWY,4140
|
| 359 |
+
numba/cuda/tests/cudapy/test_multiprocessing.py,sha256=AjYbSa9nOlv_ycZORifdm7B-b9KdKC1HV-cGLDtrJ-w,1224
|
| 360 |
+
numba/cuda/tests/cudapy/test_multithreads.py,sha256=MfCbyJZu1XsCJOCSw6vvhs4eiP4LZPcF-e9huPmW-ys,2861
|
| 361 |
+
numba/cuda/tests/cudapy/test_nondet.py,sha256=mYMX0R1tmBLRe5ZAwiDVFFuSyMuPav5guuqL3WHWGPY,1378
|
| 362 |
+
numba/cuda/tests/cudapy/test_operator.py,sha256=0nJej4D898_JU-jhlif44fR2yu42keK4GoCLP810l3U,13295
|
| 363 |
+
numba/cuda/tests/cudapy/test_optimization.py,sha256=SvqRsSFgcGxkFDZS-kul5B-mi8GxINTS98uUzAy4dhw,2647
|
| 364 |
+
numba/cuda/tests/cudapy/test_overload.py,sha256=yYgtrf0aER3i6VaPrPpzI_uDa8xjEmdCCDSSAcx91y0,8251
|
| 365 |
+
numba/cuda/tests/cudapy/test_powi.py,sha256=TI82rYRnkSnwv9VN6PMpBnr9JqMJ_F3HhH4cKY6O8tw,3276
|
| 366 |
+
numba/cuda/tests/cudapy/test_print.py,sha256=trOElKENWGwWVcJ3uN4wzqtZiJiQtjLh4vx07iobz9U,3643
|
| 367 |
+
numba/cuda/tests/cudapy/test_py2_div_issue.py,sha256=R88Vfgg3mSAZ0Jy6WT6dJNmkFTsxnVnEmO7XqpqyxuU,986
|
| 368 |
+
numba/cuda/tests/cudapy/test_random.py,sha256=rLw7_8a7BBhD_8GNqMal0l_AbWXzLs_Q0hC6_X8gdjA,3467
|
| 369 |
+
numba/cuda/tests/cudapy/test_record_dtype.py,sha256=grR64kdRlsLcR0K3IxSfI2VKsTrrqxsXuROOpvj-6nw,18769
|
| 370 |
+
numba/cuda/tests/cudapy/test_recursion.py,sha256=8dA2HfAGT6si2OioEx_IkCEgbDhbrjQ94Y7yojPtFjA,3641
|
| 371 |
+
numba/cuda/tests/cudapy/test_reduction.py,sha256=ffut_O9EZAwAwdbEXoYPzy8GkRI6tFKC5XafNdAymgY,2528
|
| 372 |
+
numba/cuda/tests/cudapy/test_retrieve_autoconverted_arrays.py,sha256=LPYAxouZ7JYiu3z4HnNjkGtjYLuIscOxKXiY6RiTv6o,2404
|
| 373 |
+
numba/cuda/tests/cudapy/test_serialize.py,sha256=alE5-lTwbjz3Tv6OvQPSmgtUtu0X9UwFzB2aKs2rYag,2321
|
| 374 |
+
numba/cuda/tests/cudapy/test_slicing.py,sha256=qW2Btdfj9wl5aB6vDFYcrc-BiT3BzzocKiQQ0klqPHY,3156
|
| 375 |
+
numba/cuda/tests/cudapy/test_sm.py,sha256=kh1F0wwQ2_bd54Q4GUX99y2oiWHQwBpyC__ckk-jiTU,14575
|
| 376 |
+
numba/cuda/tests/cudapy/test_sm_creation.py,sha256=bTXDjU94ezo6Bz_lktlPyowTcJHBOWfy7-nJB9e-B_s,7231
|
| 377 |
+
numba/cuda/tests/cudapy/test_sync.py,sha256=Y851UqNkT80U9q_C05SQfvPRCY7jjRARHOMk6g0lU4Y,7837
|
| 378 |
+
numba/cuda/tests/cudapy/test_transpose.py,sha256=JAQX2EUHwlpKCfJDGspaldmsIRbHxnXpsNUrvRrnIEE,3134
|
| 379 |
+
numba/cuda/tests/cudapy/test_ufuncs.py,sha256=-ehvkxelr45aT8sUNL9Hq8cn2GU_K4GL1yWeX-rHqEM,9680
|
| 380 |
+
numba/cuda/tests/cudapy/test_userexc.py,sha256=4ch3Lw8X_w832lU0J5Y5ZLAfxUMUSzbxnWE0bLEWdEg,1470
|
| 381 |
+
numba/cuda/tests/cudapy/test_vector_type.py,sha256=hH3G4XtOTUNr31KyBJVAbbT4053cuJon_PPzoUVlupY,10515
|
| 382 |
+
numba/cuda/tests/cudapy/test_vectorize.py,sha256=iCCiMQERoTnpa2cxU-08bs-AbgGyrQgAC7b9J5nsMUk,9248
|
| 383 |
+
numba/cuda/tests/cudapy/test_vectorize_complex.py,sha256=0cIAvARp4w4Jw38T2qZKg7RD_UZyPVWDOYC0x3AGunE,548
|
| 384 |
+
numba/cuda/tests/cudapy/test_vectorize_decor.py,sha256=rA2Jk1wKbTQXnVvVXeVnhjft8R3zPRWNjVa76M6iI3k,2071
|
| 385 |
+
numba/cuda/tests/cudapy/test_vectorize_device.py,sha256=bsC4rJAvVtoBOaVDBulLC7oY3mDPe7E77z9LUA5mzCk,983
|
| 386 |
+
numba/cuda/tests/cudapy/test_vectorize_scalar_arg.py,sha256=Ivl3RtFjwKJRHAxaFD8Xby5PxjK-mmkxbFXHUHYipNA,937
|
| 387 |
+
numba/cuda/tests/cudapy/test_warning.py,sha256=Bpcj9-pehYW20vn4KY98pADQd5A0gzDUuUk2y48HzyM,4265
|
| 388 |
+
numba/cuda/tests/cudapy/test_warp_ops.py,sha256=OGGXn4beVIjjIB5akR2keyY7gQFaMAxM_AoZNN_I3Bk,9042
|
| 389 |
+
numba/cuda/tests/cudasim/__init__.py,sha256=B1ma2w-Eyk_ooILO3PPxb2K5HMyZY8WZhikDIBATzQQ,154
|
| 390 |
+
numba/cuda/tests/cudasim/support.py,sha256=JjRrfrrLKS0V5p6GX6ibs6QTuFb1NanKfBQSgbLeiHs,114
|
| 391 |
+
numba/cuda/tests/cudasim/test_cudasim_issues.py,sha256=IsjJlxq6LMMDh_1kiO9LefXkOX_Hc1bxeSwXZdB59yU,3179
|
| 392 |
+
numba/cuda/tests/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 393 |
+
numba/cuda/tests/data/cuda_include.cu,sha256=1wj5Of86-kP0hxK5Gr6AhapuyTiiWWJAoFbCuCpyKfA,294
|
| 394 |
+
numba/cuda/tests/data/error.cu,sha256=5m65RDHgh39d0bIW6Dvj0xh9ffhKH1iILeCCR4p2ReI,138
|
| 395 |
+
numba/cuda/tests/data/jitlink.cu,sha256=ne8LLu7RHgbw2lAyJGrVlJHJ08kxUuOLBD9pH-cNxFU,541
|
| 396 |
+
numba/cuda/tests/data/jitlink.ptx,sha256=fBPV1l6krgtGfHasRfaL708M05eNszjAQG33z-NtvUg,896
|
| 397 |
+
numba/cuda/tests/data/warn.cu,sha256=6L-qsXJIxAr_n3hVMAz_EZ5j0skcJAfgzuJfDEISG_I,172
|
| 398 |
+
numba/cuda/tests/doc_examples/__init__.py,sha256=B1ma2w-Eyk_ooILO3PPxb2K5HMyZY8WZhikDIBATzQQ,154
|
| 399 |
+
numba/cuda/tests/doc_examples/ffi/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 400 |
+
numba/cuda/tests/doc_examples/ffi/functions.cu,sha256=mRZEyCfZbq4ACTN3sj1236XmTpj1d0IxZ4QTMbI3g_E,877
|
| 401 |
+
numba/cuda/tests/doc_examples/test_cg.py,sha256=9UQAez1jp3vQ0BIfoRCnGJGP17nznNcon-XFR4grqzQ,2905
|
| 402 |
+
numba/cuda/tests/doc_examples/test_cpu_gpu_compat.py,sha256=DRzvoE2iCaISJb2lkshBkJyYBEfdpqZLRXG_N9XRaFk,2305
|
| 403 |
+
numba/cuda/tests/doc_examples/test_ffi.py,sha256=RgZO7xYkJIlSIuJK4k3_APEJAekjkKy5wKOMFdfRoAM,2654
|
| 404 |
+
numba/cuda/tests/doc_examples/test_laplace.py,sha256=UH15R0DbMA4iHLmoZ0GtcttGCNctOUif-u2448JMmRo,5177
|
| 405 |
+
numba/cuda/tests/doc_examples/test_matmul.py,sha256=hS-X_T7x3-BcBanazmnmGxJE_o1A9b9f_VGk0YlJP4o,6135
|
| 406 |
+
numba/cuda/tests/doc_examples/test_montecarlo.py,sha256=_0snszis_UE7LxU5lw9ReNF19Dh5iV0yRy18mUWNd1c,3491
|
| 407 |
+
numba/cuda/tests/doc_examples/test_random.py,sha256=VTgzB55bfjeNQHKg9MINnKa70KNYzxpTOktKwYNYUkc,2192
|
| 408 |
+
numba/cuda/tests/doc_examples/test_reduction.py,sha256=9d40rXxrqvWSkI8r0lMJ42LgU98dVF3Aeon6RAqUIik,2274
|
| 409 |
+
numba/cuda/tests/doc_examples/test_sessionize.py,sha256=kNep6Y7q1WJ9dLeoMYuk9NBKTGLsIJwNiW-um86BOoc,4334
|
| 410 |
+
numba/cuda/tests/doc_examples/test_ufunc.py,sha256=UXwXjL9ybg0OuYOFKnHZk75bMjRMRzrp_xfxAdMR198,1418
|
| 411 |
+
numba/cuda/tests/doc_examples/test_vecadd.py,sha256=0RMJv3iXf9OlAMCF4aIB4Pyp4AnoKUuqC_tY-yNQGbI,2043
|
| 412 |
+
numba/cuda/tests/nocuda/__init__.py,sha256=KeAvH3QOb-KXXkFtzwvYkQp2ZrQmzgfKDkBCVIOKXXE,257
|
| 413 |
+
numba/cuda/tests/nocuda/test_dummyarray.py,sha256=hpdNlYhZLKrrN3TF4i65djpOlcPpEkTG1MX8385Qov0,13567
|
| 414 |
+
numba/cuda/tests/nocuda/test_function_resolution.py,sha256=o4DYocyHK7KVPil6LQI2jzZ2xSWop8bLZYGtV067CSs,1425
|
| 415 |
+
numba/cuda/tests/nocuda/test_import.py,sha256=teiL8rpFGQOh41kyBSSNHHFYAJYgpdStXkTcpK4_fxo,1641
|
| 416 |
+
numba/cuda/tests/nocuda/test_library_lookup.py,sha256=7kJOPHEcrjy_kTA9Ym-iT_B972bgFRu3UkRtwIgWtuI,7948
|
| 417 |
+
numba/cuda/tests/nocuda/test_nvvm.py,sha256=n0_-xFaw6QqiZbhe55oy7lnEeOwqTvA55p5EUFiTpNw,2006
|
| 418 |
+
numba/cuda/types.py,sha256=WVfjcly_VUpG9FfKueiEPzZm2NV8Hg0XAFg3bNzPdVc,1314
|
| 419 |
+
numba/cuda/ufuncs.py,sha256=4ZhGEF9VXN4o61h7kbly6DdiQeDADGet9L13fipK4QQ,23325
|
| 420 |
+
numba/cuda/vector_types.py,sha256=s18dY0IUpT-RcaBvQsa_zEbYuuL2IT0Vh6afCeccwmQ,6750
|
| 421 |
+
numba/cuda/vectorizers.py,sha256=u_0EzaD5tqVH8uOz4Gmqn3FgPC1rckwDAQuROm0BXm8,8915
|
| 422 |
+
numba/experimental/__init__.py,sha256=RBZ2sMQEP7NKSKqucS8ij-dOOZrmHiWM_qVLVP1pPe0,30
|
| 423 |
+
numba/experimental/function_type.py,sha256=KH0BteKy-Oo8hpGutWX1ujbD7Nz9ILp3Bw9cI96vt7k,12475
|
| 424 |
+
numba/experimental/jitclass/__init__.py,sha256=3Emu3qLxfO6zhqsLfzRu12vATnGwqLYERSV_jRW9g9k,219
|
| 425 |
+
numba/experimental/jitclass/_box.cpython-311-x86_64-linux-gnu.so,sha256=ty2CBPpjp4PnwT5bibwvF_Qx15Bs0LlY6iiLtrfcLbk,31440
|
| 426 |
+
numba/experimental/jitclass/base.py,sha256=hBZsyLuCphoM8NCyYSVXy0hxYRGU1LHt1rBHQe9G6mg,21359
|
| 427 |
+
numba/experimental/jitclass/boxing.py,sha256=CTJzaHvBBFiinKJp2HZsKT0FWJ8Qf5LaU_ddP0dpCwc,8296
|
| 428 |
+
numba/experimental/jitclass/decorators.py,sha256=y_Y-ugNa6jnmIX1fhLpadlu702857iRUb2tYhS3Ke3w,2404
|
| 429 |
+
numba/experimental/jitclass/overloads.py,sha256=7WDafDbobDXd96BdHovNvWf_CwZQ5CEbPA29efPGw38,7316
|
| 430 |
+
numba/experimental/structref.py,sha256=suhR0qtsIFLn8i_4fzxK6JXDrx6UYCUMRiH8BPuYv44,12075
|
| 431 |
+
numba/extending.py,sha256=dkGJPNMggy7xd1NRV1ws6teIK7Ze2lTFvpAz7Cw5drI,133
|
| 432 |
+
numba/mathnames.h,sha256=pNbqCU38izsPBn6EaZDfT_HURKIaEkmpm2STVyFtaEs,1774
|
| 433 |
+
numba/misc/POST.py,sha256=JrY0ygk5v272TXHpqQNnDKIX2FJK04pDAkmdtAVaWEc,811
|
| 434 |
+
numba/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 435 |
+
numba/misc/appdirs.py,sha256=zyXqBFfj1ERckcERX_G9d3AAGciKuB06Aj5_mnyGrTQ,22388
|
| 436 |
+
numba/misc/cffiimpl.py,sha256=5ubOeU-F0MNi2aQ5Y44AxcYvegLjPW-w3Zs8hfPhW-g,615
|
| 437 |
+
numba/misc/cmdlang.gdb,sha256=hX5t_27IhOlfgGAwV3aVPyZ8v1m7hedd6myQbE8mMB8,101
|
| 438 |
+
numba/misc/coverage_support.py,sha256=ARjlTO6wBlitMKrdojbj5inX0nozPlskiubxJ-eQKZw,6236
|
| 439 |
+
numba/misc/dump_style.py,sha256=TTQm7BmBzLT9VRuWRjpYkGqg_lXwtoAvEbcK5wIC-XQ,2265
|
| 440 |
+
numba/misc/findlib.py,sha256=r7bP2GeCTXsGHa5bWKNKsVCvqDrarMlvORqWmJoeOHg,1848
|
| 441 |
+
numba/misc/firstlinefinder.py,sha256=1pTWZIV54RlZu4BGuGAoyx7Z9Qq83cIBJ-qv4ETEmKk,3253
|
| 442 |
+
numba/misc/gdb_hook.py,sha256=qX-ZHzj3Id1eGW5eQpXALeGZD8Cj2cZyfCqdoixd8K4,8567
|
| 443 |
+
numba/misc/gdb_print_extension.py,sha256=RcKxCFhzbwr7TrZsX6DZGjJkEaNzoZn19W9vCktG4-o,7728
|
| 444 |
+
numba/misc/help/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 445 |
+
numba/misc/help/inspector.py,sha256=9tgx8tKuYEffMWTjnayD7NJbwaxcu7q7aDYKSh6AdFU,12903
|
| 446 |
+
numba/misc/init_utils.py,sha256=2vEcU37csAn4Ogoi6eyCEyNiUnEf4P-9PLcFvkk6xRI,1242
|
| 447 |
+
numba/misc/inspection.py,sha256=SSHPt4V-CphtwEIEbOFhjYURe1hHvX8a_FDpMyq-P7A,4499
|
| 448 |
+
numba/misc/literal.py,sha256=AQnd2XF5fJYnR8BuOCRcoCt97-U3APuEGViyZTie3VQ,705
|
| 449 |
+
numba/misc/llvm_pass_timings.py,sha256=IRArf2xGeIYG6Q1ffIuL84RIIeN22oTFwAmuoPiV25k,13362
|
| 450 |
+
numba/misc/memoryutils.py,sha256=V9t7kXxYPuyG_siD2CTfqqvB2naRxtK59S1m0oAW9pc,5930
|
| 451 |
+
numba/misc/mergesort.py,sha256=H4XyN8Lmw4NBZ3m_UEltHK7T5ZADc3fbok2KwOKATm8,3548
|
| 452 |
+
numba/misc/numba_entry.py,sha256=OTSqI4hYcr91ZXyNmbJmbQG6hMEQgTGZ-no6McXz4o4,2618
|
| 453 |
+
numba/misc/numba_gdbinfo.py,sha256=Dunek2AGTgxNZFQnlsEFHzjc0806J8Abz2eTTj0TZEI,5962
|
| 454 |
+
numba/misc/numba_sysinfo.py,sha256=T4HAI5A-Fg895zPYK40RVWf2M8OxrK9aKMXHzkDye04,27299
|
| 455 |
+
numba/misc/quicksort.py,sha256=qqxWmkcu5bez0x7jzYeqGMGnOS-56zEi7XDFYw0BtFc,7647
|
| 456 |
+
numba/misc/special.py,sha256=eEIAB_07X8EO7BkrQVz2Z374kjHLIXe75JFnx2j0uqs,3320
|
| 457 |
+
numba/misc/timsort.py,sha256=tSAqreRk39eRy7FD6GRCGLIpUhG-BgVygXphkxtcJiw,33503
|
| 458 |
+
numba/mviewbuf.c,sha256=iotlLmyPwyGVpAje19FbADsot8B3C9Q0UEZBItkUWiE,11950
|
| 459 |
+
numba/mviewbuf.cpython-311-x86_64-linux-gnu.so,sha256=OrDX4MUjzPy6Mc3tLGc_3TLojjsu5rEqFLrJFVx1p0Q,43704
|
| 460 |
+
numba/np/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 461 |
+
numba/np/arraymath.py,sha256=VKC2Nk-vORLxEE_3ZONh8Kwen_dtn_exLJnalL0QqJ8,158266
|
| 462 |
+
numba/np/arrayobj.py,sha256=-oqcaExA2wtdrcsy3KT8NieHBylFA7ZphUK9iUkCWN0,270005
|
| 463 |
+
numba/np/extensions.py,sha256=YEN2b5udrIy4uhHrp7Os6FEW_h4lv-dp4aRB2Z8Irhg,96
|
| 464 |
+
numba/np/linalg.py,sha256=LDqgdAcLosNDG8NCLBOFU9giFjZJo3-oyFmf99M3nUM,91872
|
| 465 |
+
numba/np/math/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 466 |
+
numba/np/math/cmathimpl.py,sha256=RZwO6pYJjgX7d4kTmymDgXIECfJzZ_oW8xG-nmDo5xY,17628
|
| 467 |
+
numba/np/math/mathimpl.py,sha256=aSqVdtQ91NRk6GZ_wiRtOpiXwsu4S4EEtaEcs6dJ0Yw,15556
|
| 468 |
+
numba/np/math/numbers.py,sha256=XrzM_xxyKkidhRYDRAdXrV0yaRT7dY208NbXx5_uLks,50276
|
| 469 |
+
numba/np/npdatetime.py,sha256=PVVbhaWWi8TbacrwqgLln5-qxdoN_ngONIk6Nq9VBRI,34541
|
| 470 |
+
numba/np/npdatetime_helpers.py,sha256=JPUTOYJ9Eg-3H4K3oLp2q0lLXKZcML3fBpG7WwJ3l8g,6649
|
| 471 |
+
numba/np/npyfuncs.py,sha256=POdhp5joCsHUA7_8yeMs0AHPjHkqqnR2UvVcP0rmZhI,63021
|
| 472 |
+
numba/np/npyimpl.py,sha256=4Y_uMWxp9d77QjWOokRO5LI2XNWI-lfSkh4wBjlBG2Q,36870
|
| 473 |
+
numba/np/numpy_support.py,sha256=2IZYGQ4sR4UqnPxNtOMw7KHlf0N2ro1GdHsuUffo3r4,26900
|
| 474 |
+
numba/np/polynomial/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 475 |
+
numba/np/polynomial/polynomial_core.py,sha256=t_4zkvCCjPQis9q9oq-6ja-eaafnE2eIbUJBRNGU8kw,9003
|
| 476 |
+
numba/np/polynomial/polynomial_functions.py,sha256=jH4uH46RBg2NJ6t_sAUwEwvrHcVrLxMdln_xsJLr-P8,10765
|
| 477 |
+
numba/np/random/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 478 |
+
numba/np/random/_constants.py,sha256=lbWbj6z1gzNQMZV-BUIcmLeYlzTl-YytJUeorQtaU-c,72630
|
| 479 |
+
numba/np/random/distributions.py,sha256=MxdSHYVvaoAFWgSJeMma-AHazvqfLJmuCcHvx2CnsnA,20906
|
| 480 |
+
numba/np/random/generator_core.py,sha256=BdY061VuV20S0ppJGYSR-s-L13UhJEdvtKxbIRKLFeE,4158
|
| 481 |
+
numba/np/random/generator_methods.py,sha256=MsZifo13zLPcipABAdlabQxQQUdNS2OySkZJmEzhNWE,34316
|
| 482 |
+
numba/np/random/random_methods.py,sha256=H18TXrqkFTqnLOrAHo_y-KUcM_iETWHDpczdLEs0_e0,10210
|
| 483 |
+
numba/np/types/__init__.py,sha256=TtFvAXPp2KZFsXnYqdcfZnIWztil_3qbXrqv4nww1ok,46
|
| 484 |
+
numba/np/types/datetime.py,sha256=Kx9Cuq_4z1XOK7oyKbCuib4JDC5hlpkjbSoiLnmYhp4,11068
|
| 485 |
+
numba/np/types/datetime_registry.py,sha256=PyA6YM5SfKnYhux2PAW_WzQGIauy8_a5VkwBbuxmtWs,2536
|
| 486 |
+
numba/np/ufunc/__init__.py,sha256=TUc7_N8172fYX5n0ZxnUn-LEbaL88rZBHmqPu_OdCdU,1070
|
| 487 |
+
numba/np/ufunc/_internal.cpython-311-x86_64-linux-gnu.so,sha256=8eU9oAhh25gexW1KbydEuJY9Wf_SJ4nvgyFSbmJfM3Q,92584
|
| 488 |
+
numba/np/ufunc/_num_threads.cpython-311-x86_64-linux-gnu.so,sha256=OD55FMptWDG2bfTKmauHcrHo7ne5iIGgwp0O7sl7X-o,26408
|
| 489 |
+
numba/np/ufunc/array_exprs.py,sha256=pJbWr9S8zCpkZPXFRJIpnjf-FKe3QfYeTB6vyZIyTrg,16878
|
| 490 |
+
numba/np/ufunc/decorators.py,sha256=_J7b_05KDBPBnyFvEcL-ys5WGSkUPfml0oIdCAnC-IA,6107
|
| 491 |
+
numba/np/ufunc/dufunc.py,sha256=8CnYG-CC0Yyq-a727Dq6Nx2aD3rx_nulDFiUfL0sC8A,40648
|
| 492 |
+
numba/np/ufunc/dufunc.pyi,sha256=fi4sgFFDaYtPn6votyj4_JxrYief04KehtFTcD9UIGw,4213
|
| 493 |
+
numba/np/ufunc/gufunc.py,sha256=lqtm8KbVNisO93gvuBXGOrsXpF2mxq0zf5dIG9rOf4Y,12794
|
| 494 |
+
numba/np/ufunc/gufunc.pyi,sha256=zlgZXtYVqRvaf-WIGXkDWCRkk8TNwotXbjHhdE0hj-8,3476
|
| 495 |
+
numba/np/ufunc/omppool.cpython-311-x86_64-linux-gnu.so,sha256=WXMQ1TlHheQ6nzc4dYy7Z-CMNQ6XShh86taRHw2qsRU,600089
|
| 496 |
+
numba/np/ufunc/parallel.py,sha256=gBZrwbkbjrOb4UeiIWoS6hkTBBLXhBdbmnyweOCynUM,26279
|
| 497 |
+
numba/np/ufunc/sigparse.py,sha256=r9068xH89U-U-sU9nL4e8JGhAuMGQv8op8ucremc8AA,1846
|
| 498 |
+
numba/np/ufunc/tbbpool.cpython-311-x86_64-linux-gnu.so,sha256=BgZDuTyyvKet3GDga24pMZWjBNeMEDPZLtdFL8h-ym0,1054537
|
| 499 |
+
numba/np/ufunc/ufunc_base.py,sha256=LhdG5z2lvspsCIadAP7IS8h706uzWjQBuyNtJcyY4Nw,3335
|
| 500 |
+
numba/np/ufunc/ufunc_base.pyi,sha256=QMDYTxe8FZSPz0DToKVGyQ1U-zj_aUkWBEcFX_lVbdE,5009
|
| 501 |
+
numba/np/ufunc/ufuncbuilder.py,sha256=BxGF-sR6K-pSk5J14AzjYHvz22HrHWn_rfaKQS2AIn0,14610
|
| 502 |
+
numba/np/ufunc/workqueue.cpython-311-x86_64-linux-gnu.so,sha256=ibcgZOdOVU7SS1sNiwZoB-iwxk5PBncMdA01WfhITFY,604632
|
| 503 |
+
numba/np/ufunc/wrappers.py,sha256=CdWTlT1USqb-tw_3tAj_CRC0VWv4tIyeDJr3n2Cq6DQ,27203
|
| 504 |
+
numba/np/ufunc_db.py,sha256=OTgMbz79rRzmRkZZ7US5-bcZ5NxZ3dKoiv9msxGUs8c,42510
|
| 505 |
+
numba/np/unsafe/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 506 |
+
numba/np/unsafe/ndarray.py,sha256=dzc0UlE86z_idhAN73eDs9A21rF4v6BkOpmEHbFYlsU,2704
|
| 507 |
+
numba/parfors/__init__.py,sha256=YXMWaFldoQqHT12hNUQyS7nd7Zg85htjssj1UopkA-o,42
|
| 508 |
+
numba/parfors/array_analysis.py,sha256=4k6K-fDMVFEhqEw0R71gbHoNhBsG00J6RReUjCm5JIg,124117
|
| 509 |
+
numba/parfors/ir_utils.py,sha256=zR5sDinvARVsMcmTPgJMW-vcCG8jD5p5ZKBvHYa-YDo,5446
|
| 510 |
+
numba/parfors/parfor.py,sha256=dlCYJAzXdJGDTsT0_1K1tVZCepGoRlEpGkUHME9Q9N8,228208
|
| 511 |
+
numba/parfors/parfor_lowering.py,sha256=0RmFmxl5uN7Lx76wrFNJ2Qyt41suWT3Hqef063sixoE,87652
|
| 512 |
+
numba/parfors/parfor_lowering_utils.py,sha256=e2ZuU0MX2PGL_bKg_DOXsVzl0kcqjdrqh5A2AKJIO1U,5638
|
| 513 |
+
numba/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 514 |
+
numba/pycc/__init__.py,sha256=TzLOywD1B2CPTXQ1c_mzyPOSQTY5C3-JR_VfNZMG4ts,1220
|
| 515 |
+
numba/pycc/cc.py,sha256=xZnsrVcSa9My6R6zZEuTU0KdXknD32AJ67M2Qt-ckhE,10626
|
| 516 |
+
numba/pycc/compiler.py,sha256=tPlNRKcVViCAs_6vBR-GmxkVuioCxPH1tbbEPL3-Dxo,19458
|
| 517 |
+
numba/pycc/decorators.py,sha256=n4WakJj9iRYkdrRFoLLohE4ibhuNhy6TDQ8I3LMwvuM,1884
|
| 518 |
+
numba/pycc/llvm_types.py,sha256=n0obSYyFc7h356LmVqGhwFMKH4NpXIXF5BxztoU240o,1239
|
| 519 |
+
numba/pycc/modulemixin.c,sha256=dxTyYa9IgaANDRM4V7i0qcaRR-wdN6yM6Y6qhcZafQQ,5984
|
| 520 |
+
numba/pycc/platform.py,sha256=b-FBpRGkI7qaZ2WdHZ1qs10NnXfkyitMp3Sq0onKI5o,7431
|
| 521 |
+
numba/pythoncapi_compat.h,sha256=wB8PCPCqYqpYR3YIdArroyYJ3WsEc5GhG1xKAp0DSZo,45414
|
| 522 |
+
numba/runtests.py,sha256=xv1W8XbzPewB_X32KXFugsmwt3lZL7lfKfryaC7N7KY,237
|
| 523 |
+
numba/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 524 |
+
numba/scripts/generate_lower_listing.py,sha256=WCaoIzn_LmFHS-pYTW6vdKufcnXl1e41-_XsV1mxnm8,5165
|
| 525 |
+
numba/stencils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 526 |
+
numba/stencils/stencil.py,sha256=FTJs2phQeT91x0mxMU4DGbdFKkIEWAlTPCgHQbxik4g,39893
|
| 527 |
+
numba/stencils/stencilparfor.py,sha256=Ar6Ge9UT25ybCsMnE8R40vDpHufK8zhzKVRW3YwA2vA,44974
|
| 528 |
+
numba/testing/__init__.py,sha256=QL904urGyqVF5OOfyq1uLnAn-uhgRcbboaQlj2obaMU,1976
|
| 529 |
+
numba/testing/__main__.py,sha256=MJrAbExox9UHv1UnMDx0f6JG_oA43cvhzHQoTOSl7IY,106
|
| 530 |
+
numba/testing/_runtests.py,sha256=V7XJTU_iTftXIu3Rv8FqQd_ECjCXG6B4vDdujOizMfI,3727
|
| 531 |
+
numba/testing/loader.py,sha256=pQdHO6VLZo0Lzbju4g0dptXGc64IJlbguzym0w006fM,1113
|
| 532 |
+
numba/testing/main.py,sha256=f65R_FQPBHTBOdLrficGN76ZVrwZ_xE196pkQbNDLPA,31576
|
| 533 |
+
numba/testing/notebook.py,sha256=zuBfj8QHXFkNvV2oyz23gjFZe1Ixt7OFAMtgjCSqm-Y,5501
|
| 534 |
+
numba/tests/__init__.py,sha256=h3tyMOp0uUiirVDAOEY3Cymim51mHA77xTpwATXeu0w,829
|
| 535 |
+
numba/tests/annotation_usecases.py,sha256=0O7hw4-dVfAQ2mUoSLbjWYakSNzcv6B6nyBJCRPajdo,316
|
| 536 |
+
numba/tests/cache_usecases.py,sha256=bFw9cZVyvN9GQTdg_Ci4U0wF_8DLAKBwf5tXh95kTQQ,3566
|
| 537 |
+
numba/tests/cffi_usecases.py,sha256=xGpQl4X7akIxuqMOjx6mxt9tXVbIhVhHe0B6nmaF9tM,4927
|
| 538 |
+
numba/tests/cfunc_cache_usecases.py,sha256=XqWmWzZZy2Oztz3iTiig1TsJ6fpZaZyB6B99ThHZYKM,1608
|
| 539 |
+
numba/tests/chained_assign_usecases.py,sha256=KjBf_w7zeb-OPAYsNzJImekuRzLyj0EcMqJ8TZys9rU,1045
|
| 540 |
+
numba/tests/cloudpickle_main_class.py,sha256=GzSO01WRCCrXYlp8HShxryKJTwUvcAImg9F68WuLnc0,155
|
| 541 |
+
numba/tests/compile_with_pycc.py,sha256=u69eNm_xG3DfmWO1FVaGIAdOdtBAxXZ_Dn1gpTOfsnM,3282
|
| 542 |
+
numba/tests/complex_usecases.py,sha256=xlbm0rUg5prZV4qIUsekCRFjJCpIGBhLpgABnefor2U,1515
|
| 543 |
+
numba/tests/ctypes_usecases.py,sha256=lOXJpgWXqBG0AJ7IguSW-zuyA6iovRqIH67drTQj4Gg,2425
|
| 544 |
+
numba/tests/doc_examples/__init__.py,sha256=AQs2XphXAaU5K8g8XL27zyLP1L3VOYH1AP1aCg1uf48,267
|
| 545 |
+
numba/tests/doc_examples/test_examples.py,sha256=vGS3EIVT2p4LzK5MVbQrLhN4AzGFkR0UH0h8Ro3PsJA,23610
|
| 546 |
+
numba/tests/doc_examples/test_interval_example.py,sha256=FhXF9YCYOiWilLYzjlEzI1NB_aDcebTb84_8IBAGZ1w,8867
|
| 547 |
+
numba/tests/doc_examples/test_jitclass.py,sha256=hEKPXpD_3JmNAGPC3fhz6GHxofYRtM8ZwM2ZLJEigSA,3057
|
| 548 |
+
numba/tests/doc_examples/test_literal_container_usage.py,sha256=BKapYbcT80Kwe_QYDVTb89sGIi-hQ-r0x0q8mwlqfUQ,5762
|
| 549 |
+
numba/tests/doc_examples/test_literally_usage.py,sha256=9LK3Tw3gW1bhpqOd2IlscVXf4q0S7esdo2fcC6Kb9eQ,1878
|
| 550 |
+
numba/tests/doc_examples/test_llvm_pass_timings.py,sha256=aolHZB8rDoUUGlYzmWhcmJR9Y9mU9d5mRNZ6SBCVFGk,953
|
| 551 |
+
numba/tests/doc_examples/test_numpy_generators.py,sha256=CDWKZS7CpJy5Z_inqu6LLPDVpnhWouIWhk7w4-M1wMM,1099
|
| 552 |
+
numba/tests/doc_examples/test_parallel_chunksize.py,sha256=pKI38Udgb58Uaf37vsVASo6WEr8l10I4bI0AM_0ZwRs,4176
|
| 553 |
+
numba/tests/doc_examples/test_rec_array.py,sha256=fhCOCXYunEcO2D2ieOs6W2Iqe28vCDfi8avyuBuSF2M,1313
|
| 554 |
+
numba/tests/doc_examples/test_structref_usage.py,sha256=hbBFmHR2s6oD3KK4yqF5Bn17iIoGzIObQ1Q7jiJ6iYQ,4852
|
| 555 |
+
numba/tests/doc_examples/test_typed_dict_usage.py,sha256=XCrsqc6dZUX2-90UZwniAVL5Qqj-_dkqCS6IVX6Rdk0,4051
|
| 556 |
+
numba/tests/doc_examples/test_typed_list_usage.py,sha256=x9XKxjziN8dMxPsjMzvQwvAI0hT7_cuUvVM_JLgn76M,2941
|
| 557 |
+
numba/tests/doc_examples/test_typed_set_usage.py,sha256=4eQJcZQt_5afKtl8HjkjEYc6NF3QhD6g60UbUyA4QWI,1352
|
| 558 |
+
numba/tests/doctest_usecase.py,sha256=i7DEqCXsEPt3XxRAk6tzMTJnHbdAJGpxPwCCXTuInjQ,484
|
| 559 |
+
numba/tests/dummy_module.py,sha256=HnzviWYvQx54SYXKY--jg7JgDDNVwSyawn1yWkyISUM,57
|
| 560 |
+
numba/tests/enum_usecases.py,sha256=rGVSwqi8zpbjsLoPdUO-vooLjL8PbNdOZcvG7ey_pZs,1018
|
| 561 |
+
numba/tests/error_usecases.py,sha256=Bf8ZmO68Vw3T2KU0pzxlmx1L8OoqYMK2IJxNsnXxcWQ,79
|
| 562 |
+
numba/tests/errorhandling_usecases.py,sha256=Ds-kMSAGf6SywK1xTyMPoXl1vwlDtIRtmchnAwluHDo,284
|
| 563 |
+
numba/tests/gdb/__init__.py,sha256=AQs2XphXAaU5K8g8XL27zyLP1L3VOYH1AP1aCg1uf48,267
|
| 564 |
+
numba/tests/gdb/test_array_arg.py,sha256=VlK8wthLszkVlo6WorHxfFO-skKhHteavYOagHedCCE,1723
|
| 565 |
+
numba/tests/gdb/test_basic.py,sha256=ttVJkT_1ZbTdAkRCN1mHq4jHt6rL_Q60At9FUfLMinQ,1162
|
| 566 |
+
numba/tests/gdb/test_break_on_symbol.py,sha256=ArsXuGi-1Zw2cLQ0TH3pQlHH-tpvEsj9FEhNBJ8WD7Y,976
|
| 567 |
+
numba/tests/gdb/test_break_on_symbol_version.py,sha256=uSK3IvYXac0RMqpqD-IAsUEzHx1Z0livBTKZjxH_dCQ,1940
|
| 568 |
+
numba/tests/gdb/test_conditional_breakpoint.py,sha256=hvzxre17KzBE9bN-NcNLg3Eg37MYk2XUgGhmDfIRD9w,1224
|
| 569 |
+
numba/tests/gdb/test_pretty_print.py,sha256=cb4bPcYpoOr_2n9CHHxiDTzpsx1I0ZB1f9CeT3oEi74,2416
|
| 570 |
+
numba/tests/gdb_support.py,sha256=geLjuf9hcrZonEuhKz3YkJo4s5Kui7O0lEj1q7HjpCc,7439
|
| 571 |
+
numba/tests/inlining_usecases.py,sha256=oC8Y29RUNdqSR0nWmEZ3JC0JeaRXCbP3wE45TauiiH4,1019
|
| 572 |
+
numba/tests/matmul_usecase.py,sha256=97UclzEySdrOuvhWLcWSvpqro5WXRMGgomZIA6M3Qdc,552
|
| 573 |
+
numba/tests/npyufunc/__init__.py,sha256=AQs2XphXAaU5K8g8XL27zyLP1L3VOYH1AP1aCg1uf48,267
|
| 574 |
+
numba/tests/npyufunc/cache_usecases.py,sha256=-XasSXNW7ewG8-HLpDj8yZThQOg38455UtWDuMfDGaE,1488
|
| 575 |
+
numba/tests/npyufunc/test_caching.py,sha256=ZFL7l3K4ma3RIOHfZTScN30NfUNhk0FeykIMKfOIScE,8569
|
| 576 |
+
numba/tests/npyufunc/test_dufunc.py,sha256=RTfcbii7yki85orvcLuRRGgC4q4po6dN8-rfkmPSVqI,42112
|
| 577 |
+
numba/tests/npyufunc/test_errors.py,sha256=zaR-AvH0tF2Ep1yFxR75cJkfcApmWBMFHRST_qD8o04,5497
|
| 578 |
+
numba/tests/npyufunc/test_gufunc.py,sha256=uFgE5JeeB_I-X6y7wxfG8xjHAn_yzQa-wJAfESyQFsM,29309
|
| 579 |
+
numba/tests/npyufunc/test_parallel_env_variable.py,sha256=NMlVyeMdSoFV3oBXxoR8VHeayPGDLMaNrgGG588MpBA,1264
|
| 580 |
+
numba/tests/npyufunc/test_parallel_low_work.py,sha256=BPeAxpfoZu9H2S880AeVAtWlIKO9FM9DryWG6niFeYY,1056
|
| 581 |
+
numba/tests/npyufunc/test_parallel_ufunc_issues.py,sha256=al2DaPWlIKXl8pI5SNJaBR7qIGnDuPAPnGsGMxUbF4g,4387
|
| 582 |
+
numba/tests/npyufunc/test_ufunc.py,sha256=oaiPMmJubzPAYDNNhu3fDwkSaGK6Atyhs8HO2qN0Cjs,5219
|
| 583 |
+
numba/tests/npyufunc/test_ufuncbuilding.py,sha256=B3BkVrm9svA58wXiJey-FUXD1Z8HBkNd9wf9stGxeqs,16809
|
| 584 |
+
numba/tests/npyufunc/test_update_inplace.py,sha256=sr748I5uqoaWhW1YNrG4j2ScagmUM1Lrq7NWZgTuj4o,5078
|
| 585 |
+
numba/tests/npyufunc/test_vectorize_decor.py,sha256=Z7NS7QmTt0CmCZbOsI-e4K_ujz6EmgvAIdqn1mZ4eAk,4504
|
| 586 |
+
numba/tests/npyufunc/ufuncbuilding_usecases.py,sha256=CM-gB-XcZqb-CKUqhEt0NiK-9slc_yUstDlYyzibaqw,1061
|
| 587 |
+
numba/tests/orphaned_semaphore_usecase.py,sha256=Lwc2zeGSfc3In51ROGkwGE7fyLeZoIwfz9_1vb5yC9Y,592
|
| 588 |
+
numba/tests/overload_usecases.py,sha256=ySd2qYfd7CYCnzbG5NJHyEvtZCTCFySM6fixrQrbWR0,582
|
| 589 |
+
numba/tests/parfor_iss9490_usecase.py,sha256=aNDICFHJvtXpKEMYcI9STPuCYuVLm7lP-OY4s75P4kM,2640
|
| 590 |
+
numba/tests/parfors_cache_usecases.py,sha256=rj-UN7QzYamC-xAYEVRihggNCyTFEpFK0ZzktUqVxxc,1778
|
| 591 |
+
numba/tests/pdlike_usecase.py,sha256=eDi-ks_pldk6qbYMRsLTDFhnCe7-fRA3g41PJGPpYNU,8780
|
| 592 |
+
numba/tests/pycc_distutils_usecase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 593 |
+
numba/tests/pycc_distutils_usecase/nested/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
| 594 |
+
numba/tests/pycc_distutils_usecase/nested/source_module.py,sha256=SXWOoaRIkoBpDt-8Djmy5Tj7aOUCQ-DMAFgMnrgB5wI,328
|
| 595 |
+
numba/tests/pycc_distutils_usecase/setup_distutils.py,sha256=uO6Qiv98Wqw_DUSup-GvyNsTVD2u-N6YOgijFIzEuZQ,207
|
| 596 |
+
numba/tests/pycc_distutils_usecase/setup_distutils_nested.py,sha256=d-HOlctJ8Mz0iF1eGfVfPgf5PC9YQtBx4SIi5BVVyj8,215
|
| 597 |
+
numba/tests/pycc_distutils_usecase/setup_setuptools.py,sha256=19kQpIjGjT-0AcYfONCTHb33JyC7lkv-IrVBSYkWkA8,173
|
| 598 |
+
numba/tests/pycc_distutils_usecase/setup_setuptools_nested.py,sha256=zWLMLRjwyBO3p-51165Qpw29fUlc4hvLWi_wBPFoIXU,180
|
| 599 |
+
numba/tests/pycc_distutils_usecase/source_module.py,sha256=XdiOyXf33sIsFquozugu4-qVkNK8uDyap2M6cR3FhzM,326
|
| 600 |
+
numba/tests/recursion_usecases.py,sha256=NIkXj_bUe2MUjK5lSlDAszG7Th3llrLWtdOv3c1AMrU,4133
|
| 601 |
+
numba/tests/serialize_usecases.py,sha256=RfKx44jFPUvfEjaumYOj3XKHeOcBKCaP6hIkV-t1gqM,1982
|
| 602 |
+
numba/tests/support.py,sha256=-2YBSv6_OIOyEFyo_HXFrwLRgMwRgmbWtT02vXvhM_Y,46877
|
| 603 |
+
numba/tests/test_alignment.py,sha256=y0vaLiqkDWaUwL10r3o3yx65OgpHVQ9FbFITSvhgC1k,1086
|
| 604 |
+
numba/tests/test_analysis.py,sha256=DDaebrUZ9IVS259ffD0a0cahcFBix7OiSKZCG_th7h8,37230
|
| 605 |
+
numba/tests/test_annotations.py,sha256=LATeDSyu9gYwo-3jYnVDSKerPEPu_RSoe9X6NbnhyQ8,7540
|
| 606 |
+
numba/tests/test_api.py,sha256=kAPv2qeCKuCmYnnYIcNmhbUU_Q00EczpTN1lqoLP-lo,2614
|
| 607 |
+
numba/tests/test_array_analysis.py,sha256=PXM-yIR9eKYuHluywQ9-zqTfQoBoFDmAXcczCJicNc0,42608
|
| 608 |
+
numba/tests/test_array_attr.py,sha256=2IU2RrTn95804oOMlZpDYs-W66uPOIZj3XXIgZSyy9U,11675
|
| 609 |
+
numba/tests/test_array_constants.py,sha256=QYL1Zz-sSYuvGxKUYnCSi65i-9CunsOiiiC_jxUNoS8,4826
|
| 610 |
+
numba/tests/test_array_exprs.py,sha256=ZJ8Pc4Y_1IAxu2tY78w-NQb1ql3TJxCSoF0thKTw318,24229
|
| 611 |
+
numba/tests/test_array_iterators.py,sha256=VXErTR-oSOrTaUEjMFvb0uOhLuOggbAC8Ftyj47AZjs,17894
|
| 612 |
+
numba/tests/test_array_manipulation.py,sha256=s9NrClPyvxuPsPf3O9VjpDIliWMU-YjIIewJXcA78v4,54748
|
| 613 |
+
numba/tests/test_array_methods.py,sha256=8zB3Qmsx2pQnpLHQTsDvfj67_4mrbe_os_bv9tLJs5c,70756
|
| 614 |
+
numba/tests/test_array_reductions.py,sha256=3cZkfx41K5HhOXCaT0tGSbQ5uf29v3IIOqroB2bu2dU,48551
|
| 615 |
+
numba/tests/test_array_return.py,sha256=xPqpMaVkFYUlV4zfr7gINoJD6UDRMf3eFJ4wvjkZkV8,856
|
| 616 |
+
numba/tests/test_asnumbatype.py,sha256=L3OQHjx5MBNXC4y-zIlWuRNvPIedgmWaKot9nBmW87c,13033
|
| 617 |
+
numba/tests/test_auto_constants.py,sha256=IEjzoT8_H88ferTGYz93Sszb8uUSi0hr8SOxwW7Oklw,688
|
| 618 |
+
numba/tests/test_blackscholes.py,sha256=7-eHw17Vhrd_tn9RXhQA_5aw6dVxURI-6VkW6TaMebs,3599
|
| 619 |
+
numba/tests/test_boundscheck.py,sha256=rX_OPNrDOef2IEz_GLD6pS7YJYzLjBHSUaQfgu5EkOs,8113
|
| 620 |
+
numba/tests/test_buffer_protocol.py,sha256=dZ8W-fkn0A3I41CbQu91mvScgU7SLvxfYjDX29EyIjE,8810
|
| 621 |
+
numba/tests/test_builtins.py,sha256=AXyizlG7NDbMehMywyWmS8ciR9p7XGjlzJks0gW3tMA,52943
|
| 622 |
+
numba/tests/test_byteflow.py,sha256=fSiY82ci3R4OsxIthMlTqt1Y42O-Pn7rBa5nHaojqBY,2426
|
| 623 |
+
numba/tests/test_caching.py,sha256=mgOflKwkg4XMpZOYXV4dfKUCjhzhcOgepjYJxVl97rw,45170
|
| 624 |
+
numba/tests/test_casting.py,sha256=KcHdtGTQgBXgMr5Yi6ghpw-4AW3io-inYTPv0mas2xs,3913
|
| 625 |
+
numba/tests/test_cffi.py,sha256=lnFqpoWcsoAz5EibxKym9TtbWYFXBYCWKd75qagQczQ,6695
|
| 626 |
+
numba/tests/test_cfunc.py,sha256=YIxEkOhtmse0d7nNzhB5NKA0vXd36oE90n260mcD1pE,13079
|
| 627 |
+
numba/tests/test_cgutils.py,sha256=CwjjiiRlPsuFKN6gybHAcGeRrSIYsx1_8vUZO26NA1Q,4863
|
| 628 |
+
numba/tests/test_chained_assign.py,sha256=Qy0fLfmKP10z24BTTyf8NSRIBaUp9Y9Cl8HRKtaLWTA,2480
|
| 629 |
+
numba/tests/test_chrome_trace.py,sha256=yBVKUJdic4GrutGM5e09lDHy1KyG-xjN6gqfAKsrIhM,1432
|
| 630 |
+
numba/tests/test_cli.py,sha256=ryU8WuXwMeKn792ephhhIPl5xolbOvDplFwz_8Qxg7E,10413
|
| 631 |
+
numba/tests/test_closure.py,sha256=GF7F90PzJiOZyxONKf1rxaLMP8nQwt6I03lBOFUsi94,13629
|
| 632 |
+
numba/tests/test_codegen.py,sha256=LsfZNz31W4nT811cHrtvgqhVmPTg9rBioYnBeBAQN5s,9048
|
| 633 |
+
numba/tests/test_compile_cache.py,sha256=_nvI7rUTKsCPQWoiEln45I1fy2zYAB7cH_ioGDDgMG4,6456
|
| 634 |
+
numba/tests/test_compiler_flags.py,sha256=DKZkORlXLVM9qWL6mT7M5NL9a6_D8tKVn_eXJgGasME,3554
|
| 635 |
+
numba/tests/test_compiler_lock.py,sha256=lojUn2JRt9uINgVJobHwFfNOvJiKaGTWvjuNZ8_xyIg,511
|
| 636 |
+
numba/tests/test_complex.py,sha256=l6p0K9jaDXUx7m2NxcO1nINmUtgyWnuHxcUjk6qjp_E,11378
|
| 637 |
+
numba/tests/test_comprehension.py,sha256=A9Tf_Nfcl7fJofV2-Sky4l2ZdL6QYH2AvHXoIULYLpE,17716
|
| 638 |
+
numba/tests/test_conditions_as_predicates.py,sha256=EC925MaOIm_6fVmn4YtvlwwOCX0i_4T-kI6I0Oql9wY,5275
|
| 639 |
+
numba/tests/test_config.py,sha256=DkRUifyGOL7Pawt99wsb_hxiZQZXZkA3ZbJNl7D9Z3o,7934
|
| 640 |
+
numba/tests/test_controlflow.py,sha256=6hQ7VdKwX2RgXfJLxA5VNaN2_uEd1NY3xc9XXwYCJzk,5098
|
| 641 |
+
numba/tests/test_conversion.py,sha256=AYC5UL9SjzPl1sS89Tj9kPMZBiZMMvIVtfo7GAome4I,6900
|
| 642 |
+
numba/tests/test_copy_propagate.py,sha256=-IY8udIT0z9LKBKgjs0f-799OLsuhfXptJ1x4TFtNbI,5658
|
| 643 |
+
numba/tests/test_ctypes.py,sha256=OYEIJ75kdAUrE5sYNDSiF26t8jRazbELiscDu1_LBJY,7431
|
| 644 |
+
numba/tests/test_dataflow.py,sha256=P77UdUTt6_pZiUsG6Kn-VyIPlixcAvDoqbpK0gYQylY,4848
|
| 645 |
+
numba/tests/test_datamodel.py,sha256=sRe5QyCVkX7y-p105AGpK45C84YGJFMt5R9lvuq_B6I,7014
|
| 646 |
+
numba/tests/test_debug.py,sha256=VW67kUy6XaVWXJS6GlJDXOurgkf2wHYt9TO7mFujsmM,12092
|
| 647 |
+
numba/tests/test_debuginfo.py,sha256=618wSAVv6HyTmsCpnB6lUqG7JyCEUIrF8Np-EhniXmE,30613
|
| 648 |
+
numba/tests/test_deprecations.py,sha256=J9_Y4eO_RDdxymBb15GvJex9e1ASzSkPupYSQrAlp1g,10186
|
| 649 |
+
numba/tests/test_dictimpl.py,sha256=3ybNw_n9O0n7QmWMEmmLj_1IQcZnjTiQBEUMRwkAZPs,20038
|
| 650 |
+
numba/tests/test_dictobject.py,sha256=QtWk2NPuwPCl0avzchECc-qfcX1mJnI8DYQNSV4hwX0,71361
|
| 651 |
+
numba/tests/test_dicts.py,sha256=qNiyJx7wv_UcWuoeP2iDaXJjiWOO6sLncpCKgnuVr6s,6066
|
| 652 |
+
numba/tests/test_dispatcher.py,sha256=v-bvjnA2edIGl0n3r8HjLljuFdCe3ytkXVu5DTKDduU,38541
|
| 653 |
+
numba/tests/test_doctest.py,sha256=ntvCtFkfebvihMiW7NhAeFK9Mn5f3Om-DR4fiTburzI,795
|
| 654 |
+
numba/tests/test_dyn_array.py,sha256=VM2w2fee_vspTMGbsruAFGJZ02glnkZo8QWdi85grMM,55791
|
| 655 |
+
numba/tests/test_dyn_func.py,sha256=VeYpJCAymujXN1nBuyHl0W8pHS3cbpBDBpAGQ2CiYJM,811
|
| 656 |
+
numba/tests/test_entrypoints.py,sha256=33rd8aC3S_B14v3T80KmdcLfC9Jk_Covn2EbV5Aljto,8152
|
| 657 |
+
numba/tests/test_enums.py,sha256=svJ3SzcmpvnFe9jw9Ig56jpNtgZeZjEkA-bFrqU2q8k,4988
|
| 658 |
+
numba/tests/test_errorhandling.py,sha256=cbao_2A78U9H52fc3Y1vSb3EH0uf1okm2w6gXhvsfaQ,15968
|
| 659 |
+
numba/tests/test_errormodels.py,sha256=1Cxqp7-0pwdJlArxDyeohTAfImHYpMKb7_acbW7OqRA,585
|
| 660 |
+
numba/tests/test_event.py,sha256=j0QylybHn5QEJhrVvQPyeI9F__kHrn4m7jpB9JRw6rE,7333
|
| 661 |
+
numba/tests/test_exceptions.py,sha256=KgNWp8Neq2c9HDMys_iGpnTWS8WGMr1s_L7kQEZZtGY,16133
|
| 662 |
+
numba/tests/test_extended_arg.py,sha256=M7CKc4Kiu0j0OYDuuvk_zxBruNHFGX7FC-uDATeEVDs,1571
|
| 663 |
+
numba/tests/test_extending.py,sha256=t4ZSj_J9t7iWfQ_eTeCoZs6xlb1Oo39twVrg6LOBPOs,68201
|
| 664 |
+
numba/tests/test_extending_types.py,sha256=3T4005XZFWOzscGAmNB6qwnC5HlVz4_AcsO47dW_Wvg,4990
|
| 665 |
+
numba/tests/test_fancy_indexing.py,sha256=kAIO0Uk2J5fI56eL7e4NVf87JS2rx3mP2sIo8kZDgPI,19597
|
| 666 |
+
numba/tests/test_fastmath.py,sha256=WmCUk3znkhiBhkxhTsudEaA4ci2B6UN_ZnfQky6ib4I,4564
|
| 667 |
+
numba/tests/test_findlib.py,sha256=Tt9Xzn0-3EprPqAEt946-Ses3I8-YwYCN-hMi-ctfig,324
|
| 668 |
+
numba/tests/test_firstlinefinder.py,sha256=m9cowyNiHonOtcydvL0fUfyBQzYJQhM9hjVZtK2wDJA,6831
|
| 669 |
+
numba/tests/test_flow_control.py,sha256=LFuGkotUoJfGkZFWuz0Y3I1O0EXeVaj2tGChZbkNfUk,42671
|
| 670 |
+
numba/tests/test_func_interface.py,sha256=pOMEhD3kH27XbNpe79TahiFRN8ueCcUanbNTwAH1OXg,1038
|
| 671 |
+
numba/tests/test_func_lifetime.py,sha256=3cETb4trG71QeIMSN4foYos7DkZTLQufrc9ENs8ACmY,4908
|
| 672 |
+
numba/tests/test_funcdesc.py,sha256=PJ4s19wiKGYUTlO5wpHNroM2H5ifddYsPiPpIgiKNv8,1698
|
| 673 |
+
numba/tests/test_function_type.py,sha256=A5aFUTuGpgxzOhtTgl56DvcYjrytVYP_kDSCOgjwByQ,39010
|
| 674 |
+
numba/tests/test_gdb_bindings.py,sha256=gPD5l-zxMGrhQziarBEC_QaGM0eoL38SRDBqgc2CRrg,8317
|
| 675 |
+
numba/tests/test_gdb_dwarf.py,sha256=HYg0qUCIP0ucW1UGD85v0OLZ_Rr0Tfu4s3uP5B9Ytu0,9269
|
| 676 |
+
numba/tests/test_generators.py,sha256=b_0h4IZfKRTnb-rWanA02GcP0t2neBOW3bQzIEVVKQo,16981
|
| 677 |
+
numba/tests/test_getitem_on_types.py,sha256=hsEpV7IgJXWNUYP1L77xKaNujlbmOvbLK4uIdRc6ri4,3564
|
| 678 |
+
numba/tests/test_gil.py,sha256=07knzRi9lQZFqEkcCUMnd9gE4IuYswkqya_wyyCAes8,5966
|
| 679 |
+
numba/tests/test_globals.py,sha256=VQgRuotHnILWTfFY7Bg91VGxDsNmmMM2GKPF1AeXAiU,7329
|
| 680 |
+
numba/tests/test_hashing.py,sha256=ss_UGyIxaCiHwUVcgu5y2ztLMgziDJ-8zITrpLOTAsI,19226
|
| 681 |
+
numba/tests/test_heapq.py,sha256=VXHJSinvSStGoVQLpgBOx17G3ytBbKrsUBJezPUW_O4,14456
|
| 682 |
+
numba/tests/test_help.py,sha256=VAYX2JIdCqrjtFuJo72r-_4Kj9iPcF8JSIKtRwxzSMs,3523
|
| 683 |
+
numba/tests/test_import.py,sha256=NuydzvkFHh4Ig5G4WIWTo6Ay51Jj9d2oKP9RMakXYuc,4234
|
| 684 |
+
numba/tests/test_indexing.py,sha256=PxuwFkrvhqdrASk9ZMsTqzCPoqm7SOvIztSdbLwqgI0,39134
|
| 685 |
+
numba/tests/test_init_utils.py,sha256=GVZ3bG9xAfp6rWmfmtAYoJk9FyxyqhEq0VSBY9JA4M0,1557
|
| 686 |
+
numba/tests/test_inlining.py,sha256=-pMzweKPnI9HkbgEUc4Kc3gzzm-UKYFP99Bi4HsvcAk,11520
|
| 687 |
+
numba/tests/test_interpreter.py,sha256=qVSslKyVjndqJp5957QZz2nndMrRAGBYqsTuFI598vE,30293
|
| 688 |
+
numba/tests/test_interproc.py,sha256=NLOub2C1frPWw7dlVKHTllI2_rLF5BcAzFEg4a3Fgkc,1099
|
| 689 |
+
numba/tests/test_intwidth.py,sha256=A9JymBQSHZtQaGkQqmMOCKdbDgY97JMKnYjIEWVMdMg,2703
|
| 690 |
+
numba/tests/test_ir.py,sha256=1rxR9bb41EyrlsJwRqlLBCroKSS-L0LbBNpCSt-98B4,20239
|
| 691 |
+
numba/tests/test_ir_inlining.py,sha256=6e9AM6u2oup76ZhlCmm7Lz6YVuWmbaeFKtEOm99igjI,44716
|
| 692 |
+
numba/tests/test_ir_utils.py,sha256=yTZuOjtAdGIq-TXicdblro-Vr5Gr00gYlzRaQa7MjbQ,9613
|
| 693 |
+
numba/tests/test_itanium_mangler.py,sha256=eGG6LBnVcAXltL3laDLJuMnQN34gfI_GbGzaRXiPFbc,2561
|
| 694 |
+
numba/tests/test_iteration.py,sha256=xyYG4PgnanlE7M9SNzv33vJo8PKNPC_pk8rd7D_vDBQ,7049
|
| 695 |
+
numba/tests/test_jit_module.py,sha256=gAkHb87P2kk3ppThgeCWOdag-8PDhvQBdTvu0CmA0PY,5248
|
| 696 |
+
numba/tests/test_jitclasses.py,sha256=Cn0sw8xj4ePSWUGUFLnaXaaIkHinR5BUlJBthwKNCkY,59870
|
| 697 |
+
numba/tests/test_jitmethod.py,sha256=g2RTCmvFbNyNO4JaKcsLWeAdmrrOXrjB30pOUGyH_iU,2000
|
| 698 |
+
numba/tests/test_linalg.py,sha256=xz6w0KYO3_FEuEi5muJA0AaCVkbFFXxKeFMLAs4Ybhw,96098
|
| 699 |
+
numba/tests/test_listimpl.py,sha256=FEgWroRVAkeiorccJFwfmgLhXsJsyiCVkGvQzUvjESE,16147
|
| 700 |
+
numba/tests/test_listobject.py,sha256=52f6E2RX0vASiB6d7CjmQ62tjmcFFGu9pUAHyx8dYkM,44676
|
| 701 |
+
numba/tests/test_lists.py,sha256=ARmbrrb3sFU3yyUfBtI-XGlKEQl7gbBR_ngEWg-NNFY,51554
|
| 702 |
+
numba/tests/test_literal_dispatch.py,sha256=cYQ6P4o7rYyJc6jNTV66-knNKo02B-anN3Ctccvplpk,11732
|
| 703 |
+
numba/tests/test_llvm_pass_timings.py,sha256=z8MXzdlTAqIQ_KWFqPZCrULg4usUNCPk2eUm---59zQ,4493
|
| 704 |
+
numba/tests/test_llvm_version_check.py,sha256=o8RSkDrsnljJ3xzbtsDQAkkqUEJwI3F2SEN9b1f1uMA,1284
|
| 705 |
+
numba/tests/test_locals.py,sha256=8d61r5d1lkIXllE1ObI5oDZ1IwTTyeAtkHFaiLG4orw,335
|
| 706 |
+
numba/tests/test_looplifting.py,sha256=-DjuAyC5e9DLNWJw1q5YB4DfslTeoSiVic4kIXlwh54,17273
|
| 707 |
+
numba/tests/test_make_function_to_jit_function.py,sha256=JFsIpGLwunSUqImiWUcik_3AX7JRqRTY4qgZNMnPgmc,8288
|
| 708 |
+
numba/tests/test_mandelbrot.py,sha256=ZLrAAKncKA74KLlgLbyfu6y7gp3FwZy_riAIwVlRkx4,595
|
| 709 |
+
numba/tests/test_mangling.py,sha256=TtBFeN7EKTKtozvkwuAktbnKONG-bCH1jlHD-3n4EWw,1264
|
| 710 |
+
numba/tests/test_map_filter_reduce.py,sha256=xyfL19UnK8WGXY2cNXBbiAKU7ZX3q5wZSVWZqaWLrYE,2031
|
| 711 |
+
numba/tests/test_mathlib.py,sha256=lohGVCFAacVvaakttvVZTCv4D_S9QENhEeFi8IqQ980,17892
|
| 712 |
+
numba/tests/test_maxmin.py,sha256=UDqYYUfJveub3U1xEqvjR_w1t7q67vPG86mZtizXzEA,747
|
| 713 |
+
numba/tests/test_misc_coverage_support.py,sha256=bBKiVEMlYPRnDD15e1pZMXzTZydyZmIaUPW5-9wuz0Y,2952
|
| 714 |
+
numba/tests/test_mixed_tuple_unroller.py,sha256=TMVAg_qm39WVfnz6XT_TZM4NgrLg7S20FeMAcOdBEfA,62041
|
| 715 |
+
numba/tests/test_moved_modules.py,sha256=OcjNSGqNgvXwFQT0ipI4j8XP-ZbHPRFrXi1-8rjZIZE,1319
|
| 716 |
+
numba/tests/test_multi3.py,sha256=hCHPIsHlx5wXW1PgkycrEVAxw7J1HGbn8NmnnbLN5Zw,1229
|
| 717 |
+
numba/tests/test_nan.py,sha256=hmWtRaxUQvuBSQlfQkksgwaw4ZZ7Xjq6oyOktMnCU6M,751
|
| 718 |
+
numba/tests/test_ndarray_subclasses.py,sha256=Jw2Zf5fanHlhihcp6BwzzxOlTYPhSQ3FcIdOOcK0v_0,10687
|
| 719 |
+
numba/tests/test_nested_calls.py,sha256=Vb3wzSbS7dcqJq2K-8NFo_n0V37NCvm-tIX1r98aRpo,4082
|
| 720 |
+
numba/tests/test_np_functions.py,sha256=KN6GbwBgRIrBebsWNu1gF9T4ooNKiazzYEeNB1c5kD0,241573
|
| 721 |
+
numba/tests/test_np_randomgen.py,sha256=jp7Pj3sL_oXrfX9587Ou_wqohzHhs_ktbEkvSQqI5Ig,54301
|
| 722 |
+
numba/tests/test_npdatetime.py,sha256=7j6Gb_MuY7STJCvYe6rDYMuWO0n09y3v5npzn9DAP8U,44289
|
| 723 |
+
numba/tests/test_nrt.py,sha256=tBmx6Yoo2bcDD1YAlaDtw1IuQFknLyuQr62U7icpeUs,29806
|
| 724 |
+
numba/tests/test_nrt_refct.py,sha256=k09EmgKBFPL3aCXBUaf7PYm9RmMXf3aqG2Fe2ZjR_Ic,2911
|
| 725 |
+
numba/tests/test_num_threads.py,sha256=ZpuRV1hDfNYqStXZZ-pBkJP-8Iz7QKHjeTvJn1DyPMw,23511
|
| 726 |
+
numba/tests/test_numberctor.py,sha256=uMpKKjN7S3quNI-ajwBxatwy12RHhbR8Parg1E4BYyw,7179
|
| 727 |
+
numba/tests/test_numbers.py,sha256=iV9xS_t0FC0_ecUgva1pRY3-2_X3_1Xd58yk1oUw5hk,3415
|
| 728 |
+
numba/tests/test_numconv.py,sha256=dFdTlZA1_agMuxP1OER02cKqZ-RR8dh0ES_69XdP20w,1008
|
| 729 |
+
numba/tests/test_numpy_support.py,sha256=kJT2I4yjzibJ3lKthnumU5rX5DuIiROHzaY6rZ2FKTU,17873
|
| 730 |
+
numba/tests/test_numpyadapt.py,sha256=f9iBBwwkwxrIpHC1Frp-bf0gl0oqcWhB9OwF3AzbuMk,1307
|
| 731 |
+
numba/tests/test_obj_lifetime.py,sha256=g8N8pszctyim9xlC_SFdWlEkB9POJdXbi3E2NuOnPXU,15316
|
| 732 |
+
numba/tests/test_object_mode.py,sha256=CC3peFxQudYVtpyMQVZxr2AkgF-ks3dgdnFDCVVvlmc,5798
|
| 733 |
+
numba/tests/test_objects.py,sha256=RtRWC40agdYKfJubbWD2VUIp99U-8Vlel-KLAJOl4_o,1319
|
| 734 |
+
numba/tests/test_operators.py,sha256=D1tFpKxSnZ7YdQJbLmMrmlYCTOtV4n3EGZFH_BmBI5I,50969
|
| 735 |
+
numba/tests/test_optimisation_pipelines.py,sha256=z4n9_uQYGFPFOOAwth0IugJrWmcejyjBi9Pe4yigjpw,1692
|
| 736 |
+
numba/tests/test_optional.py,sha256=0its7sre69mtSqePamMqOzudWdYGcdRYbcHWn99HeT4,6502
|
| 737 |
+
numba/tests/test_overlap.py,sha256=P8MUVACNycTX54KFFmYzVlNxogayjlVspS9HtKZH-2w,3839
|
| 738 |
+
numba/tests/test_parallel_backend.py,sha256=8PyoHAyXzkpuFf9Zzx2qvllZcYahPN1-B8nzTaypIKY,42150
|
| 739 |
+
numba/tests/test_parfors.py,sha256=Z9Z63sn9J411crYlWEExxDXEXbzy_Jn-faxuBcmlEI4,166490
|
| 740 |
+
numba/tests/test_parfors_caching.py,sha256=rf148DXLmLZNWFQgNCnW26lIBECRop4PufbWgk-pC7I,2962
|
| 741 |
+
numba/tests/test_parfors_passes.py,sha256=TP_mY4NjR9dicGgOhSSeLqB3uxvYo2HwrbL40KfU254,21064
|
| 742 |
+
numba/tests/test_pipeline.py,sha256=pqCu3ZyutdOxwGwPf2UEgh0BuajETlnb1m7UqwVjxV8,5254
|
| 743 |
+
numba/tests/test_polynomial.py,sha256=wiK0QaSAV49M0DFNMGN_XfX8NLpxEdyc0ahWwLpmyzU,19776
|
| 744 |
+
numba/tests/test_practical_lowering_issues.py,sha256=ecFnAiMhzk7fwxAHvvVXaoepQZDjhvW4U15ixnL0oRM,6953
|
| 745 |
+
numba/tests/test_print.py,sha256=EaNmfFd8gx4RsLKc0d22fVtAdLqi4LMXEh3f03UJLFI,6144
|
| 746 |
+
numba/tests/test_profiler.py,sha256=T-46A6_bMjHc3izo9zrmjIdZ7EQSewAbEAQ1AFK1AfM,4060
|
| 747 |
+
numba/tests/test_pycc.py,sha256=Xtae_PZgZ29sa9eWRI6v7rpeO2HlWEtefatUBG4FkOg,14894
|
| 748 |
+
numba/tests/test_python_int.py,sha256=bZhwlvC2KpAn1x0ID8HOerUpSuOULPMz-cLO4gNXVIs,1690
|
| 749 |
+
numba/tests/test_pythonapi.py,sha256=pLN9H8hX-xP8SfWPLdh_OOC0dn7jOvrtY8j5trV3Rls,3935
|
| 750 |
+
numba/tests/test_random.py,sha256=JHaXD0jLzSUTlceZWCLJJnRe3pyG7y_oh77O4ceJ-tg,74031
|
| 751 |
+
numba/tests/test_range.py,sha256=sazrpcMDSYZPdT0lOkUb33GXerz2RaGITADFQZKOGU0,5643
|
| 752 |
+
numba/tests/test_recarray_usecases.py,sha256=v5UuuUNowgDnJ3nx5vPKBNt00tQMZMg9BBQ6_KzWcjk,3839
|
| 753 |
+
numba/tests/test_record_dtype.py,sha256=8TIJbFz92G6FmSuPys-ym2biuU_JTjVnG4lA0_3YLxE,57298
|
| 754 |
+
numba/tests/test_recursion.py,sha256=K6Z1vT5beETZgN5Xz6qs-3vHP7zEY_KDT7XDjHJeshI,4602
|
| 755 |
+
numba/tests/test_refop_pruning.py,sha256=JvoSR9phrGl4KiXAWJe_O_ongYAD0qgUFLTtz1AAn0Y,5950
|
| 756 |
+
numba/tests/test_remove_dead.py,sha256=KUEbJ1uujvquy8exzEhpFeytZfYxm1CWRnTMvcQZxcc,13717
|
| 757 |
+
numba/tests/test_repr.py,sha256=vMYY2byejl_KyZTB5JopGMKCD8NeYeNjnjJ_uYFRgdU,1656
|
| 758 |
+
numba/tests/test_return_values.py,sha256=KCLvJRAoSJugioiXe45HZHAWbPGy35-v7TWi-joEodM,2062
|
| 759 |
+
numba/tests/test_runtests.py,sha256=C7RCZ6u1XGDszfsg9qZceGuBfWLvrqmDUmBRSjYo5jk,11265
|
| 760 |
+
numba/tests/test_serialize.py,sha256=UhQQCzPwzODqbI8DqROlLYyyYvaX9VKIsgg3mcH9MA8,11088
|
| 761 |
+
numba/tests/test_setimpl.py,sha256=QZqH8IZpGAR8mlQbcQHs2Nf0WoFex-IsWkuHIQ41LE0,7635
|
| 762 |
+
numba/tests/test_setobject.py,sha256=5hZ8K7XwxiDRbr2rrfCAEwt3KanEX-0xNlGkj8rJoPs,5207
|
| 763 |
+
numba/tests/test_sets.py,sha256=2JbWMI63gfq85FoGfqYNF1XgPWodbI1SohfvSgvdTgo,23282
|
| 764 |
+
numba/tests/test_slices.py,sha256=4zotg9-XrVJEyYf7AMWt5AwKp-luxJ-_nEIRHl-Oiy4,8449
|
| 765 |
+
numba/tests/test_sort.py,sha256=ZM3jMJKfmQFDfkRoYVbOX9NEhOkMyQ_5U4lfjRyklLY,40848
|
| 766 |
+
numba/tests/test_ssa.py,sha256=08zQ9c7R6FOL3iOoW6dlG2pwUU8Q8Wz0wXLh__5P1cE,18974
|
| 767 |
+
numba/tests/test_stencils.py,sha256=OA7TyK4Mq1V6EHTaNLIflJPCQYEp5_zISkTts69aYII,127272
|
| 768 |
+
numba/tests/test_storeslice.py,sha256=LVlURBWUfpaGUsk8TC5rv2uSLZM-FuPAnaz3PiEhFE0,1940
|
| 769 |
+
numba/tests/test_struct_ref.py,sha256=lCVvc5HFXLVNrVhYRfbkgL5iRnuUhDiCsvNHS0ZIiKI,12458
|
| 770 |
+
numba/tests/test_support.py,sha256=XToSTZabtQLbS8oALFCElZWNSQjVmltENakMcn37Uzk,14139
|
| 771 |
+
numba/tests/test_svml.py,sha256=uYoS5Tmu0P4zpMc53dgS7aLTyB83TfuF0OCp8d7aeiw,15736
|
| 772 |
+
numba/tests/test_sys_monitoring.py,sha256=55maYzv6n8W5fCnoq6Cpdp929iOLJaa-QTTRTFHAxmY,35472
|
| 773 |
+
numba/tests/test_sys_stdin_assignment.py,sha256=NfkWGUZSKP9S1Ljr8FHjh58xnqTnOWrdh6OtEo8N148,1665
|
| 774 |
+
numba/tests/test_sysinfo.py,sha256=Ja_Stj3ma9m9wmJUremtL83pTASNe4GwGBZ3ooCMD1Y,5842
|
| 775 |
+
numba/tests/test_target_extension.py,sha256=wGmlHdocHb0CLD32Lf9saq01rNmsbbyYF-68X16dtEU,28255
|
| 776 |
+
numba/tests/test_target_overloadselector.py,sha256=mLwsAg2bdMfVT9gZA1Xh40ejOpkHvrVpeuxn48PTSow,6226
|
| 777 |
+
numba/tests/test_threadsafety.py,sha256=R-5T_uNcy27TX57izO7GuTf5WZXpkXdEiofc0VJT5QU,2787
|
| 778 |
+
numba/tests/test_tracing.py,sha256=DC1Gabw7E9b3BzwdApxlE6oEM73nmQoYxBucL8jAoAU,4855
|
| 779 |
+
numba/tests/test_try_except.py,sha256=HTdxPk4Bfu4Rg_ZOepHgT9w8aLIdcVgF6GcizKf1zYk,23887
|
| 780 |
+
numba/tests/test_tuples.py,sha256=fbYmlJA7wtogDauMsiz6lZzicPqu3nK0F4ezt-yyTS4,23912
|
| 781 |
+
numba/tests/test_typeconv.py,sha256=M3S82AjZTIiuBDx-AUZNfTOhrVIgT6tEPEPRB2XY5gQ,11167
|
| 782 |
+
numba/tests/test_typedlist.py,sha256=w3IUmFnfZ8M2jC20ZOkCi1kgCMcrNud5SDrOdzoG-jE,50620
|
| 783 |
+
numba/tests/test_typedobjectutils.py,sha256=wORlAhi7rywQ1JpHduOJDlZH_l_a7JAhEgqdSvdU5Ck,2352
|
| 784 |
+
numba/tests/test_typeguard.py,sha256=0kLxdIvu-C6kcbSfBb2yI9Ylb4L3MCZ0T5oleiHEQuQ,1153
|
| 785 |
+
numba/tests/test_typeinfer.py,sha256=BdSo9yQ9DoPUHTcEyUYxyNfYvZDWt7eIffHETa2svek,32790
|
| 786 |
+
numba/tests/test_typenames.py,sha256=1LJcfCcSP8Ilqb9NMuFfRgszLGquaxFoPAwbuc43o1g,348
|
| 787 |
+
numba/tests/test_typeof.py,sha256=nXjg6V9ELNCG0Yrfv_2PabB86SI7TA5l6fn4-XrH1rI,21678
|
| 788 |
+
numba/tests/test_types.py,sha256=74sBbMrJQvKP1ST0FIvuElQQgyE2J-7cFspwueFMxd8,31236
|
| 789 |
+
numba/tests/test_typingerror.py,sha256=zSFlST4KnTw2wNJe84mvYCIQxk3c-O5PXj9gnNw0dds,7235
|
| 790 |
+
numba/tests/test_ufuncs.py,sha256=M5i1q2zkoow2o1rsn7p32Jw22gnYcSDQo_XXn7_Gv0E,71677
|
| 791 |
+
numba/tests/test_unicode.py,sha256=72fcvRFVRRdwaphM8XRa6CFL5WDOxHjLPeXKXLOCV8c,98539
|
| 792 |
+
numba/tests/test_unicode_array.py,sha256=DHLGut0dDX2n3KR0RmV4iSTRuWZYNF2KfiObwLuHqwI,28996
|
| 793 |
+
numba/tests/test_unicode_names.py,sha256=YPJbxE4DzjQpFi7Wow7DGb4mwdqaTGTb5det8ayiupw,1563
|
| 794 |
+
numba/tests/test_unpack_sequence.py,sha256=7edSjmBZUOJz0uxPsj1nELfYWlh0MxgN8nzxVjyuwDs,6745
|
| 795 |
+
numba/tests/test_unpickle_without_module.py,sha256=OVLcy0Zwui5SPjr_Hs12ShxzhfPMmF7oS9XkX4iDQDo,1631
|
| 796 |
+
numba/tests/test_unsafe_intrinsics.py,sha256=WCYZrNyu_70rX2ep7WgP5sw9vvOv730YWfQWO5j7oBo,7619
|
| 797 |
+
numba/tests/test_usecases.py,sha256=gn3HkS--zzZ5U9b08oY2T5nzhySxg7AHlIyLiuacVMU,5893
|
| 798 |
+
numba/tests/test_vectorization.py,sha256=tMLcZ6_7CPimUNwhymiQJGw7mInOktOc8mIhKi1zoyA,2932
|
| 799 |
+
numba/tests/test_vectorization_type_inference.py,sha256=Hd9WtE3urYqslprNdKbbNk4X5lOzL2IM7aWr1rKAxrk,1162
|
| 800 |
+
numba/tests/test_warnings.py,sha256=pm4J3GKggNbi2WWu6mmIazz7pDGT6E_-ZlUXOo6RvXw,7408
|
| 801 |
+
numba/tests/test_withlifting.py,sha256=xDbtq5OUygvleCfJpKipzoIUGLPkdHIazlCDJbITsgM,35262
|
| 802 |
+
numba/tests/threading_backend_usecases.py,sha256=q0In5DcjTg6LqAQY-Q1_WnmG7-4MhGBqIMDrSuysz8Y,618
|
| 803 |
+
numba/tests/typedlist_usecases.py,sha256=Uo-2XbzPxNwPBeWh1U4yr7KkfEjADZ4NouO_PP6oX3o,287
|
| 804 |
+
numba/tests/usecases.py,sha256=q5AbT3VfeLTN7P4whdfQ-851Y56BrnZ4K4EvbiegeLk,1618
|
| 805 |
+
numba/typed/__init__.py,sha256=nq5XV0GfWezaRLTpui-gOTndStXFfaF1Vnv8vGnizro,508
|
| 806 |
+
numba/typed/dictimpl.py,sha256=7qPLFW3ex2n1wmysA7IyZqehPoUHG6ICuiwVGXDLAU0,1101
|
| 807 |
+
numba/typed/dictobject.py,sha256=AOiju2bCzq1o52JHVqAR6v6M9AKw99iHl4d4fgddPsA,40961
|
| 808 |
+
numba/typed/listobject.py,sha256=bnWhzafxdzzkrrpd4dmnoeafMAdpLwaJCXFZw6zLum0,46028
|
| 809 |
+
numba/typed/setobject.py,sha256=OWXu7qZQzvMi2tMY0ysnVQ4dOBn3K7ePMdLq4hYAntA,20236
|
| 810 |
+
numba/typed/typeddict.py,sha256=tfQWKMur0hwxlOiaiy8fTxQ0O1gCPEPmhA33_NBV6QA,12216
|
| 811 |
+
numba/typed/typedlist.py,sha256=0Mipv8f1LK3nOt6FfN1jImEzKzbt8OFpAfNAPAtpVJk,18791
|
| 812 |
+
numba/typed/typedobjectutils.py,sha256=EsOTnBwYCQMG-IqoRsCDU1s3gbdlEJDjoCaYo8QZEGc,7036
|
| 813 |
+
numba/typed/typedset.py,sha256=uC1cWjfZsfRawkefZi3eTF5SJAiNdudNk3AMAEeKREs,8226
|
| 814 |
+
numba/types/__init__.py,sha256=bSQKeXj0suDD-j13RK4CxMnB5TXbgab4jo2536aMQI4,134
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/REQUESTED
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/WHEEL
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wheel-Version: 1.0
|
| 2 |
+
Generator: setuptools (82.0.1)
|
| 3 |
+
Root-Is-Purelib: false
|
| 4 |
+
Tag: cp311-cp311-manylinux_2_17_x86_64
|
| 5 |
+
Tag: cp311-cp311-manylinux2014_x86_64
|
| 6 |
+
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/licenses/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright (c) 2012, Anaconda, Inc.
|
| 2 |
+
All rights reserved.
|
| 3 |
+
|
| 4 |
+
Redistribution and use in source and binary forms, with or without
|
| 5 |
+
modification, are permitted provided that the following conditions are
|
| 6 |
+
met:
|
| 7 |
+
|
| 8 |
+
Redistributions of source code must retain the above copyright notice,
|
| 9 |
+
this list of conditions and the following disclaimer.
|
| 10 |
+
|
| 11 |
+
Redistributions in binary form must reproduce the above copyright
|
| 12 |
+
notice, this list of conditions and the following disclaimer in the
|
| 13 |
+
documentation and/or other materials provided with the distribution.
|
| 14 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 15 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 16 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 17 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 18 |
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 19 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 20 |
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 21 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 22 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 23 |
+
(INCLUDING NEGLIGENCE OR OTHERWIS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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
The Numba source tree includes vendored libraries governed by the following
|
| 2 |
+
licenses.
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
appdirs
|
| 6 |
+
-------
|
| 7 |
+
|
| 8 |
+
# This is the MIT license
|
| 9 |
+
|
| 10 |
+
Copyright (c) 2010 ActiveState Software Inc.
|
| 11 |
+
|
| 12 |
+
Permission is hereby granted, free of charge, to any person obtaining a
|
| 13 |
+
copy of this software and associated documentation files (the
|
| 14 |
+
"Software"), to deal in the Software without restriction, including
|
| 15 |
+
without limitation the rights to use, copy, modify, merge, publish,
|
| 16 |
+
distribute, sublicense, and/or sell copies of the Software, and to
|
| 17 |
+
permit persons to whom the Software is furnished to do so, subject to
|
| 18 |
+
the following conditions:
|
| 19 |
+
|
| 20 |
+
The above copyright notice and this permission notice shall be included
|
| 21 |
+
in all copies or substantial portions of the Software.
|
| 22 |
+
|
| 23 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
| 24 |
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
| 25 |
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
| 26 |
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
| 27 |
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
| 28 |
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
| 29 |
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
NetworkX
|
| 33 |
+
--------
|
| 34 |
+
The dominance frontier algorithm is from a pull request
|
| 35 |
+
https://github.com/numba/numba/pull/4149/files which is based
|
| 36 |
+
on the implementation of NetworkX of dominance. NetworkX has the following
|
| 37 |
+
license:
|
| 38 |
+
|
| 39 |
+
NetworkX is distributed with the 3-clause BSD license.
|
| 40 |
+
|
| 41 |
+
::
|
| 42 |
+
|
| 43 |
+
Copyright (C) 2004-2019, NetworkX Developers
|
| 44 |
+
Aric Hagberg <hagberg@lanl.gov>
|
| 45 |
+
Dan Schult <dschult@colgate.edu>
|
| 46 |
+
Pieter Swart <swart@lanl.gov>
|
| 47 |
+
All rights reserved.
|
| 48 |
+
|
| 49 |
+
Redistribution and use in source and binary forms, with or without
|
| 50 |
+
modification, are permitted provided that the following conditions are
|
| 51 |
+
met:
|
| 52 |
+
|
| 53 |
+
* Redistributions of source code must retain the above copyright
|
| 54 |
+
notice, this list of conditions and the following disclaimer.
|
| 55 |
+
|
| 56 |
+
* Redistributions in binary form must reproduce the above
|
| 57 |
+
copyright notice, this list of conditions and the following
|
| 58 |
+
disclaimer in the documentation and/or other materials provided
|
| 59 |
+
with the distribution.
|
| 60 |
+
|
| 61 |
+
* Neither the name of the NetworkX Developers nor the names of its
|
| 62 |
+
contributors may be used to endorse or promote products derived
|
| 63 |
+
from this software without specific prior written permission.
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 67 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 68 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 69 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 70 |
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 71 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 72 |
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 73 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 74 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 75 |
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 76 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
jquery.graphviz.svg (https://github.com/mountainstorm/jquery.graphviz.svg/)
|
| 80 |
+
---------------------------------------------------------------------------
|
| 81 |
+
The DAG roadmap rendering code in docs/dagmap/ uses Javascript from this
|
| 82 |
+
package to draw graphs in HTML.
|
| 83 |
+
|
| 84 |
+
Copyright (c) 2015 Mountainstorm
|
| 85 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 86 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 87 |
+
in the Software without restriction, including without limitation the rights
|
| 88 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 89 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 90 |
+
furnished to do so, subject to the following conditions:
|
| 91 |
+
The above copyright notice and this permission notice shall be included in all
|
| 92 |
+
copies or substantial portions of the Software.
|
| 93 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 94 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 95 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 96 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 97 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 98 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 99 |
+
SOFTWARE.
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
CPython (https://github.com/python/cpython)
|
| 104 |
+
-------------------------------------------
|
| 105 |
+
Numba source code that references URLs starting with:
|
| 106 |
+
|
| 107 |
+
https://github.com/python/cpython/
|
| 108 |
+
|
| 109 |
+
relates to use/inclusion of CPython source code which has the following license:
|
| 110 |
+
|
| 111 |
+
A. HISTORY OF THE SOFTWARE
|
| 112 |
+
==========================
|
| 113 |
+
|
| 114 |
+
Python was created in the early 1990s by Guido van Rossum at Stichting
|
| 115 |
+
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
|
| 116 |
+
as a successor of a language called ABC. Guido remains Python's
|
| 117 |
+
principal author, although it includes many contributions from others.
|
| 118 |
+
|
| 119 |
+
In 1995, Guido continued his work on Python at the Corporation for
|
| 120 |
+
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
|
| 121 |
+
in Reston, Virginia where he released several versions of the
|
| 122 |
+
software.
|
| 123 |
+
|
| 124 |
+
In May 2000, Guido and the Python core development team moved to
|
| 125 |
+
BeOpen.com to form the BeOpen PythonLabs team. In October of the same
|
| 126 |
+
year, the PythonLabs team moved to Digital Creations, which became
|
| 127 |
+
Zope Corporation. In 2001, the Python Software Foundation (PSF, see
|
| 128 |
+
https://www.python.org/psf/) was formed, a non-profit organization
|
| 129 |
+
created specifically to own Python-related Intellectual Property.
|
| 130 |
+
Zope Corporation was a sponsoring member of the PSF.
|
| 131 |
+
|
| 132 |
+
All Python releases are Open Source (see http://www.opensource.org for
|
| 133 |
+
the Open Source Definition). Historically, most, but not all, Python
|
| 134 |
+
releases have also been GPL-compatible; the table below summarizes
|
| 135 |
+
the various releases.
|
| 136 |
+
|
| 137 |
+
Release Derived Year Owner GPL-
|
| 138 |
+
from compatible? (1)
|
| 139 |
+
|
| 140 |
+
0.9.0 thru 1.2 1991-1995 CWI yes
|
| 141 |
+
1.3 thru 1.5.2 1.2 1995-1999 CNRI yes
|
| 142 |
+
1.6 1.5.2 2000 CNRI no
|
| 143 |
+
2.0 1.6 2000 BeOpen.com no
|
| 144 |
+
1.6.1 1.6 2001 CNRI yes (2)
|
| 145 |
+
2.1 2.0+1.6.1 2001 PSF no
|
| 146 |
+
2.0.1 2.0+1.6.1 2001 PSF yes
|
| 147 |
+
2.1.1 2.1+2.0.1 2001 PSF yes
|
| 148 |
+
2.1.2 2.1.1 2002 PSF yes
|
| 149 |
+
2.1.3 2.1.2 2002 PSF yes
|
| 150 |
+
2.2 and above 2.1.1 2001-now PSF yes
|
| 151 |
+
|
| 152 |
+
Footnotes:
|
| 153 |
+
|
| 154 |
+
(1) GPL-compatible doesn't mean that we're distributing Python under
|
| 155 |
+
the GPL. All Python licenses, unlike the GPL, let you distribute
|
| 156 |
+
a modified version without making your changes open source. The
|
| 157 |
+
GPL-compatible licenses make it possible to combine Python with
|
| 158 |
+
other software that is released under the GPL; the others don't.
|
| 159 |
+
|
| 160 |
+
(2) According to Richard Stallman, 1.6.1 is not GPL-compatible,
|
| 161 |
+
because its license has a choice of law clause. According to
|
| 162 |
+
CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1
|
| 163 |
+
is "not incompatible" with the GPL.
|
| 164 |
+
|
| 165 |
+
Thanks to the many outside volunteers who have worked under Guido's
|
| 166 |
+
direction to make these releases possible.
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON
|
| 170 |
+
===============================================================
|
| 171 |
+
|
| 172 |
+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
|
| 173 |
+
--------------------------------------------
|
| 174 |
+
|
| 175 |
+
1. This LICENSE AGREEMENT is between the Python Software Foundation
|
| 176 |
+
("PSF"), and the Individual or Organization ("Licensee") accessing and
|
| 177 |
+
otherwise using this software ("Python") in source or binary form and
|
| 178 |
+
its associated documentation.
|
| 179 |
+
|
| 180 |
+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
|
| 181 |
+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
|
| 182 |
+
analyze, test, perform and/or display publicly, prepare derivative works,
|
| 183 |
+
distribute, and otherwise use Python alone or in any derivative version,
|
| 184 |
+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
|
| 185 |
+
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
|
| 186 |
+
2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Python Software Foundation;
|
| 187 |
+
All Rights Reserved" are retained in Python alone or in any derivative version
|
| 188 |
+
prepared by Licensee.
|
| 189 |
+
|
| 190 |
+
3. In the event Licensee prepares a derivative work that is based on
|
| 191 |
+
or incorporates Python or any part thereof, and wants to make
|
| 192 |
+
the derivative work available to others as provided herein, then
|
| 193 |
+
Licensee hereby agrees to include in any such work a brief summary of
|
| 194 |
+
the changes made to Python.
|
| 195 |
+
|
| 196 |
+
4. PSF is making Python available to Licensee on an "AS IS"
|
| 197 |
+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 198 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
|
| 199 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 200 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
|
| 201 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 202 |
+
|
| 203 |
+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
| 204 |
+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
| 205 |
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
|
| 206 |
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 207 |
+
|
| 208 |
+
6. This License Agreement will automatically terminate upon a material
|
| 209 |
+
breach of its terms and conditions.
|
| 210 |
+
|
| 211 |
+
7. Nothing in this License Agreement shall be deemed to create any
|
| 212 |
+
relationship of agency, partnership, or joint venture between PSF and
|
| 213 |
+
Licensee. This License Agreement does not grant permission to use PSF
|
| 214 |
+
trademarks or trade name in a trademark sense to endorse or promote
|
| 215 |
+
products or services of Licensee, or any third party.
|
| 216 |
+
|
| 217 |
+
8. By copying, installing or otherwise using Python, Licensee
|
| 218 |
+
agrees to be bound by the terms and conditions of this License
|
| 219 |
+
Agreement.
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0
|
| 223 |
+
-------------------------------------------
|
| 224 |
+
|
| 225 |
+
BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1
|
| 226 |
+
|
| 227 |
+
1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an
|
| 228 |
+
office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the
|
| 229 |
+
Individual or Organization ("Licensee") accessing and otherwise using
|
| 230 |
+
this software in source or binary form and its associated
|
| 231 |
+
documentation ("the Software").
|
| 232 |
+
|
| 233 |
+
2. Subject to the terms and conditions of this BeOpen Python License
|
| 234 |
+
Agreement, BeOpen hereby grants Licensee a non-exclusive,
|
| 235 |
+
royalty-free, world-wide license to reproduce, analyze, test, perform
|
| 236 |
+
and/or display publicly, prepare derivative works, distribute, and
|
| 237 |
+
otherwise use the Software alone or in any derivative version,
|
| 238 |
+
provided, however, that the BeOpen Python License is retained in the
|
| 239 |
+
Software, alone or in any derivative version prepared by Licensee.
|
| 240 |
+
|
| 241 |
+
3. BeOpen is making the Software available to Licensee on an "AS IS"
|
| 242 |
+
basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 243 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND
|
| 244 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 245 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT
|
| 246 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 247 |
+
|
| 248 |
+
4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE
|
| 249 |
+
SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS
|
| 250 |
+
AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY
|
| 251 |
+
DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 252 |
+
|
| 253 |
+
5. This License Agreement will automatically terminate upon a material
|
| 254 |
+
breach of its terms and conditions.
|
| 255 |
+
|
| 256 |
+
6. This License Agreement shall be governed by and interpreted in all
|
| 257 |
+
respects by the law of the State of California, excluding conflict of
|
| 258 |
+
law provisions. Nothing in this License Agreement shall be deemed to
|
| 259 |
+
create any relationship of agency, partnership, or joint venture
|
| 260 |
+
between BeOpen and Licensee. This License Agreement does not grant
|
| 261 |
+
permission to use BeOpen trademarks or trade names in a trademark
|
| 262 |
+
sense to endorse or promote products or services of Licensee, or any
|
| 263 |
+
third party. As an exception, the "BeOpen Python" logos available at
|
| 264 |
+
http://www.pythonlabs.com/logos.html may be used according to the
|
| 265 |
+
permissions granted on that web page.
|
| 266 |
+
|
| 267 |
+
7. By copying, installing or otherwise using the software, Licensee
|
| 268 |
+
agrees to be bound by the terms and conditions of this License
|
| 269 |
+
Agreement.
|
| 270 |
+
|
| 271 |
+
|
| 272 |
+
CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1
|
| 273 |
+
---------------------------------------
|
| 274 |
+
|
| 275 |
+
1. This LICENSE AGREEMENT is between the Corporation for National
|
| 276 |
+
Research Initiatives, having an office at 1895 Preston White Drive,
|
| 277 |
+
Reston, VA 20191 ("CNRI"), and the Individual or Organization
|
| 278 |
+
("Licensee") accessing and otherwise using Python 1.6.1 software in
|
| 279 |
+
source or binary form and its associated documentation.
|
| 280 |
+
|
| 281 |
+
2. Subject to the terms and conditions of this License Agreement, CNRI
|
| 282 |
+
hereby grants Licensee a nonexclusive, royalty-free, world-wide
|
| 283 |
+
license to reproduce, analyze, test, perform and/or display publicly,
|
| 284 |
+
prepare derivative works, distribute, and otherwise use Python 1.6.1
|
| 285 |
+
alone or in any derivative version, provided, however, that CNRI's
|
| 286 |
+
License Agreement and CNRI's notice of copyright, i.e., "Copyright (c)
|
| 287 |
+
1995-2001 Corporation for National Research Initiatives; All Rights
|
| 288 |
+
Reserved" are retained in Python 1.6.1 alone or in any derivative
|
| 289 |
+
version prepared by Licensee. Alternately, in lieu of CNRI's License
|
| 290 |
+
Agreement, Licensee may substitute the following text (omitting the
|
| 291 |
+
quotes): "Python 1.6.1 is made available subject to the terms and
|
| 292 |
+
conditions in CNRI's License Agreement. This Agreement together with
|
| 293 |
+
Python 1.6.1 may be located on the Internet using the following
|
| 294 |
+
unique, persistent identifier (known as a handle): 1895.22/1013. This
|
| 295 |
+
Agreement may also be obtained from a proxy server on the Internet
|
| 296 |
+
using the following URL: http://hdl.handle.net/1895.22/1013".
|
| 297 |
+
|
| 298 |
+
3. In the event Licensee prepares a derivative work that is based on
|
| 299 |
+
or incorporates Python 1.6.1 or any part thereof, and wants to make
|
| 300 |
+
the derivative work available to others as provided herein, then
|
| 301 |
+
Licensee hereby agrees to include in any such work a brief summary of
|
| 302 |
+
the changes made to Python 1.6.1.
|
| 303 |
+
|
| 304 |
+
4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS"
|
| 305 |
+
basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
|
| 306 |
+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND
|
| 307 |
+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
|
| 308 |
+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT
|
| 309 |
+
INFRINGE ANY THIRD PARTY RIGHTS.
|
| 310 |
+
|
| 311 |
+
5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
|
| 312 |
+
1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
|
| 313 |
+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1,
|
| 314 |
+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
|
| 315 |
+
|
| 316 |
+
6. This License Agreement will automatically terminate upon a material
|
| 317 |
+
breach of its terms and conditions.
|
| 318 |
+
|
| 319 |
+
7. This License Agreement shall be governed by the federal
|
| 320 |
+
intellectual property law of the United States, including without
|
| 321 |
+
limitation the federal copyright law, and, to the extent such
|
| 322 |
+
U.S. federal law does not apply, by the law of the Commonwealth of
|
| 323 |
+
Virginia, excluding Virginia's conflict of law provisions.
|
| 324 |
+
Notwithstanding the foregoing, with regard to derivative works based
|
| 325 |
+
on Python 1.6.1 that incorporate non-separable material that was
|
| 326 |
+
previously distributed under the GNU General Public License (GPL), the
|
| 327 |
+
law of the Commonwealth of Virginia shall govern this License
|
| 328 |
+
Agreement only as to issues arising under or with respect to
|
| 329 |
+
Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this
|
| 330 |
+
License Agreement shall be deemed to create any relationship of
|
| 331 |
+
agency, partnership, or joint venture between CNRI and Licensee. This
|
| 332 |
+
License Agreement does not grant permission to use CNRI trademarks or
|
| 333 |
+
trade name in a trademark sense to endorse or promote products or
|
| 334 |
+
services of Licensee, or any third party.
|
| 335 |
+
|
| 336 |
+
8. By clicking on the "ACCEPT" button where indicated, or by copying,
|
| 337 |
+
installing or otherwise using Python 1.6.1, Licensee agrees to be
|
| 338 |
+
bound by the terms and conditions of this License Agreement.
|
| 339 |
+
|
| 340 |
+
ACCEPT
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2
|
| 344 |
+
--------------------------------------------------
|
| 345 |
+
|
| 346 |
+
Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam,
|
| 347 |
+
The Netherlands. All rights reserved.
|
| 348 |
+
|
| 349 |
+
Permission to use, copy, modify, and distribute this software and its
|
| 350 |
+
documentation for any purpose and without fee is hereby granted,
|
| 351 |
+
provided that the above copyright notice appear in all copies and that
|
| 352 |
+
both that copyright notice and this permission notice appear in
|
| 353 |
+
supporting documentation, and that the name of Stichting Mathematisch
|
| 354 |
+
Centrum or CWI not be used in advertising or publicity pertaining to
|
| 355 |
+
distribution of the software without specific, written prior
|
| 356 |
+
permission.
|
| 357 |
+
|
| 358 |
+
STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
| 359 |
+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
| 360 |
+
FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
|
| 361 |
+
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 362 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 363 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
| 364 |
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
CPython unicode (https://github.com/python/cpython)
|
| 368 |
+
---------------------------------------------------
|
| 369 |
+
Numba's unicode support includes source code/algorithms from CPython's unicode
|
| 370 |
+
implementation, Numba source code that has a reference starting with:
|
| 371 |
+
|
| 372 |
+
https://github.com/python/cpython/
|
| 373 |
+
|
| 374 |
+
and contains in the path "Objects/unicodeobject.c" relates to use/inclusion of
|
| 375 |
+
CPython source code which has the following license along with the standard
|
| 376 |
+
CPython license:
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
Unicode implementation based on original code by Fredrik Lundh,
|
| 380 |
+
modified by Marc-Andre Lemburg <mal@lemburg.com>.
|
| 381 |
+
|
| 382 |
+
Major speed upgrades to the method implementations at the Reykjavik
|
| 383 |
+
NeedForSpeed sprint, by Fredrik Lundh and Andrew Dalke.
|
| 384 |
+
|
| 385 |
+
Copyright (c) Corporation for National Research Initiatives.
|
| 386 |
+
|
| 387 |
+
--------------------------------------------------------------------
|
| 388 |
+
The original string type implementation is:
|
| 389 |
+
|
| 390 |
+
Copyright (c) 1999 by Secret Labs AB
|
| 391 |
+
Copyright (c) 1999 by Fredrik Lundh
|
| 392 |
+
|
| 393 |
+
By obtaining, using, and/or copying this software and/or its
|
| 394 |
+
associated documentation, you agree that you have read, understood,
|
| 395 |
+
and will comply with the following terms and conditions:
|
| 396 |
+
|
| 397 |
+
Permission to use, copy, modify, and distribute this software and its
|
| 398 |
+
associated documentation for any purpose and without fee is hereby
|
| 399 |
+
granted, provided that the above copyright notice appears in all
|
| 400 |
+
copies, and that both that copyright notice and this permission notice
|
| 401 |
+
appear in supporting documentation, and that the name of Secret Labs
|
| 402 |
+
AB or the author not be used in advertising or publicity pertaining to
|
| 403 |
+
distribution of the software without specific, written prior
|
| 404 |
+
permission.
|
| 405 |
+
|
| 406 |
+
SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
| 407 |
+
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
| 408 |
+
FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR
|
| 409 |
+
ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 410 |
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 411 |
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
| 412 |
+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
| 413 |
+
--------------------------------------------------------------------
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
cloudpickle
|
| 417 |
+
-----------
|
| 418 |
+
|
| 419 |
+
This module was extracted from the `cloud` package, developed by
|
| 420 |
+
PiCloud, Inc.
|
| 421 |
+
|
| 422 |
+
Copyright (c) 2015, Cloudpickle contributors.
|
| 423 |
+
Copyright (c) 2012, Regents of the University of California.
|
| 424 |
+
Copyright (c) 2009 PiCloud, Inc. http://www.picloud.com.
|
| 425 |
+
All rights reserved.
|
| 426 |
+
|
| 427 |
+
Redistribution and use in source and binary forms, with or without
|
| 428 |
+
modification, are permitted provided that the following conditions
|
| 429 |
+
are met:
|
| 430 |
+
* Redistributions of source code must retain the above copyright
|
| 431 |
+
notice, this list of conditions and the following disclaimer.
|
| 432 |
+
* Redistributions in binary form must reproduce the above copyright
|
| 433 |
+
notice, this list of conditions and the following disclaimer in the
|
| 434 |
+
documentation and/or other materials provided with the distribution.
|
| 435 |
+
* Neither the name of the University of California, Berkeley nor the
|
| 436 |
+
names of its contributors may be used to endorse or promote
|
| 437 |
+
products derived from this software without specific prior written
|
| 438 |
+
permission.
|
| 439 |
+
|
| 440 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 441 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 442 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 443 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 444 |
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 445 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
| 446 |
+
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
| 447 |
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
| 448 |
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
| 449 |
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| 450 |
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 451 |
+
© 2020 GitHub, Inc.
|
| 452 |
+
|
| 453 |
+
|
| 454 |
+
NumPy (https://github.com/numpy/numpy)
|
| 455 |
+
--------------------------------------
|
| 456 |
+
Numba source code that references URLs starting with:
|
| 457 |
+
|
| 458 |
+
https://github.com/numpy/numpy
|
| 459 |
+
|
| 460 |
+
relates to use of/inclusion of/derivate work based on NumPy source code which
|
| 461 |
+
has the following license:
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
Copyright (c) 2005-2021, NumPy Developers.
|
| 465 |
+
All rights reserved.
|
| 466 |
+
|
| 467 |
+
Redistribution and use in source and binary forms, with or without
|
| 468 |
+
modification, are permitted provided that the following conditions are
|
| 469 |
+
met:
|
| 470 |
+
|
| 471 |
+
* Redistributions of source code must retain the above copyright
|
| 472 |
+
notice, this list of conditions and the following disclaimer.
|
| 473 |
+
|
| 474 |
+
* Redistributions in binary form must reproduce the above
|
| 475 |
+
copyright notice, this list of conditions and the following
|
| 476 |
+
disclaimer in the documentation and/or other materials provided
|
| 477 |
+
with the distribution.
|
| 478 |
+
|
| 479 |
+
* Neither the name of the NumPy Developers nor the names of any
|
| 480 |
+
contributors may be used to endorse or promote products derived
|
| 481 |
+
from this software without specific prior written permission.
|
| 482 |
+
|
| 483 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 484 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 485 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 486 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 487 |
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 488 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 489 |
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 490 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 491 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 492 |
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 493 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
CUDA Half Precision Headers
|
| 497 |
+
---------------------------
|
| 498 |
+
|
| 499 |
+
The files numba/cuda/cuda_fp16.h and numba/cuda/cuda_fp16.hpp are vendored from
|
| 500 |
+
the CUDA Toolkit version 11.2.2 under the terms of the NVIDIA Software License
|
| 501 |
+
Agreement and CUDA Supplement to Software License Agreement, available at:
|
| 502 |
+
|
| 503 |
+
https://docs.nvidia.com/cuda/archive/11.2.2/eula/index.html
|
| 504 |
+
|
| 505 |
+
These files are distributable as listed in Attachment A:
|
| 506 |
+
|
| 507 |
+
https://docs.nvidia.com/cuda/archive/11.2.2/eula/index.html#attachment-a
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
pythoncapi_compat
|
| 511 |
+
-----------------
|
| 512 |
+
|
| 513 |
+
The file numba/pythoncapi_compat.h is vendored from
|
| 514 |
+
https://github.com/python/pythoncapi_compat under the terms of
|
| 515 |
+
the Zero Clause BSD (0BSD) license, which is available at:
|
| 516 |
+
https://github.com/python/pythoncapi-compat/blob/main/COPYING and its text is
|
| 517 |
+
reproduced below:
|
| 518 |
+
|
| 519 |
+
BSD Zero Clause License
|
| 520 |
+
|
| 521 |
+
Copyright Contributors to the pythoncapi_compat project.
|
| 522 |
+
|
| 523 |
+
Permission to use, copy, modify, and/or distribute this software for any
|
| 524 |
+
purpose with or without fee is hereby granted.
|
| 525 |
+
|
| 526 |
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
| 527 |
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
| 528 |
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
| 529 |
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
| 530 |
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
| 531 |
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
| 532 |
+
PERFORMANCE OF THIS SOFTWARE.
|
| 533 |
+
|
| 534 |
+
numba-cuda
|
| 535 |
+
----------
|
| 536 |
+
Numba source code that references URLs starting with:
|
| 537 |
+
|
| 538 |
+
https://github.com/NVIDIA/numba-cuda
|
| 539 |
+
|
| 540 |
+
relates to use of/inclusion of/derivate work based on numba-cuda source code which
|
| 541 |
+
has the following license:
|
| 542 |
+
|
| 543 |
+
|
| 544 |
+
Copyright (c) 2012, Anaconda, Inc.
|
| 545 |
+
Copyright (c) 2024, NVIDIA CORPORATION.
|
| 546 |
+
All rights reserved.
|
| 547 |
+
|
| 548 |
+
Redistribution and use in source and binary forms, with or without
|
| 549 |
+
modification, are permitted provided that the following conditions are
|
| 550 |
+
met:
|
| 551 |
+
|
| 552 |
+
Redistributions of source code must retain the above copyright notice,
|
| 553 |
+
this list of conditions and the following disclaimer.
|
| 554 |
+
|
| 555 |
+
Redistributions in binary form must reproduce the above copyright
|
| 556 |
+
notice, this list of conditions and the following disclaimer in the
|
| 557 |
+
documentation and/or other materials provided with the distribution.
|
| 558 |
+
|
| 559 |
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| 560 |
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| 561 |
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| 562 |
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
| 563 |
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
| 564 |
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
| 565 |
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
| 566 |
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
| 567 |
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
| 568 |
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 569 |
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/sboms/auditwheel.cdx.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"bomFormat": "CycloneDX", "specVersion": "1.4", "version": 1, "metadata": {"component": {"type": "library", "bom-ref": "pkg:pypi/numba@0.66.0?file_name=numba-0.66.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", "name": "numba", "version": "0.66.0", "purl": "pkg:pypi/numba@0.66.0?file_name=numba-0.66.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl"}, "tools": [{"name": "auditwheel", "version": "6.7.0"}]}, "components": [{"type": "library", "bom-ref": "pkg:pypi/numba@0.66.0?file_name=numba-0.66.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", "name": "numba", "version": "0.66.0", "purl": "pkg:pypi/numba@0.66.0?file_name=numba-0.66.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl"}, {"type": "library", "bom-ref": "pkg:rpm/centos/libgomp@4.8.5-44.el7#c61017c9a24eb6e1e1a3cdc9becd004a6419cbda3d54b4848b98f240a4829571", "name": "libgomp", "version": "4.8.5-44.el7", "purl": "pkg:rpm/centos/libgomp@4.8.5-44.el7"}], "dependencies": [{"ref": "pkg:pypi/numba@0.66.0?file_name=numba-0.66.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", "dependsOn": ["pkg:rpm/centos/libgomp@4.8.5-44.el7#c61017c9a24eb6e1e1a3cdc9becd004a6419cbda3d54b4848b98f240a4829571"]}, {"ref": "pkg:rpm/centos/libgomp@4.8.5-44.el7#c61017c9a24eb6e1e1a3cdc9becd004a6419cbda3d54b4848b98f240a4829571"}]}
|
.venv/lib/python3.11/site-packages/numba-0.66.0.dist-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
numba
|
.venv/lib/python3.11/site-packages/numba/pycc/modulemixin.c
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* This C file is compiled and linked into pycc-generated shared objects.
|
| 3 |
+
* It provides the Numba helper functions for runtime use in pycc-compiled
|
| 4 |
+
* functions.
|
| 5 |
+
*/
|
| 6 |
+
|
| 7 |
+
#include "../_numba_common.h"
|
| 8 |
+
#include "../_pymodule.h"
|
| 9 |
+
|
| 10 |
+
/* Define all runtime-required symbols in this C module, but do not
|
| 11 |
+
export them outside the shared library if possible. */
|
| 12 |
+
|
| 13 |
+
#define NUMBA_EXPORT_FUNC(_rettype) VISIBILITY_HIDDEN _rettype
|
| 14 |
+
#define NUMBA_EXPORT_DATA(_vartype) VISIBILITY_HIDDEN _vartype
|
| 15 |
+
|
| 16 |
+
#define PYCC_COMPILING
|
| 17 |
+
|
| 18 |
+
#include "../_helperlib.c"
|
| 19 |
+
#include "../_dynfunc.c"
|
| 20 |
+
|
| 21 |
+
#if PYCC_USE_NRT
|
| 22 |
+
#include "../core/runtime/_nrt_python.c"
|
| 23 |
+
#include "../core/runtime/nrt.h"
|
| 24 |
+
#endif
|
| 25 |
+
|
| 26 |
+
#if (PY_MAJOR_VERSION == 3) && (PY_MINOR_VERSION >= 12)
|
| 27 |
+
#define Py_BUILD_CORE 1
|
| 28 |
+
#include "internal/pycore_pyhash.h"
|
| 29 |
+
#undef Py_BUILD_CORE
|
| 30 |
+
#endif
|
| 31 |
+
|
| 32 |
+
/* Defines hashsecret variables (see issue #6386) */
|
| 33 |
+
int64_t _numba_hashsecret_siphash_k0;
|
| 34 |
+
int64_t _numba_hashsecret_siphash_k1;
|
| 35 |
+
int64_t _numba_hashsecret_djbx33a_suffix;
|
| 36 |
+
|
| 37 |
+
/* NOTE: import_array() is macro, not a function. It returns NULL on
|
| 38 |
+
failure */
|
| 39 |
+
static void *
|
| 40 |
+
wrap_import_array(void) {
|
| 41 |
+
import_array();
|
| 42 |
+
return (void *) 1;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
static int
|
| 47 |
+
init_numpy(void) {
|
| 48 |
+
return wrap_import_array() != NULL;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
#ifndef PYCC_MODULE_NAME
|
| 53 |
+
#error PYCC_MODULE_NAME must be defined
|
| 54 |
+
#endif
|
| 55 |
+
|
| 56 |
+
/* Preprocessor trick: need to use two levels of macros otherwise
|
| 57 |
+
PYCC_MODULE_NAME would not get expanded */
|
| 58 |
+
#define __PYCC(prefix, modname) prefix ## modname
|
| 59 |
+
#define _PYCC(prefix, modname) __PYCC(prefix, modname)
|
| 60 |
+
#define PYCC(prefix) _PYCC(prefix, PYCC_MODULE_NAME)
|
| 61 |
+
|
| 62 |
+
/* Silence warnings about unused functions */
|
| 63 |
+
VISIBILITY_HIDDEN void **PYCC(_unused_) = {
|
| 64 |
+
(void *) Numba_make_generator,
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
/* The structure type constructed by PythonAPI.serialize_uncached() */
|
| 68 |
+
typedef struct {
|
| 69 |
+
const char *data;
|
| 70 |
+
int len;
|
| 71 |
+
const char *hashbuf;
|
| 72 |
+
const char *func_ptr; // pointer to unwrap dyn args function
|
| 73 |
+
int alloc_flag;
|
| 74 |
+
} env_def_t;
|
| 75 |
+
|
| 76 |
+
/* Environment GlobalVariable address type */
|
| 77 |
+
typedef void **env_gv_t;
|
| 78 |
+
|
| 79 |
+
/*
|
| 80 |
+
* Recreate an environment object from a env_def_t structure.
|
| 81 |
+
*/
|
| 82 |
+
static EnvironmentObject *
|
| 83 |
+
recreate_environment(PyObject *module, env_def_t env)
|
| 84 |
+
{
|
| 85 |
+
EnvironmentObject *envobj;
|
| 86 |
+
PyObject *env_consts;
|
| 87 |
+
|
| 88 |
+
env_consts = numba_unpickle(env.data, env.len, env.hashbuf);
|
| 89 |
+
if (env_consts == NULL)
|
| 90 |
+
return NULL;
|
| 91 |
+
if (!PyList_Check(env_consts)) {
|
| 92 |
+
PyErr_Format(PyExc_TypeError,
|
| 93 |
+
"environment constants should be a list, got '%s'",
|
| 94 |
+
Py_TYPE(env_consts)->tp_name);
|
| 95 |
+
Py_DECREF(env_consts);
|
| 96 |
+
return NULL;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
envobj = env_new_empty(&EnvironmentType);
|
| 100 |
+
if (envobj == NULL) {
|
| 101 |
+
Py_DECREF(env_consts);
|
| 102 |
+
return NULL;
|
| 103 |
+
}
|
| 104 |
+
envobj->consts = env_consts;
|
| 105 |
+
envobj->globals = PyModule_GetDict(module);
|
| 106 |
+
if (envobj->globals == NULL) {
|
| 107 |
+
Py_DECREF(envobj);
|
| 108 |
+
return NULL;
|
| 109 |
+
}
|
| 110 |
+
Py_INCREF(envobj->globals);
|
| 111 |
+
return envobj;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
/*
|
| 115 |
+
* Subroutine to initialize all resources required for running the
|
| 116 |
+
* pycc-compiled functions.
|
| 117 |
+
*/
|
| 118 |
+
|
| 119 |
+
int
|
| 120 |
+
PYCC(pycc_init_) (PyObject *module, PyMethodDef *defs,
|
| 121 |
+
env_def_t *envs,
|
| 122 |
+
env_gv_t *envgvs)
|
| 123 |
+
{
|
| 124 |
+
/* Aligns hashsecret with values in current python process so that
|
| 125 |
+
* hashes computed inside the pycc module are correct if imported
|
| 126 |
+
* by the current process. Imports in a new process get the right
|
| 127 |
+
* hash secret through:
|
| 128 |
+
* `numba.cpython.hashing._load_hashsecret`.
|
| 129 |
+
*/
|
| 130 |
+
_numba_hashsecret_siphash_k0 = _Py_HashSecret.siphash.k0;
|
| 131 |
+
_numba_hashsecret_siphash_k1 = _Py_HashSecret.siphash.k1;
|
| 132 |
+
_numba_hashsecret_djbx33a_suffix = _Py_HashSecret.djbx33a.suffix;
|
| 133 |
+
|
| 134 |
+
PyMethodDef *fdef;
|
| 135 |
+
PyObject *modname = NULL;
|
| 136 |
+
PyObject *docobj = NULL;
|
| 137 |
+
int i;
|
| 138 |
+
|
| 139 |
+
if (!init_numpy()) {
|
| 140 |
+
goto error;
|
| 141 |
+
}
|
| 142 |
+
if (init_dynfunc_module(module)) {
|
| 143 |
+
goto error;
|
| 144 |
+
}
|
| 145 |
+
/* Initialize random generation. */
|
| 146 |
+
numba_rnd_ensure_global_init();
|
| 147 |
+
|
| 148 |
+
#if PYCC_USE_NRT
|
| 149 |
+
NRT_MemSys_init();
|
| 150 |
+
if (init_nrt_python_module(module)) {
|
| 151 |
+
goto error;
|
| 152 |
+
}
|
| 153 |
+
#endif
|
| 154 |
+
|
| 155 |
+
modname = PyObject_GetAttrString(module, "__name__");
|
| 156 |
+
if (modname == NULL) {
|
| 157 |
+
goto error;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
/* Empty docstring for all compiled functions */
|
| 161 |
+
docobj = PyString_FromString("");
|
| 162 |
+
if (docobj == NULL) {
|
| 163 |
+
goto error;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
/* Overwrite C method objects with our own Closure objects, in order
|
| 167 |
+
* to make their environments available to the compiled functions.
|
| 168 |
+
*/
|
| 169 |
+
for (i = 0, fdef = defs; fdef->ml_name != NULL; i++, fdef++) {
|
| 170 |
+
PyObject *func;
|
| 171 |
+
PyObject *nameobj;
|
| 172 |
+
EnvironmentObject *envobj;
|
| 173 |
+
|
| 174 |
+
envobj = recreate_environment(module, envs[i]);
|
| 175 |
+
if (envobj == NULL) {
|
| 176 |
+
goto error;
|
| 177 |
+
}
|
| 178 |
+
nameobj = PyString_FromString(fdef->ml_name);
|
| 179 |
+
if (nameobj == NULL) {
|
| 180 |
+
Py_DECREF(envobj);
|
| 181 |
+
goto error;
|
| 182 |
+
}
|
| 183 |
+
// Store the environment pointer into the global
|
| 184 |
+
*envgvs[i] = envobj;
|
| 185 |
+
|
| 186 |
+
func = pycfunction_new(module, nameobj, docobj,
|
| 187 |
+
fdef->ml_meth, envobj, NULL);
|
| 188 |
+
Py_DECREF(envobj);
|
| 189 |
+
Py_DECREF(nameobj);
|
| 190 |
+
|
| 191 |
+
if (func == NULL) {
|
| 192 |
+
goto error;
|
| 193 |
+
}
|
| 194 |
+
if (PyObject_SetAttrString(module, fdef->ml_name, func)) {
|
| 195 |
+
Py_DECREF(func);
|
| 196 |
+
goto error;
|
| 197 |
+
}
|
| 198 |
+
Py_DECREF(func);
|
| 199 |
+
}
|
| 200 |
+
/* Recreate other environment objects
|
| 201 |
+
envgvs is expected to end with a NULL pointer.
|
| 202 |
+
*/
|
| 203 |
+
for (; envgvs[i]; ++i) {
|
| 204 |
+
EnvironmentObject *envobj;
|
| 205 |
+
envobj = recreate_environment(module, envs[i]);
|
| 206 |
+
if (envobj == NULL) {
|
| 207 |
+
goto error;
|
| 208 |
+
}
|
| 209 |
+
// Store the environment pointer into the global
|
| 210 |
+
*envgvs[i] = envobj;
|
| 211 |
+
Py_DECREF(envobj);
|
| 212 |
+
}
|
| 213 |
+
Py_DECREF(docobj);
|
| 214 |
+
Py_DECREF(modname);
|
| 215 |
+
return 0;
|
| 216 |
+
|
| 217 |
+
error:
|
| 218 |
+
Py_XDECREF(docobj);
|
| 219 |
+
Py_XDECREF(modname);
|
| 220 |
+
return -1;
|
| 221 |
+
}
|
.venv/lib/python3.11/site-packages/numba/pycc/platform.py
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import setuptools
|
| 2 |
+
from setuptools.command.build_ext import build_ext
|
| 3 |
+
from setuptools.dist import Distribution
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
import functools
|
| 7 |
+
import os
|
| 8 |
+
import subprocess
|
| 9 |
+
import sys
|
| 10 |
+
from tempfile import mkdtemp
|
| 11 |
+
from contextlib import contextmanager
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
# Wire in distutils components from setuptools
|
| 15 |
+
CCompiler = setuptools.distutils.ccompiler.CCompiler
|
| 16 |
+
new_compiler = setuptools.distutils.ccompiler.new_compiler
|
| 17 |
+
customize_compiler = setuptools.distutils.sysconfig.customize_compiler
|
| 18 |
+
log = setuptools.distutils.log
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
_configs = {
|
| 22 |
+
# DLL suffix, Python C extension suffix
|
| 23 |
+
'win': ('.dll', '.pyd'),
|
| 24 |
+
'default': ('.so', '.so'),
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def get_configs(arg):
|
| 29 |
+
return _configs.get(sys.platform[:3], _configs['default'])[arg]
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
find_shared_ending = functools.partial(get_configs, 0)
|
| 33 |
+
find_pyext_ending = functools.partial(get_configs, 1)
|
| 34 |
+
|
| 35 |
+
@contextmanager
|
| 36 |
+
def _gentmpfile(suffix):
|
| 37 |
+
# windows locks the tempfile so use a tempdir + file, see
|
| 38 |
+
# https://github.com/numba/numba/issues/3304
|
| 39 |
+
try:
|
| 40 |
+
tmpdir = mkdtemp()
|
| 41 |
+
ntf = open(os.path.join(tmpdir, "temp%s" % suffix), 'wt')
|
| 42 |
+
yield ntf
|
| 43 |
+
finally:
|
| 44 |
+
try:
|
| 45 |
+
ntf.close()
|
| 46 |
+
os.remove(ntf)
|
| 47 |
+
except Exception:
|
| 48 |
+
pass
|
| 49 |
+
else:
|
| 50 |
+
os.rmdir(tmpdir)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
@functools.lru_cache(maxsize=1)
|
| 54 |
+
def external_compiler_works():
|
| 55 |
+
"""
|
| 56 |
+
Returns True if the "external compiler" bound in numpy.distutil is present
|
| 57 |
+
and working, False otherwise.
|
| 58 |
+
"""
|
| 59 |
+
compiler = new_compiler()
|
| 60 |
+
customize_compiler(compiler)
|
| 61 |
+
for suffix in ['.c', '.cxx']:
|
| 62 |
+
try:
|
| 63 |
+
with _gentmpfile(suffix) as ntf:
|
| 64 |
+
simple_c = "int main(void) { return 0; }"
|
| 65 |
+
ntf.write(simple_c)
|
| 66 |
+
ntf.flush()
|
| 67 |
+
ntf.close()
|
| 68 |
+
# *output_dir* is set to avoid the compiler putting temp files
|
| 69 |
+
# in the current directory.
|
| 70 |
+
compiler.compile([ntf.name], output_dir=Path(ntf.name).anchor)
|
| 71 |
+
except Exception: # likely CompileError or file system issue
|
| 72 |
+
return False
|
| 73 |
+
return True
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class _DummyExtension(object):
|
| 77 |
+
libraries = []
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
class Toolchain(object):
|
| 81 |
+
|
| 82 |
+
def __init__(self):
|
| 83 |
+
if not external_compiler_works():
|
| 84 |
+
self._raise_external_compiler_error()
|
| 85 |
+
|
| 86 |
+
self._verbose = False
|
| 87 |
+
self._compiler = new_compiler()
|
| 88 |
+
customize_compiler(self._compiler)
|
| 89 |
+
self._build_ext = build_ext(Distribution())
|
| 90 |
+
self._build_ext.finalize_options()
|
| 91 |
+
self._py_lib_dirs = self._build_ext.library_dirs
|
| 92 |
+
self._py_include_dirs = self._build_ext.include_dirs
|
| 93 |
+
np_compile_args = {'include_dirs': [np.get_include(),],}
|
| 94 |
+
if sys.platform == 'win32':
|
| 95 |
+
np_compile_args['libraries'] = []
|
| 96 |
+
else:
|
| 97 |
+
np_compile_args['libraries'] = ['m',]
|
| 98 |
+
self._math_info = np_compile_args
|
| 99 |
+
|
| 100 |
+
@property
|
| 101 |
+
def verbose(self):
|
| 102 |
+
return self._verbose
|
| 103 |
+
|
| 104 |
+
@verbose.setter
|
| 105 |
+
def verbose(self, value):
|
| 106 |
+
self._verbose = value
|
| 107 |
+
# DEBUG will let Numpy spew many messages, so stick to INFO
|
| 108 |
+
# to print commands executed by distutils
|
| 109 |
+
log.set_threshold(log.INFO if value else log.WARN)
|
| 110 |
+
|
| 111 |
+
def _raise_external_compiler_error(self):
|
| 112 |
+
basemsg = ("Attempted to compile AOT function without the "
|
| 113 |
+
"compiler used by `numpy.distutils` present.")
|
| 114 |
+
conda_msg = "If using conda try:\n\n#> conda install %s"
|
| 115 |
+
plt = sys.platform
|
| 116 |
+
if plt.startswith('linux'):
|
| 117 |
+
if sys.maxsize <= 2 ** 32:
|
| 118 |
+
compilers = ['gcc_linux-32', 'gxx_linux-32']
|
| 119 |
+
else:
|
| 120 |
+
compilers = ['gcc_linux-64', 'gxx_linux-64']
|
| 121 |
+
msg = "%s %s" % (basemsg, conda_msg % ' '.join(compilers))
|
| 122 |
+
elif plt.startswith('darwin'):
|
| 123 |
+
compilers = ['clang_osx-64', 'clangxx_osx-64']
|
| 124 |
+
msg = "%s %s" % (basemsg, conda_msg % ' '.join(compilers))
|
| 125 |
+
elif plt.startswith('win32'):
|
| 126 |
+
winmsg = "Cannot find suitable msvc."
|
| 127 |
+
msg = "%s %s" % (basemsg, winmsg)
|
| 128 |
+
else:
|
| 129 |
+
msg = "Unknown platform %s" % plt
|
| 130 |
+
raise RuntimeError(msg)
|
| 131 |
+
|
| 132 |
+
def compile_objects(self, sources, output_dir,
|
| 133 |
+
include_dirs=(), depends=(), macros=(),
|
| 134 |
+
extra_cflags=None):
|
| 135 |
+
"""
|
| 136 |
+
Compile the given source files into a separate object file each,
|
| 137 |
+
all beneath the *output_dir*. A list of paths to object files
|
| 138 |
+
is returned.
|
| 139 |
+
|
| 140 |
+
*macros* has the same format as in distutils: a list of 1- or 2-tuples.
|
| 141 |
+
If a 1-tuple (name,), the given name is considered undefined by
|
| 142 |
+
the C preprocessor.
|
| 143 |
+
If a 2-tuple (name, value), the given name is expanded into the
|
| 144 |
+
given value by the C preprocessor.
|
| 145 |
+
"""
|
| 146 |
+
objects = self._compiler.compile(sources,
|
| 147 |
+
output_dir=output_dir,
|
| 148 |
+
include_dirs=include_dirs,
|
| 149 |
+
depends=depends,
|
| 150 |
+
macros=macros or [],
|
| 151 |
+
extra_preargs=extra_cflags)
|
| 152 |
+
return objects
|
| 153 |
+
|
| 154 |
+
def link_shared(self, output, objects, libraries=(),
|
| 155 |
+
library_dirs=(), export_symbols=(),
|
| 156 |
+
extra_ldflags=None):
|
| 157 |
+
"""
|
| 158 |
+
Create a shared library *output* linking the given *objects*
|
| 159 |
+
and *libraries* (all strings).
|
| 160 |
+
"""
|
| 161 |
+
output_dir, output_filename = os.path.split(output)
|
| 162 |
+
self._compiler.link(CCompiler.SHARED_OBJECT, objects,
|
| 163 |
+
output_filename, output_dir,
|
| 164 |
+
libraries, library_dirs,
|
| 165 |
+
export_symbols=export_symbols,
|
| 166 |
+
extra_preargs=extra_ldflags)
|
| 167 |
+
|
| 168 |
+
def get_python_libraries(self):
|
| 169 |
+
"""
|
| 170 |
+
Get the library arguments necessary to link with Python.
|
| 171 |
+
"""
|
| 172 |
+
libs = self._build_ext.get_libraries(_DummyExtension())
|
| 173 |
+
if sys.platform == 'win32':
|
| 174 |
+
# Under Windows, need to link explicitly against the CRT,
|
| 175 |
+
# as the MSVC compiler would implicitly do.
|
| 176 |
+
# (XXX msvcrtd in pydebug mode?)
|
| 177 |
+
libs = libs + ['msvcrt']
|
| 178 |
+
return libs + self._math_info['libraries']
|
| 179 |
+
|
| 180 |
+
def get_python_library_dirs(self):
|
| 181 |
+
"""
|
| 182 |
+
Get the library directories necessary to link with Python.
|
| 183 |
+
"""
|
| 184 |
+
return list(self._py_lib_dirs)
|
| 185 |
+
|
| 186 |
+
def get_python_include_dirs(self):
|
| 187 |
+
"""
|
| 188 |
+
Get the include directories necessary to compile against the Python
|
| 189 |
+
and Numpy C APIs.
|
| 190 |
+
"""
|
| 191 |
+
return list(self._py_include_dirs) + self._math_info['include_dirs']
|
| 192 |
+
|
| 193 |
+
def get_ext_filename(self, ext_name):
|
| 194 |
+
"""
|
| 195 |
+
Given a C extension's module name, return its intended filename.
|
| 196 |
+
"""
|
| 197 |
+
return self._build_ext.get_ext_filename(ext_name)
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def _quote_arg(arg):
|
| 201 |
+
"""
|
| 202 |
+
Quote the argument for safe use in a shell command line.
|
| 203 |
+
"""
|
| 204 |
+
# If there is a quote in the string, assume relevants parts of the
|
| 205 |
+
# string are already quoted (e.g. '-I"C:\\Program Files\\..."')
|
| 206 |
+
if '"' not in arg and ' ' in arg:
|
| 207 |
+
return '"%s"' % arg
|
| 208 |
+
return arg
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def _is_sequence(arg):
|
| 212 |
+
if isinstance(arg, (str, bytes)):
|
| 213 |
+
return False
|
| 214 |
+
try:
|
| 215 |
+
len(arg)
|
| 216 |
+
return True
|
| 217 |
+
except Exception:
|
| 218 |
+
return False
|
.venv/lib/python3.11/site-packages/numba/pythoncapi_compat.h
ADDED
|
@@ -0,0 +1,1696 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Header file providing new C API functions to old Python versions.
|
| 2 |
+
//
|
| 3 |
+
// File distributed under the Zero Clause BSD (0BSD) license.
|
| 4 |
+
// Copyright Contributors to the pythoncapi_compat project.
|
| 5 |
+
//
|
| 6 |
+
// Homepage:
|
| 7 |
+
// https://github.com/python/pythoncapi_compat
|
| 8 |
+
//
|
| 9 |
+
// Latest version:
|
| 10 |
+
// https://raw.githubusercontent.com/python/pythoncapi-compat/0041177c4f348c8952b4c8980b2c90856e61c7c7/pythoncapi_compat.h
|
| 11 |
+
//
|
| 12 |
+
// SPDX-License-Identifier: 0BSD
|
| 13 |
+
|
| 14 |
+
#ifndef PYTHONCAPI_COMPAT
|
| 15 |
+
#define PYTHONCAPI_COMPAT
|
| 16 |
+
|
| 17 |
+
#ifdef __cplusplus
|
| 18 |
+
extern "C" {
|
| 19 |
+
#endif
|
| 20 |
+
|
| 21 |
+
#include <Python.h>
|
| 22 |
+
|
| 23 |
+
// Python 3.11.0b4 added PyFrame_Back() to Python.h
|
| 24 |
+
#if PY_VERSION_HEX < 0x030b00B4 && !defined(PYPY_VERSION)
|
| 25 |
+
# include "frameobject.h" // PyFrameObject, PyFrame_GetBack()
|
| 26 |
+
#endif
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
#ifndef _Py_CAST
|
| 30 |
+
# define _Py_CAST(type, expr) ((type)(expr))
|
| 31 |
+
#endif
|
| 32 |
+
|
| 33 |
+
// Static inline functions should use _Py_NULL rather than using directly NULL
|
| 34 |
+
// to prevent C++ compiler warnings. On C23 and newer and on C++11 and newer,
|
| 35 |
+
// _Py_NULL is defined as nullptr.
|
| 36 |
+
#if (defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L) \
|
| 37 |
+
|| (defined(__cplusplus) && __cplusplus >= 201103)
|
| 38 |
+
# define _Py_NULL nullptr
|
| 39 |
+
#else
|
| 40 |
+
# define _Py_NULL NULL
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
// Cast argument to PyObject* type.
|
| 44 |
+
#ifndef _PyObject_CAST
|
| 45 |
+
# define _PyObject_CAST(op) _Py_CAST(PyObject*, op)
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
#ifndef Py_BUILD_ASSERT
|
| 49 |
+
# define Py_BUILD_ASSERT(cond) \
|
| 50 |
+
do { \
|
| 51 |
+
(void)sizeof(char [1 - 2 * !(cond)]); \
|
| 52 |
+
} while(0)
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
// bpo-42262 added Py_NewRef() to Python 3.10.0a3
|
| 57 |
+
#if PY_VERSION_HEX < 0x030A00A3 && !defined(Py_NewRef)
|
| 58 |
+
static inline PyObject* _Py_NewRef(PyObject *obj)
|
| 59 |
+
{
|
| 60 |
+
Py_INCREF(obj);
|
| 61 |
+
return obj;
|
| 62 |
+
}
|
| 63 |
+
#define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
// bpo-42262 added Py_XNewRef() to Python 3.10.0a3
|
| 68 |
+
#if PY_VERSION_HEX < 0x030A00A3 && !defined(Py_XNewRef)
|
| 69 |
+
static inline PyObject* _Py_XNewRef(PyObject *obj)
|
| 70 |
+
{
|
| 71 |
+
Py_XINCREF(obj);
|
| 72 |
+
return obj;
|
| 73 |
+
}
|
| 74 |
+
#define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
|
| 75 |
+
#endif
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
// bpo-39573 added Py_SET_REFCNT() to Python 3.9.0a4
|
| 79 |
+
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_REFCNT)
|
| 80 |
+
static inline void _Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt)
|
| 81 |
+
{
|
| 82 |
+
ob->ob_refcnt = refcnt;
|
| 83 |
+
}
|
| 84 |
+
#define Py_SET_REFCNT(ob, refcnt) _Py_SET_REFCNT(_PyObject_CAST(ob), refcnt)
|
| 85 |
+
#endif
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
// Py_SETREF() and Py_XSETREF() were added to Python 3.5.2.
|
| 89 |
+
// It is excluded from the limited C API.
|
| 90 |
+
#if (PY_VERSION_HEX < 0x03050200 && !defined(Py_SETREF)) && !defined(Py_LIMITED_API)
|
| 91 |
+
#define Py_SETREF(dst, src) \
|
| 92 |
+
do { \
|
| 93 |
+
PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \
|
| 94 |
+
PyObject *_tmp_dst = (*_tmp_dst_ptr); \
|
| 95 |
+
*_tmp_dst_ptr = _PyObject_CAST(src); \
|
| 96 |
+
Py_DECREF(_tmp_dst); \
|
| 97 |
+
} while (0)
|
| 98 |
+
|
| 99 |
+
#define Py_XSETREF(dst, src) \
|
| 100 |
+
do { \
|
| 101 |
+
PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \
|
| 102 |
+
PyObject *_tmp_dst = (*_tmp_dst_ptr); \
|
| 103 |
+
*_tmp_dst_ptr = _PyObject_CAST(src); \
|
| 104 |
+
Py_XDECREF(_tmp_dst); \
|
| 105 |
+
} while (0)
|
| 106 |
+
#endif
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
// bpo-43753 added Py_Is(), Py_IsNone(), Py_IsTrue() and Py_IsFalse()
|
| 110 |
+
// to Python 3.10.0b1.
|
| 111 |
+
#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_Is)
|
| 112 |
+
# define Py_Is(x, y) ((x) == (y))
|
| 113 |
+
#endif
|
| 114 |
+
#if PY_VERSION_HEX < 0x030A00B1 && !defined(Py_IsNone)
|
| 115 |
+
# define Py_IsNone(x) Py_Is(x, Py_None)
|
| 116 |
+
#endif
|
| 117 |
+
#if (PY_VERSION_HEX < 0x030A00B1 || defined(PYPY_VERSION)) && !defined(Py_IsTrue)
|
| 118 |
+
# define Py_IsTrue(x) Py_Is(x, Py_True)
|
| 119 |
+
#endif
|
| 120 |
+
#if (PY_VERSION_HEX < 0x030A00B1 || defined(PYPY_VERSION)) && !defined(Py_IsFalse)
|
| 121 |
+
# define Py_IsFalse(x) Py_Is(x, Py_False)
|
| 122 |
+
#endif
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
// bpo-39573 added Py_SET_TYPE() to Python 3.9.0a4
|
| 126 |
+
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
|
| 127 |
+
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
|
| 128 |
+
{
|
| 129 |
+
ob->ob_type = type;
|
| 130 |
+
}
|
| 131 |
+
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE(_PyObject_CAST(ob), type)
|
| 132 |
+
#endif
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
// bpo-39573 added Py_SET_SIZE() to Python 3.9.0a4
|
| 136 |
+
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_SIZE)
|
| 137 |
+
static inline void _Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)
|
| 138 |
+
{
|
| 139 |
+
ob->ob_size = size;
|
| 140 |
+
}
|
| 141 |
+
#define Py_SET_SIZE(ob, size) _Py_SET_SIZE((PyVarObject*)(ob), size)
|
| 142 |
+
#endif
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
// bpo-40421 added PyFrame_GetCode() to Python 3.9.0b1
|
| 146 |
+
#if PY_VERSION_HEX < 0x030900B1 || defined(PYPY_VERSION)
|
| 147 |
+
static inline PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
|
| 148 |
+
{
|
| 149 |
+
assert(frame != _Py_NULL);
|
| 150 |
+
assert(frame->f_code != _Py_NULL);
|
| 151 |
+
return _Py_CAST(PyCodeObject*, Py_NewRef(frame->f_code));
|
| 152 |
+
}
|
| 153 |
+
#endif
|
| 154 |
+
|
| 155 |
+
static inline PyCodeObject* _PyFrame_GetCodeBorrow(PyFrameObject *frame)
|
| 156 |
+
{
|
| 157 |
+
PyCodeObject *code = PyFrame_GetCode(frame);
|
| 158 |
+
Py_DECREF(code);
|
| 159 |
+
return code;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
// bpo-40421 added PyFrame_GetBack() to Python 3.9.0b1
|
| 164 |
+
#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
|
| 165 |
+
static inline PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
|
| 166 |
+
{
|
| 167 |
+
assert(frame != _Py_NULL);
|
| 168 |
+
return _Py_CAST(PyFrameObject*, Py_XNewRef(frame->f_back));
|
| 169 |
+
}
|
| 170 |
+
#endif
|
| 171 |
+
|
| 172 |
+
#if !defined(PYPY_VERSION)
|
| 173 |
+
static inline PyFrameObject* _PyFrame_GetBackBorrow(PyFrameObject *frame)
|
| 174 |
+
{
|
| 175 |
+
PyFrameObject *back = PyFrame_GetBack(frame);
|
| 176 |
+
Py_XDECREF(back);
|
| 177 |
+
return back;
|
| 178 |
+
}
|
| 179 |
+
#endif
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
// bpo-40421 added PyFrame_GetLocals() to Python 3.11.0a7
|
| 183 |
+
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
|
| 184 |
+
static inline PyObject* PyFrame_GetLocals(PyFrameObject *frame)
|
| 185 |
+
{
|
| 186 |
+
#if PY_VERSION_HEX >= 0x030400B1
|
| 187 |
+
if (PyFrame_FastToLocalsWithError(frame) < 0) {
|
| 188 |
+
return NULL;
|
| 189 |
+
}
|
| 190 |
+
#else
|
| 191 |
+
PyFrame_FastToLocals(frame);
|
| 192 |
+
#endif
|
| 193 |
+
return Py_NewRef(frame->f_locals);
|
| 194 |
+
}
|
| 195 |
+
#endif
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
// bpo-40421 added PyFrame_GetGlobals() to Python 3.11.0a7
|
| 199 |
+
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
|
| 200 |
+
static inline PyObject* PyFrame_GetGlobals(PyFrameObject *frame)
|
| 201 |
+
{
|
| 202 |
+
return Py_NewRef(frame->f_globals);
|
| 203 |
+
}
|
| 204 |
+
#endif
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
// bpo-40421 added PyFrame_GetBuiltins() to Python 3.11.0a7
|
| 208 |
+
#if PY_VERSION_HEX < 0x030B00A7 && !defined(PYPY_VERSION)
|
| 209 |
+
static inline PyObject* PyFrame_GetBuiltins(PyFrameObject *frame)
|
| 210 |
+
{
|
| 211 |
+
return Py_NewRef(frame->f_builtins);
|
| 212 |
+
}
|
| 213 |
+
#endif
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
// bpo-40421 added PyFrame_GetLasti() to Python 3.11.0b1
|
| 217 |
+
#if PY_VERSION_HEX < 0x030B00B1 && !defined(PYPY_VERSION)
|
| 218 |
+
static inline int PyFrame_GetLasti(PyFrameObject *frame)
|
| 219 |
+
{
|
| 220 |
+
#if PY_VERSION_HEX >= 0x030A00A7
|
| 221 |
+
// bpo-27129: Since Python 3.10.0a7, f_lasti is an instruction offset,
|
| 222 |
+
// not a bytes offset anymore. Python uses 16-bit "wordcode" (2 bytes)
|
| 223 |
+
// instructions.
|
| 224 |
+
if (frame->f_lasti < 0) {
|
| 225 |
+
return -1;
|
| 226 |
+
}
|
| 227 |
+
return frame->f_lasti * 2;
|
| 228 |
+
#else
|
| 229 |
+
return frame->f_lasti;
|
| 230 |
+
#endif
|
| 231 |
+
}
|
| 232 |
+
#endif
|
| 233 |
+
|
| 234 |
+
|
| 235 |
+
// gh-91248 added PyFrame_GetVar() to Python 3.12.0a2
|
| 236 |
+
#if PY_VERSION_HEX < 0x030C00A2 && !defined(PYPY_VERSION)
|
| 237 |
+
static inline PyObject* PyFrame_GetVar(PyFrameObject *frame, PyObject *name)
|
| 238 |
+
{
|
| 239 |
+
PyObject *locals, *value;
|
| 240 |
+
|
| 241 |
+
locals = PyFrame_GetLocals(frame);
|
| 242 |
+
if (locals == NULL) {
|
| 243 |
+
return NULL;
|
| 244 |
+
}
|
| 245 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 246 |
+
value = PyDict_GetItemWithError(locals, name);
|
| 247 |
+
#else
|
| 248 |
+
value = _PyDict_GetItemWithError(locals, name);
|
| 249 |
+
#endif
|
| 250 |
+
Py_DECREF(locals);
|
| 251 |
+
|
| 252 |
+
if (value == NULL) {
|
| 253 |
+
if (PyErr_Occurred()) {
|
| 254 |
+
return NULL;
|
| 255 |
+
}
|
| 256 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 257 |
+
PyErr_Format(PyExc_NameError, "variable %R does not exist", name);
|
| 258 |
+
#else
|
| 259 |
+
PyErr_SetString(PyExc_NameError, "variable does not exist");
|
| 260 |
+
#endif
|
| 261 |
+
return NULL;
|
| 262 |
+
}
|
| 263 |
+
return Py_NewRef(value);
|
| 264 |
+
}
|
| 265 |
+
#endif
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
// gh-91248 added PyFrame_GetVarString() to Python 3.12.0a2
|
| 269 |
+
#if PY_VERSION_HEX < 0x030C00A2 && !defined(PYPY_VERSION)
|
| 270 |
+
static inline PyObject*
|
| 271 |
+
PyFrame_GetVarString(PyFrameObject *frame, const char *name)
|
| 272 |
+
{
|
| 273 |
+
PyObject *name_obj, *value;
|
| 274 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 275 |
+
name_obj = PyUnicode_FromString(name);
|
| 276 |
+
#else
|
| 277 |
+
name_obj = PyString_FromString(name);
|
| 278 |
+
#endif
|
| 279 |
+
if (name_obj == NULL) {
|
| 280 |
+
return NULL;
|
| 281 |
+
}
|
| 282 |
+
value = PyFrame_GetVar(frame, name_obj);
|
| 283 |
+
Py_DECREF(name_obj);
|
| 284 |
+
return value;
|
| 285 |
+
}
|
| 286 |
+
#endif
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
// bpo-39947 added PyThreadState_GetInterpreter() to Python 3.9.0a5
|
| 290 |
+
#if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION)
|
| 291 |
+
static inline PyInterpreterState *
|
| 292 |
+
PyThreadState_GetInterpreter(PyThreadState *tstate)
|
| 293 |
+
{
|
| 294 |
+
assert(tstate != _Py_NULL);
|
| 295 |
+
return tstate->interp;
|
| 296 |
+
}
|
| 297 |
+
#endif
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
// bpo-40429 added PyThreadState_GetFrame() to Python 3.9.0b1
|
| 301 |
+
#if PY_VERSION_HEX < 0x030900B1 && !defined(PYPY_VERSION)
|
| 302 |
+
static inline PyFrameObject* PyThreadState_GetFrame(PyThreadState *tstate)
|
| 303 |
+
{
|
| 304 |
+
assert(tstate != _Py_NULL);
|
| 305 |
+
return _Py_CAST(PyFrameObject *, Py_XNewRef(tstate->frame));
|
| 306 |
+
}
|
| 307 |
+
#endif
|
| 308 |
+
|
| 309 |
+
#if !defined(PYPY_VERSION)
|
| 310 |
+
static inline PyFrameObject*
|
| 311 |
+
_PyThreadState_GetFrameBorrow(PyThreadState *tstate)
|
| 312 |
+
{
|
| 313 |
+
PyFrameObject *frame = PyThreadState_GetFrame(tstate);
|
| 314 |
+
Py_XDECREF(frame);
|
| 315 |
+
return frame;
|
| 316 |
+
}
|
| 317 |
+
#endif
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
// bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a5
|
| 321 |
+
#if PY_VERSION_HEX < 0x030900A5 || defined(PYPY_VERSION)
|
| 322 |
+
static inline PyInterpreterState* PyInterpreterState_Get(void)
|
| 323 |
+
{
|
| 324 |
+
PyThreadState *tstate;
|
| 325 |
+
PyInterpreterState *interp;
|
| 326 |
+
|
| 327 |
+
tstate = PyThreadState_GET();
|
| 328 |
+
if (tstate == _Py_NULL) {
|
| 329 |
+
Py_FatalError("GIL released (tstate is NULL)");
|
| 330 |
+
}
|
| 331 |
+
interp = tstate->interp;
|
| 332 |
+
if (interp == _Py_NULL) {
|
| 333 |
+
Py_FatalError("no current interpreter");
|
| 334 |
+
}
|
| 335 |
+
return interp;
|
| 336 |
+
}
|
| 337 |
+
#endif
|
| 338 |
+
|
| 339 |
+
|
| 340 |
+
// bpo-39947 added PyInterpreterState_Get() to Python 3.9.0a6
|
| 341 |
+
#if 0x030700A1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
|
| 342 |
+
static inline uint64_t PyThreadState_GetID(PyThreadState *tstate)
|
| 343 |
+
{
|
| 344 |
+
assert(tstate != _Py_NULL);
|
| 345 |
+
return tstate->id;
|
| 346 |
+
}
|
| 347 |
+
#endif
|
| 348 |
+
|
| 349 |
+
// bpo-43760 added PyThreadState_EnterTracing() to Python 3.11.0a2
|
| 350 |
+
#if PY_VERSION_HEX < 0x030B00A2 && !defined(PYPY_VERSION)
|
| 351 |
+
static inline void PyThreadState_EnterTracing(PyThreadState *tstate)
|
| 352 |
+
{
|
| 353 |
+
tstate->tracing++;
|
| 354 |
+
#if PY_VERSION_HEX >= 0x030A00A1
|
| 355 |
+
tstate->cframe->use_tracing = 0;
|
| 356 |
+
#else
|
| 357 |
+
tstate->use_tracing = 0;
|
| 358 |
+
#endif
|
| 359 |
+
}
|
| 360 |
+
#endif
|
| 361 |
+
|
| 362 |
+
// bpo-43760 added PyThreadState_LeaveTracing() to Python 3.11.0a2
|
| 363 |
+
#if PY_VERSION_HEX < 0x030B00A2 && !defined(PYPY_VERSION)
|
| 364 |
+
static inline void PyThreadState_LeaveTracing(PyThreadState *tstate)
|
| 365 |
+
{
|
| 366 |
+
int use_tracing = (tstate->c_tracefunc != _Py_NULL
|
| 367 |
+
|| tstate->c_profilefunc != _Py_NULL);
|
| 368 |
+
tstate->tracing--;
|
| 369 |
+
#if PY_VERSION_HEX >= 0x030A00A1
|
| 370 |
+
tstate->cframe->use_tracing = use_tracing;
|
| 371 |
+
#else
|
| 372 |
+
tstate->use_tracing = use_tracing;
|
| 373 |
+
#endif
|
| 374 |
+
}
|
| 375 |
+
#endif
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
// bpo-37194 added PyObject_CallNoArgs() to Python 3.9.0a1
|
| 379 |
+
// PyObject_CallNoArgs() added to PyPy 3.9.16-v7.3.11
|
| 380 |
+
#if !defined(PyObject_CallNoArgs) && PY_VERSION_HEX < 0x030900A1
|
| 381 |
+
static inline PyObject* PyObject_CallNoArgs(PyObject *func)
|
| 382 |
+
{
|
| 383 |
+
return PyObject_CallFunctionObjArgs(func, NULL);
|
| 384 |
+
}
|
| 385 |
+
#endif
|
| 386 |
+
|
| 387 |
+
|
| 388 |
+
// bpo-39245 made PyObject_CallOneArg() public (previously called
|
| 389 |
+
// _PyObject_CallOneArg) in Python 3.9.0a4
|
| 390 |
+
// PyObject_CallOneArg() added to PyPy 3.9.16-v7.3.11
|
| 391 |
+
#if !defined(PyObject_CallOneArg) && PY_VERSION_HEX < 0x030900A4
|
| 392 |
+
static inline PyObject* PyObject_CallOneArg(PyObject *func, PyObject *arg)
|
| 393 |
+
{
|
| 394 |
+
return PyObject_CallFunctionObjArgs(func, arg, NULL);
|
| 395 |
+
}
|
| 396 |
+
#endif
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
// bpo-1635741 added PyModule_AddObjectRef() to Python 3.10.0a3
|
| 400 |
+
#if PY_VERSION_HEX < 0x030A00A3
|
| 401 |
+
static inline int
|
| 402 |
+
PyModule_AddObjectRef(PyObject *module, const char *name, PyObject *value)
|
| 403 |
+
{
|
| 404 |
+
int res;
|
| 405 |
+
|
| 406 |
+
if (!value && !PyErr_Occurred()) {
|
| 407 |
+
// PyModule_AddObject() raises TypeError in this case
|
| 408 |
+
PyErr_SetString(PyExc_SystemError,
|
| 409 |
+
"PyModule_AddObjectRef() must be called "
|
| 410 |
+
"with an exception raised if value is NULL");
|
| 411 |
+
return -1;
|
| 412 |
+
}
|
| 413 |
+
|
| 414 |
+
Py_XINCREF(value);
|
| 415 |
+
res = PyModule_AddObject(module, name, value);
|
| 416 |
+
if (res < 0) {
|
| 417 |
+
Py_XDECREF(value);
|
| 418 |
+
}
|
| 419 |
+
return res;
|
| 420 |
+
}
|
| 421 |
+
#endif
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
// bpo-40024 added PyModule_AddType() to Python 3.9.0a5
|
| 425 |
+
#if PY_VERSION_HEX < 0x030900A5
|
| 426 |
+
static inline int PyModule_AddType(PyObject *module, PyTypeObject *type)
|
| 427 |
+
{
|
| 428 |
+
const char *name, *dot;
|
| 429 |
+
|
| 430 |
+
if (PyType_Ready(type) < 0) {
|
| 431 |
+
return -1;
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
// inline _PyType_Name()
|
| 435 |
+
name = type->tp_name;
|
| 436 |
+
assert(name != _Py_NULL);
|
| 437 |
+
dot = strrchr(name, '.');
|
| 438 |
+
if (dot != _Py_NULL) {
|
| 439 |
+
name = dot + 1;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
return PyModule_AddObjectRef(module, name, _PyObject_CAST(type));
|
| 443 |
+
}
|
| 444 |
+
#endif
|
| 445 |
+
|
| 446 |
+
|
| 447 |
+
// bpo-40241 added PyObject_GC_IsTracked() to Python 3.9.0a6.
|
| 448 |
+
// bpo-4688 added _PyObject_GC_IS_TRACKED() to Python 2.7.0a2.
|
| 449 |
+
#if PY_VERSION_HEX < 0x030900A6 && !defined(PYPY_VERSION)
|
| 450 |
+
static inline int PyObject_GC_IsTracked(PyObject* obj)
|
| 451 |
+
{
|
| 452 |
+
return (PyObject_IS_GC(obj) && _PyObject_GC_IS_TRACKED(obj));
|
| 453 |
+
}
|
| 454 |
+
#endif
|
| 455 |
+
|
| 456 |
+
// bpo-40241 added PyObject_GC_IsFinalized() to Python 3.9.0a6.
|
| 457 |
+
// bpo-18112 added _PyGCHead_FINALIZED() to Python 3.4.0 final.
|
| 458 |
+
#if PY_VERSION_HEX < 0x030900A6 && PY_VERSION_HEX >= 0x030400F0 && !defined(PYPY_VERSION)
|
| 459 |
+
static inline int PyObject_GC_IsFinalized(PyObject *obj)
|
| 460 |
+
{
|
| 461 |
+
PyGC_Head *gc = _Py_CAST(PyGC_Head*, obj) - 1;
|
| 462 |
+
return (PyObject_IS_GC(obj) && _PyGCHead_FINALIZED(gc));
|
| 463 |
+
}
|
| 464 |
+
#endif
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
// bpo-39573 added Py_IS_TYPE() to Python 3.9.0a4
|
| 468 |
+
#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_IS_TYPE)
|
| 469 |
+
static inline int _Py_IS_TYPE(PyObject *ob, PyTypeObject *type) {
|
| 470 |
+
return Py_TYPE(ob) == type;
|
| 471 |
+
}
|
| 472 |
+
#define Py_IS_TYPE(ob, type) _Py_IS_TYPE(_PyObject_CAST(ob), type)
|
| 473 |
+
#endif
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
// bpo-46906 added PyFloat_Pack2() and PyFloat_Unpack2() to Python 3.11a7.
|
| 477 |
+
// bpo-11734 added _PyFloat_Pack2() and _PyFloat_Unpack2() to Python 3.6.0b1.
|
| 478 |
+
// Python 3.11a2 moved _PyFloat_Pack2() and _PyFloat_Unpack2() to the internal
|
| 479 |
+
// C API: Python 3.11a2-3.11a6 versions are not supported.
|
| 480 |
+
#if 0x030600B1 <= PY_VERSION_HEX && PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
|
| 481 |
+
static inline int PyFloat_Pack2(double x, char *p, int le)
|
| 482 |
+
{ return _PyFloat_Pack2(x, (unsigned char*)p, le); }
|
| 483 |
+
|
| 484 |
+
static inline double PyFloat_Unpack2(const char *p, int le)
|
| 485 |
+
{ return _PyFloat_Unpack2((const unsigned char *)p, le); }
|
| 486 |
+
#endif
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
// bpo-46906 added PyFloat_Pack4(), PyFloat_Pack8(), PyFloat_Unpack4() and
|
| 490 |
+
// PyFloat_Unpack8() to Python 3.11a7.
|
| 491 |
+
// Python 3.11a2 moved _PyFloat_Pack4(), _PyFloat_Pack8(), _PyFloat_Unpack4()
|
| 492 |
+
// and _PyFloat_Unpack8() to the internal C API: Python 3.11a2-3.11a6 versions
|
| 493 |
+
// are not supported.
|
| 494 |
+
#if PY_VERSION_HEX <= 0x030B00A1 && !defined(PYPY_VERSION)
|
| 495 |
+
static inline int PyFloat_Pack4(double x, char *p, int le)
|
| 496 |
+
{ return _PyFloat_Pack4(x, (unsigned char*)p, le); }
|
| 497 |
+
|
| 498 |
+
static inline int PyFloat_Pack8(double x, char *p, int le)
|
| 499 |
+
{ return _PyFloat_Pack8(x, (unsigned char*)p, le); }
|
| 500 |
+
|
| 501 |
+
static inline double PyFloat_Unpack4(const char *p, int le)
|
| 502 |
+
{ return _PyFloat_Unpack4((const unsigned char *)p, le); }
|
| 503 |
+
|
| 504 |
+
static inline double PyFloat_Unpack8(const char *p, int le)
|
| 505 |
+
{ return _PyFloat_Unpack8((const unsigned char *)p, le); }
|
| 506 |
+
#endif
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
// gh-92154 added PyCode_GetCode() to Python 3.11.0b1
|
| 510 |
+
#if PY_VERSION_HEX < 0x030B00B1 && !defined(PYPY_VERSION)
|
| 511 |
+
static inline PyObject* PyCode_GetCode(PyCodeObject *code)
|
| 512 |
+
{
|
| 513 |
+
return Py_NewRef(code->co_code);
|
| 514 |
+
}
|
| 515 |
+
#endif
|
| 516 |
+
|
| 517 |
+
|
| 518 |
+
// gh-95008 added PyCode_GetVarnames() to Python 3.11.0rc1
|
| 519 |
+
#if PY_VERSION_HEX < 0x030B00C1 && !defined(PYPY_VERSION)
|
| 520 |
+
static inline PyObject* PyCode_GetVarnames(PyCodeObject *code)
|
| 521 |
+
{
|
| 522 |
+
return Py_NewRef(code->co_varnames);
|
| 523 |
+
}
|
| 524 |
+
#endif
|
| 525 |
+
|
| 526 |
+
// gh-95008 added PyCode_GetFreevars() to Python 3.11.0rc1
|
| 527 |
+
#if PY_VERSION_HEX < 0x030B00C1 && !defined(PYPY_VERSION)
|
| 528 |
+
static inline PyObject* PyCode_GetFreevars(PyCodeObject *code)
|
| 529 |
+
{
|
| 530 |
+
return Py_NewRef(code->co_freevars);
|
| 531 |
+
}
|
| 532 |
+
#endif
|
| 533 |
+
|
| 534 |
+
// gh-95008 added PyCode_GetCellvars() to Python 3.11.0rc1
|
| 535 |
+
#if PY_VERSION_HEX < 0x030B00C1 && !defined(PYPY_VERSION)
|
| 536 |
+
static inline PyObject* PyCode_GetCellvars(PyCodeObject *code)
|
| 537 |
+
{
|
| 538 |
+
return Py_NewRef(code->co_cellvars);
|
| 539 |
+
}
|
| 540 |
+
#endif
|
| 541 |
+
|
| 542 |
+
|
| 543 |
+
// Py_UNUSED() was added to Python 3.4.0b2.
|
| 544 |
+
#if PY_VERSION_HEX < 0x030400B2 && !defined(Py_UNUSED)
|
| 545 |
+
# if defined(__GNUC__) || defined(__clang__)
|
| 546 |
+
# define Py_UNUSED(name) _unused_ ## name __attribute__((unused))
|
| 547 |
+
# else
|
| 548 |
+
# define Py_UNUSED(name) _unused_ ## name
|
| 549 |
+
# endif
|
| 550 |
+
#endif
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
// gh-105922 added PyImport_AddModuleRef() to Python 3.13.0a1
|
| 554 |
+
#if PY_VERSION_HEX < 0x030D00A0
|
| 555 |
+
static inline PyObject* PyImport_AddModuleRef(const char *name)
|
| 556 |
+
{
|
| 557 |
+
return Py_XNewRef(PyImport_AddModule(name));
|
| 558 |
+
}
|
| 559 |
+
#endif
|
| 560 |
+
|
| 561 |
+
|
| 562 |
+
// gh-105927 added PyWeakref_GetRef() to Python 3.13.0a1
|
| 563 |
+
#if PY_VERSION_HEX < 0x030D0000
|
| 564 |
+
static inline int PyWeakref_GetRef(PyObject *ref, PyObject **pobj)
|
| 565 |
+
{
|
| 566 |
+
PyObject *obj;
|
| 567 |
+
if (ref != NULL && !PyWeakref_Check(ref)) {
|
| 568 |
+
*pobj = NULL;
|
| 569 |
+
PyErr_SetString(PyExc_TypeError, "expected a weakref");
|
| 570 |
+
return -1;
|
| 571 |
+
}
|
| 572 |
+
obj = PyWeakref_GetObject(ref);
|
| 573 |
+
if (obj == NULL) {
|
| 574 |
+
// SystemError if ref is NULL
|
| 575 |
+
*pobj = NULL;
|
| 576 |
+
return -1;
|
| 577 |
+
}
|
| 578 |
+
if (obj == Py_None) {
|
| 579 |
+
*pobj = NULL;
|
| 580 |
+
return 0;
|
| 581 |
+
}
|
| 582 |
+
*pobj = Py_NewRef(obj);
|
| 583 |
+
return (*pobj != NULL);
|
| 584 |
+
}
|
| 585 |
+
#endif
|
| 586 |
+
|
| 587 |
+
|
| 588 |
+
// bpo-36974 added PY_VECTORCALL_ARGUMENTS_OFFSET to Python 3.8b1
|
| 589 |
+
#ifndef PY_VECTORCALL_ARGUMENTS_OFFSET
|
| 590 |
+
# define PY_VECTORCALL_ARGUMENTS_OFFSET (_Py_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
|
| 591 |
+
#endif
|
| 592 |
+
|
| 593 |
+
// bpo-36974 added PyVectorcall_NARGS() to Python 3.8b1
|
| 594 |
+
#if PY_VERSION_HEX < 0x030800B1
|
| 595 |
+
static inline Py_ssize_t PyVectorcall_NARGS(size_t n)
|
| 596 |
+
{
|
| 597 |
+
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
|
| 598 |
+
}
|
| 599 |
+
#endif
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
// gh-105922 added PyObject_Vectorcall() to Python 3.9.0a4
|
| 603 |
+
#if PY_VERSION_HEX < 0x030900A4
|
| 604 |
+
static inline PyObject*
|
| 605 |
+
PyObject_Vectorcall(PyObject *callable, PyObject *const *args,
|
| 606 |
+
size_t nargsf, PyObject *kwnames)
|
| 607 |
+
{
|
| 608 |
+
#if PY_VERSION_HEX >= 0x030800B1 && !defined(PYPY_VERSION)
|
| 609 |
+
// bpo-36974 added _PyObject_Vectorcall() to Python 3.8.0b1
|
| 610 |
+
return _PyObject_Vectorcall(callable, args, nargsf, kwnames);
|
| 611 |
+
#else
|
| 612 |
+
PyObject *posargs = NULL, *kwargs = NULL;
|
| 613 |
+
PyObject *res;
|
| 614 |
+
Py_ssize_t nposargs, nkwargs, i;
|
| 615 |
+
|
| 616 |
+
if (nargsf != 0 && args == NULL) {
|
| 617 |
+
PyErr_BadInternalCall();
|
| 618 |
+
goto error;
|
| 619 |
+
}
|
| 620 |
+
if (kwnames != NULL && !PyTuple_Check(kwnames)) {
|
| 621 |
+
PyErr_BadInternalCall();
|
| 622 |
+
goto error;
|
| 623 |
+
}
|
| 624 |
+
|
| 625 |
+
nposargs = (Py_ssize_t)PyVectorcall_NARGS(nargsf);
|
| 626 |
+
if (kwnames) {
|
| 627 |
+
nkwargs = PyTuple_GET_SIZE(kwnames);
|
| 628 |
+
}
|
| 629 |
+
else {
|
| 630 |
+
nkwargs = 0;
|
| 631 |
+
}
|
| 632 |
+
|
| 633 |
+
posargs = PyTuple_New(nposargs);
|
| 634 |
+
if (posargs == NULL) {
|
| 635 |
+
goto error;
|
| 636 |
+
}
|
| 637 |
+
if (nposargs) {
|
| 638 |
+
for (i=0; i < nposargs; i++) {
|
| 639 |
+
PyTuple_SET_ITEM(posargs, i, Py_NewRef(*args));
|
| 640 |
+
args++;
|
| 641 |
+
}
|
| 642 |
+
}
|
| 643 |
+
|
| 644 |
+
if (nkwargs) {
|
| 645 |
+
kwargs = PyDict_New();
|
| 646 |
+
if (kwargs == NULL) {
|
| 647 |
+
goto error;
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
for (i = 0; i < nkwargs; i++) {
|
| 651 |
+
PyObject *key = PyTuple_GET_ITEM(kwnames, i);
|
| 652 |
+
PyObject *value = *args;
|
| 653 |
+
args++;
|
| 654 |
+
if (PyDict_SetItem(kwargs, key, value) < 0) {
|
| 655 |
+
goto error;
|
| 656 |
+
}
|
| 657 |
+
}
|
| 658 |
+
}
|
| 659 |
+
else {
|
| 660 |
+
kwargs = NULL;
|
| 661 |
+
}
|
| 662 |
+
|
| 663 |
+
res = PyObject_Call(callable, posargs, kwargs);
|
| 664 |
+
Py_DECREF(posargs);
|
| 665 |
+
Py_XDECREF(kwargs);
|
| 666 |
+
return res;
|
| 667 |
+
|
| 668 |
+
error:
|
| 669 |
+
Py_DECREF(posargs);
|
| 670 |
+
Py_XDECREF(kwargs);
|
| 671 |
+
return NULL;
|
| 672 |
+
#endif
|
| 673 |
+
}
|
| 674 |
+
#endif
|
| 675 |
+
|
| 676 |
+
|
| 677 |
+
// gh-106521 added PyObject_GetOptionalAttr() and
|
| 678 |
+
// PyObject_GetOptionalAttrString() to Python 3.13.0a1
|
| 679 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 680 |
+
static inline int
|
| 681 |
+
PyObject_GetOptionalAttr(PyObject *obj, PyObject *attr_name, PyObject **result)
|
| 682 |
+
{
|
| 683 |
+
// bpo-32571 added _PyObject_LookupAttr() to Python 3.7.0b1
|
| 684 |
+
#if PY_VERSION_HEX >= 0x030700B1 && !defined(PYPY_VERSION)
|
| 685 |
+
return _PyObject_LookupAttr(obj, attr_name, result);
|
| 686 |
+
#else
|
| 687 |
+
*result = PyObject_GetAttr(obj, attr_name);
|
| 688 |
+
if (*result != NULL) {
|
| 689 |
+
return 1;
|
| 690 |
+
}
|
| 691 |
+
if (!PyErr_Occurred()) {
|
| 692 |
+
return 0;
|
| 693 |
+
}
|
| 694 |
+
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
| 695 |
+
PyErr_Clear();
|
| 696 |
+
return 0;
|
| 697 |
+
}
|
| 698 |
+
return -1;
|
| 699 |
+
#endif
|
| 700 |
+
}
|
| 701 |
+
|
| 702 |
+
static inline int
|
| 703 |
+
PyObject_GetOptionalAttrString(PyObject *obj, const char *attr_name, PyObject **result)
|
| 704 |
+
{
|
| 705 |
+
PyObject *name_obj;
|
| 706 |
+
int rc;
|
| 707 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 708 |
+
name_obj = PyUnicode_FromString(attr_name);
|
| 709 |
+
#else
|
| 710 |
+
name_obj = PyString_FromString(attr_name);
|
| 711 |
+
#endif
|
| 712 |
+
if (name_obj == NULL) {
|
| 713 |
+
*result = NULL;
|
| 714 |
+
return -1;
|
| 715 |
+
}
|
| 716 |
+
rc = PyObject_GetOptionalAttr(obj, name_obj, result);
|
| 717 |
+
Py_DECREF(name_obj);
|
| 718 |
+
return rc;
|
| 719 |
+
}
|
| 720 |
+
#endif
|
| 721 |
+
|
| 722 |
+
|
| 723 |
+
// gh-106307 added PyObject_GetOptionalAttr() and
|
| 724 |
+
// PyMapping_GetOptionalItemString() to Python 3.13.0a1
|
| 725 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 726 |
+
static inline int
|
| 727 |
+
PyMapping_GetOptionalItem(PyObject *obj, PyObject *key, PyObject **result)
|
| 728 |
+
{
|
| 729 |
+
*result = PyObject_GetItem(obj, key);
|
| 730 |
+
if (*result) {
|
| 731 |
+
return 1;
|
| 732 |
+
}
|
| 733 |
+
if (!PyErr_ExceptionMatches(PyExc_KeyError)) {
|
| 734 |
+
return -1;
|
| 735 |
+
}
|
| 736 |
+
PyErr_Clear();
|
| 737 |
+
return 0;
|
| 738 |
+
}
|
| 739 |
+
|
| 740 |
+
static inline int
|
| 741 |
+
PyMapping_GetOptionalItemString(PyObject *obj, const char *key, PyObject **result)
|
| 742 |
+
{
|
| 743 |
+
PyObject *key_obj;
|
| 744 |
+
int rc;
|
| 745 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 746 |
+
key_obj = PyUnicode_FromString(key);
|
| 747 |
+
#else
|
| 748 |
+
key_obj = PyString_FromString(key);
|
| 749 |
+
#endif
|
| 750 |
+
if (key_obj == NULL) {
|
| 751 |
+
*result = NULL;
|
| 752 |
+
return -1;
|
| 753 |
+
}
|
| 754 |
+
rc = PyMapping_GetOptionalItem(obj, key_obj, result);
|
| 755 |
+
Py_DECREF(key_obj);
|
| 756 |
+
return rc;
|
| 757 |
+
}
|
| 758 |
+
#endif
|
| 759 |
+
|
| 760 |
+
// gh-108511 added PyMapping_HasKeyWithError() and
|
| 761 |
+
// PyMapping_HasKeyStringWithError() to Python 3.13.0a1
|
| 762 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 763 |
+
static inline int
|
| 764 |
+
PyMapping_HasKeyWithError(PyObject *obj, PyObject *key)
|
| 765 |
+
{
|
| 766 |
+
PyObject *res;
|
| 767 |
+
int rc = PyMapping_GetOptionalItem(obj, key, &res);
|
| 768 |
+
Py_XDECREF(res);
|
| 769 |
+
return rc;
|
| 770 |
+
}
|
| 771 |
+
|
| 772 |
+
static inline int
|
| 773 |
+
PyMapping_HasKeyStringWithError(PyObject *obj, const char *key)
|
| 774 |
+
{
|
| 775 |
+
PyObject *res;
|
| 776 |
+
int rc = PyMapping_GetOptionalItemString(obj, key, &res);
|
| 777 |
+
Py_XDECREF(res);
|
| 778 |
+
return rc;
|
| 779 |
+
}
|
| 780 |
+
#endif
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
// gh-108511 added PyObject_HasAttrWithError() and
|
| 784 |
+
// PyObject_HasAttrStringWithError() to Python 3.13.0a1
|
| 785 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 786 |
+
static inline int
|
| 787 |
+
PyObject_HasAttrWithError(PyObject *obj, PyObject *attr)
|
| 788 |
+
{
|
| 789 |
+
PyObject *res;
|
| 790 |
+
int rc = PyObject_GetOptionalAttr(obj, attr, &res);
|
| 791 |
+
Py_XDECREF(res);
|
| 792 |
+
return rc;
|
| 793 |
+
}
|
| 794 |
+
|
| 795 |
+
static inline int
|
| 796 |
+
PyObject_HasAttrStringWithError(PyObject *obj, const char *attr)
|
| 797 |
+
{
|
| 798 |
+
PyObject *res;
|
| 799 |
+
int rc = PyObject_GetOptionalAttrString(obj, attr, &res);
|
| 800 |
+
Py_XDECREF(res);
|
| 801 |
+
return rc;
|
| 802 |
+
}
|
| 803 |
+
#endif
|
| 804 |
+
|
| 805 |
+
|
| 806 |
+
// gh-106004 added PyDict_GetItemRef() and PyDict_GetItemStringRef()
|
| 807 |
+
// to Python 3.13.0a1
|
| 808 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 809 |
+
static inline int
|
| 810 |
+
PyDict_GetItemRef(PyObject *mp, PyObject *key, PyObject **result)
|
| 811 |
+
{
|
| 812 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 813 |
+
PyObject *item = PyDict_GetItemWithError(mp, key);
|
| 814 |
+
#else
|
| 815 |
+
PyObject *item = _PyDict_GetItemWithError(mp, key);
|
| 816 |
+
#endif
|
| 817 |
+
if (item != NULL) {
|
| 818 |
+
*result = Py_NewRef(item);
|
| 819 |
+
return 1; // found
|
| 820 |
+
}
|
| 821 |
+
if (!PyErr_Occurred()) {
|
| 822 |
+
*result = NULL;
|
| 823 |
+
return 0; // not found
|
| 824 |
+
}
|
| 825 |
+
*result = NULL;
|
| 826 |
+
return -1;
|
| 827 |
+
}
|
| 828 |
+
|
| 829 |
+
static inline int
|
| 830 |
+
PyDict_GetItemStringRef(PyObject *mp, const char *key, PyObject **result)
|
| 831 |
+
{
|
| 832 |
+
int res;
|
| 833 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 834 |
+
PyObject *key_obj = PyUnicode_FromString(key);
|
| 835 |
+
#else
|
| 836 |
+
PyObject *key_obj = PyString_FromString(key);
|
| 837 |
+
#endif
|
| 838 |
+
if (key_obj == NULL) {
|
| 839 |
+
*result = NULL;
|
| 840 |
+
return -1;
|
| 841 |
+
}
|
| 842 |
+
res = PyDict_GetItemRef(mp, key_obj, result);
|
| 843 |
+
Py_DECREF(key_obj);
|
| 844 |
+
return res;
|
| 845 |
+
}
|
| 846 |
+
#endif
|
| 847 |
+
|
| 848 |
+
|
| 849 |
+
// gh-106307 added PyModule_Add() to Python 3.13.0a1
|
| 850 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 851 |
+
static inline int
|
| 852 |
+
PyModule_Add(PyObject *mod, const char *name, PyObject *value)
|
| 853 |
+
{
|
| 854 |
+
int res = PyModule_AddObjectRef(mod, name, value);
|
| 855 |
+
Py_XDECREF(value);
|
| 856 |
+
return res;
|
| 857 |
+
}
|
| 858 |
+
#endif
|
| 859 |
+
|
| 860 |
+
|
| 861 |
+
// gh-108014 added Py_IsFinalizing() to Python 3.13.0a1
|
| 862 |
+
// bpo-1856 added _Py_Finalizing to Python 3.2.1b1.
|
| 863 |
+
// _Py_IsFinalizing() was added to PyPy 7.3.0.
|
| 864 |
+
#if (0x030201B1 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x030D00A1) \
|
| 865 |
+
&& (!defined(PYPY_VERSION_NUM) || PYPY_VERSION_NUM >= 0x7030000)
|
| 866 |
+
static inline int Py_IsFinalizing(void)
|
| 867 |
+
{
|
| 868 |
+
#if PY_VERSION_HEX >= 0x030700A1
|
| 869 |
+
// _Py_IsFinalizing() was added to Python 3.7.0a1.
|
| 870 |
+
return _Py_IsFinalizing();
|
| 871 |
+
#else
|
| 872 |
+
return (_Py_Finalizing != NULL);
|
| 873 |
+
#endif
|
| 874 |
+
}
|
| 875 |
+
#endif
|
| 876 |
+
|
| 877 |
+
|
| 878 |
+
// gh-108323 added PyDict_ContainsString() to Python 3.13.0a1
|
| 879 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 880 |
+
static inline int PyDict_ContainsString(PyObject *op, const char *key)
|
| 881 |
+
{
|
| 882 |
+
PyObject *key_obj = PyUnicode_FromString(key);
|
| 883 |
+
if (key_obj == NULL) {
|
| 884 |
+
return -1;
|
| 885 |
+
}
|
| 886 |
+
int res = PyDict_Contains(op, key_obj);
|
| 887 |
+
Py_DECREF(key_obj);
|
| 888 |
+
return res;
|
| 889 |
+
}
|
| 890 |
+
#endif
|
| 891 |
+
|
| 892 |
+
|
| 893 |
+
// gh-108445 added PyLong_AsInt() to Python 3.13.0a1
|
| 894 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 895 |
+
static inline int PyLong_AsInt(PyObject *obj)
|
| 896 |
+
{
|
| 897 |
+
#ifdef PYPY_VERSION
|
| 898 |
+
long value = PyLong_AsLong(obj);
|
| 899 |
+
if (value == -1 && PyErr_Occurred()) {
|
| 900 |
+
return -1;
|
| 901 |
+
}
|
| 902 |
+
if (value < (long)INT_MIN || (long)INT_MAX < value) {
|
| 903 |
+
PyErr_SetString(PyExc_OverflowError,
|
| 904 |
+
"Python int too large to convert to C int");
|
| 905 |
+
return -1;
|
| 906 |
+
}
|
| 907 |
+
return (int)value;
|
| 908 |
+
#else
|
| 909 |
+
return _PyLong_AsInt(obj);
|
| 910 |
+
#endif
|
| 911 |
+
}
|
| 912 |
+
#endif
|
| 913 |
+
|
| 914 |
+
|
| 915 |
+
// gh-107073 added PyObject_VisitManagedDict() to Python 3.13.0a1
|
| 916 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 917 |
+
static inline int
|
| 918 |
+
PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg)
|
| 919 |
+
{
|
| 920 |
+
PyObject **dict = _PyObject_GetDictPtr(obj);
|
| 921 |
+
if (*dict == NULL) {
|
| 922 |
+
return -1;
|
| 923 |
+
}
|
| 924 |
+
Py_VISIT(*dict);
|
| 925 |
+
return 0;
|
| 926 |
+
}
|
| 927 |
+
|
| 928 |
+
static inline void
|
| 929 |
+
PyObject_ClearManagedDict(PyObject *obj)
|
| 930 |
+
{
|
| 931 |
+
PyObject **dict = _PyObject_GetDictPtr(obj);
|
| 932 |
+
if (*dict == NULL) {
|
| 933 |
+
return;
|
| 934 |
+
}
|
| 935 |
+
Py_CLEAR(*dict);
|
| 936 |
+
}
|
| 937 |
+
#endif
|
| 938 |
+
|
| 939 |
+
// gh-108867 added PyThreadState_GetUnchecked() to Python 3.13.0a1
|
| 940 |
+
// Python 3.5.2 added _PyThreadState_UncheckedGet().
|
| 941 |
+
#if PY_VERSION_HEX >= 0x03050200 && PY_VERSION_HEX < 0x030D00A1
|
| 942 |
+
static inline PyThreadState*
|
| 943 |
+
PyThreadState_GetUnchecked(void)
|
| 944 |
+
{
|
| 945 |
+
return _PyThreadState_UncheckedGet();
|
| 946 |
+
}
|
| 947 |
+
#endif
|
| 948 |
+
|
| 949 |
+
// gh-110289 added PyUnicode_EqualToUTF8() and PyUnicode_EqualToUTF8AndSize()
|
| 950 |
+
// to Python 3.13.0a1
|
| 951 |
+
#if PY_VERSION_HEX < 0x030D00A1
|
| 952 |
+
static inline int
|
| 953 |
+
PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *str, Py_ssize_t str_len)
|
| 954 |
+
{
|
| 955 |
+
Py_ssize_t len;
|
| 956 |
+
const void *utf8;
|
| 957 |
+
PyObject *exc_type, *exc_value, *exc_tb;
|
| 958 |
+
int res;
|
| 959 |
+
|
| 960 |
+
// API cannot report errors so save/restore the exception
|
| 961 |
+
PyErr_Fetch(&exc_type, &exc_value, &exc_tb);
|
| 962 |
+
|
| 963 |
+
// Python 3.3.0a1 added PyUnicode_AsUTF8AndSize()
|
| 964 |
+
#if PY_VERSION_HEX >= 0x030300A1
|
| 965 |
+
if (PyUnicode_IS_ASCII(unicode)) {
|
| 966 |
+
utf8 = PyUnicode_DATA(unicode);
|
| 967 |
+
len = PyUnicode_GET_LENGTH(unicode);
|
| 968 |
+
}
|
| 969 |
+
else {
|
| 970 |
+
utf8 = PyUnicode_AsUTF8AndSize(unicode, &len);
|
| 971 |
+
if (utf8 == NULL) {
|
| 972 |
+
// Memory allocation failure. The API cannot report error,
|
| 973 |
+
// so ignore the exception and return 0.
|
| 974 |
+
res = 0;
|
| 975 |
+
goto done;
|
| 976 |
+
}
|
| 977 |
+
}
|
| 978 |
+
|
| 979 |
+
if (len != str_len) {
|
| 980 |
+
res = 0;
|
| 981 |
+
goto done;
|
| 982 |
+
}
|
| 983 |
+
res = (memcmp(utf8, str, (size_t)len) == 0);
|
| 984 |
+
#else
|
| 985 |
+
PyObject *bytes = PyUnicode_AsUTF8String(unicode);
|
| 986 |
+
if (bytes == NULL) {
|
| 987 |
+
// Memory allocation failure. The API cannot report error,
|
| 988 |
+
// so ignore the exception and return 0.
|
| 989 |
+
res = 0;
|
| 990 |
+
goto done;
|
| 991 |
+
}
|
| 992 |
+
|
| 993 |
+
#if PY_VERSION_HEX >= 0x03000000
|
| 994 |
+
len = PyBytes_GET_SIZE(bytes);
|
| 995 |
+
utf8 = PyBytes_AS_STRING(bytes);
|
| 996 |
+
#else
|
| 997 |
+
len = PyString_GET_SIZE(bytes);
|
| 998 |
+
utf8 = PyString_AS_STRING(bytes);
|
| 999 |
+
#endif
|
| 1000 |
+
if (len != str_len) {
|
| 1001 |
+
Py_DECREF(bytes);
|
| 1002 |
+
res = 0;
|
| 1003 |
+
goto done;
|
| 1004 |
+
}
|
| 1005 |
+
|
| 1006 |
+
res = (memcmp(utf8, str, (size_t)len) == 0);
|
| 1007 |
+
Py_DECREF(bytes);
|
| 1008 |
+
#endif
|
| 1009 |
+
|
| 1010 |
+
done:
|
| 1011 |
+
PyErr_Restore(exc_type, exc_value, exc_tb);
|
| 1012 |
+
return res;
|
| 1013 |
+
}
|
| 1014 |
+
|
| 1015 |
+
static inline int
|
| 1016 |
+
PyUnicode_EqualToUTF8(PyObject *unicode, const char *str)
|
| 1017 |
+
{
|
| 1018 |
+
return PyUnicode_EqualToUTF8AndSize(unicode, str, (Py_ssize_t)strlen(str));
|
| 1019 |
+
}
|
| 1020 |
+
#endif
|
| 1021 |
+
|
| 1022 |
+
|
| 1023 |
+
// gh-111138 added PyList_Extend() and PyList_Clear() to Python 3.13.0a2
|
| 1024 |
+
#if PY_VERSION_HEX < 0x030D00A2
|
| 1025 |
+
static inline int
|
| 1026 |
+
PyList_Extend(PyObject *list, PyObject *iterable)
|
| 1027 |
+
{
|
| 1028 |
+
return PyList_SetSlice(list, PY_SSIZE_T_MAX, PY_SSIZE_T_MAX, iterable);
|
| 1029 |
+
}
|
| 1030 |
+
|
| 1031 |
+
static inline int
|
| 1032 |
+
PyList_Clear(PyObject *list)
|
| 1033 |
+
{
|
| 1034 |
+
return PyList_SetSlice(list, 0, PY_SSIZE_T_MAX, NULL);
|
| 1035 |
+
}
|
| 1036 |
+
#endif
|
| 1037 |
+
|
| 1038 |
+
// gh-111262 added PyDict_Pop() and PyDict_PopString() to Python 3.13.0a2
|
| 1039 |
+
#if PY_VERSION_HEX < 0x030D00A2
|
| 1040 |
+
static inline int
|
| 1041 |
+
PyDict_Pop(PyObject *dict, PyObject *key, PyObject **result)
|
| 1042 |
+
{
|
| 1043 |
+
PyObject *value;
|
| 1044 |
+
|
| 1045 |
+
if (!PyDict_Check(dict)) {
|
| 1046 |
+
PyErr_BadInternalCall();
|
| 1047 |
+
if (result) {
|
| 1048 |
+
*result = NULL;
|
| 1049 |
+
}
|
| 1050 |
+
return -1;
|
| 1051 |
+
}
|
| 1052 |
+
|
| 1053 |
+
// bpo-16991 added _PyDict_Pop() to Python 3.5.0b2.
|
| 1054 |
+
// Python 3.6.0b3 changed _PyDict_Pop() first argument type to PyObject*.
|
| 1055 |
+
// Python 3.13.0a1 removed _PyDict_Pop().
|
| 1056 |
+
#if defined(PYPY_VERSION) || PY_VERSION_HEX < 0x030500b2 || PY_VERSION_HEX >= 0x030D0000
|
| 1057 |
+
value = PyObject_CallMethod(dict, "pop", "O", key);
|
| 1058 |
+
#elif PY_VERSION_HEX < 0x030600b3
|
| 1059 |
+
value = _PyDict_Pop(_Py_CAST(PyDictObject*, dict), key, NULL);
|
| 1060 |
+
#else
|
| 1061 |
+
value = _PyDict_Pop(dict, key, NULL);
|
| 1062 |
+
#endif
|
| 1063 |
+
if (value == NULL) {
|
| 1064 |
+
if (result) {
|
| 1065 |
+
*result = NULL;
|
| 1066 |
+
}
|
| 1067 |
+
if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_KeyError)) {
|
| 1068 |
+
return -1;
|
| 1069 |
+
}
|
| 1070 |
+
PyErr_Clear();
|
| 1071 |
+
return 0;
|
| 1072 |
+
}
|
| 1073 |
+
if (result) {
|
| 1074 |
+
*result = value;
|
| 1075 |
+
}
|
| 1076 |
+
else {
|
| 1077 |
+
Py_DECREF(value);
|
| 1078 |
+
}
|
| 1079 |
+
return 1;
|
| 1080 |
+
}
|
| 1081 |
+
|
| 1082 |
+
static inline int
|
| 1083 |
+
PyDict_PopString(PyObject *dict, const char *key, PyObject **result)
|
| 1084 |
+
{
|
| 1085 |
+
PyObject *key_obj = PyUnicode_FromString(key);
|
| 1086 |
+
if (key_obj == NULL) {
|
| 1087 |
+
if (result != NULL) {
|
| 1088 |
+
*result = NULL;
|
| 1089 |
+
}
|
| 1090 |
+
return -1;
|
| 1091 |
+
}
|
| 1092 |
+
|
| 1093 |
+
int res = PyDict_Pop(dict, key_obj, result);
|
| 1094 |
+
Py_DECREF(key_obj);
|
| 1095 |
+
return res;
|
| 1096 |
+
}
|
| 1097 |
+
#endif
|
| 1098 |
+
|
| 1099 |
+
|
| 1100 |
+
#if PY_VERSION_HEX < 0x030200A4
|
| 1101 |
+
// Python 3.2.0a4 added Py_hash_t type
|
| 1102 |
+
typedef Py_ssize_t Py_hash_t;
|
| 1103 |
+
#endif
|
| 1104 |
+
|
| 1105 |
+
|
| 1106 |
+
// gh-111545 added Py_HashPointer() to Python 3.13.0a3
|
| 1107 |
+
#if PY_VERSION_HEX < 0x030D00A3
|
| 1108 |
+
static inline Py_hash_t Py_HashPointer(const void *ptr)
|
| 1109 |
+
{
|
| 1110 |
+
#if PY_VERSION_HEX >= 0x030900A4 && !defined(PYPY_VERSION)
|
| 1111 |
+
return _Py_HashPointer(ptr);
|
| 1112 |
+
#else
|
| 1113 |
+
return _Py_HashPointer(_Py_CAST(void*, ptr));
|
| 1114 |
+
#endif
|
| 1115 |
+
}
|
| 1116 |
+
#endif
|
| 1117 |
+
|
| 1118 |
+
|
| 1119 |
+
// Python 3.13a4 added a PyTime API.
|
| 1120 |
+
// Use the private API added to Python 3.5.
|
| 1121 |
+
#if PY_VERSION_HEX < 0x030D00A4 && PY_VERSION_HEX >= 0x03050000
|
| 1122 |
+
typedef _PyTime_t PyTime_t;
|
| 1123 |
+
#define PyTime_MIN _PyTime_MIN
|
| 1124 |
+
#define PyTime_MAX _PyTime_MAX
|
| 1125 |
+
|
| 1126 |
+
static inline double PyTime_AsSecondsDouble(PyTime_t t)
|
| 1127 |
+
{ return _PyTime_AsSecondsDouble(t); }
|
| 1128 |
+
|
| 1129 |
+
static inline int PyTime_Monotonic(PyTime_t *result)
|
| 1130 |
+
{ return _PyTime_GetMonotonicClockWithInfo(result, NULL); }
|
| 1131 |
+
|
| 1132 |
+
static inline int PyTime_Time(PyTime_t *result)
|
| 1133 |
+
{ return _PyTime_GetSystemClockWithInfo(result, NULL); }
|
| 1134 |
+
|
| 1135 |
+
static inline int PyTime_PerfCounter(PyTime_t *result)
|
| 1136 |
+
{
|
| 1137 |
+
#if PY_VERSION_HEX >= 0x03070000 && !defined(PYPY_VERSION)
|
| 1138 |
+
return _PyTime_GetPerfCounterWithInfo(result, NULL);
|
| 1139 |
+
#elif PY_VERSION_HEX >= 0x03070000
|
| 1140 |
+
// Call time.perf_counter_ns() and convert Python int object to PyTime_t.
|
| 1141 |
+
// Cache time.perf_counter_ns() function for best performance.
|
| 1142 |
+
static PyObject *func = NULL;
|
| 1143 |
+
if (func == NULL) {
|
| 1144 |
+
PyObject *mod = PyImport_ImportModule("time");
|
| 1145 |
+
if (mod == NULL) {
|
| 1146 |
+
return -1;
|
| 1147 |
+
}
|
| 1148 |
+
|
| 1149 |
+
func = PyObject_GetAttrString(mod, "perf_counter_ns");
|
| 1150 |
+
Py_DECREF(mod);
|
| 1151 |
+
if (func == NULL) {
|
| 1152 |
+
return -1;
|
| 1153 |
+
}
|
| 1154 |
+
}
|
| 1155 |
+
|
| 1156 |
+
PyObject *res = PyObject_CallNoArgs(func);
|
| 1157 |
+
if (res == NULL) {
|
| 1158 |
+
return -1;
|
| 1159 |
+
}
|
| 1160 |
+
long long value = PyLong_AsLongLong(res);
|
| 1161 |
+
Py_DECREF(res);
|
| 1162 |
+
|
| 1163 |
+
if (value == -1 && PyErr_Occurred()) {
|
| 1164 |
+
return -1;
|
| 1165 |
+
}
|
| 1166 |
+
|
| 1167 |
+
Py_BUILD_ASSERT(sizeof(value) >= sizeof(PyTime_t));
|
| 1168 |
+
*result = (PyTime_t)value;
|
| 1169 |
+
return 0;
|
| 1170 |
+
#else
|
| 1171 |
+
// Call time.perf_counter() and convert C double to PyTime_t.
|
| 1172 |
+
// Cache time.perf_counter() function for best performance.
|
| 1173 |
+
static PyObject *func = NULL;
|
| 1174 |
+
if (func == NULL) {
|
| 1175 |
+
PyObject *mod = PyImport_ImportModule("time");
|
| 1176 |
+
if (mod == NULL) {
|
| 1177 |
+
return -1;
|
| 1178 |
+
}
|
| 1179 |
+
|
| 1180 |
+
func = PyObject_GetAttrString(mod, "perf_counter");
|
| 1181 |
+
Py_DECREF(mod);
|
| 1182 |
+
if (func == NULL) {
|
| 1183 |
+
return -1;
|
| 1184 |
+
}
|
| 1185 |
+
}
|
| 1186 |
+
|
| 1187 |
+
PyObject *res = PyObject_CallNoArgs(func);
|
| 1188 |
+
if (res == NULL) {
|
| 1189 |
+
return -1;
|
| 1190 |
+
}
|
| 1191 |
+
double d = PyFloat_AsDouble(res);
|
| 1192 |
+
Py_DECREF(res);
|
| 1193 |
+
|
| 1194 |
+
if (d == -1.0 && PyErr_Occurred()) {
|
| 1195 |
+
return -1;
|
| 1196 |
+
}
|
| 1197 |
+
|
| 1198 |
+
// Avoid floor() to avoid having to link to libm
|
| 1199 |
+
*result = (PyTime_t)(d * 1e9);
|
| 1200 |
+
return 0;
|
| 1201 |
+
#endif
|
| 1202 |
+
}
|
| 1203 |
+
|
| 1204 |
+
#endif
|
| 1205 |
+
|
| 1206 |
+
// gh-111389 added hash constants to Python 3.13.0a5. These constants were
|
| 1207 |
+
// added first as private macros to Python 3.4.0b1 and PyPy 7.3.9.
|
| 1208 |
+
#if (!defined(PyHASH_BITS) \
|
| 1209 |
+
&& ((!defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x030400B1) \
|
| 1210 |
+
|| (defined(PYPY_VERSION) && PY_VERSION_HEX >= 0x03070000 \
|
| 1211 |
+
&& PYPY_VERSION_NUM >= 0x07090000)))
|
| 1212 |
+
# define PyHASH_BITS _PyHASH_BITS
|
| 1213 |
+
# define PyHASH_MODULUS _PyHASH_MODULUS
|
| 1214 |
+
# define PyHASH_INF _PyHASH_INF
|
| 1215 |
+
# define PyHASH_IMAG _PyHASH_IMAG
|
| 1216 |
+
#endif
|
| 1217 |
+
|
| 1218 |
+
|
| 1219 |
+
// gh-111545 added Py_GetConstant() and Py_GetConstantBorrowed()
|
| 1220 |
+
// to Python 3.13.0a6
|
| 1221 |
+
#if PY_VERSION_HEX < 0x030D00A6 && !defined(Py_CONSTANT_NONE)
|
| 1222 |
+
|
| 1223 |
+
#define Py_CONSTANT_NONE 0
|
| 1224 |
+
#define Py_CONSTANT_FALSE 1
|
| 1225 |
+
#define Py_CONSTANT_TRUE 2
|
| 1226 |
+
#define Py_CONSTANT_ELLIPSIS 3
|
| 1227 |
+
#define Py_CONSTANT_NOT_IMPLEMENTED 4
|
| 1228 |
+
#define Py_CONSTANT_ZERO 5
|
| 1229 |
+
#define Py_CONSTANT_ONE 6
|
| 1230 |
+
#define Py_CONSTANT_EMPTY_STR 7
|
| 1231 |
+
#define Py_CONSTANT_EMPTY_BYTES 8
|
| 1232 |
+
#define Py_CONSTANT_EMPTY_TUPLE 9
|
| 1233 |
+
|
| 1234 |
+
static inline PyObject* Py_GetConstant(unsigned int constant_id)
|
| 1235 |
+
{
|
| 1236 |
+
static PyObject* constants[Py_CONSTANT_EMPTY_TUPLE + 1] = {NULL};
|
| 1237 |
+
|
| 1238 |
+
if (constants[Py_CONSTANT_NONE] == NULL) {
|
| 1239 |
+
constants[Py_CONSTANT_NONE] = Py_None;
|
| 1240 |
+
constants[Py_CONSTANT_FALSE] = Py_False;
|
| 1241 |
+
constants[Py_CONSTANT_TRUE] = Py_True;
|
| 1242 |
+
constants[Py_CONSTANT_ELLIPSIS] = Py_Ellipsis;
|
| 1243 |
+
constants[Py_CONSTANT_NOT_IMPLEMENTED] = Py_NotImplemented;
|
| 1244 |
+
|
| 1245 |
+
constants[Py_CONSTANT_ZERO] = PyLong_FromLong(0);
|
| 1246 |
+
if (constants[Py_CONSTANT_ZERO] == NULL) {
|
| 1247 |
+
goto fatal_error;
|
| 1248 |
+
}
|
| 1249 |
+
|
| 1250 |
+
constants[Py_CONSTANT_ONE] = PyLong_FromLong(1);
|
| 1251 |
+
if (constants[Py_CONSTANT_ONE] == NULL) {
|
| 1252 |
+
goto fatal_error;
|
| 1253 |
+
}
|
| 1254 |
+
|
| 1255 |
+
constants[Py_CONSTANT_EMPTY_STR] = PyUnicode_FromStringAndSize("", 0);
|
| 1256 |
+
if (constants[Py_CONSTANT_EMPTY_STR] == NULL) {
|
| 1257 |
+
goto fatal_error;
|
| 1258 |
+
}
|
| 1259 |
+
|
| 1260 |
+
constants[Py_CONSTANT_EMPTY_BYTES] = PyBytes_FromStringAndSize("", 0);
|
| 1261 |
+
if (constants[Py_CONSTANT_EMPTY_BYTES] == NULL) {
|
| 1262 |
+
goto fatal_error;
|
| 1263 |
+
}
|
| 1264 |
+
|
| 1265 |
+
constants[Py_CONSTANT_EMPTY_TUPLE] = PyTuple_New(0);
|
| 1266 |
+
if (constants[Py_CONSTANT_EMPTY_TUPLE] == NULL) {
|
| 1267 |
+
goto fatal_error;
|
| 1268 |
+
}
|
| 1269 |
+
// goto dance to avoid compiler warnings about Py_FatalError()
|
| 1270 |
+
goto init_done;
|
| 1271 |
+
|
| 1272 |
+
fatal_error:
|
| 1273 |
+
// This case should never happen
|
| 1274 |
+
Py_FatalError("Py_GetConstant() failed to get constants");
|
| 1275 |
+
}
|
| 1276 |
+
|
| 1277 |
+
init_done:
|
| 1278 |
+
if (constant_id <= Py_CONSTANT_EMPTY_TUPLE) {
|
| 1279 |
+
return Py_NewRef(constants[constant_id]);
|
| 1280 |
+
}
|
| 1281 |
+
else {
|
| 1282 |
+
PyErr_BadInternalCall();
|
| 1283 |
+
return NULL;
|
| 1284 |
+
}
|
| 1285 |
+
}
|
| 1286 |
+
|
| 1287 |
+
static inline PyObject* Py_GetConstantBorrowed(unsigned int constant_id)
|
| 1288 |
+
{
|
| 1289 |
+
PyObject *obj = Py_GetConstant(constant_id);
|
| 1290 |
+
Py_XDECREF(obj);
|
| 1291 |
+
return obj;
|
| 1292 |
+
}
|
| 1293 |
+
#endif
|
| 1294 |
+
|
| 1295 |
+
|
| 1296 |
+
// gh-114329 added PyList_GetItemRef() to Python 3.13.0a4
|
| 1297 |
+
#if PY_VERSION_HEX < 0x030D00A4
|
| 1298 |
+
static inline PyObject *
|
| 1299 |
+
PyList_GetItemRef(PyObject *op, Py_ssize_t index)
|
| 1300 |
+
{
|
| 1301 |
+
PyObject *item = PyList_GetItem(op, index);
|
| 1302 |
+
Py_XINCREF(item);
|
| 1303 |
+
return item;
|
| 1304 |
+
}
|
| 1305 |
+
#endif
|
| 1306 |
+
|
| 1307 |
+
|
| 1308 |
+
// gh-114329 added PyList_GetItemRef() to Python 3.13.0a4
|
| 1309 |
+
#if PY_VERSION_HEX < 0x030D00A4
|
| 1310 |
+
static inline int
|
| 1311 |
+
PyDict_SetDefaultRef(PyObject *d, PyObject *key, PyObject *default_value,
|
| 1312 |
+
PyObject **result)
|
| 1313 |
+
{
|
| 1314 |
+
PyObject *value;
|
| 1315 |
+
if (PyDict_GetItemRef(d, key, &value) < 0) {
|
| 1316 |
+
// get error
|
| 1317 |
+
if (result) {
|
| 1318 |
+
*result = NULL;
|
| 1319 |
+
}
|
| 1320 |
+
return -1;
|
| 1321 |
+
}
|
| 1322 |
+
if (value != NULL) {
|
| 1323 |
+
// present
|
| 1324 |
+
if (result) {
|
| 1325 |
+
*result = value;
|
| 1326 |
+
}
|
| 1327 |
+
else {
|
| 1328 |
+
Py_DECREF(value);
|
| 1329 |
+
}
|
| 1330 |
+
return 1;
|
| 1331 |
+
}
|
| 1332 |
+
|
| 1333 |
+
// missing: set the item
|
| 1334 |
+
if (PyDict_SetItem(d, key, default_value) < 0) {
|
| 1335 |
+
// set error
|
| 1336 |
+
if (result) {
|
| 1337 |
+
*result = NULL;
|
| 1338 |
+
}
|
| 1339 |
+
return -1;
|
| 1340 |
+
}
|
| 1341 |
+
if (result) {
|
| 1342 |
+
*result = Py_NewRef(default_value);
|
| 1343 |
+
}
|
| 1344 |
+
return 0;
|
| 1345 |
+
}
|
| 1346 |
+
#endif
|
| 1347 |
+
|
| 1348 |
+
#if PY_VERSION_HEX < 0x030D00B3
|
| 1349 |
+
# define Py_BEGIN_CRITICAL_SECTION(op) {
|
| 1350 |
+
# define Py_END_CRITICAL_SECTION() }
|
| 1351 |
+
# define Py_BEGIN_CRITICAL_SECTION2(a, b) {
|
| 1352 |
+
# define Py_END_CRITICAL_SECTION2() }
|
| 1353 |
+
#endif
|
| 1354 |
+
|
| 1355 |
+
#if PY_VERSION_HEX < 0x030E0000 && PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
|
| 1356 |
+
typedef struct PyUnicodeWriter PyUnicodeWriter;
|
| 1357 |
+
|
| 1358 |
+
static inline void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
|
| 1359 |
+
{
|
| 1360 |
+
_PyUnicodeWriter_Dealloc((_PyUnicodeWriter*)writer);
|
| 1361 |
+
PyMem_Free(writer);
|
| 1362 |
+
}
|
| 1363 |
+
|
| 1364 |
+
static inline PyUnicodeWriter* PyUnicodeWriter_Create(Py_ssize_t length)
|
| 1365 |
+
{
|
| 1366 |
+
if (length < 0) {
|
| 1367 |
+
PyErr_SetString(PyExc_ValueError,
|
| 1368 |
+
"length must be positive");
|
| 1369 |
+
return NULL;
|
| 1370 |
+
}
|
| 1371 |
+
|
| 1372 |
+
const size_t size = sizeof(_PyUnicodeWriter);
|
| 1373 |
+
PyUnicodeWriter *pub_writer = (PyUnicodeWriter *)PyMem_Malloc(size);
|
| 1374 |
+
if (pub_writer == _Py_NULL) {
|
| 1375 |
+
PyErr_NoMemory();
|
| 1376 |
+
return _Py_NULL;
|
| 1377 |
+
}
|
| 1378 |
+
_PyUnicodeWriter *writer = (_PyUnicodeWriter *)pub_writer;
|
| 1379 |
+
|
| 1380 |
+
_PyUnicodeWriter_Init(writer);
|
| 1381 |
+
if (_PyUnicodeWriter_Prepare(writer, length, 127) < 0) {
|
| 1382 |
+
PyUnicodeWriter_Discard(pub_writer);
|
| 1383 |
+
return NULL;
|
| 1384 |
+
}
|
| 1385 |
+
writer->overallocate = 1;
|
| 1386 |
+
return pub_writer;
|
| 1387 |
+
}
|
| 1388 |
+
|
| 1389 |
+
static inline PyObject* PyUnicodeWriter_Finish(PyUnicodeWriter *writer)
|
| 1390 |
+
{
|
| 1391 |
+
PyObject *str = _PyUnicodeWriter_Finish((_PyUnicodeWriter*)writer);
|
| 1392 |
+
assert(((_PyUnicodeWriter*)writer)->buffer == NULL);
|
| 1393 |
+
PyMem_Free(writer);
|
| 1394 |
+
return str;
|
| 1395 |
+
}
|
| 1396 |
+
|
| 1397 |
+
static inline int
|
| 1398 |
+
PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
|
| 1399 |
+
{
|
| 1400 |
+
if (ch > 0x10ffff) {
|
| 1401 |
+
PyErr_SetString(PyExc_ValueError,
|
| 1402 |
+
"character must be in range(0x110000)");
|
| 1403 |
+
return -1;
|
| 1404 |
+
}
|
| 1405 |
+
|
| 1406 |
+
return _PyUnicodeWriter_WriteChar((_PyUnicodeWriter*)writer, ch);
|
| 1407 |
+
}
|
| 1408 |
+
|
| 1409 |
+
static inline int
|
| 1410 |
+
PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)
|
| 1411 |
+
{
|
| 1412 |
+
PyObject *str = PyObject_Str(obj);
|
| 1413 |
+
if (str == NULL) {
|
| 1414 |
+
return -1;
|
| 1415 |
+
}
|
| 1416 |
+
|
| 1417 |
+
int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str);
|
| 1418 |
+
Py_DECREF(str);
|
| 1419 |
+
return res;
|
| 1420 |
+
}
|
| 1421 |
+
|
| 1422 |
+
static inline int
|
| 1423 |
+
PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj)
|
| 1424 |
+
{
|
| 1425 |
+
PyObject *str = PyObject_Repr(obj);
|
| 1426 |
+
if (str == NULL) {
|
| 1427 |
+
return -1;
|
| 1428 |
+
}
|
| 1429 |
+
|
| 1430 |
+
int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str);
|
| 1431 |
+
Py_DECREF(str);
|
| 1432 |
+
return res;
|
| 1433 |
+
}
|
| 1434 |
+
|
| 1435 |
+
static inline int
|
| 1436 |
+
PyUnicodeWriter_WriteUTF8(PyUnicodeWriter *writer,
|
| 1437 |
+
const char *str, Py_ssize_t size)
|
| 1438 |
+
{
|
| 1439 |
+
if (size < 0) {
|
| 1440 |
+
size = (Py_ssize_t)strlen(str);
|
| 1441 |
+
}
|
| 1442 |
+
|
| 1443 |
+
PyObject *str_obj = PyUnicode_FromStringAndSize(str, size);
|
| 1444 |
+
if (str_obj == _Py_NULL) {
|
| 1445 |
+
return -1;
|
| 1446 |
+
}
|
| 1447 |
+
|
| 1448 |
+
int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str_obj);
|
| 1449 |
+
Py_DECREF(str_obj);
|
| 1450 |
+
return res;
|
| 1451 |
+
}
|
| 1452 |
+
|
| 1453 |
+
static inline int
|
| 1454 |
+
PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer,
|
| 1455 |
+
const wchar_t *str, Py_ssize_t size)
|
| 1456 |
+
{
|
| 1457 |
+
if (size < 0) {
|
| 1458 |
+
size = (Py_ssize_t)wcslen(str);
|
| 1459 |
+
}
|
| 1460 |
+
|
| 1461 |
+
PyObject *str_obj = PyUnicode_FromWideChar(str, size);
|
| 1462 |
+
if (str_obj == _Py_NULL) {
|
| 1463 |
+
return -1;
|
| 1464 |
+
}
|
| 1465 |
+
|
| 1466 |
+
int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str_obj);
|
| 1467 |
+
Py_DECREF(str_obj);
|
| 1468 |
+
return res;
|
| 1469 |
+
}
|
| 1470 |
+
|
| 1471 |
+
static inline int
|
| 1472 |
+
PyUnicodeWriter_WriteSubstring(PyUnicodeWriter *writer, PyObject *str,
|
| 1473 |
+
Py_ssize_t start, Py_ssize_t end)
|
| 1474 |
+
{
|
| 1475 |
+
if (!PyUnicode_Check(str)) {
|
| 1476 |
+
PyErr_Format(PyExc_TypeError, "expect str, not %T", str);
|
| 1477 |
+
return -1;
|
| 1478 |
+
}
|
| 1479 |
+
if (start < 0 || start > end) {
|
| 1480 |
+
PyErr_Format(PyExc_ValueError, "invalid start argument");
|
| 1481 |
+
return -1;
|
| 1482 |
+
}
|
| 1483 |
+
if (end > PyUnicode_GET_LENGTH(str)) {
|
| 1484 |
+
PyErr_Format(PyExc_ValueError, "invalid end argument");
|
| 1485 |
+
return -1;
|
| 1486 |
+
}
|
| 1487 |
+
|
| 1488 |
+
return _PyUnicodeWriter_WriteSubstring((_PyUnicodeWriter*)writer, str,
|
| 1489 |
+
start, end);
|
| 1490 |
+
}
|
| 1491 |
+
|
| 1492 |
+
static inline int
|
| 1493 |
+
PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...)
|
| 1494 |
+
{
|
| 1495 |
+
va_list vargs;
|
| 1496 |
+
va_start(vargs, format);
|
| 1497 |
+
PyObject *str = PyUnicode_FromFormatV(format, vargs);
|
| 1498 |
+
va_end(vargs);
|
| 1499 |
+
if (str == _Py_NULL) {
|
| 1500 |
+
return -1;
|
| 1501 |
+
}
|
| 1502 |
+
|
| 1503 |
+
int res = _PyUnicodeWriter_WriteStr((_PyUnicodeWriter*)writer, str);
|
| 1504 |
+
Py_DECREF(str);
|
| 1505 |
+
return res;
|
| 1506 |
+
}
|
| 1507 |
+
#endif // PY_VERSION_HEX < 0x030E0000
|
| 1508 |
+
|
| 1509 |
+
// gh-116560 added PyLong_GetSign() to Python 3.14.0a0
|
| 1510 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1511 |
+
static inline int PyLong_GetSign(PyObject *obj, int *sign)
|
| 1512 |
+
{
|
| 1513 |
+
if (!PyLong_Check(obj)) {
|
| 1514 |
+
PyErr_Format(PyExc_TypeError, "expect int, got %s", Py_TYPE(obj)->tp_name);
|
| 1515 |
+
return -1;
|
| 1516 |
+
}
|
| 1517 |
+
|
| 1518 |
+
*sign = _PyLong_Sign(obj);
|
| 1519 |
+
return 0;
|
| 1520 |
+
}
|
| 1521 |
+
#endif
|
| 1522 |
+
|
| 1523 |
+
|
| 1524 |
+
// gh-124502 added PyUnicode_Equal() to Python 3.14.0a0
|
| 1525 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1526 |
+
static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
|
| 1527 |
+
{
|
| 1528 |
+
if (!PyUnicode_Check(str1)) {
|
| 1529 |
+
PyErr_Format(PyExc_TypeError, "first argument must be str, not %s",
|
| 1530 |
+
Py_TYPE(str1)->tp_name);
|
| 1531 |
+
return -1;
|
| 1532 |
+
}
|
| 1533 |
+
if (!PyUnicode_Check(str2)) {
|
| 1534 |
+
PyErr_Format(PyExc_TypeError, "second argument must be str, not %s",
|
| 1535 |
+
Py_TYPE(str2)->tp_name);
|
| 1536 |
+
return -1;
|
| 1537 |
+
}
|
| 1538 |
+
|
| 1539 |
+
#if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION)
|
| 1540 |
+
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *str1, PyObject *str2);
|
| 1541 |
+
|
| 1542 |
+
return _PyUnicode_Equal(str1, str2);
|
| 1543 |
+
#elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
|
| 1544 |
+
return _PyUnicode_EQ(str1, str2);
|
| 1545 |
+
#elif PY_VERSION_HEX >= 0x03090000 && defined(PYPY_VERSION)
|
| 1546 |
+
return _PyUnicode_EQ(str1, str2);
|
| 1547 |
+
#else
|
| 1548 |
+
return (PyUnicode_Compare(str1, str2) == 0);
|
| 1549 |
+
#endif
|
| 1550 |
+
}
|
| 1551 |
+
#endif
|
| 1552 |
+
|
| 1553 |
+
|
| 1554 |
+
// gh-121645 added PyBytes_Join() to Python 3.14.0a0
|
| 1555 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1556 |
+
static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
|
| 1557 |
+
{
|
| 1558 |
+
return _PyBytes_Join(sep, iterable);
|
| 1559 |
+
}
|
| 1560 |
+
#endif
|
| 1561 |
+
|
| 1562 |
+
|
| 1563 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1564 |
+
static inline Py_hash_t Py_HashBuffer(const void *ptr, Py_ssize_t len)
|
| 1565 |
+
{
|
| 1566 |
+
#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
|
| 1567 |
+
PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void *src, Py_ssize_t len);
|
| 1568 |
+
|
| 1569 |
+
return _Py_HashBytes(ptr, len);
|
| 1570 |
+
#else
|
| 1571 |
+
Py_hash_t hash;
|
| 1572 |
+
PyObject *bytes = PyBytes_FromStringAndSize((const char*)ptr, len);
|
| 1573 |
+
if (bytes == NULL) {
|
| 1574 |
+
return -1;
|
| 1575 |
+
}
|
| 1576 |
+
hash = PyObject_Hash(bytes);
|
| 1577 |
+
Py_DECREF(bytes);
|
| 1578 |
+
return hash;
|
| 1579 |
+
#endif
|
| 1580 |
+
}
|
| 1581 |
+
#endif
|
| 1582 |
+
|
| 1583 |
+
|
| 1584 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1585 |
+
static inline int PyIter_NextItem(PyObject *iter, PyObject **item)
|
| 1586 |
+
{
|
| 1587 |
+
iternextfunc tp_iternext;
|
| 1588 |
+
|
| 1589 |
+
assert(iter != NULL);
|
| 1590 |
+
assert(item != NULL);
|
| 1591 |
+
|
| 1592 |
+
tp_iternext = Py_TYPE(iter)->tp_iternext;
|
| 1593 |
+
if (tp_iternext == NULL) {
|
| 1594 |
+
*item = NULL;
|
| 1595 |
+
PyErr_Format(PyExc_TypeError, "expected an iterator, got '%s'",
|
| 1596 |
+
Py_TYPE(iter)->tp_name);
|
| 1597 |
+
return -1;
|
| 1598 |
+
}
|
| 1599 |
+
|
| 1600 |
+
if ((*item = tp_iternext(iter))) {
|
| 1601 |
+
return 1;
|
| 1602 |
+
}
|
| 1603 |
+
if (!PyErr_Occurred()) {
|
| 1604 |
+
return 0;
|
| 1605 |
+
}
|
| 1606 |
+
if (PyErr_ExceptionMatches(PyExc_StopIteration)) {
|
| 1607 |
+
PyErr_Clear();
|
| 1608 |
+
return 0;
|
| 1609 |
+
}
|
| 1610 |
+
return -1;
|
| 1611 |
+
}
|
| 1612 |
+
#endif
|
| 1613 |
+
|
| 1614 |
+
|
| 1615 |
+
#if PY_VERSION_HEX < 0x030E00A0
|
| 1616 |
+
static inline PyObject* PyLong_FromInt32(int32_t value)
|
| 1617 |
+
{
|
| 1618 |
+
Py_BUILD_ASSERT(sizeof(long) >= 4);
|
| 1619 |
+
return PyLong_FromLong(value);
|
| 1620 |
+
}
|
| 1621 |
+
|
| 1622 |
+
static inline PyObject* PyLong_FromInt64(int64_t value)
|
| 1623 |
+
{
|
| 1624 |
+
Py_BUILD_ASSERT(sizeof(long long) >= 8);
|
| 1625 |
+
return PyLong_FromLongLong(value);
|
| 1626 |
+
}
|
| 1627 |
+
|
| 1628 |
+
static inline PyObject* PyLong_FromUInt32(uint32_t value)
|
| 1629 |
+
{
|
| 1630 |
+
Py_BUILD_ASSERT(sizeof(unsigned long) >= 4);
|
| 1631 |
+
return PyLong_FromUnsignedLong(value);
|
| 1632 |
+
}
|
| 1633 |
+
|
| 1634 |
+
static inline PyObject* PyLong_FromUInt64(uint64_t value)
|
| 1635 |
+
{
|
| 1636 |
+
Py_BUILD_ASSERT(sizeof(unsigned long long) >= 8);
|
| 1637 |
+
return PyLong_FromUnsignedLongLong(value);
|
| 1638 |
+
}
|
| 1639 |
+
|
| 1640 |
+
static inline int PyLong_AsInt32(PyObject *obj, int32_t *pvalue)
|
| 1641 |
+
{
|
| 1642 |
+
Py_BUILD_ASSERT(sizeof(int) == 4);
|
| 1643 |
+
int value = PyLong_AsInt(obj);
|
| 1644 |
+
if (value == -1 && PyErr_Occurred()) {
|
| 1645 |
+
return -1;
|
| 1646 |
+
}
|
| 1647 |
+
*pvalue = (int32_t)value;
|
| 1648 |
+
return 0;
|
| 1649 |
+
}
|
| 1650 |
+
|
| 1651 |
+
static inline int PyLong_AsInt64(PyObject *obj, int64_t *pvalue)
|
| 1652 |
+
{
|
| 1653 |
+
Py_BUILD_ASSERT(sizeof(long long) == 8);
|
| 1654 |
+
long long value = PyLong_AsLongLong(obj);
|
| 1655 |
+
if (value == -1 && PyErr_Occurred()) {
|
| 1656 |
+
return -1;
|
| 1657 |
+
}
|
| 1658 |
+
*pvalue = (int64_t)value;
|
| 1659 |
+
return 0;
|
| 1660 |
+
}
|
| 1661 |
+
|
| 1662 |
+
static inline int PyLong_AsUInt32(PyObject *obj, uint32_t *pvalue)
|
| 1663 |
+
{
|
| 1664 |
+
Py_BUILD_ASSERT(sizeof(long) >= 4);
|
| 1665 |
+
unsigned long value = PyLong_AsUnsignedLong(obj);
|
| 1666 |
+
if (value == (unsigned long)-1 && PyErr_Occurred()) {
|
| 1667 |
+
return -1;
|
| 1668 |
+
}
|
| 1669 |
+
#if SIZEOF_LONG > 4
|
| 1670 |
+
if ((unsigned long)UINT32_MAX < value) {
|
| 1671 |
+
PyErr_SetString(PyExc_OverflowError,
|
| 1672 |
+
"Python int too large to convert to C uint32_t");
|
| 1673 |
+
return -1;
|
| 1674 |
+
}
|
| 1675 |
+
#endif
|
| 1676 |
+
*pvalue = (uint32_t)value;
|
| 1677 |
+
return 0;
|
| 1678 |
+
}
|
| 1679 |
+
|
| 1680 |
+
static inline int PyLong_AsUInt64(PyObject *obj, uint64_t *pvalue)
|
| 1681 |
+
{
|
| 1682 |
+
Py_BUILD_ASSERT(sizeof(long long) == 8);
|
| 1683 |
+
unsigned long long value = PyLong_AsUnsignedLongLong(obj);
|
| 1684 |
+
if (value == (unsigned long long)-1 && PyErr_Occurred()) {
|
| 1685 |
+
return -1;
|
| 1686 |
+
}
|
| 1687 |
+
*pvalue = (uint64_t)value;
|
| 1688 |
+
return 0;
|
| 1689 |
+
}
|
| 1690 |
+
#endif
|
| 1691 |
+
|
| 1692 |
+
|
| 1693 |
+
#ifdef __cplusplus
|
| 1694 |
+
}
|
| 1695 |
+
#endif
|
| 1696 |
+
#endif // PYTHONCAPI_COMPAT
|
.venv/lib/python3.11/site-packages/numba/runtests.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from numba.testing._runtests import _main
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
if __name__ == '__main__':
|
| 5 |
+
import sys
|
| 6 |
+
# For parallel testing under Windows
|
| 7 |
+
from multiprocessing import freeze_support
|
| 8 |
+
freeze_support()
|
| 9 |
+
sys.exit(0 if _main(sys.argv) else 1)
|
.venv/lib/python3.11/site-packages/numba/scripts/__init__.py
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/numba/scripts/generate_lower_listing.py
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Generate documentation for all registered implementation for lowering
|
| 3 |
+
using reStructured text.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
from subprocess import check_output
|
| 8 |
+
|
| 9 |
+
import os.path
|
| 10 |
+
try:
|
| 11 |
+
from StringIO import StringIO # py2
|
| 12 |
+
except ImportError:
|
| 13 |
+
from io import StringIO
|
| 14 |
+
from collections import defaultdict
|
| 15 |
+
import inspect
|
| 16 |
+
from functools import partial
|
| 17 |
+
|
| 18 |
+
import numba
|
| 19 |
+
from numba.core.registry import cpu_target
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
def git_hash():
|
| 23 |
+
out = check_output(['git', 'log', "--pretty=format:'%H'", '-n', '1'])
|
| 24 |
+
return out.decode('ascii').strip("'\"")
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def get_func_name(fn):
|
| 28 |
+
return getattr(fn, '__qualname__', fn.__name__)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def gather_function_info(backend):
|
| 32 |
+
fninfos = defaultdict(list)
|
| 33 |
+
basepath = os.path.dirname(os.path.dirname(numba.__file__))
|
| 34 |
+
for fn, osel in backend._defns.items():
|
| 35 |
+
for sig, impl in osel.versions:
|
| 36 |
+
info = {}
|
| 37 |
+
fninfos[fn].append(info)
|
| 38 |
+
info['fn'] = fn
|
| 39 |
+
info['sig'] = sig
|
| 40 |
+
code, firstlineno = inspect.getsourcelines(impl)
|
| 41 |
+
path = inspect.getsourcefile(impl)
|
| 42 |
+
info['impl'] = {
|
| 43 |
+
'name': get_func_name(impl),
|
| 44 |
+
'filename': os.path.relpath(path, start=basepath),
|
| 45 |
+
'lines': (firstlineno, firstlineno + len(code) - 1),
|
| 46 |
+
'docstring': impl.__doc__
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
return fninfos
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def bind_file_to_print(fobj):
|
| 53 |
+
return partial(print, file=fobj)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def format_signature(sig):
|
| 57 |
+
def fmt(c):
|
| 58 |
+
try:
|
| 59 |
+
return c.__name__
|
| 60 |
+
except AttributeError:
|
| 61 |
+
return repr(c).strip('\'"')
|
| 62 |
+
out = tuple(map(fmt, sig))
|
| 63 |
+
return '`({0})`'.format(', '.join(out))
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
github_url = ('https://github.com/numba/numba/blob/'
|
| 67 |
+
'{commit}/{path}#L{firstline}-L{lastline}')
|
| 68 |
+
|
| 69 |
+
description = """
|
| 70 |
+
This lists all lowering definition registered to the CPU target.
|
| 71 |
+
Each subsection corresponds to a Python function that is supported by numba
|
| 72 |
+
nopython mode. These functions have one or more lower implementation with
|
| 73 |
+
different signatures. The compiler chooses the most specific implementation
|
| 74 |
+
from all overloads.
|
| 75 |
+
"""
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def format_function_infos(fninfos):
|
| 79 |
+
buf = StringIO()
|
| 80 |
+
try:
|
| 81 |
+
print = bind_file_to_print(buf)
|
| 82 |
+
|
| 83 |
+
title_line = "Lowering Listing"
|
| 84 |
+
print(title_line)
|
| 85 |
+
print('=' * len(title_line))
|
| 86 |
+
|
| 87 |
+
print(description)
|
| 88 |
+
|
| 89 |
+
commit = git_hash()
|
| 90 |
+
|
| 91 |
+
def format_fname(fn):
|
| 92 |
+
try:
|
| 93 |
+
fname = "{0}.{1}".format(fn.__module__, get_func_name(fn))
|
| 94 |
+
except AttributeError:
|
| 95 |
+
fname = repr(fn)
|
| 96 |
+
return fn, fname
|
| 97 |
+
|
| 98 |
+
for fn, fname in sorted(map(format_fname, fninfos), key=lambda x: x[1]):
|
| 99 |
+
impinfos = fninfos[fn]
|
| 100 |
+
header_line = "``{0}``".format(fname)
|
| 101 |
+
print(header_line)
|
| 102 |
+
print('-' * len(header_line))
|
| 103 |
+
print()
|
| 104 |
+
|
| 105 |
+
formatted_sigs = map(
|
| 106 |
+
lambda x: format_signature(x['sig']), impinfos)
|
| 107 |
+
sorted_impinfos = sorted(zip(formatted_sigs, impinfos),
|
| 108 |
+
key=lambda x: x[0])
|
| 109 |
+
|
| 110 |
+
col_signatures = ['Signature']
|
| 111 |
+
col_urls = ['Definition']
|
| 112 |
+
|
| 113 |
+
for fmtsig, info in sorted_impinfos:
|
| 114 |
+
impl = info['impl']
|
| 115 |
+
|
| 116 |
+
filename = impl['filename']
|
| 117 |
+
lines = impl['lines']
|
| 118 |
+
fname = impl['name']
|
| 119 |
+
|
| 120 |
+
source = '{0} lines {1}-{2}'.format(filename, *lines)
|
| 121 |
+
link = github_url.format(commit=commit, path=filename,
|
| 122 |
+
firstline=lines[0], lastline=lines[1])
|
| 123 |
+
url = '``{0}`` `{1} <{2}>`_'.format(fname, source, link)
|
| 124 |
+
|
| 125 |
+
col_signatures.append(fmtsig)
|
| 126 |
+
col_urls.append(url)
|
| 127 |
+
|
| 128 |
+
# table formatting
|
| 129 |
+
max_width_col_sig = max(map(len, col_signatures))
|
| 130 |
+
max_width_col_url = max(map(len, col_urls))
|
| 131 |
+
padding = 2
|
| 132 |
+
width_col_sig = padding * 2 + max_width_col_sig
|
| 133 |
+
width_col_url = padding * 2 + max_width_col_url
|
| 134 |
+
line_format = "{{0:^{0}}} {{1:^{1}}}".format(width_col_sig,
|
| 135 |
+
width_col_url)
|
| 136 |
+
print(line_format.format('=' * width_col_sig, '=' * width_col_url))
|
| 137 |
+
print(line_format.format(col_signatures[0], col_urls[0]))
|
| 138 |
+
print(line_format.format('=' * width_col_sig, '=' * width_col_url))
|
| 139 |
+
for sig, url in zip(col_signatures[1:], col_urls[1:]):
|
| 140 |
+
print(line_format.format(sig, url))
|
| 141 |
+
print(line_format.format('=' * width_col_sig, '=' * width_col_url))
|
| 142 |
+
print()
|
| 143 |
+
|
| 144 |
+
return buf.getvalue()
|
| 145 |
+
finally:
|
| 146 |
+
buf.close()
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
# Main routine for this module:
|
| 150 |
+
|
| 151 |
+
def gen_lower_listing(path=None):
|
| 152 |
+
"""
|
| 153 |
+
Generate lowering listing to ``path`` or (if None) to stdout.
|
| 154 |
+
"""
|
| 155 |
+
cpu_backend = cpu_target.target_context
|
| 156 |
+
cpu_backend.refresh()
|
| 157 |
+
|
| 158 |
+
fninfos = gather_function_info(cpu_backend)
|
| 159 |
+
out = format_function_infos(fninfos)
|
| 160 |
+
|
| 161 |
+
if path is None:
|
| 162 |
+
print(out)
|
| 163 |
+
else:
|
| 164 |
+
with open(path, 'w') as fobj:
|
| 165 |
+
print(out, file=fobj)
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
if __name__ == '__main__':
|
| 169 |
+
gen_lower_listing()
|
.venv/lib/python3.11/site-packages/numba/stencils/__init__.py
ADDED
|
File without changes
|
.venv/lib/python3.11/site-packages/numba/stencils/stencil.py
ADDED
|
@@ -0,0 +1,836 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Copyright (c) 2017 Intel Corporation
|
| 3 |
+
# SPDX-License-Identifier: BSD-2-Clause
|
| 4 |
+
#
|
| 5 |
+
|
| 6 |
+
import copy
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
from llvmlite import ir as lir
|
| 10 |
+
|
| 11 |
+
from numba.core import types, typing, utils, ir, config, ir_utils, registry
|
| 12 |
+
from numba.core.typing.templates import (CallableTemplate, signature,
|
| 13 |
+
infer_global, AbstractTemplate)
|
| 14 |
+
from numba.core.imputils import lower_builtin
|
| 15 |
+
from numba.core.extending import register_jitable
|
| 16 |
+
from numba.core.errors import NumbaValueError
|
| 17 |
+
from numba.misc.special import literal_unroll
|
| 18 |
+
import numba
|
| 19 |
+
|
| 20 |
+
import operator
|
| 21 |
+
from numba.np import numpy_support
|
| 22 |
+
|
| 23 |
+
class StencilFuncLowerer(object):
|
| 24 |
+
'''Callable class responsible for lowering calls to a specific StencilFunc.
|
| 25 |
+
'''
|
| 26 |
+
def __init__(self, sf):
|
| 27 |
+
self.stencilFunc = sf
|
| 28 |
+
|
| 29 |
+
def __call__(self, context, builder, sig, args):
|
| 30 |
+
cres = self.stencilFunc.compile_for_argtys(sig.args, {},
|
| 31 |
+
sig.return_type, None)
|
| 32 |
+
res = context.call_internal(builder, cres.fndesc, sig, args)
|
| 33 |
+
context.add_linking_libs([cres.library])
|
| 34 |
+
return res
|
| 35 |
+
|
| 36 |
+
@register_jitable
|
| 37 |
+
def raise_if_incompatible_array_sizes(a, *args):
|
| 38 |
+
ashape = a.shape
|
| 39 |
+
|
| 40 |
+
# We need literal_unroll here because the stencil might take
|
| 41 |
+
# multiple input arrays with different types that are not compatible
|
| 42 |
+
# (e.g. values as float[:] and flags as bool[:])
|
| 43 |
+
# When more than three total arrays are given, the second and third
|
| 44 |
+
# are iterated over in the loop below. Without literal_unroll, their
|
| 45 |
+
# types have to match.
|
| 46 |
+
# An example failing signature without literal_unroll might be
|
| 47 |
+
# (float[:], float[:], bool[:]) (Just (float[:], bool[:]) wouldn't fail)
|
| 48 |
+
for arg in literal_unroll(args):
|
| 49 |
+
if a.ndim != arg.ndim:
|
| 50 |
+
raise ValueError("Secondary stencil array does not have same number "
|
| 51 |
+
" of dimensions as the first stencil input.")
|
| 52 |
+
argshape = arg.shape
|
| 53 |
+
for i in range(len(ashape)):
|
| 54 |
+
if ashape[i] > argshape[i]:
|
| 55 |
+
raise ValueError("Secondary stencil array has some dimension "
|
| 56 |
+
"smaller the same dimension in the first "
|
| 57 |
+
"stencil input.")
|
| 58 |
+
|
| 59 |
+
def slice_addition(the_slice, addend):
|
| 60 |
+
""" Called by stencil in Python mode to add the loop index to a
|
| 61 |
+
user-specified slice.
|
| 62 |
+
"""
|
| 63 |
+
return slice(the_slice.start + addend, the_slice.stop + addend)
|
| 64 |
+
|
| 65 |
+
class StencilFunc(object):
|
| 66 |
+
"""
|
| 67 |
+
A special type to hold stencil information for the IR.
|
| 68 |
+
"""
|
| 69 |
+
|
| 70 |
+
id_counter = 0
|
| 71 |
+
|
| 72 |
+
def __init__(self, kernel_ir, mode, options):
|
| 73 |
+
self.id = type(self).id_counter
|
| 74 |
+
type(self).id_counter += 1
|
| 75 |
+
self.kernel_ir = kernel_ir
|
| 76 |
+
self.mode = mode
|
| 77 |
+
self.options = options
|
| 78 |
+
self.kws = [] # remember original kws arguments
|
| 79 |
+
|
| 80 |
+
# stencils only supported for CPU context currently
|
| 81 |
+
self._typingctx = registry.cpu_target.typing_context
|
| 82 |
+
self._targetctx = registry.cpu_target.target_context
|
| 83 |
+
self._install_type(self._typingctx)
|
| 84 |
+
self.neighborhood = self.options.get("neighborhood")
|
| 85 |
+
self._type_cache = {}
|
| 86 |
+
self._lower_me = StencilFuncLowerer(self)
|
| 87 |
+
|
| 88 |
+
def replace_return_with_setitem(self, blocks, index_vars, out_name):
|
| 89 |
+
"""
|
| 90 |
+
Find return statements in the IR and replace them with a SetItem
|
| 91 |
+
call of the value "returned" by the kernel into the result array.
|
| 92 |
+
Returns the block labels that contained return statements.
|
| 93 |
+
"""
|
| 94 |
+
ret_blocks = []
|
| 95 |
+
|
| 96 |
+
for label, block in blocks.items():
|
| 97 |
+
scope = block.scope
|
| 98 |
+
loc = block.loc
|
| 99 |
+
new_body = []
|
| 100 |
+
for stmt in block.body:
|
| 101 |
+
if isinstance(stmt, ir.Return):
|
| 102 |
+
ret_blocks.append(label)
|
| 103 |
+
# If 1D array then avoid the tuple construction.
|
| 104 |
+
if len(index_vars) == 1:
|
| 105 |
+
rvar = ir.Var(scope, out_name, loc)
|
| 106 |
+
ivar = ir.Var(scope, index_vars[0], loc)
|
| 107 |
+
new_body.append(ir.SetItem(rvar, ivar, stmt.value, loc))
|
| 108 |
+
else:
|
| 109 |
+
# Convert the string names of the index variables into
|
| 110 |
+
# ir.Var's.
|
| 111 |
+
var_index_vars = []
|
| 112 |
+
for one_var in index_vars:
|
| 113 |
+
index_var = ir.Var(scope, one_var, loc)
|
| 114 |
+
var_index_vars += [index_var]
|
| 115 |
+
|
| 116 |
+
s_index_var = scope.redefine("stencil_index", loc)
|
| 117 |
+
# Build a tuple from the index ir.Var's.
|
| 118 |
+
tuple_call = ir.Expr.build_tuple(var_index_vars, loc)
|
| 119 |
+
new_body.append(ir.Assign(tuple_call, s_index_var, loc))
|
| 120 |
+
rvar = ir.Var(scope, out_name, loc)
|
| 121 |
+
# Write the return statements original value into
|
| 122 |
+
# the array using the tuple index.
|
| 123 |
+
si = ir.SetItem(rvar, s_index_var, stmt.value, loc)
|
| 124 |
+
new_body.append(si)
|
| 125 |
+
else:
|
| 126 |
+
new_body.append(stmt)
|
| 127 |
+
block.body = new_body
|
| 128 |
+
return ret_blocks
|
| 129 |
+
|
| 130 |
+
def add_indices_to_kernel(self, kernel, index_names, ndim,
|
| 131 |
+
neighborhood, standard_indexed, typemap, calltypes):
|
| 132 |
+
"""
|
| 133 |
+
Transforms the stencil kernel as specified by the user into one
|
| 134 |
+
that includes each dimension's index variable as part of the getitem
|
| 135 |
+
calls. So, in effect array[-1] becomes array[index0-1].
|
| 136 |
+
"""
|
| 137 |
+
const_dict = {}
|
| 138 |
+
kernel_consts = []
|
| 139 |
+
|
| 140 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 141 |
+
print("add_indices_to_kernel", ndim, neighborhood)
|
| 142 |
+
ir_utils.dump_blocks(kernel.blocks)
|
| 143 |
+
|
| 144 |
+
if neighborhood is None:
|
| 145 |
+
need_to_calc_kernel = True
|
| 146 |
+
else:
|
| 147 |
+
need_to_calc_kernel = False
|
| 148 |
+
if len(neighborhood) != ndim:
|
| 149 |
+
raise NumbaValueError("%d dimensional neighborhood specified "
|
| 150 |
+
"for %d dimensional input array" %
|
| 151 |
+
(len(neighborhood), ndim))
|
| 152 |
+
|
| 153 |
+
tuple_table = ir_utils.get_tuple_table(kernel.blocks)
|
| 154 |
+
|
| 155 |
+
relatively_indexed = set()
|
| 156 |
+
|
| 157 |
+
for block in kernel.blocks.values():
|
| 158 |
+
scope = block.scope
|
| 159 |
+
loc = block.loc
|
| 160 |
+
new_body = []
|
| 161 |
+
for stmt in block.body:
|
| 162 |
+
if (isinstance(stmt, ir.Assign) and
|
| 163 |
+
isinstance(stmt.value, ir.Const)):
|
| 164 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 165 |
+
print("remembering in const_dict", stmt.target.name,
|
| 166 |
+
stmt.value.value)
|
| 167 |
+
# Remember consts for use later.
|
| 168 |
+
const_dict[stmt.target.name] = stmt.value.value
|
| 169 |
+
if ((isinstance(stmt, ir.Assign)
|
| 170 |
+
and isinstance(stmt.value, ir.Expr)
|
| 171 |
+
and stmt.value.op in ['setitem', 'static_setitem']
|
| 172 |
+
and stmt.value.value.name in kernel.arg_names) or
|
| 173 |
+
(isinstance(stmt, ir.SetItem)
|
| 174 |
+
and stmt.target.name in kernel.arg_names)):
|
| 175 |
+
raise NumbaValueError("Assignments to arrays passed to " \
|
| 176 |
+
"stencil kernels is not allowed.")
|
| 177 |
+
if (isinstance(stmt, ir.Assign)
|
| 178 |
+
and isinstance(stmt.value, ir.Expr)
|
| 179 |
+
and stmt.value.op in ['getitem', 'static_getitem']
|
| 180 |
+
and stmt.value.value.name in kernel.arg_names
|
| 181 |
+
and stmt.value.value.name not in standard_indexed):
|
| 182 |
+
# We found a getitem from the input array.
|
| 183 |
+
if stmt.value.op == 'getitem':
|
| 184 |
+
stmt_index_var = stmt.value.index
|
| 185 |
+
else:
|
| 186 |
+
stmt_index_var = stmt.value.index_var
|
| 187 |
+
# allow static_getitem since rewrite passes are applied
|
| 188 |
+
#raise ValueError("Unexpected static_getitem in add_indices_to_kernel.")
|
| 189 |
+
|
| 190 |
+
relatively_indexed.add(stmt.value.value.name)
|
| 191 |
+
|
| 192 |
+
# Store the index used after looking up the variable in
|
| 193 |
+
# the const dictionary.
|
| 194 |
+
if need_to_calc_kernel:
|
| 195 |
+
assert hasattr(stmt_index_var, 'name')
|
| 196 |
+
|
| 197 |
+
if stmt_index_var.name in tuple_table:
|
| 198 |
+
kernel_consts += [tuple_table[stmt_index_var.name]]
|
| 199 |
+
elif stmt_index_var.name in const_dict:
|
| 200 |
+
kernel_consts += [const_dict[stmt_index_var.name]]
|
| 201 |
+
else:
|
| 202 |
+
raise NumbaValueError("stencil kernel index is not "
|
| 203 |
+
"constant, 'neighborhood' option required")
|
| 204 |
+
|
| 205 |
+
if ndim == 1:
|
| 206 |
+
# Single dimension always has index variable 'index0'.
|
| 207 |
+
# tmpvar will hold the real index and is computed by
|
| 208 |
+
# adding the relative offset in stmt.value.index to
|
| 209 |
+
# the current absolute location in index0.
|
| 210 |
+
index_var = ir.Var(scope, index_names[0], loc)
|
| 211 |
+
tmpvar = scope.redefine("stencil_index", loc)
|
| 212 |
+
stmt_index_var_typ = typemap[stmt_index_var.name]
|
| 213 |
+
# If the array is indexed with a slice then we
|
| 214 |
+
# have to add the index value with a call to
|
| 215 |
+
# slice_addition.
|
| 216 |
+
if isinstance(stmt_index_var_typ, types.misc.SliceType):
|
| 217 |
+
sa_var = scope.redefine("slice_addition", loc)
|
| 218 |
+
sa_func = numba.njit(slice_addition)
|
| 219 |
+
sa_func_typ = types.functions.Dispatcher(sa_func)
|
| 220 |
+
typemap[sa_var.name] = sa_func_typ
|
| 221 |
+
g_sa = ir.Global("slice_addition", sa_func, loc)
|
| 222 |
+
new_body.append(ir.Assign(g_sa, sa_var, loc))
|
| 223 |
+
slice_addition_call = ir.Expr.call(sa_var, [stmt_index_var, index_var], (), loc)
|
| 224 |
+
calltypes[slice_addition_call] = sa_func_typ.get_call_type(self._typingctx, [stmt_index_var_typ, types.intp], {})
|
| 225 |
+
new_body.append(ir.Assign(slice_addition_call, tmpvar, loc))
|
| 226 |
+
new_body.append(ir.Assign(
|
| 227 |
+
ir.Expr.getitem(stmt.value.value, tmpvar, loc),
|
| 228 |
+
stmt.target, loc))
|
| 229 |
+
else:
|
| 230 |
+
acc_call = ir.Expr.binop(operator.add, stmt_index_var,
|
| 231 |
+
index_var, loc)
|
| 232 |
+
new_body.append(ir.Assign(acc_call, tmpvar, loc))
|
| 233 |
+
new_body.append(ir.Assign(
|
| 234 |
+
ir.Expr.getitem(stmt.value.value, tmpvar, loc),
|
| 235 |
+
stmt.target, loc))
|
| 236 |
+
else:
|
| 237 |
+
index_vars = []
|
| 238 |
+
sum_results = []
|
| 239 |
+
s_index_var = scope.redefine("stencil_index", loc)
|
| 240 |
+
const_index_vars = []
|
| 241 |
+
ind_stencils = []
|
| 242 |
+
|
| 243 |
+
stmt_index_var_typ = typemap[stmt_index_var.name]
|
| 244 |
+
# Same idea as above but you have to extract
|
| 245 |
+
# individual elements out of the tuple indexing
|
| 246 |
+
# expression and add the corresponding index variable
|
| 247 |
+
# to them and then reconstitute as a tuple that can
|
| 248 |
+
# index the array.
|
| 249 |
+
for dim in range(ndim):
|
| 250 |
+
tmpvar = scope.redefine("const_index", loc)
|
| 251 |
+
new_body.append(ir.Assign(ir.Const(dim, loc),
|
| 252 |
+
tmpvar, loc))
|
| 253 |
+
const_index_vars += [tmpvar]
|
| 254 |
+
index_var = ir.Var(scope, index_names[dim], loc)
|
| 255 |
+
index_vars += [index_var]
|
| 256 |
+
|
| 257 |
+
tmpvar = scope.redefine("ind_stencil_index", loc)
|
| 258 |
+
ind_stencils += [tmpvar]
|
| 259 |
+
getitemvar = scope.redefine("getitem", loc)
|
| 260 |
+
getitemcall = ir.Expr.getitem(stmt_index_var,
|
| 261 |
+
const_index_vars[dim], loc)
|
| 262 |
+
new_body.append(ir.Assign(getitemcall, getitemvar, loc))
|
| 263 |
+
# Get the type of this particular part of the index tuple.
|
| 264 |
+
if isinstance(stmt_index_var_typ, types.ConstSized):
|
| 265 |
+
one_index_typ = stmt_index_var_typ[dim]
|
| 266 |
+
else:
|
| 267 |
+
one_index_typ = stmt_index_var_typ[:]
|
| 268 |
+
# If the array is indexed with a slice then we
|
| 269 |
+
# have to add the index value with a call to
|
| 270 |
+
# slice_addition.
|
| 271 |
+
if isinstance(one_index_typ, types.misc.SliceType):
|
| 272 |
+
sa_var = scope.redefine("slice_addition", loc)
|
| 273 |
+
sa_func = numba.njit(slice_addition)
|
| 274 |
+
sa_func_typ = types.functions.Dispatcher(sa_func)
|
| 275 |
+
typemap[sa_var.name] = sa_func_typ
|
| 276 |
+
g_sa = ir.Global("slice_addition", sa_func, loc)
|
| 277 |
+
new_body.append(ir.Assign(g_sa, sa_var, loc))
|
| 278 |
+
slice_addition_call = ir.Expr.call(sa_var, [getitemvar, index_vars[dim]], (), loc)
|
| 279 |
+
calltypes[slice_addition_call] = sa_func_typ.get_call_type(self._typingctx, [one_index_typ, types.intp], {})
|
| 280 |
+
new_body.append(ir.Assign(slice_addition_call, tmpvar, loc))
|
| 281 |
+
else:
|
| 282 |
+
acc_call = ir.Expr.binop(operator.add, getitemvar,
|
| 283 |
+
index_vars[dim], loc)
|
| 284 |
+
new_body.append(ir.Assign(acc_call, tmpvar, loc))
|
| 285 |
+
|
| 286 |
+
tuple_call = ir.Expr.build_tuple(ind_stencils, loc)
|
| 287 |
+
new_body.append(ir.Assign(tuple_call, s_index_var, loc))
|
| 288 |
+
new_body.append(ir.Assign(
|
| 289 |
+
ir.Expr.getitem(stmt.value.value,s_index_var,loc),
|
| 290 |
+
stmt.target,loc))
|
| 291 |
+
else:
|
| 292 |
+
new_body.append(stmt)
|
| 293 |
+
block.body = new_body
|
| 294 |
+
|
| 295 |
+
if need_to_calc_kernel:
|
| 296 |
+
# Find the size of the kernel by finding the maximum absolute value
|
| 297 |
+
# index used in the kernel specification.
|
| 298 |
+
neighborhood = [[0,0] for _ in range(ndim)]
|
| 299 |
+
if len(kernel_consts) == 0:
|
| 300 |
+
raise NumbaValueError("Stencil kernel with no accesses to "
|
| 301 |
+
"relatively indexed arrays.")
|
| 302 |
+
|
| 303 |
+
for index in kernel_consts:
|
| 304 |
+
if isinstance(index, tuple) or isinstance(index, list):
|
| 305 |
+
for i in range(len(index)):
|
| 306 |
+
te = index[i]
|
| 307 |
+
if isinstance(te, ir.Var) and te.name in const_dict:
|
| 308 |
+
te = const_dict[te.name]
|
| 309 |
+
if isinstance(te, int):
|
| 310 |
+
neighborhood[i][0] = min(neighborhood[i][0], te)
|
| 311 |
+
neighborhood[i][1] = max(neighborhood[i][1], te)
|
| 312 |
+
else:
|
| 313 |
+
raise NumbaValueError(
|
| 314 |
+
"stencil kernel index is not constant,"
|
| 315 |
+
"'neighborhood' option required")
|
| 316 |
+
index_len = len(index)
|
| 317 |
+
elif isinstance(index, int):
|
| 318 |
+
neighborhood[0][0] = min(neighborhood[0][0], index)
|
| 319 |
+
neighborhood[0][1] = max(neighborhood[0][1], index)
|
| 320 |
+
index_len = 1
|
| 321 |
+
else:
|
| 322 |
+
raise NumbaValueError(
|
| 323 |
+
"Non-tuple or non-integer used as stencil index.")
|
| 324 |
+
if index_len != ndim:
|
| 325 |
+
raise NumbaValueError(
|
| 326 |
+
"Stencil index does not match array dimensionality.")
|
| 327 |
+
|
| 328 |
+
return (neighborhood, relatively_indexed)
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
def get_return_type(self, argtys):
|
| 332 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 333 |
+
print("get_return_type", argtys)
|
| 334 |
+
ir_utils.dump_blocks(self.kernel_ir.blocks)
|
| 335 |
+
|
| 336 |
+
if not isinstance(argtys[0], types.npytypes.Array):
|
| 337 |
+
raise NumbaValueError("The first argument to a stencil kernel must "
|
| 338 |
+
"be the primary input array.")
|
| 339 |
+
|
| 340 |
+
from numba.core import typed_passes
|
| 341 |
+
typemap, return_type, calltypes, _ = typed_passes.type_inference_stage(
|
| 342 |
+
self._typingctx,
|
| 343 |
+
self._targetctx,
|
| 344 |
+
self.kernel_ir,
|
| 345 |
+
argtys,
|
| 346 |
+
None,
|
| 347 |
+
{})
|
| 348 |
+
if isinstance(return_type, types.npytypes.Array):
|
| 349 |
+
raise NumbaValueError(
|
| 350 |
+
"Stencil kernel must return a scalar and not a numpy array.")
|
| 351 |
+
|
| 352 |
+
real_ret = types.npytypes.Array(return_type, argtys[0].ndim,
|
| 353 |
+
argtys[0].layout)
|
| 354 |
+
return (real_ret, typemap, calltypes)
|
| 355 |
+
|
| 356 |
+
def _install_type(self, typingctx):
|
| 357 |
+
"""Constructs and installs a typing class for a StencilFunc object in
|
| 358 |
+
the input typing context.
|
| 359 |
+
"""
|
| 360 |
+
_ty_cls = type('StencilFuncTyping_' +
|
| 361 |
+
str(self.id),
|
| 362 |
+
(AbstractTemplate,),
|
| 363 |
+
dict(key=self, generic=self._type_me))
|
| 364 |
+
typingctx.insert_user_function(self, _ty_cls)
|
| 365 |
+
|
| 366 |
+
def compile_for_argtys(self, argtys, kwtys, return_type, sigret):
|
| 367 |
+
# look in the type cache to find if result array is passed
|
| 368 |
+
(_, result, typemap, calltypes) = self._type_cache[argtys]
|
| 369 |
+
new_func = self._stencil_wrapper(result, sigret, return_type,
|
| 370 |
+
typemap, calltypes, *argtys)
|
| 371 |
+
return new_func
|
| 372 |
+
|
| 373 |
+
def _type_me(self, argtys, kwtys):
|
| 374 |
+
"""
|
| 375 |
+
Implement AbstractTemplate.generic() for the typing class
|
| 376 |
+
built by StencilFunc._install_type().
|
| 377 |
+
Return the call-site signature.
|
| 378 |
+
"""
|
| 379 |
+
if (self.neighborhood is not None and
|
| 380 |
+
len(self.neighborhood) != argtys[0].ndim):
|
| 381 |
+
raise NumbaValueError("%d dimensional neighborhood specified "
|
| 382 |
+
"for %d dimensional input array" %
|
| 383 |
+
(len(self.neighborhood), argtys[0].ndim))
|
| 384 |
+
|
| 385 |
+
argtys_extra = argtys
|
| 386 |
+
sig_extra = ""
|
| 387 |
+
result = None
|
| 388 |
+
if 'out' in kwtys:
|
| 389 |
+
argtys_extra += (kwtys['out'],)
|
| 390 |
+
sig_extra += ", out=None"
|
| 391 |
+
result = kwtys['out']
|
| 392 |
+
|
| 393 |
+
if 'neighborhood' in kwtys:
|
| 394 |
+
argtys_extra += (kwtys['neighborhood'],)
|
| 395 |
+
sig_extra += ", neighborhood=None"
|
| 396 |
+
|
| 397 |
+
# look in the type cache first
|
| 398 |
+
if argtys_extra in self._type_cache:
|
| 399 |
+
(_sig, _, _, _) = self._type_cache[argtys_extra]
|
| 400 |
+
return _sig
|
| 401 |
+
|
| 402 |
+
(real_ret, typemap, calltypes) = self.get_return_type(argtys)
|
| 403 |
+
sig = signature(real_ret, *argtys_extra)
|
| 404 |
+
dummy_text = ("def __numba_dummy_stencil({}{}):\n pass\n".format(
|
| 405 |
+
",".join(self.kernel_ir.arg_names), sig_extra))
|
| 406 |
+
dct = {}
|
| 407 |
+
exec(dummy_text, dct)
|
| 408 |
+
dummy_func = dct["__numba_dummy_stencil"]
|
| 409 |
+
sig = sig.replace(pysig=utils.pysignature(dummy_func))
|
| 410 |
+
self._targetctx.insert_func_defn([(self._lower_me, self, argtys_extra)])
|
| 411 |
+
self._type_cache[argtys_extra] = (sig, result, typemap, calltypes)
|
| 412 |
+
return sig
|
| 413 |
+
|
| 414 |
+
def copy_ir_with_calltypes(self, ir, calltypes):
|
| 415 |
+
"""
|
| 416 |
+
Create a copy of a given IR along with its calltype information.
|
| 417 |
+
We need a copy of the calltypes because copy propagation applied
|
| 418 |
+
to the copied IR will change the calltypes and make subsequent
|
| 419 |
+
uses of the original IR invalid.
|
| 420 |
+
"""
|
| 421 |
+
copy_calltypes = {}
|
| 422 |
+
kernel_copy = ir.copy()
|
| 423 |
+
kernel_copy.blocks = {}
|
| 424 |
+
# For each block...
|
| 425 |
+
for (block_label, block) in ir.blocks.items():
|
| 426 |
+
new_block = copy.deepcopy(ir.blocks[block_label])
|
| 427 |
+
new_block.body = []
|
| 428 |
+
# For each statement in each block...
|
| 429 |
+
for stmt in ir.blocks[block_label].body:
|
| 430 |
+
# Copy the statement to the new copy of the kernel
|
| 431 |
+
# and if the original statement is in the original
|
| 432 |
+
# calltypes then add the type associated with this
|
| 433 |
+
# statement to the calltypes copy.
|
| 434 |
+
scopy = copy.deepcopy(stmt)
|
| 435 |
+
new_block.body.append(scopy)
|
| 436 |
+
if stmt in calltypes:
|
| 437 |
+
copy_calltypes[scopy] = calltypes[stmt]
|
| 438 |
+
kernel_copy.blocks[block_label] = new_block
|
| 439 |
+
return (kernel_copy, copy_calltypes)
|
| 440 |
+
|
| 441 |
+
def _stencil_wrapper(self, result, sigret, return_type, typemap, calltypes, *args):
|
| 442 |
+
# Overall approach:
|
| 443 |
+
# 1) Construct a string containing a function definition for the stencil function
|
| 444 |
+
# that will execute the stencil kernel. This function definition includes a
|
| 445 |
+
# unique stencil function name, the parameters to the stencil kernel, loop
|
| 446 |
+
# nests across the dimensions of the input array. Those loop nests use the
|
| 447 |
+
# computed stencil kernel size so as not to try to compute elements where
|
| 448 |
+
# elements outside the bounds of the input array would be needed.
|
| 449 |
+
# 2) The but of the loop nest in this new function is a special sentinel
|
| 450 |
+
# assignment.
|
| 451 |
+
# 3) Get the IR of this new function.
|
| 452 |
+
# 4) Split the block containing the sentinel assignment and remove the sentinel
|
| 453 |
+
# assignment. Insert the stencil kernel IR into the stencil function IR
|
| 454 |
+
# after label and variable renaming of the stencil kernel IR to prevent
|
| 455 |
+
# conflicts with the stencil function IR.
|
| 456 |
+
# 5) Compile the combined stencil function IR + stencil kernel IR into existence.
|
| 457 |
+
|
| 458 |
+
# Copy the kernel so that our changes for this callsite
|
| 459 |
+
# won't effect other callsites.
|
| 460 |
+
(kernel_copy, copy_calltypes) = self.copy_ir_with_calltypes(
|
| 461 |
+
self.kernel_ir, calltypes)
|
| 462 |
+
# The stencil kernel body becomes the body of a loop, for which args aren't needed.
|
| 463 |
+
ir_utils.remove_args(kernel_copy.blocks)
|
| 464 |
+
first_arg = kernel_copy.arg_names[0]
|
| 465 |
+
|
| 466 |
+
in_cps, out_cps = ir_utils.copy_propagate(kernel_copy.blocks, typemap)
|
| 467 |
+
name_var_table = ir_utils.get_name_var_table(kernel_copy.blocks)
|
| 468 |
+
ir_utils.apply_copy_propagate(
|
| 469 |
+
kernel_copy.blocks,
|
| 470 |
+
in_cps,
|
| 471 |
+
name_var_table,
|
| 472 |
+
typemap,
|
| 473 |
+
copy_calltypes)
|
| 474 |
+
|
| 475 |
+
if "out" in name_var_table:
|
| 476 |
+
raise NumbaValueError("Cannot use the reserved word 'out' in stencil kernels.")
|
| 477 |
+
|
| 478 |
+
sentinel_name = ir_utils.get_unused_var_name("__sentinel__", name_var_table)
|
| 479 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 480 |
+
print("name_var_table", name_var_table, sentinel_name)
|
| 481 |
+
|
| 482 |
+
the_array = args[0]
|
| 483 |
+
|
| 484 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 485 |
+
print("_stencil_wrapper", return_type, return_type.dtype,
|
| 486 |
+
type(return_type.dtype), args)
|
| 487 |
+
ir_utils.dump_blocks(kernel_copy.blocks)
|
| 488 |
+
|
| 489 |
+
# We generate a Numba function to execute this stencil and here
|
| 490 |
+
# create the unique name of this function.
|
| 491 |
+
stencil_func_name = "__numba_stencil_%s_%s" % (
|
| 492 |
+
hex(id(the_array)).replace("-", "_"),
|
| 493 |
+
self.id)
|
| 494 |
+
|
| 495 |
+
# We will put a loop nest in the generated function for each
|
| 496 |
+
# dimension in the input array. Here we create the name for
|
| 497 |
+
# the index variable for each dimension. index0, index1, ...
|
| 498 |
+
index_vars = []
|
| 499 |
+
for i in range(the_array.ndim):
|
| 500 |
+
index_var_name = ir_utils.get_unused_var_name("index" + str(i),
|
| 501 |
+
name_var_table)
|
| 502 |
+
index_vars += [index_var_name]
|
| 503 |
+
|
| 504 |
+
# Create extra signature for out and neighborhood.
|
| 505 |
+
out_name = ir_utils.get_unused_var_name("out", name_var_table)
|
| 506 |
+
neighborhood_name = ir_utils.get_unused_var_name("neighborhood",
|
| 507 |
+
name_var_table)
|
| 508 |
+
sig_extra = ""
|
| 509 |
+
if result is not None:
|
| 510 |
+
sig_extra += ", {}=None".format(out_name)
|
| 511 |
+
if "neighborhood" in dict(self.kws):
|
| 512 |
+
sig_extra += ", {}=None".format(neighborhood_name)
|
| 513 |
+
|
| 514 |
+
# Get a list of the standard indexed array names.
|
| 515 |
+
standard_indexed = self.options.get("standard_indexing", [])
|
| 516 |
+
|
| 517 |
+
if first_arg in standard_indexed:
|
| 518 |
+
raise NumbaValueError("The first argument to a stencil kernel must "
|
| 519 |
+
"use relative indexing, not standard indexing.")
|
| 520 |
+
|
| 521 |
+
if len(set(standard_indexed) - set(kernel_copy.arg_names)) != 0:
|
| 522 |
+
raise NumbaValueError("Standard indexing requested for an array name "
|
| 523 |
+
"not present in the stencil kernel definition.")
|
| 524 |
+
|
| 525 |
+
# Add index variables to getitems in the IR to transition the accesses
|
| 526 |
+
# in the kernel from relative to regular Python indexing. Returns the
|
| 527 |
+
# computed size of the stencil kernel and a list of the relatively indexed
|
| 528 |
+
# arrays.
|
| 529 |
+
kernel_size, relatively_indexed = self.add_indices_to_kernel(
|
| 530 |
+
kernel_copy, index_vars, the_array.ndim,
|
| 531 |
+
self.neighborhood, standard_indexed, typemap, copy_calltypes)
|
| 532 |
+
if self.neighborhood is None:
|
| 533 |
+
self.neighborhood = kernel_size
|
| 534 |
+
|
| 535 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 536 |
+
print("After add_indices_to_kernel")
|
| 537 |
+
ir_utils.dump_blocks(kernel_copy.blocks)
|
| 538 |
+
|
| 539 |
+
# The return in the stencil kernel becomes a setitem for that
|
| 540 |
+
# particular point in the iteration space.
|
| 541 |
+
ret_blocks = self.replace_return_with_setitem(kernel_copy.blocks,
|
| 542 |
+
index_vars, out_name)
|
| 543 |
+
|
| 544 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 545 |
+
print("After replace_return_with_setitem", ret_blocks)
|
| 546 |
+
ir_utils.dump_blocks(kernel_copy.blocks)
|
| 547 |
+
|
| 548 |
+
# Start to form the new function to execute the stencil kernel.
|
| 549 |
+
func_text = "def {}({}{}):\n".format(stencil_func_name,
|
| 550 |
+
",".join(kernel_copy.arg_names), sig_extra)
|
| 551 |
+
|
| 552 |
+
# Get loop ranges for each dimension, which could be either int
|
| 553 |
+
# or variable. In the latter case we'll use the extra neighborhood
|
| 554 |
+
# argument to the function.
|
| 555 |
+
ranges = []
|
| 556 |
+
for i in range(the_array.ndim):
|
| 557 |
+
if isinstance(kernel_size[i][0], int):
|
| 558 |
+
lo = kernel_size[i][0]
|
| 559 |
+
hi = kernel_size[i][1]
|
| 560 |
+
else:
|
| 561 |
+
lo = "{}[{}][0]".format(neighborhood_name, i)
|
| 562 |
+
hi = "{}[{}][1]".format(neighborhood_name, i)
|
| 563 |
+
ranges.append((lo, hi))
|
| 564 |
+
|
| 565 |
+
# If there are more than one relatively indexed arrays, add a call to
|
| 566 |
+
# a function that will raise an error if any of the relatively indexed
|
| 567 |
+
# arrays are of different size than the first input array.
|
| 568 |
+
if len(relatively_indexed) > 1:
|
| 569 |
+
func_text += " raise_if_incompatible_array_sizes(" + first_arg
|
| 570 |
+
for other_array in relatively_indexed:
|
| 571 |
+
if other_array != first_arg:
|
| 572 |
+
func_text += "," + other_array
|
| 573 |
+
func_text += ")\n"
|
| 574 |
+
|
| 575 |
+
# Get the shape of the first input array.
|
| 576 |
+
shape_name = ir_utils.get_unused_var_name("full_shape", name_var_table)
|
| 577 |
+
func_text += " {} = {}.shape\n".format(shape_name, first_arg)
|
| 578 |
+
|
| 579 |
+
# Converts cval to a string constant
|
| 580 |
+
def cval_as_str(cval):
|
| 581 |
+
if not np.isfinite(cval):
|
| 582 |
+
# See if this is a string-repr numerical const, issue #7286
|
| 583 |
+
if np.isnan(cval):
|
| 584 |
+
return "np.nan"
|
| 585 |
+
elif np.isinf(cval):
|
| 586 |
+
if cval < 0:
|
| 587 |
+
return "-np.inf"
|
| 588 |
+
else:
|
| 589 |
+
return "np.inf"
|
| 590 |
+
else:
|
| 591 |
+
return str(cval)
|
| 592 |
+
|
| 593 |
+
# If we have to allocate the output array (the out argument was not used)
|
| 594 |
+
# then us numpy.full if the user specified a cval stencil decorator option
|
| 595 |
+
# or np.zeros if they didn't to allocate the array.
|
| 596 |
+
if result is None:
|
| 597 |
+
return_type_name = numpy_support.as_dtype(
|
| 598 |
+
return_type.dtype).type.__name__
|
| 599 |
+
out_init ="{} = np.empty({}, dtype=np.{})\n".format(
|
| 600 |
+
out_name, shape_name, return_type_name)
|
| 601 |
+
|
| 602 |
+
if "cval" in self.options:
|
| 603 |
+
cval = self.options["cval"]
|
| 604 |
+
cval_ty = typing.typeof.typeof(cval)
|
| 605 |
+
if not self._typingctx.can_convert(cval_ty, return_type.dtype):
|
| 606 |
+
msg = "cval type does not match stencil return type."
|
| 607 |
+
raise NumbaValueError(msg)
|
| 608 |
+
else:
|
| 609 |
+
cval = 0
|
| 610 |
+
func_text += " " + out_init
|
| 611 |
+
for dim in range(the_array.ndim):
|
| 612 |
+
start_items = [":"] * the_array.ndim
|
| 613 |
+
end_items = [":"] * the_array.ndim
|
| 614 |
+
start_items[dim] = ":-{}".format(self.neighborhood[dim][0])
|
| 615 |
+
end_items[dim] = "-{}:".format(self.neighborhood[dim][1])
|
| 616 |
+
func_text += " " + "{}[{}] = {}\n".format(out_name, ",".join(start_items), cval_as_str(cval))
|
| 617 |
+
func_text += " " + "{}[{}] = {}\n".format(out_name, ",".join(end_items), cval_as_str(cval))
|
| 618 |
+
else: # result is present, if cval is set then use it
|
| 619 |
+
if "cval" in self.options:
|
| 620 |
+
cval = self.options["cval"]
|
| 621 |
+
cval_ty = typing.typeof.typeof(cval)
|
| 622 |
+
if not self._typingctx.can_convert(cval_ty, return_type.dtype):
|
| 623 |
+
msg = "cval type does not match stencil return type."
|
| 624 |
+
raise NumbaValueError(msg)
|
| 625 |
+
out_init = "{}[:] = {}\n".format(out_name, cval_as_str(cval))
|
| 626 |
+
func_text += " " + out_init
|
| 627 |
+
|
| 628 |
+
offset = 1
|
| 629 |
+
# Add the loop nests to the new function.
|
| 630 |
+
for i in range(the_array.ndim):
|
| 631 |
+
for j in range(offset):
|
| 632 |
+
func_text += " "
|
| 633 |
+
# ranges[i][0] is the minimum index used in the i'th dimension
|
| 634 |
+
# but minimum's greater than 0 don't preclude any entry in the array.
|
| 635 |
+
# So, take the minimum of 0 and the minimum index found in the kernel
|
| 636 |
+
# and this will be a negative number (potentially -0). Then, we do
|
| 637 |
+
# unary - on that to get the positive offset in this dimension whose
|
| 638 |
+
# use is precluded.
|
| 639 |
+
# ranges[i][1] is the maximum of 0 and the observed maximum index
|
| 640 |
+
# in this dimension because negative maximums would not cause us to
|
| 641 |
+
# preclude any entry in the array from being used.
|
| 642 |
+
func_text += ("for {} in range(-min(0,{}),"
|
| 643 |
+
"{}[{}]-max(0,{})):\n").format(
|
| 644 |
+
index_vars[i],
|
| 645 |
+
ranges[i][0],
|
| 646 |
+
shape_name,
|
| 647 |
+
i,
|
| 648 |
+
ranges[i][1])
|
| 649 |
+
offset += 1
|
| 650 |
+
|
| 651 |
+
for j in range(offset):
|
| 652 |
+
func_text += " "
|
| 653 |
+
# Put a sentinel in the code so we can locate it in the IR. We will
|
| 654 |
+
# remove this sentinel assignment and replace it with the IR for the
|
| 655 |
+
# stencil kernel body.
|
| 656 |
+
func_text += "{} = 0\n".format(sentinel_name)
|
| 657 |
+
func_text += " return {}\n".format(out_name)
|
| 658 |
+
|
| 659 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 660 |
+
print("new stencil func text")
|
| 661 |
+
print(func_text)
|
| 662 |
+
|
| 663 |
+
# Force the new stencil function into existence.
|
| 664 |
+
dct = {}
|
| 665 |
+
dct.update(globals())
|
| 666 |
+
exec(func_text, dct)
|
| 667 |
+
stencil_func = dct[stencil_func_name]
|
| 668 |
+
if sigret is not None:
|
| 669 |
+
pysig = utils.pysignature(stencil_func)
|
| 670 |
+
sigret.pysig = pysig
|
| 671 |
+
# Get the IR for the newly created stencil function.
|
| 672 |
+
from numba.core import compiler
|
| 673 |
+
stencil_ir = compiler.run_frontend(stencil_func)
|
| 674 |
+
ir_utils.remove_dels(stencil_ir.blocks)
|
| 675 |
+
|
| 676 |
+
# rename all variables in stencil_ir afresh
|
| 677 |
+
var_table = ir_utils.get_name_var_table(stencil_ir.blocks)
|
| 678 |
+
new_var_dict = {}
|
| 679 |
+
reserved_names = ([sentinel_name, out_name, neighborhood_name,
|
| 680 |
+
shape_name] + kernel_copy.arg_names + index_vars)
|
| 681 |
+
for name, var in var_table.items():
|
| 682 |
+
if not name in reserved_names:
|
| 683 |
+
assert isinstance(var, ir.Var)
|
| 684 |
+
new_var = var.scope.redefine(var.name, var.loc)
|
| 685 |
+
new_var_dict[name] = new_var.name
|
| 686 |
+
ir_utils.replace_var_names(stencil_ir.blocks, new_var_dict)
|
| 687 |
+
|
| 688 |
+
stencil_stub_last_label = max(stencil_ir.blocks.keys()) + 1
|
| 689 |
+
|
| 690 |
+
# Shift labels in the kernel copy so they are guaranteed unique
|
| 691 |
+
# and don't conflict with any labels in the stencil_ir.
|
| 692 |
+
kernel_copy.blocks = ir_utils.add_offset_to_labels(
|
| 693 |
+
kernel_copy.blocks, stencil_stub_last_label)
|
| 694 |
+
new_label = max(kernel_copy.blocks.keys()) + 1
|
| 695 |
+
# Adjust ret_blocks to account for addition of the offset.
|
| 696 |
+
ret_blocks = [x + stencil_stub_last_label for x in ret_blocks]
|
| 697 |
+
|
| 698 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 699 |
+
print("ret_blocks w/ offsets", ret_blocks, stencil_stub_last_label)
|
| 700 |
+
print("before replace sentinel stencil_ir")
|
| 701 |
+
ir_utils.dump_blocks(stencil_ir.blocks)
|
| 702 |
+
print("before replace sentinel kernel_copy")
|
| 703 |
+
ir_utils.dump_blocks(kernel_copy.blocks)
|
| 704 |
+
|
| 705 |
+
# Search all the block in the stencil outline for the sentinel.
|
| 706 |
+
for label, block in stencil_ir.blocks.items():
|
| 707 |
+
for i, inst in enumerate(block.body):
|
| 708 |
+
if (isinstance( inst, ir.Assign) and
|
| 709 |
+
inst.target.name == sentinel_name):
|
| 710 |
+
# We found the sentinel assignment.
|
| 711 |
+
loc = inst.loc
|
| 712 |
+
scope = block.scope
|
| 713 |
+
# split block across __sentinel__
|
| 714 |
+
# A new block is allocated for the statements prior to the
|
| 715 |
+
# sentinel but the new block maintains the current block
|
| 716 |
+
# label.
|
| 717 |
+
prev_block = ir.Block(scope, loc)
|
| 718 |
+
prev_block.body = block.body[:i]
|
| 719 |
+
# The current block is used for statements after sentinel.
|
| 720 |
+
block.body = block.body[i + 1:]
|
| 721 |
+
# But the current block gets a new label.
|
| 722 |
+
body_first_label = min(kernel_copy.blocks.keys())
|
| 723 |
+
|
| 724 |
+
# The previous block jumps to the minimum labelled block of
|
| 725 |
+
# the parfor body.
|
| 726 |
+
prev_block.append(ir.Jump(body_first_label, loc))
|
| 727 |
+
# Add all the parfor loop body blocks to the gufunc
|
| 728 |
+
# function's IR.
|
| 729 |
+
for (l, b) in kernel_copy.blocks.items():
|
| 730 |
+
stencil_ir.blocks[l] = b
|
| 731 |
+
|
| 732 |
+
stencil_ir.blocks[new_label] = block
|
| 733 |
+
stencil_ir.blocks[label] = prev_block
|
| 734 |
+
# Add a jump from all the blocks that previously contained
|
| 735 |
+
# a return in the stencil kernel to the block
|
| 736 |
+
# containing statements after the sentinel.
|
| 737 |
+
for ret_block in ret_blocks:
|
| 738 |
+
stencil_ir.blocks[ret_block].append(
|
| 739 |
+
ir.Jump(new_label, loc))
|
| 740 |
+
break
|
| 741 |
+
else:
|
| 742 |
+
continue
|
| 743 |
+
break
|
| 744 |
+
|
| 745 |
+
stencil_ir.blocks = ir_utils.rename_labels(stencil_ir.blocks)
|
| 746 |
+
ir_utils.remove_dels(stencil_ir.blocks)
|
| 747 |
+
|
| 748 |
+
assert(isinstance(the_array, types.Type))
|
| 749 |
+
array_types = args
|
| 750 |
+
|
| 751 |
+
new_stencil_param_types = list(array_types)
|
| 752 |
+
|
| 753 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 754 |
+
print("new_stencil_param_types", new_stencil_param_types)
|
| 755 |
+
ir_utils.dump_blocks(stencil_ir.blocks)
|
| 756 |
+
|
| 757 |
+
# Compile the combined stencil function with the replaced loop
|
| 758 |
+
# body in it.
|
| 759 |
+
ir_utils.fixup_var_define_in_scope(stencil_ir.blocks)
|
| 760 |
+
new_func = compiler.compile_ir(
|
| 761 |
+
self._typingctx,
|
| 762 |
+
self._targetctx,
|
| 763 |
+
stencil_ir,
|
| 764 |
+
new_stencil_param_types,
|
| 765 |
+
None,
|
| 766 |
+
compiler.DEFAULT_FLAGS,
|
| 767 |
+
{})
|
| 768 |
+
return new_func
|
| 769 |
+
|
| 770 |
+
def __call__(self, *args, **kwargs):
|
| 771 |
+
self._typingctx.refresh()
|
| 772 |
+
if (self.neighborhood is not None and
|
| 773 |
+
len(self.neighborhood) != args[0].ndim):
|
| 774 |
+
raise NumbaValueError("{} dimensional neighborhood specified for "
|
| 775 |
+
"{} dimensional input array".format(
|
| 776 |
+
len(self.neighborhood), args[0].ndim))
|
| 777 |
+
|
| 778 |
+
if 'out' in kwargs:
|
| 779 |
+
result = kwargs['out']
|
| 780 |
+
rdtype = result.dtype
|
| 781 |
+
rttype = numpy_support.from_dtype(rdtype)
|
| 782 |
+
result_type = types.npytypes.Array(rttype, result.ndim,
|
| 783 |
+
numpy_support.map_layout(result))
|
| 784 |
+
array_types = tuple([typing.typeof.typeof(x) for x in args])
|
| 785 |
+
array_types_full = tuple([typing.typeof.typeof(x) for x in args] +
|
| 786 |
+
[result_type])
|
| 787 |
+
else:
|
| 788 |
+
result = None
|
| 789 |
+
array_types = tuple([typing.typeof.typeof(x) for x in args])
|
| 790 |
+
array_types_full = array_types
|
| 791 |
+
|
| 792 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 793 |
+
print("__call__", array_types, args, kwargs)
|
| 794 |
+
|
| 795 |
+
(real_ret, typemap, calltypes) = self.get_return_type(array_types)
|
| 796 |
+
new_func = self._stencil_wrapper(result, None, real_ret, typemap,
|
| 797 |
+
calltypes, *array_types_full)
|
| 798 |
+
|
| 799 |
+
if result is None:
|
| 800 |
+
return new_func.entry_point(*args)
|
| 801 |
+
else:
|
| 802 |
+
return new_func.entry_point(*(args+(result,)))
|
| 803 |
+
|
| 804 |
+
def stencil(func_or_mode='constant', **options):
|
| 805 |
+
# called on function without specifying mode style
|
| 806 |
+
if not isinstance(func_or_mode, str):
|
| 807 |
+
mode = 'constant' # default style
|
| 808 |
+
func = func_or_mode
|
| 809 |
+
else:
|
| 810 |
+
mode = func_or_mode
|
| 811 |
+
func = None
|
| 812 |
+
|
| 813 |
+
for option in options:
|
| 814 |
+
if option not in ["cval", "standard_indexing", "neighborhood"]:
|
| 815 |
+
raise NumbaValueError("Unknown stencil option " + option)
|
| 816 |
+
|
| 817 |
+
wrapper = _stencil(mode, options)
|
| 818 |
+
if func is not None:
|
| 819 |
+
return wrapper(func)
|
| 820 |
+
return wrapper
|
| 821 |
+
|
| 822 |
+
def _stencil(mode, options):
|
| 823 |
+
if mode != 'constant':
|
| 824 |
+
raise NumbaValueError("Unsupported mode style " + mode)
|
| 825 |
+
|
| 826 |
+
def decorated(func):
|
| 827 |
+
from numba.core import compiler
|
| 828 |
+
kernel_ir = compiler.run_frontend(func)
|
| 829 |
+
return StencilFunc(kernel_ir, mode, options)
|
| 830 |
+
|
| 831 |
+
return decorated
|
| 832 |
+
|
| 833 |
+
@lower_builtin(stencil)
|
| 834 |
+
def stencil_dummy_lower(context, builder, sig, args):
|
| 835 |
+
"lowering for dummy stencil calls"
|
| 836 |
+
return lir.Constant(lir.IntType(types.intp.bitwidth), 0)
|
.venv/lib/python3.11/site-packages/numba/stencils/stencilparfor.py
ADDED
|
@@ -0,0 +1,957 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#
|
| 2 |
+
# Copyright (c) 2017 Intel Corporation
|
| 3 |
+
# SPDX-License-Identifier: BSD-2-Clause
|
| 4 |
+
#
|
| 5 |
+
|
| 6 |
+
import numbers
|
| 7 |
+
import copy
|
| 8 |
+
import types as pytypes
|
| 9 |
+
from operator import add
|
| 10 |
+
import operator
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
|
| 14 |
+
import numba.parfors.parfor
|
| 15 |
+
from numba.core import types, ir, rewrites, config, ir_utils
|
| 16 |
+
from numba.core.typing.templates import infer_global, AbstractTemplate
|
| 17 |
+
from numba.core.typing import signature
|
| 18 |
+
from numba.core import utils, typing
|
| 19 |
+
from numba.core.ir_utils import (get_call_table, mk_unique_var,
|
| 20 |
+
compile_to_numba_ir, replace_arg_nodes, guard,
|
| 21 |
+
find_callname, require, find_const, GuardException)
|
| 22 |
+
from numba.core.errors import NumbaValueError
|
| 23 |
+
from numba.core.utils import OPERATORS_TO_BUILTINS
|
| 24 |
+
from numba.np import numpy_support
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def _compute_last_ind(dim_size, index_const):
|
| 28 |
+
if index_const > 0:
|
| 29 |
+
return dim_size - index_const
|
| 30 |
+
else:
|
| 31 |
+
return dim_size
|
| 32 |
+
|
| 33 |
+
class StencilPass(object):
|
| 34 |
+
def __init__(self, func_ir, typemap, calltypes, array_analysis, typingctx,
|
| 35 |
+
targetctx, flags):
|
| 36 |
+
self.func_ir = func_ir
|
| 37 |
+
self.typemap = typemap
|
| 38 |
+
self.calltypes = calltypes
|
| 39 |
+
self.array_analysis = array_analysis
|
| 40 |
+
self.typingctx = typingctx
|
| 41 |
+
self.targetctx = targetctx
|
| 42 |
+
self.flags = flags
|
| 43 |
+
|
| 44 |
+
def run(self):
|
| 45 |
+
""" Finds all calls to StencilFuncs in the IR and converts them to parfor.
|
| 46 |
+
"""
|
| 47 |
+
from numba.stencils.stencil import StencilFunc
|
| 48 |
+
|
| 49 |
+
# Get all the calls in the function IR.
|
| 50 |
+
call_table, _ = get_call_table(self.func_ir.blocks)
|
| 51 |
+
stencil_calls = []
|
| 52 |
+
stencil_dict = {}
|
| 53 |
+
for call_varname, call_list in call_table.items():
|
| 54 |
+
for one_call in call_list:
|
| 55 |
+
if isinstance(one_call, StencilFunc):
|
| 56 |
+
# Remember all calls to StencilFuncs.
|
| 57 |
+
stencil_calls.append(call_varname)
|
| 58 |
+
stencil_dict[call_varname] = one_call
|
| 59 |
+
if not stencil_calls:
|
| 60 |
+
return # return early if no stencil calls found
|
| 61 |
+
|
| 62 |
+
# find and transform stencil calls
|
| 63 |
+
for label, block in self.func_ir.blocks.items():
|
| 64 |
+
for i, stmt in reversed(list(enumerate(block.body))):
|
| 65 |
+
# Found a call to a StencilFunc.
|
| 66 |
+
if (isinstance(stmt, ir.Assign)
|
| 67 |
+
and isinstance(stmt.value, ir.Expr)
|
| 68 |
+
and stmt.value.op == 'call'
|
| 69 |
+
and stmt.value.func.name in stencil_calls):
|
| 70 |
+
kws = dict(stmt.value.kws)
|
| 71 |
+
# Create dictionary of input argument number to
|
| 72 |
+
# the argument itself.
|
| 73 |
+
input_dict = {i: stmt.value.args[i] for i in
|
| 74 |
+
range(len(stmt.value.args))}
|
| 75 |
+
in_args = stmt.value.args
|
| 76 |
+
arg_typemap = tuple(self.typemap[i.name] for i in in_args)
|
| 77 |
+
for arg_type in arg_typemap:
|
| 78 |
+
if isinstance(arg_type, types.BaseTuple):
|
| 79 |
+
raise NumbaValueError("Tuple parameters not " \
|
| 80 |
+
"supported for stencil " \
|
| 81 |
+
"kernels in parallel=True " \
|
| 82 |
+
"mode.")
|
| 83 |
+
|
| 84 |
+
out_arr = kws.get('out')
|
| 85 |
+
|
| 86 |
+
# Get the StencilFunc object corresponding to this call.
|
| 87 |
+
sf = stencil_dict[stmt.value.func.name]
|
| 88 |
+
stencil_ir, rt, arg_to_arr_dict = get_stencil_ir(sf,
|
| 89 |
+
self.typingctx, arg_typemap,
|
| 90 |
+
block.scope, block.loc, input_dict,
|
| 91 |
+
self.typemap, self.calltypes)
|
| 92 |
+
index_offsets = sf.options.get('index_offsets', None)
|
| 93 |
+
gen_nodes = self._mk_stencil_parfor(label, in_args, out_arr,
|
| 94 |
+
stencil_ir, index_offsets, stmt.target, rt, sf,
|
| 95 |
+
arg_to_arr_dict)
|
| 96 |
+
block.body = block.body[:i] + gen_nodes + block.body[i+1:]
|
| 97 |
+
# Found a call to a stencil via numba.stencil().
|
| 98 |
+
elif (isinstance(stmt, ir.Assign)
|
| 99 |
+
and isinstance(stmt.value, ir.Expr)
|
| 100 |
+
and stmt.value.op == 'call'
|
| 101 |
+
and guard(find_callname, self.func_ir, stmt.value)
|
| 102 |
+
== ('stencil', 'numba')):
|
| 103 |
+
# remove dummy stencil() call
|
| 104 |
+
stmt.value = ir.Const(0, stmt.loc)
|
| 105 |
+
|
| 106 |
+
def replace_return_with_setitem(self, blocks, exit_value_var,
|
| 107 |
+
parfor_body_exit_label):
|
| 108 |
+
"""
|
| 109 |
+
Find return statements in the IR and replace them with a SetItem
|
| 110 |
+
call of the value "returned" by the kernel into the result array.
|
| 111 |
+
Returns the block labels that contained return statements.
|
| 112 |
+
"""
|
| 113 |
+
for label, block in blocks.items():
|
| 114 |
+
scope = block.scope
|
| 115 |
+
loc = block.loc
|
| 116 |
+
new_body = []
|
| 117 |
+
for stmt in block.body:
|
| 118 |
+
if isinstance(stmt, ir.Return):
|
| 119 |
+
# previous stmt should have been a cast
|
| 120 |
+
prev_stmt = new_body.pop()
|
| 121 |
+
assert (isinstance(prev_stmt, ir.Assign)
|
| 122 |
+
and isinstance(prev_stmt.value, ir.Expr)
|
| 123 |
+
and prev_stmt.value.op == 'cast')
|
| 124 |
+
|
| 125 |
+
new_body.append(ir.Assign(prev_stmt.value.value, exit_value_var, loc))
|
| 126 |
+
new_body.append(ir.Jump(parfor_body_exit_label, loc))
|
| 127 |
+
else:
|
| 128 |
+
new_body.append(stmt)
|
| 129 |
+
block.body = new_body
|
| 130 |
+
|
| 131 |
+
def _mk_stencil_parfor(self, label, in_args, out_arr, stencil_ir,
|
| 132 |
+
index_offsets, target, return_type, stencil_func,
|
| 133 |
+
arg_to_arr_dict):
|
| 134 |
+
""" Converts a set of stencil kernel blocks to a parfor.
|
| 135 |
+
"""
|
| 136 |
+
gen_nodes = []
|
| 137 |
+
stencil_blocks = stencil_ir.blocks
|
| 138 |
+
|
| 139 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 140 |
+
print("_mk_stencil_parfor", label, in_args, out_arr, index_offsets,
|
| 141 |
+
return_type, stencil_func, stencil_blocks)
|
| 142 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 143 |
+
|
| 144 |
+
in_arr = in_args[0]
|
| 145 |
+
# run copy propagate to replace in_args copies (e.g. a = A)
|
| 146 |
+
in_arr_typ = self.typemap[in_arr.name]
|
| 147 |
+
in_cps, out_cps = ir_utils.copy_propagate(stencil_blocks, self.typemap)
|
| 148 |
+
name_var_table = ir_utils.get_name_var_table(stencil_blocks)
|
| 149 |
+
|
| 150 |
+
ir_utils.apply_copy_propagate(
|
| 151 |
+
stencil_blocks,
|
| 152 |
+
in_cps,
|
| 153 |
+
name_var_table,
|
| 154 |
+
self.typemap,
|
| 155 |
+
self.calltypes)
|
| 156 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 157 |
+
print("stencil_blocks after copy_propagate")
|
| 158 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 159 |
+
ir_utils.remove_dead(stencil_blocks, self.func_ir.arg_names, stencil_ir,
|
| 160 |
+
self.typemap)
|
| 161 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 162 |
+
print("stencil_blocks after removing dead code")
|
| 163 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 164 |
+
|
| 165 |
+
# create parfor vars
|
| 166 |
+
ndims = self.typemap[in_arr.name].ndim
|
| 167 |
+
scope = in_arr.scope
|
| 168 |
+
loc = in_arr.loc
|
| 169 |
+
parfor_vars = []
|
| 170 |
+
for i in range(ndims):
|
| 171 |
+
parfor_var = ir.Var(scope, mk_unique_var(
|
| 172 |
+
"$parfor_index_var"), loc)
|
| 173 |
+
self.typemap[parfor_var.name] = types.intp
|
| 174 |
+
parfor_vars.append(parfor_var)
|
| 175 |
+
|
| 176 |
+
start_lengths, end_lengths = self._replace_stencil_accesses(
|
| 177 |
+
stencil_ir, parfor_vars, in_args, index_offsets, stencil_func,
|
| 178 |
+
arg_to_arr_dict)
|
| 179 |
+
|
| 180 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 181 |
+
print("stencil_blocks after replace stencil accesses")
|
| 182 |
+
print("start_lengths:", start_lengths)
|
| 183 |
+
print("end_lengths:", end_lengths)
|
| 184 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 185 |
+
|
| 186 |
+
# create parfor loop nests
|
| 187 |
+
loopnests = []
|
| 188 |
+
equiv_set = self.array_analysis.get_equiv_set(label)
|
| 189 |
+
in_arr_dim_sizes = equiv_set.get_shape(in_arr)
|
| 190 |
+
|
| 191 |
+
assert ndims == len(in_arr_dim_sizes)
|
| 192 |
+
start_inds = []
|
| 193 |
+
last_inds = []
|
| 194 |
+
for i in range(ndims):
|
| 195 |
+
last_ind = self._get_stencil_last_ind(in_arr_dim_sizes[i],
|
| 196 |
+
end_lengths[i], gen_nodes, scope, loc)
|
| 197 |
+
start_ind = self._get_stencil_start_ind(
|
| 198 |
+
start_lengths[i], gen_nodes, scope, loc)
|
| 199 |
+
start_inds.append(start_ind)
|
| 200 |
+
last_inds.append(last_ind)
|
| 201 |
+
# start from stencil size to avoid invalid array access
|
| 202 |
+
loopnests.append(numba.parfors.parfor.LoopNest(parfor_vars[i],
|
| 203 |
+
start_ind, last_ind, 1))
|
| 204 |
+
|
| 205 |
+
# We have to guarantee that the exit block has maximum label and that
|
| 206 |
+
# there's only one exit block for the parfor body.
|
| 207 |
+
# So, all return statements will change to jump to the parfor exit block.
|
| 208 |
+
parfor_body_exit_label = max(stencil_blocks.keys()) + 1
|
| 209 |
+
stencil_blocks[parfor_body_exit_label] = ir.Block(scope, loc)
|
| 210 |
+
exit_value_var = ir.Var(scope, mk_unique_var("$parfor_exit_value"), loc)
|
| 211 |
+
self.typemap[exit_value_var.name] = return_type.dtype
|
| 212 |
+
|
| 213 |
+
# create parfor index var
|
| 214 |
+
for_replacing_ret = []
|
| 215 |
+
if ndims == 1:
|
| 216 |
+
parfor_ind_var = parfor_vars[0]
|
| 217 |
+
else:
|
| 218 |
+
parfor_ind_var = ir.Var(scope, mk_unique_var(
|
| 219 |
+
"$parfor_index_tuple_var"), loc)
|
| 220 |
+
self.typemap[parfor_ind_var.name] = types.containers.UniTuple(
|
| 221 |
+
types.intp, ndims)
|
| 222 |
+
tuple_call = ir.Expr.build_tuple(parfor_vars, loc)
|
| 223 |
+
tuple_assign = ir.Assign(tuple_call, parfor_ind_var, loc)
|
| 224 |
+
for_replacing_ret.append(tuple_assign)
|
| 225 |
+
|
| 226 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 227 |
+
print("stencil_blocks after creating parfor index var")
|
| 228 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 229 |
+
|
| 230 |
+
# empty init block
|
| 231 |
+
init_block = ir.Block(scope, loc)
|
| 232 |
+
if out_arr is None:
|
| 233 |
+
in_arr_typ = self.typemap[in_arr.name]
|
| 234 |
+
|
| 235 |
+
shape_name = ir_utils.mk_unique_var("in_arr_shape")
|
| 236 |
+
shape_var = ir.Var(scope, shape_name, loc)
|
| 237 |
+
shape_getattr = ir.Expr.getattr(in_arr, "shape", loc)
|
| 238 |
+
self.typemap[shape_name] = types.containers.UniTuple(types.intp,
|
| 239 |
+
in_arr_typ.ndim)
|
| 240 |
+
init_block.body.extend([ir.Assign(shape_getattr, shape_var, loc)])
|
| 241 |
+
|
| 242 |
+
zero_name = ir_utils.mk_unique_var("zero_val")
|
| 243 |
+
zero_var = ir.Var(scope, zero_name, loc)
|
| 244 |
+
if "cval" in stencil_func.options:
|
| 245 |
+
cval = stencil_func.options["cval"]
|
| 246 |
+
# TODO: Loosen this restriction to adhere to casting rules.
|
| 247 |
+
cval_ty = typing.typeof.typeof(cval)
|
| 248 |
+
if not self.typingctx.can_convert(cval_ty, return_type.dtype):
|
| 249 |
+
raise NumbaValueError("cval type does not match stencil " \
|
| 250 |
+
"return type.")
|
| 251 |
+
|
| 252 |
+
temp2 = return_type.dtype(cval)
|
| 253 |
+
else:
|
| 254 |
+
temp2 = return_type.dtype(0)
|
| 255 |
+
full_const = ir.Const(temp2, loc)
|
| 256 |
+
self.typemap[zero_name] = return_type.dtype
|
| 257 |
+
init_block.body.extend([ir.Assign(full_const, zero_var, loc)])
|
| 258 |
+
|
| 259 |
+
so_name = ir_utils.mk_unique_var("stencil_output")
|
| 260 |
+
out_arr = ir.Var(scope, so_name, loc)
|
| 261 |
+
self.typemap[out_arr.name] = numba.core.types.npytypes.Array(
|
| 262 |
+
return_type.dtype,
|
| 263 |
+
in_arr_typ.ndim,
|
| 264 |
+
in_arr_typ.layout)
|
| 265 |
+
dtype_g_np_var = ir.Var(scope, mk_unique_var("$np_g_var"), loc)
|
| 266 |
+
self.typemap[dtype_g_np_var.name] = types.misc.Module(np)
|
| 267 |
+
dtype_g_np = ir.Global('np', np, loc)
|
| 268 |
+
dtype_g_np_assign = ir.Assign(dtype_g_np, dtype_g_np_var, loc)
|
| 269 |
+
init_block.body.append(dtype_g_np_assign)
|
| 270 |
+
|
| 271 |
+
return_type_name = numpy_support.as_dtype(
|
| 272 |
+
return_type.dtype).type.__name__
|
| 273 |
+
if return_type_name == 'bool':
|
| 274 |
+
return_type_name = 'bool_'
|
| 275 |
+
dtype_np_attr_call = ir.Expr.getattr(dtype_g_np_var, return_type_name, loc)
|
| 276 |
+
dtype_attr_var = ir.Var(scope, mk_unique_var("$np_attr_attr"), loc)
|
| 277 |
+
self.typemap[dtype_attr_var.name] = types.functions.NumberClass(return_type.dtype)
|
| 278 |
+
dtype_attr_assign = ir.Assign(dtype_np_attr_call, dtype_attr_var, loc)
|
| 279 |
+
init_block.body.append(dtype_attr_assign)
|
| 280 |
+
|
| 281 |
+
stmts = ir_utils.gen_np_call("empty",
|
| 282 |
+
np.empty,
|
| 283 |
+
out_arr,
|
| 284 |
+
[shape_var, dtype_attr_var],
|
| 285 |
+
self.typingctx,
|
| 286 |
+
self.typemap,
|
| 287 |
+
self.calltypes)
|
| 288 |
+
# ------------------
|
| 289 |
+
# Generate the code to fill just the border with zero_var.
|
| 290 |
+
|
| 291 |
+
# Generate a none var to use in slicing.
|
| 292 |
+
none_var = ir.Var(scope, mk_unique_var("$none_var"), loc)
|
| 293 |
+
none_assign = ir.Assign(ir.Const(None, loc), none_var, loc)
|
| 294 |
+
stmts.append(none_assign)
|
| 295 |
+
self.typemap[none_var.name] = types.none
|
| 296 |
+
# Generate a zero var to use in slicing.
|
| 297 |
+
zero_index_var = ir.Var(scope, mk_unique_var("$zero_index_var"), loc)
|
| 298 |
+
zero_index_assign = ir.Assign(ir.Const(0, loc), zero_index_var, loc)
|
| 299 |
+
stmts.append(zero_index_assign)
|
| 300 |
+
self.typemap[zero_index_var.name] = types.intp
|
| 301 |
+
# Generate generic ":" slice.
|
| 302 |
+
# ---- Generate var to hold slice func var.
|
| 303 |
+
slice_func_var = ir.Var(scope, mk_unique_var("$slice_func_var"), loc)
|
| 304 |
+
slice_fn_ty = self.typingctx.resolve_value_type(slice)
|
| 305 |
+
self.typemap[slice_func_var.name] = slice_fn_ty
|
| 306 |
+
slice_g = ir.Global('slice', slice, loc)
|
| 307 |
+
slice_assign = ir.Assign(slice_g, slice_func_var, loc)
|
| 308 |
+
stmts.append(slice_assign)
|
| 309 |
+
# ---- Generate call to slice func.
|
| 310 |
+
sig = self.typingctx.resolve_function_type(slice_fn_ty,
|
| 311 |
+
(types.none,) * 2,
|
| 312 |
+
{})
|
| 313 |
+
slice_callexpr = ir.Expr.call(func=slice_func_var,
|
| 314 |
+
args=(none_var, none_var),
|
| 315 |
+
kws=(),
|
| 316 |
+
loc=loc)
|
| 317 |
+
self.calltypes[slice_callexpr] = sig
|
| 318 |
+
# ---- Generate slice var
|
| 319 |
+
slice_var = ir.Var(scope, mk_unique_var("$slice"), loc)
|
| 320 |
+
self.typemap[slice_var.name] = types.slice2_type
|
| 321 |
+
slice_assign = ir.Assign(slice_callexpr, slice_var, loc)
|
| 322 |
+
stmts.append(slice_assign)
|
| 323 |
+
|
| 324 |
+
def handle_border(slice_fn_ty,
|
| 325 |
+
dim,
|
| 326 |
+
scope,
|
| 327 |
+
loc,
|
| 328 |
+
slice_func_var,
|
| 329 |
+
stmts,
|
| 330 |
+
border_inds,
|
| 331 |
+
border_tuple_items,
|
| 332 |
+
other_arg,
|
| 333 |
+
other_first):
|
| 334 |
+
# Handle the border for start or end of the index range.
|
| 335 |
+
# ---- Generate call to slice func.
|
| 336 |
+
sig = self.typingctx.resolve_function_type(
|
| 337 |
+
slice_fn_ty,
|
| 338 |
+
(types.intp,) * 2,
|
| 339 |
+
{})
|
| 340 |
+
si = border_inds[dim]
|
| 341 |
+
assert(isinstance(si, (int, ir.Var)))
|
| 342 |
+
si_var = ir.Var(scope, mk_unique_var("$border_ind"), loc)
|
| 343 |
+
self.typemap[si_var.name] = types.intp
|
| 344 |
+
if isinstance(si, int):
|
| 345 |
+
si_assign = ir.Assign(ir.Const(si, loc), si_var, loc)
|
| 346 |
+
else:
|
| 347 |
+
si_assign = ir.Assign(si, si_var, loc)
|
| 348 |
+
stmts.append(si_assign)
|
| 349 |
+
|
| 350 |
+
slice_callexpr = ir.Expr.call(
|
| 351 |
+
func=slice_func_var,
|
| 352 |
+
args=(other_arg, si_var) if other_first else (si_var, other_arg),
|
| 353 |
+
kws=(),
|
| 354 |
+
loc=loc)
|
| 355 |
+
self.calltypes[slice_callexpr] = sig
|
| 356 |
+
# ---- Generate slice var
|
| 357 |
+
border_slice_var = ir.Var(scope, mk_unique_var("$slice"), loc)
|
| 358 |
+
self.typemap[border_slice_var.name] = types.slice2_type
|
| 359 |
+
slice_assign = ir.Assign(slice_callexpr, border_slice_var, loc)
|
| 360 |
+
stmts.append(slice_assign)
|
| 361 |
+
|
| 362 |
+
border_tuple_items[dim] = border_slice_var
|
| 363 |
+
border_ind_var = ir.Var(scope, mk_unique_var(
|
| 364 |
+
"$border_index_tuple_var"), loc)
|
| 365 |
+
self.typemap[border_ind_var.name] = types.containers.UniTuple(
|
| 366 |
+
types.slice2_type, ndims)
|
| 367 |
+
tuple_call = ir.Expr.build_tuple(border_tuple_items, loc)
|
| 368 |
+
tuple_assign = ir.Assign(tuple_call, border_ind_var, loc)
|
| 369 |
+
stmts.append(tuple_assign)
|
| 370 |
+
|
| 371 |
+
setitem_call = ir.SetItem(out_arr, border_ind_var, zero_var, loc)
|
| 372 |
+
self.calltypes[setitem_call] = signature(
|
| 373 |
+
types.none, self.typemap[out_arr.name],
|
| 374 |
+
self.typemap[border_ind_var.name],
|
| 375 |
+
self.typemap[out_arr.name].dtype
|
| 376 |
+
)
|
| 377 |
+
stmts.append(setitem_call)
|
| 378 |
+
|
| 379 |
+
# For each dimension, add setitem to set border values.
|
| 380 |
+
for dim in range(in_arr_typ.ndim):
|
| 381 |
+
# First, fill all entries with ":".
|
| 382 |
+
start_tuple_items = [slice_var] * in_arr_typ.ndim
|
| 383 |
+
last_tuple_items = [slice_var] * in_arr_typ.ndim
|
| 384 |
+
|
| 385 |
+
handle_border(slice_fn_ty,
|
| 386 |
+
dim,
|
| 387 |
+
scope,
|
| 388 |
+
loc,
|
| 389 |
+
slice_func_var,
|
| 390 |
+
stmts,
|
| 391 |
+
start_inds,
|
| 392 |
+
start_tuple_items,
|
| 393 |
+
zero_index_var,
|
| 394 |
+
True)
|
| 395 |
+
handle_border(slice_fn_ty,
|
| 396 |
+
dim,
|
| 397 |
+
scope,
|
| 398 |
+
loc,
|
| 399 |
+
slice_func_var,
|
| 400 |
+
stmts,
|
| 401 |
+
last_inds,
|
| 402 |
+
last_tuple_items,
|
| 403 |
+
in_arr_dim_sizes[dim],
|
| 404 |
+
False)
|
| 405 |
+
|
| 406 |
+
# ------------------
|
| 407 |
+
|
| 408 |
+
equiv_set.insert_equiv(out_arr, in_arr_dim_sizes)
|
| 409 |
+
init_block.body.extend(stmts)
|
| 410 |
+
else: # out is present
|
| 411 |
+
if "cval" in stencil_func.options: # do out[:] = cval
|
| 412 |
+
cval = stencil_func.options["cval"]
|
| 413 |
+
# TODO: Loosen this restriction to adhere to casting rules.
|
| 414 |
+
cval_ty = typing.typeof.typeof(cval)
|
| 415 |
+
if not self.typingctx.can_convert(cval_ty, return_type.dtype):
|
| 416 |
+
msg = "cval type does not match stencil return type."
|
| 417 |
+
raise NumbaValueError(msg)
|
| 418 |
+
|
| 419 |
+
# get slice ref
|
| 420 |
+
slice_var = ir.Var(scope, mk_unique_var("$py_g_var"), loc)
|
| 421 |
+
slice_fn_ty = self.typingctx.resolve_value_type(slice)
|
| 422 |
+
self.typemap[slice_var.name] = slice_fn_ty
|
| 423 |
+
slice_g = ir.Global('slice', slice, loc)
|
| 424 |
+
slice_assigned = ir.Assign(slice_g, slice_var, loc)
|
| 425 |
+
init_block.body.append(slice_assigned)
|
| 426 |
+
|
| 427 |
+
sig = self.typingctx.resolve_function_type(slice_fn_ty,
|
| 428 |
+
(types.none,) * 2,
|
| 429 |
+
{})
|
| 430 |
+
|
| 431 |
+
callexpr = ir.Expr.call(func=slice_var, args=(), kws=(),
|
| 432 |
+
loc=loc)
|
| 433 |
+
|
| 434 |
+
self.calltypes[callexpr] = sig
|
| 435 |
+
slice_inst_var = ir.Var(scope, mk_unique_var("$slice_inst"),
|
| 436 |
+
loc)
|
| 437 |
+
self.typemap[slice_inst_var.name] = types.slice2_type
|
| 438 |
+
slice_assign = ir.Assign(callexpr, slice_inst_var, loc)
|
| 439 |
+
init_block.body.append(slice_assign)
|
| 440 |
+
|
| 441 |
+
# get const val for cval
|
| 442 |
+
cval_const_val = ir.Const(return_type.dtype(cval), loc)
|
| 443 |
+
cval_const_var = ir.Var(scope, mk_unique_var("$cval_const"),
|
| 444 |
+
loc)
|
| 445 |
+
self.typemap[cval_const_var.name] = return_type.dtype
|
| 446 |
+
cval_const_assign = ir.Assign(cval_const_val,
|
| 447 |
+
cval_const_var, loc)
|
| 448 |
+
init_block.body.append(cval_const_assign)
|
| 449 |
+
|
| 450 |
+
# do setitem on `out` array
|
| 451 |
+
setitemexpr = ir.StaticSetItem(out_arr, slice(None, None),
|
| 452 |
+
slice_inst_var, cval_const_var,
|
| 453 |
+
loc)
|
| 454 |
+
init_block.body.append(setitemexpr)
|
| 455 |
+
sig = signature(types.none, self.typemap[out_arr.name],
|
| 456 |
+
self.typemap[slice_inst_var.name],
|
| 457 |
+
self.typemap[out_arr.name].dtype)
|
| 458 |
+
self.calltypes[setitemexpr] = sig
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
self.replace_return_with_setitem(stencil_blocks, exit_value_var,
|
| 462 |
+
parfor_body_exit_label)
|
| 463 |
+
|
| 464 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 465 |
+
print("stencil_blocks after replacing return")
|
| 466 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 467 |
+
|
| 468 |
+
setitem_call = ir.SetItem(out_arr, parfor_ind_var, exit_value_var, loc)
|
| 469 |
+
self.calltypes[setitem_call] = signature(
|
| 470 |
+
types.none, self.typemap[out_arr.name],
|
| 471 |
+
self.typemap[parfor_ind_var.name],
|
| 472 |
+
self.typemap[out_arr.name].dtype
|
| 473 |
+
)
|
| 474 |
+
stencil_blocks[parfor_body_exit_label].body.extend(for_replacing_ret)
|
| 475 |
+
stencil_blocks[parfor_body_exit_label].body.append(setitem_call)
|
| 476 |
+
|
| 477 |
+
# simplify CFG of parfor body (exit block could be simplified often)
|
| 478 |
+
# add dummy return to enable CFG
|
| 479 |
+
dummy_loc = ir.Loc("stencilparfor_dummy", -1)
|
| 480 |
+
ret_const_var = ir.Var(scope, mk_unique_var("$cval_const"), dummy_loc)
|
| 481 |
+
cval_const_assign = ir.Assign(ir.Const(0, loc=dummy_loc), ret_const_var, dummy_loc)
|
| 482 |
+
stencil_blocks[parfor_body_exit_label].body.append(cval_const_assign)
|
| 483 |
+
|
| 484 |
+
stencil_blocks[parfor_body_exit_label].body.append(
|
| 485 |
+
ir.Return(ret_const_var, dummy_loc),
|
| 486 |
+
)
|
| 487 |
+
stencil_blocks = ir_utils.simplify_CFG(stencil_blocks)
|
| 488 |
+
stencil_blocks[max(stencil_blocks.keys())].body.pop()
|
| 489 |
+
|
| 490 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 491 |
+
print("stencil_blocks after adding SetItem")
|
| 492 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 493 |
+
|
| 494 |
+
pattern = ('stencil', [start_lengths, end_lengths])
|
| 495 |
+
parfor = numba.parfors.parfor.Parfor(loopnests, init_block, stencil_blocks,
|
| 496 |
+
loc, parfor_ind_var, equiv_set, pattern, self.flags)
|
| 497 |
+
gen_nodes.append(parfor)
|
| 498 |
+
gen_nodes.append(ir.Assign(out_arr, target, loc))
|
| 499 |
+
return gen_nodes
|
| 500 |
+
|
| 501 |
+
def _get_stencil_last_ind(self, dim_size, end_length, gen_nodes, scope,
|
| 502 |
+
loc):
|
| 503 |
+
last_ind = dim_size
|
| 504 |
+
if end_length != 0:
|
| 505 |
+
# set last index to size minus stencil size to avoid invalid
|
| 506 |
+
# memory access
|
| 507 |
+
index_const = ir.Var(scope, mk_unique_var("stencil_const_var"),
|
| 508 |
+
loc)
|
| 509 |
+
self.typemap[index_const.name] = types.intp
|
| 510 |
+
if isinstance(end_length, numbers.Number):
|
| 511 |
+
const_assign = ir.Assign(ir.Const(end_length, loc),
|
| 512 |
+
index_const, loc)
|
| 513 |
+
else:
|
| 514 |
+
const_assign = ir.Assign(end_length, index_const, loc)
|
| 515 |
+
|
| 516 |
+
gen_nodes.append(const_assign)
|
| 517 |
+
last_ind = ir.Var(scope, mk_unique_var("last_ind"), loc)
|
| 518 |
+
self.typemap[last_ind.name] = types.intp
|
| 519 |
+
|
| 520 |
+
g_var = ir.Var(scope, mk_unique_var("compute_last_ind_var"), loc)
|
| 521 |
+
check_func = numba.njit(_compute_last_ind)
|
| 522 |
+
func_typ = types.functions.Dispatcher(check_func)
|
| 523 |
+
self.typemap[g_var.name] = func_typ
|
| 524 |
+
g_obj = ir.Global("_compute_last_ind", check_func, loc)
|
| 525 |
+
g_assign = ir.Assign(g_obj, g_var, loc)
|
| 526 |
+
gen_nodes.append(g_assign)
|
| 527 |
+
index_call = ir.Expr.call(g_var, [dim_size, index_const], (), loc)
|
| 528 |
+
self.calltypes[index_call] = func_typ.get_call_type(
|
| 529 |
+
self.typingctx, [types.intp, types.intp], {})
|
| 530 |
+
index_assign = ir.Assign(index_call, last_ind, loc)
|
| 531 |
+
gen_nodes.append(index_assign)
|
| 532 |
+
|
| 533 |
+
return last_ind
|
| 534 |
+
|
| 535 |
+
def _get_stencil_start_ind(self, start_length, gen_nodes, scope, loc):
|
| 536 |
+
if isinstance(start_length, int):
|
| 537 |
+
return abs(min(start_length, 0))
|
| 538 |
+
def get_start_ind(s_length):
|
| 539 |
+
return abs(min(s_length, 0))
|
| 540 |
+
f_ir = compile_to_numba_ir(get_start_ind, {}, self.typingctx,
|
| 541 |
+
self.targetctx, (types.intp,), self.typemap,
|
| 542 |
+
self.calltypes)
|
| 543 |
+
assert len(f_ir.blocks) == 1
|
| 544 |
+
block = f_ir.blocks.popitem()[1]
|
| 545 |
+
replace_arg_nodes(block, [start_length])
|
| 546 |
+
gen_nodes += block.body[:-2]
|
| 547 |
+
ret_var = block.body[-2].value.value
|
| 548 |
+
return ret_var
|
| 549 |
+
|
| 550 |
+
def _replace_stencil_accesses(self, stencil_ir, parfor_vars, in_args,
|
| 551 |
+
index_offsets, stencil_func, arg_to_arr_dict):
|
| 552 |
+
""" Convert relative indexing in the stencil kernel to standard indexing
|
| 553 |
+
by adding the loop index variables to the corresponding dimensions
|
| 554 |
+
of the array index tuples.
|
| 555 |
+
"""
|
| 556 |
+
stencil_blocks = stencil_ir.blocks
|
| 557 |
+
in_arr = in_args[0]
|
| 558 |
+
in_arg_names = [x.name for x in in_args]
|
| 559 |
+
|
| 560 |
+
if "standard_indexing" in stencil_func.options:
|
| 561 |
+
for x in stencil_func.options["standard_indexing"]:
|
| 562 |
+
if x not in arg_to_arr_dict:
|
| 563 |
+
raise NumbaValueError("Standard indexing requested for " \
|
| 564 |
+
"an array name not present in the " \
|
| 565 |
+
"stencil kernel definition.")
|
| 566 |
+
standard_indexed = [arg_to_arr_dict[x] for x in
|
| 567 |
+
stencil_func.options["standard_indexing"]]
|
| 568 |
+
else:
|
| 569 |
+
standard_indexed = []
|
| 570 |
+
|
| 571 |
+
if in_arr.name in standard_indexed:
|
| 572 |
+
raise NumbaValueError("The first argument to a stencil kernel " \
|
| 573 |
+
"must use relative indexing, not standard " \
|
| 574 |
+
"indexing.")
|
| 575 |
+
|
| 576 |
+
ndims = self.typemap[in_arr.name].ndim
|
| 577 |
+
scope = in_arr.scope
|
| 578 |
+
loc = in_arr.loc
|
| 579 |
+
# replace access indices, find access lengths in each dimension
|
| 580 |
+
need_to_calc_kernel = stencil_func.neighborhood is None
|
| 581 |
+
|
| 582 |
+
# If we need to infer the kernel size then initialize the minimum and
|
| 583 |
+
# maximum seen indices for each dimension to 0. If we already have
|
| 584 |
+
# the neighborhood calculated then just convert from neighborhood format
|
| 585 |
+
# to the separate start and end lengths format used here.
|
| 586 |
+
if need_to_calc_kernel:
|
| 587 |
+
start_lengths = ndims*[0]
|
| 588 |
+
end_lengths = ndims*[0]
|
| 589 |
+
else:
|
| 590 |
+
start_lengths = [x[0] for x in stencil_func.neighborhood]
|
| 591 |
+
end_lengths = [x[1] for x in stencil_func.neighborhood]
|
| 592 |
+
|
| 593 |
+
# Get all the tuples defined in the stencil blocks.
|
| 594 |
+
tuple_table = ir_utils.get_tuple_table(stencil_blocks)
|
| 595 |
+
|
| 596 |
+
found_relative_index = False
|
| 597 |
+
|
| 598 |
+
# For all blocks in the stencil kernel...
|
| 599 |
+
for label, block in stencil_blocks.items():
|
| 600 |
+
new_body = []
|
| 601 |
+
# For all statements in those blocks...
|
| 602 |
+
for stmt in block.body:
|
| 603 |
+
# Reject assignments to input arrays.
|
| 604 |
+
if ((isinstance(stmt, ir.Assign)
|
| 605 |
+
and isinstance(stmt.value, ir.Expr)
|
| 606 |
+
and stmt.value.op in ['setitem', 'static_setitem']
|
| 607 |
+
and stmt.value.value.name in in_arg_names) or
|
| 608 |
+
((isinstance(stmt, ir.SetItem) or
|
| 609 |
+
isinstance(stmt, ir.StaticSetItem))
|
| 610 |
+
and stmt.target.name in in_arg_names)):
|
| 611 |
+
raise NumbaValueError("Assignments to arrays passed to " \
|
| 612 |
+
"stencil kernels is not allowed.")
|
| 613 |
+
# We found a getitem for some array. If that array is an input
|
| 614 |
+
# array and isn't in the list of standard indexed arrays then
|
| 615 |
+
# update min and max seen indices if we are inferring the
|
| 616 |
+
# kernel size and create a new tuple where the relative offsets
|
| 617 |
+
# are added to loop index vars to get standard indexing.
|
| 618 |
+
if (isinstance(stmt, ir.Assign)
|
| 619 |
+
and isinstance(stmt.value, ir.Expr)
|
| 620 |
+
and stmt.value.op in ['static_getitem', 'getitem']
|
| 621 |
+
and stmt.value.value.name in in_arg_names
|
| 622 |
+
and stmt.value.value.name not in standard_indexed):
|
| 623 |
+
index_list = stmt.value.index
|
| 624 |
+
# handle 1D case
|
| 625 |
+
if ndims == 1:
|
| 626 |
+
index_list = [index_list]
|
| 627 |
+
else:
|
| 628 |
+
if hasattr(index_list, 'name') and index_list.name in tuple_table:
|
| 629 |
+
index_list = tuple_table[index_list.name]
|
| 630 |
+
# indices can be inferred as constant in simple expressions
|
| 631 |
+
# like -c where c is constant
|
| 632 |
+
# handled here since this is a common stencil index pattern
|
| 633 |
+
stencil_ir._definitions = ir_utils.build_definitions(stencil_blocks)
|
| 634 |
+
index_list = [_get_const_index_expr(
|
| 635 |
+
stencil_ir, self.func_ir, v) for v in index_list]
|
| 636 |
+
if index_offsets:
|
| 637 |
+
index_list = self._add_index_offsets(index_list,
|
| 638 |
+
list(index_offsets), new_body, scope, loc)
|
| 639 |
+
|
| 640 |
+
# update min and max indices
|
| 641 |
+
if need_to_calc_kernel:
|
| 642 |
+
# all indices should be integer to be able to calculate
|
| 643 |
+
# neighborhood automatically
|
| 644 |
+
if (isinstance(index_list, ir.Var) or
|
| 645 |
+
any([not isinstance(v, int) for v in index_list])):
|
| 646 |
+
raise NumbaValueError("Variable stencil index " \
|
| 647 |
+
"only possible with known " \
|
| 648 |
+
"neighborhood")
|
| 649 |
+
start_lengths = list(map(min, start_lengths,
|
| 650 |
+
index_list))
|
| 651 |
+
end_lengths = list(map(max, end_lengths, index_list))
|
| 652 |
+
found_relative_index = True
|
| 653 |
+
|
| 654 |
+
# update access indices
|
| 655 |
+
index_vars = self._add_index_offsets(parfor_vars,
|
| 656 |
+
list(index_list), new_body, scope, loc)
|
| 657 |
+
|
| 658 |
+
# new access index tuple
|
| 659 |
+
if ndims == 1:
|
| 660 |
+
ind_var = index_vars[0]
|
| 661 |
+
else:
|
| 662 |
+
ind_var = ir.Var(scope, mk_unique_var(
|
| 663 |
+
"$parfor_index_ind_var"), loc)
|
| 664 |
+
self.typemap[ind_var.name] = types.containers.UniTuple(
|
| 665 |
+
types.intp, ndims)
|
| 666 |
+
tuple_call = ir.Expr.build_tuple(index_vars, loc)
|
| 667 |
+
tuple_assign = ir.Assign(tuple_call, ind_var, loc)
|
| 668 |
+
new_body.append(tuple_assign)
|
| 669 |
+
|
| 670 |
+
# getitem return type is scalar if all indices are integer
|
| 671 |
+
if all([self.typemap[v.name] == types.intp
|
| 672 |
+
for v in index_vars]):
|
| 673 |
+
getitem_return_typ = self.typemap[
|
| 674 |
+
stmt.value.value.name].dtype
|
| 675 |
+
else:
|
| 676 |
+
# getitem returns an array
|
| 677 |
+
getitem_return_typ = self.typemap[stmt.value.value.name]
|
| 678 |
+
# new getitem with the new index var
|
| 679 |
+
getitem_call = ir.Expr.getitem(stmt.value.value, ind_var,
|
| 680 |
+
loc)
|
| 681 |
+
self.calltypes[getitem_call] = signature(
|
| 682 |
+
getitem_return_typ,
|
| 683 |
+
self.typemap[stmt.value.value.name],
|
| 684 |
+
self.typemap[ind_var.name])
|
| 685 |
+
stmt.value = getitem_call
|
| 686 |
+
|
| 687 |
+
new_body.append(stmt)
|
| 688 |
+
block.body = new_body
|
| 689 |
+
if need_to_calc_kernel and not found_relative_index:
|
| 690 |
+
raise NumbaValueError("Stencil kernel with no accesses to " \
|
| 691 |
+
"relatively indexed arrays.")
|
| 692 |
+
|
| 693 |
+
return start_lengths, end_lengths
|
| 694 |
+
|
| 695 |
+
def _add_index_offsets(self, index_list, index_offsets, new_body,
|
| 696 |
+
scope, loc):
|
| 697 |
+
""" Does the actual work of adding loop index variables to the
|
| 698 |
+
relative index constants or variables.
|
| 699 |
+
"""
|
| 700 |
+
assert len(index_list) == len(index_offsets)
|
| 701 |
+
|
| 702 |
+
# shortcut if all values are integer
|
| 703 |
+
if all([isinstance(v, int) for v in index_list+index_offsets]):
|
| 704 |
+
# add offsets in all dimensions
|
| 705 |
+
return list(map(add, index_list, index_offsets))
|
| 706 |
+
|
| 707 |
+
out_nodes = []
|
| 708 |
+
index_vars = []
|
| 709 |
+
for i in range(len(index_list)):
|
| 710 |
+
# new_index = old_index + offset
|
| 711 |
+
old_index_var = index_list[i]
|
| 712 |
+
if isinstance(old_index_var, int):
|
| 713 |
+
old_index_var = ir.Var(scope,
|
| 714 |
+
mk_unique_var("old_index_var"), loc)
|
| 715 |
+
self.typemap[old_index_var.name] = types.intp
|
| 716 |
+
const_assign = ir.Assign(ir.Const(index_list[i], loc),
|
| 717 |
+
old_index_var, loc)
|
| 718 |
+
out_nodes.append(const_assign)
|
| 719 |
+
|
| 720 |
+
offset_var = index_offsets[i]
|
| 721 |
+
if isinstance(offset_var, int):
|
| 722 |
+
offset_var = ir.Var(scope,
|
| 723 |
+
mk_unique_var("offset_var"), loc)
|
| 724 |
+
self.typemap[offset_var.name] = types.intp
|
| 725 |
+
const_assign = ir.Assign(ir.Const(index_offsets[i], loc),
|
| 726 |
+
offset_var, loc)
|
| 727 |
+
out_nodes.append(const_assign)
|
| 728 |
+
|
| 729 |
+
if (isinstance(old_index_var, slice)
|
| 730 |
+
or isinstance(self.typemap[old_index_var.name],
|
| 731 |
+
types.misc.SliceType)):
|
| 732 |
+
# only one arg can be slice
|
| 733 |
+
assert self.typemap[offset_var.name] == types.intp
|
| 734 |
+
index_var = self._add_offset_to_slice(old_index_var, offset_var,
|
| 735 |
+
out_nodes, scope, loc)
|
| 736 |
+
index_vars.append(index_var)
|
| 737 |
+
continue
|
| 738 |
+
|
| 739 |
+
if (isinstance(offset_var, slice)
|
| 740 |
+
or isinstance(self.typemap[offset_var.name],
|
| 741 |
+
types.misc.SliceType)):
|
| 742 |
+
# only one arg can be slice
|
| 743 |
+
assert self.typemap[old_index_var.name] == types.intp
|
| 744 |
+
index_var = self._add_offset_to_slice(offset_var, old_index_var,
|
| 745 |
+
out_nodes, scope, loc)
|
| 746 |
+
index_vars.append(index_var)
|
| 747 |
+
continue
|
| 748 |
+
|
| 749 |
+
index_var = ir.Var(scope,
|
| 750 |
+
mk_unique_var("offset_stencil_index"), loc)
|
| 751 |
+
self.typemap[index_var.name] = types.intp
|
| 752 |
+
index_call = ir.Expr.binop(operator.add, old_index_var,
|
| 753 |
+
offset_var, loc)
|
| 754 |
+
self.calltypes[index_call] = self.typingctx.resolve_function_type(
|
| 755 |
+
operator.add, (types.intp, types.intp), {})
|
| 756 |
+
index_assign = ir.Assign(index_call, index_var, loc)
|
| 757 |
+
out_nodes.append(index_assign)
|
| 758 |
+
index_vars.append(index_var)
|
| 759 |
+
|
| 760 |
+
new_body.extend(out_nodes)
|
| 761 |
+
return index_vars
|
| 762 |
+
|
| 763 |
+
def _add_offset_to_slice(self, slice_var, offset_var, out_nodes, scope,
|
| 764 |
+
loc):
|
| 765 |
+
if isinstance(slice_var, slice):
|
| 766 |
+
f_text = """def f(offset):
|
| 767 |
+
return slice({} + offset, {} + offset)
|
| 768 |
+
""".format(slice_var.start, slice_var.stop)
|
| 769 |
+
loc = {}
|
| 770 |
+
exec(f_text, {}, loc)
|
| 771 |
+
f = loc['f']
|
| 772 |
+
args = [offset_var]
|
| 773 |
+
arg_typs = (types.intp,)
|
| 774 |
+
else:
|
| 775 |
+
def f(old_slice, offset):
|
| 776 |
+
return slice(old_slice.start + offset, old_slice.stop + offset)
|
| 777 |
+
args = [slice_var, offset_var]
|
| 778 |
+
slice_type = self.typemap[slice_var.name]
|
| 779 |
+
arg_typs = (slice_type, types.intp,)
|
| 780 |
+
_globals = self.func_ir.func_id.func.__globals__
|
| 781 |
+
f_ir = compile_to_numba_ir(f, _globals, self.typingctx, self.targetctx,
|
| 782 |
+
arg_typs, self.typemap, self.calltypes)
|
| 783 |
+
_, block = f_ir.blocks.popitem()
|
| 784 |
+
replace_arg_nodes(block, args)
|
| 785 |
+
new_index = block.body[-2].value.value
|
| 786 |
+
out_nodes.extend(block.body[:-2]) # ignore return nodes
|
| 787 |
+
return new_index
|
| 788 |
+
|
| 789 |
+
def get_stencil_ir(sf, typingctx, args, scope, loc, input_dict, typemap,
|
| 790 |
+
calltypes):
|
| 791 |
+
"""get typed IR from stencil bytecode
|
| 792 |
+
"""
|
| 793 |
+
from numba.core.cpu import CPUContext
|
| 794 |
+
from numba.core.registry import cpu_target
|
| 795 |
+
from numba.core.annotations import type_annotations
|
| 796 |
+
from numba.core.typed_passes import type_inference_stage
|
| 797 |
+
|
| 798 |
+
# get untyped IR
|
| 799 |
+
stencil_func_ir = sf.kernel_ir.copy()
|
| 800 |
+
# copy the IR nodes to avoid changing IR in the StencilFunc object
|
| 801 |
+
stencil_blocks = copy.deepcopy(stencil_func_ir.blocks)
|
| 802 |
+
stencil_func_ir.blocks = stencil_blocks
|
| 803 |
+
|
| 804 |
+
name_var_table = ir_utils.get_name_var_table(stencil_func_ir.blocks)
|
| 805 |
+
if "out" in name_var_table:
|
| 806 |
+
raise NumbaValueError("Cannot use the reserved word 'out' in stencil " \
|
| 807 |
+
"kernels.")
|
| 808 |
+
|
| 809 |
+
# get typed IR with a dummy pipeline (similar to test_parfors.py)
|
| 810 |
+
from numba.core.registry import cpu_target
|
| 811 |
+
targetctx = cpu_target.target_context
|
| 812 |
+
|
| 813 |
+
tp = DummyPipeline(typingctx, targetctx, args, stencil_func_ir)
|
| 814 |
+
|
| 815 |
+
rewrites.rewrite_registry.apply('before-inference', tp.state)
|
| 816 |
+
|
| 817 |
+
tp.state.typemap, tp.state.return_type, tp.state.calltypes, _ = type_inference_stage(
|
| 818 |
+
tp.state.typingctx, tp.state.targetctx, tp.state.func_ir,
|
| 819 |
+
tp.state.args, None)
|
| 820 |
+
|
| 821 |
+
type_annotations.TypeAnnotation(
|
| 822 |
+
func_ir=tp.state.func_ir,
|
| 823 |
+
typemap=tp.state.typemap,
|
| 824 |
+
calltypes=tp.state.calltypes,
|
| 825 |
+
lifted=(),
|
| 826 |
+
lifted_from=None,
|
| 827 |
+
args=tp.state.args,
|
| 828 |
+
return_type=tp.state.return_type,
|
| 829 |
+
html_output=config.HTML)
|
| 830 |
+
|
| 831 |
+
# make block labels unique
|
| 832 |
+
stencil_blocks = ir_utils.add_offset_to_labels(stencil_blocks,
|
| 833 |
+
ir_utils.next_label())
|
| 834 |
+
min_label = min(stencil_blocks.keys())
|
| 835 |
+
max_label = max(stencil_blocks.keys())
|
| 836 |
+
ir_utils._the_max_label.update(max_label)
|
| 837 |
+
|
| 838 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 839 |
+
print("Initial stencil_blocks")
|
| 840 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 841 |
+
|
| 842 |
+
# rename variables,
|
| 843 |
+
var_dict = {}
|
| 844 |
+
for v, typ in tp.state.typemap.items():
|
| 845 |
+
new_var = ir.Var(scope, mk_unique_var(v), loc)
|
| 846 |
+
var_dict[v] = new_var
|
| 847 |
+
typemap[new_var.name] = typ # add new var type for overall function
|
| 848 |
+
ir_utils.replace_vars(stencil_blocks, var_dict)
|
| 849 |
+
|
| 850 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 851 |
+
print("After replace_vars")
|
| 852 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 853 |
+
|
| 854 |
+
# add call types to overall function
|
| 855 |
+
for call, call_typ in tp.state.calltypes.items():
|
| 856 |
+
calltypes[call] = call_typ
|
| 857 |
+
|
| 858 |
+
arg_to_arr_dict = {}
|
| 859 |
+
# replace arg with arr
|
| 860 |
+
for block in stencil_blocks.values():
|
| 861 |
+
for stmt in block.body:
|
| 862 |
+
if isinstance(stmt, ir.Assign) and isinstance(stmt.value, ir.Arg):
|
| 863 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 864 |
+
print("input_dict", input_dict, stmt.value.index,
|
| 865 |
+
stmt.value.name, stmt.value.index in input_dict)
|
| 866 |
+
arg_to_arr_dict[stmt.value.name] = input_dict[stmt.value.index].name
|
| 867 |
+
stmt.value = input_dict[stmt.value.index]
|
| 868 |
+
|
| 869 |
+
if config.DEBUG_ARRAY_OPT >= 1:
|
| 870 |
+
print("arg_to_arr_dict", arg_to_arr_dict)
|
| 871 |
+
print("After replace arg with arr")
|
| 872 |
+
ir_utils.dump_blocks(stencil_blocks)
|
| 873 |
+
|
| 874 |
+
ir_utils.remove_dels(stencil_blocks)
|
| 875 |
+
stencil_func_ir.blocks = stencil_blocks
|
| 876 |
+
return stencil_func_ir, sf.get_return_type(args)[0], arg_to_arr_dict
|
| 877 |
+
|
| 878 |
+
class DummyPipeline(object):
|
| 879 |
+
def __init__(self, typingctx, targetctx, args, f_ir):
|
| 880 |
+
from numba.core.compiler import StateDict
|
| 881 |
+
self.state = StateDict()
|
| 882 |
+
self.state.typingctx = typingctx
|
| 883 |
+
self.state.targetctx = targetctx
|
| 884 |
+
self.state.args = args
|
| 885 |
+
self.state.func_ir = f_ir
|
| 886 |
+
self.state.typemap = None
|
| 887 |
+
self.state.return_type = None
|
| 888 |
+
self.state.calltypes = None
|
| 889 |
+
|
| 890 |
+
|
| 891 |
+
def _get_const_index_expr(stencil_ir, func_ir, index_var):
|
| 892 |
+
"""
|
| 893 |
+
infer index_var as constant if it is of a expression form like c-1 where c
|
| 894 |
+
is a constant in the outer function.
|
| 895 |
+
index_var is assumed to be inside stencil kernel
|
| 896 |
+
"""
|
| 897 |
+
const_val = guard(
|
| 898 |
+
_get_const_index_expr_inner, stencil_ir, func_ir, index_var)
|
| 899 |
+
if const_val is not None:
|
| 900 |
+
return const_val
|
| 901 |
+
return index_var
|
| 902 |
+
|
| 903 |
+
def _get_const_index_expr_inner(stencil_ir, func_ir, index_var):
|
| 904 |
+
"""inner constant inference function that calls constant, unary and binary
|
| 905 |
+
cases.
|
| 906 |
+
"""
|
| 907 |
+
require(isinstance(index_var, ir.Var))
|
| 908 |
+
# case where the index is a const itself in outer function
|
| 909 |
+
var_const = guard(_get_const_two_irs, stencil_ir, func_ir, index_var)
|
| 910 |
+
if var_const is not None:
|
| 911 |
+
return var_const
|
| 912 |
+
# get index definition
|
| 913 |
+
index_def = ir_utils.get_definition(stencil_ir, index_var)
|
| 914 |
+
# match inner_var = unary(index_var)
|
| 915 |
+
var_const = guard(
|
| 916 |
+
_get_const_unary_expr, stencil_ir, func_ir, index_def)
|
| 917 |
+
if var_const is not None:
|
| 918 |
+
return var_const
|
| 919 |
+
# match inner_var = arg1 + arg2
|
| 920 |
+
var_const = guard(
|
| 921 |
+
_get_const_binary_expr, stencil_ir, func_ir, index_def)
|
| 922 |
+
if var_const is not None:
|
| 923 |
+
return var_const
|
| 924 |
+
raise GuardException
|
| 925 |
+
|
| 926 |
+
def _get_const_two_irs(ir1, ir2, var):
|
| 927 |
+
"""get constant in either of two IRs if available
|
| 928 |
+
otherwise, throw GuardException
|
| 929 |
+
"""
|
| 930 |
+
var_const = guard(find_const, ir1, var)
|
| 931 |
+
if var_const is not None:
|
| 932 |
+
return var_const
|
| 933 |
+
var_const = guard(find_const, ir2, var)
|
| 934 |
+
if var_const is not None:
|
| 935 |
+
return var_const
|
| 936 |
+
raise GuardException
|
| 937 |
+
|
| 938 |
+
def _get_const_unary_expr(stencil_ir, func_ir, index_def):
|
| 939 |
+
"""evaluate constant unary expr if possible
|
| 940 |
+
otherwise, raise GuardException
|
| 941 |
+
"""
|
| 942 |
+
require(isinstance(index_def, ir.Expr) and index_def.op == 'unary')
|
| 943 |
+
inner_var = index_def.value
|
| 944 |
+
# return -c as constant
|
| 945 |
+
const_val = _get_const_index_expr_inner(stencil_ir, func_ir, inner_var)
|
| 946 |
+
op = OPERATORS_TO_BUILTINS[index_def.fn]
|
| 947 |
+
return eval("{}{}".format(op, const_val))
|
| 948 |
+
|
| 949 |
+
def _get_const_binary_expr(stencil_ir, func_ir, index_def):
|
| 950 |
+
"""evaluate constant binary expr if possible
|
| 951 |
+
otherwise, raise GuardException
|
| 952 |
+
"""
|
| 953 |
+
require(isinstance(index_def, ir.Expr) and index_def.op == 'binop')
|
| 954 |
+
arg1 = _get_const_index_expr_inner(stencil_ir, func_ir, index_def.lhs)
|
| 955 |
+
arg2 = _get_const_index_expr_inner(stencil_ir, func_ir, index_def.rhs)
|
| 956 |
+
op = OPERATORS_TO_BUILTINS[index_def.fn]
|
| 957 |
+
return eval("{}{}{}".format(arg1, op, arg2))
|
.venv/lib/python3.11/site-packages/numba/testing/__init__.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
import functools
|
| 4 |
+
import unittest
|
| 5 |
+
import traceback
|
| 6 |
+
from fnmatch import fnmatch
|
| 7 |
+
from os.path import join, isfile, relpath, normpath, splitext
|
| 8 |
+
|
| 9 |
+
from .main import NumbaTestProgram, SerialSuite, make_tag_decorator
|
| 10 |
+
from numba.core import config
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def load_testsuite(loader, dir):
|
| 14 |
+
"""Find tests in 'dir'."""
|
| 15 |
+
try:
|
| 16 |
+
suite = unittest.TestSuite()
|
| 17 |
+
files = []
|
| 18 |
+
for f in os.listdir(dir):
|
| 19 |
+
path = join(dir, f)
|
| 20 |
+
if isfile(path) and fnmatch(f, 'test_*.py'):
|
| 21 |
+
files.append(f)
|
| 22 |
+
elif isfile(join(path, '__init__.py')):
|
| 23 |
+
suite.addTests(loader.discover(path))
|
| 24 |
+
for f in files:
|
| 25 |
+
# turn 'f' into a filename relative to the toplevel dir...
|
| 26 |
+
f = relpath(join(dir, f), loader._top_level_dir)
|
| 27 |
+
# ...and translate it to a module name.
|
| 28 |
+
f = splitext(normpath(f.replace(os.path.sep, '.')))[0]
|
| 29 |
+
suite.addTests(loader.loadTestsFromName(f))
|
| 30 |
+
return suite
|
| 31 |
+
except Exception:
|
| 32 |
+
traceback.print_exc(file=sys.stderr)
|
| 33 |
+
sys.exit(-1)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def run_tests(argv=None, defaultTest=None, topleveldir=None,
|
| 37 |
+
xmloutput=None, verbosity=1, nomultiproc=False):
|
| 38 |
+
"""
|
| 39 |
+
args
|
| 40 |
+
----
|
| 41 |
+
- xmloutput [str or None]
|
| 42 |
+
Path of XML output directory (optional)
|
| 43 |
+
- verbosity [int]
|
| 44 |
+
Verbosity level of tests output
|
| 45 |
+
|
| 46 |
+
Returns the TestResult object after running the test *suite*.
|
| 47 |
+
"""
|
| 48 |
+
|
| 49 |
+
if xmloutput is not None:
|
| 50 |
+
import xmlrunner
|
| 51 |
+
runner = xmlrunner.XMLTestRunner(output=xmloutput)
|
| 52 |
+
else:
|
| 53 |
+
runner = None
|
| 54 |
+
prog = NumbaTestProgram(argv=argv,
|
| 55 |
+
module=None,
|
| 56 |
+
defaultTest=defaultTest,
|
| 57 |
+
topleveldir=topleveldir,
|
| 58 |
+
testRunner=runner, exit=False,
|
| 59 |
+
verbosity=verbosity,
|
| 60 |
+
nomultiproc=nomultiproc)
|
| 61 |
+
return prog.result
|
.venv/lib/python3.11/site-packages/numba/testing/__main__.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
from numba.testing import run_tests
|
| 3 |
+
|
| 4 |
+
sys.exit(0 if run_tests(sys.argv).wasSuccessful() else 1)
|
.venv/lib/python3.11/site-packages/numba/testing/_runtests.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import re
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def _main(argv, **kwds):
|
| 7 |
+
from numba.testing import run_tests
|
| 8 |
+
# This helper function assumes the first element of argv
|
| 9 |
+
# is the name of the calling program.
|
| 10 |
+
# The 'main' API function is invoked in-process, and thus
|
| 11 |
+
# will synthesize that name.
|
| 12 |
+
|
| 13 |
+
if '--log' in argv:
|
| 14 |
+
logging.basicConfig(level=logging.DEBUG)
|
| 15 |
+
argv.remove('--log')
|
| 16 |
+
|
| 17 |
+
if '--failed-first' in argv:
|
| 18 |
+
# Failed first
|
| 19 |
+
argv.remove('--failed-first')
|
| 20 |
+
return _FailedFirstRunner().main(argv, kwds)
|
| 21 |
+
elif '--last-failed' in argv:
|
| 22 |
+
argv.remove('--last-failed')
|
| 23 |
+
return _FailedFirstRunner(last_failed=True).main(argv, kwds)
|
| 24 |
+
else:
|
| 25 |
+
return run_tests(argv, defaultTest='numba.tests',
|
| 26 |
+
**kwds).wasSuccessful()
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def main(*argv, **kwds):
|
| 30 |
+
"""keyword arguments are accepted for backward compatibility only.
|
| 31 |
+
See `numba.testing.run_tests()` documentation for details."""
|
| 32 |
+
return _main(['<main>'] + list(argv), **kwds)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
class _FailedFirstRunner(object):
|
| 36 |
+
"""
|
| 37 |
+
Test Runner to handle the failed-first (--failed-first) option.
|
| 38 |
+
"""
|
| 39 |
+
cache_filename = '.runtests_lastfailed'
|
| 40 |
+
|
| 41 |
+
def __init__(self, last_failed=False):
|
| 42 |
+
self.last_failed = last_failed
|
| 43 |
+
|
| 44 |
+
def main(self, argv, kwds):
|
| 45 |
+
from numba.testing import run_tests
|
| 46 |
+
prog = argv[0]
|
| 47 |
+
argv = argv[1:]
|
| 48 |
+
flags = [a for a in argv if a.startswith('-')]
|
| 49 |
+
|
| 50 |
+
all_tests, failed_tests = self.find_last_failed(argv)
|
| 51 |
+
# Prepare tests to run
|
| 52 |
+
if failed_tests:
|
| 53 |
+
ft = "There were {} previously failed tests"
|
| 54 |
+
print(ft.format(len(failed_tests)))
|
| 55 |
+
remaing_tests = [t for t in all_tests
|
| 56 |
+
if t not in failed_tests]
|
| 57 |
+
if self.last_failed:
|
| 58 |
+
tests = list(failed_tests)
|
| 59 |
+
else:
|
| 60 |
+
tests = failed_tests + remaing_tests
|
| 61 |
+
else:
|
| 62 |
+
if self.last_failed:
|
| 63 |
+
tests = []
|
| 64 |
+
else:
|
| 65 |
+
tests = list(all_tests)
|
| 66 |
+
|
| 67 |
+
if not tests:
|
| 68 |
+
print("No tests to run")
|
| 69 |
+
return True
|
| 70 |
+
# Run the testsuite
|
| 71 |
+
print("Running {} tests".format(len(tests)))
|
| 72 |
+
print('Flags', flags)
|
| 73 |
+
result = run_tests([prog] + flags + tests, **kwds)
|
| 74 |
+
# Update failed tests records only if we have run the all the tests
|
| 75 |
+
# last failed.
|
| 76 |
+
if len(tests) == result.testsRun:
|
| 77 |
+
self.save_failed_tests(result, all_tests)
|
| 78 |
+
return result.wasSuccessful()
|
| 79 |
+
|
| 80 |
+
def save_failed_tests(self, result, all_tests):
|
| 81 |
+
print("Saving failed tests to {}".format(self.cache_filename))
|
| 82 |
+
cache = []
|
| 83 |
+
# Find failed tests
|
| 84 |
+
failed = set()
|
| 85 |
+
for case in result.errors + result.failures:
|
| 86 |
+
failed.add(case[0].id())
|
| 87 |
+
# Build cache
|
| 88 |
+
for t in all_tests:
|
| 89 |
+
if t in failed:
|
| 90 |
+
cache.append(t)
|
| 91 |
+
# Write cache
|
| 92 |
+
with open(self.cache_filename, 'w') as fout:
|
| 93 |
+
json.dump(cache, fout)
|
| 94 |
+
|
| 95 |
+
def find_last_failed(self, argv):
|
| 96 |
+
from numba.tests.support import captured_output
|
| 97 |
+
|
| 98 |
+
# Find all tests
|
| 99 |
+
listargv = ['-l'] + [a for a in argv if not a.startswith('-')]
|
| 100 |
+
with captured_output("stdout") as stream:
|
| 101 |
+
main(*listargv)
|
| 102 |
+
|
| 103 |
+
pat = re.compile(r"^(\w+\.)+\w+$")
|
| 104 |
+
lines = stream.getvalue().splitlines()
|
| 105 |
+
all_tests = [x for x in lines if pat.match(x) is not None]
|
| 106 |
+
|
| 107 |
+
try:
|
| 108 |
+
fobj = open(self.cache_filename)
|
| 109 |
+
except OSError:
|
| 110 |
+
failed_tests = []
|
| 111 |
+
else:
|
| 112 |
+
with fobj as fin:
|
| 113 |
+
failed_tests = json.load(fin)
|
| 114 |
+
return all_tests, failed_tests
|
.venv/lib/python3.11/site-packages/numba/testing/loader.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from unittest import loader, case
|
| 2 |
+
from os.path import isdir, isfile, join, dirname, basename
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class TestLoader(loader.TestLoader):
|
| 6 |
+
|
| 7 |
+
def __init__(self, topleveldir=None):
|
| 8 |
+
super(TestLoader, self).__init__()
|
| 9 |
+
self._top_level_dir = topleveldir or dirname(dirname(dirname(__file__)))
|
| 10 |
+
|
| 11 |
+
def _find_tests(self, start_dir, pattern, namespace=False):
|
| 12 |
+
# Upstream doesn't look for 'load_tests' in start_dir.
|
| 13 |
+
|
| 14 |
+
if isdir(start_dir) and not namespace and isfile(join(start_dir, '__init__.py')):
|
| 15 |
+
name = self._get_name_from_path(start_dir)
|
| 16 |
+
package = self._get_module_from_name(name)
|
| 17 |
+
load_tests = getattr(package, 'load_tests', None)
|
| 18 |
+
tests = self.loadTestsFromModule(package)
|
| 19 |
+
if load_tests is not None:
|
| 20 |
+
try:
|
| 21 |
+
yield load_tests(self, tests, pattern)
|
| 22 |
+
except Exception as e:
|
| 23 |
+
yield loader._make_failed_load_tests(package.__name__, e, self.suiteClass)
|
| 24 |
+
else:
|
| 25 |
+
for t in super(TestLoader, self)._find_tests(start_dir, pattern):
|
| 26 |
+
yield t
|
.venv/lib/python3.11/site-packages/numba/testing/main.py
ADDED
|
@@ -0,0 +1,871 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import collections
|
| 2 |
+
import contextlib
|
| 3 |
+
import cProfile
|
| 4 |
+
import inspect
|
| 5 |
+
import gc
|
| 6 |
+
import multiprocessing
|
| 7 |
+
import os
|
| 8 |
+
import random
|
| 9 |
+
import sys
|
| 10 |
+
import time
|
| 11 |
+
import unittest
|
| 12 |
+
import warnings
|
| 13 |
+
import zlib
|
| 14 |
+
import traceback
|
| 15 |
+
|
| 16 |
+
from functools import lru_cache
|
| 17 |
+
from io import StringIO
|
| 18 |
+
from unittest import result, runner, signals, suite, loader, case
|
| 19 |
+
|
| 20 |
+
from .loader import TestLoader
|
| 21 |
+
from numba.core import config
|
| 22 |
+
from numba.misc import memoryutils
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
from multiprocessing import TimeoutError
|
| 26 |
+
except ImportError:
|
| 27 |
+
from Queue import Empty as TimeoutError
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def make_tag_decorator(known_tags):
|
| 31 |
+
"""
|
| 32 |
+
Create a decorator allowing tests to be tagged with the *known_tags*.
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
def tag(*tags):
|
| 36 |
+
"""
|
| 37 |
+
Tag a test method with the given tags.
|
| 38 |
+
Can be used in conjunction with the --tags command-line argument
|
| 39 |
+
for runtests.py.
|
| 40 |
+
"""
|
| 41 |
+
for t in tags:
|
| 42 |
+
if t not in known_tags:
|
| 43 |
+
raise ValueError("unknown tag: %r" % (t,))
|
| 44 |
+
|
| 45 |
+
def decorate(func):
|
| 46 |
+
if (not callable(func) or isinstance(func, type)
|
| 47 |
+
or not func.__name__.startswith('test_')):
|
| 48 |
+
raise TypeError("@tag(...) should be used on test methods")
|
| 49 |
+
try:
|
| 50 |
+
s = func.tags
|
| 51 |
+
except AttributeError:
|
| 52 |
+
s = func.tags = set()
|
| 53 |
+
s.update(tags)
|
| 54 |
+
return func
|
| 55 |
+
return decorate
|
| 56 |
+
|
| 57 |
+
return tag
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
# Chances are the next queried class is the same as the previous, locally 128
|
| 61 |
+
# entries seems to be fastest.
|
| 62 |
+
# Current number of test classes can be found with:
|
| 63 |
+
# $ ./runtests.py -l|sed -e 's/\(.*\)\..*/\1/'|grep ^numba|sort|uniq|wc -l
|
| 64 |
+
# as of writing it's 658.
|
| 65 |
+
@lru_cache(maxsize=128)
|
| 66 |
+
def _get_mtime(cls):
|
| 67 |
+
"""
|
| 68 |
+
Gets the mtime of the file in which a test class is defined.
|
| 69 |
+
"""
|
| 70 |
+
return str(os.path.getmtime(inspect.getfile(cls)))
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def cuda_sensitive_mtime(x):
|
| 74 |
+
"""
|
| 75 |
+
Return a key for sorting tests bases on mtime and test name. For CUDA
|
| 76 |
+
tests, interleaving tests from different classes is dangerous as the CUDA
|
| 77 |
+
context might get reset unexpectedly between methods of a class, so for
|
| 78 |
+
CUDA tests the key prioritises the test module and class ahead of the
|
| 79 |
+
mtime.
|
| 80 |
+
"""
|
| 81 |
+
cls = x.__class__
|
| 82 |
+
key = _get_mtime(cls) + str(x)
|
| 83 |
+
|
| 84 |
+
from numba.cuda.testing import CUDATestCase
|
| 85 |
+
if CUDATestCase in cls.mro():
|
| 86 |
+
key = "%s.%s %s" % (str(cls.__module__), str(cls.__name__), key)
|
| 87 |
+
|
| 88 |
+
return key
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def parse_slice(useslice):
|
| 92 |
+
"""Parses the argument string "useslice" as a shard index and number and
|
| 93 |
+
returns a function that filters on those arguments. i.e. input
|
| 94 |
+
useslice="1:3" leads to output something like `lambda x: zlib.crc32(x) % 3
|
| 95 |
+
== 1`.
|
| 96 |
+
"""
|
| 97 |
+
if callable(useslice):
|
| 98 |
+
return useslice
|
| 99 |
+
if not useslice:
|
| 100 |
+
return lambda x: True
|
| 101 |
+
try:
|
| 102 |
+
(index, count) = useslice.split(":")
|
| 103 |
+
index = int(index)
|
| 104 |
+
count = int(count)
|
| 105 |
+
except Exception:
|
| 106 |
+
msg = (
|
| 107 |
+
"Expected arguments shard index and count to follow "
|
| 108 |
+
"option `-j i:t`, where i is the shard number and t "
|
| 109 |
+
"is the total number of shards, found '%s'" % useslice)
|
| 110 |
+
raise ValueError(msg)
|
| 111 |
+
if count == 0:
|
| 112 |
+
return lambda x: True
|
| 113 |
+
elif count < 0 or index < 0 or index >= count:
|
| 114 |
+
raise ValueError("Sharding out of range")
|
| 115 |
+
else:
|
| 116 |
+
def decide(test):
|
| 117 |
+
func = getattr(test, test._testMethodName)
|
| 118 |
+
if "always_test" in getattr(func, 'tags', {}):
|
| 119 |
+
return True
|
| 120 |
+
return abs(zlib.crc32(test.id().encode('utf-8'))) % count == index
|
| 121 |
+
return decide
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class TestLister(object):
|
| 125 |
+
"""Simply list available tests rather than running them."""
|
| 126 |
+
def __init__(self, useslice):
|
| 127 |
+
self.useslice = parse_slice(useslice)
|
| 128 |
+
|
| 129 |
+
def run(self, test):
|
| 130 |
+
result = runner.TextTestResult(sys.stderr, descriptions=True,
|
| 131 |
+
verbosity=1)
|
| 132 |
+
self._test_list = _flatten_suite(test)
|
| 133 |
+
masked_list = list(filter(self.useslice, self._test_list))
|
| 134 |
+
self._test_list.sort(key=cuda_sensitive_mtime)
|
| 135 |
+
for t in masked_list:
|
| 136 |
+
print(t.id())
|
| 137 |
+
print('%d tests found. %s selected' % (len(self._test_list),
|
| 138 |
+
len(masked_list)))
|
| 139 |
+
return result
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
class SerialSuite(unittest.TestSuite):
|
| 143 |
+
"""A simple marker to make sure tests in this suite are run serially.
|
| 144 |
+
|
| 145 |
+
Note: As the suite is going through internals of unittest,
|
| 146 |
+
it may get unpacked and stuffed into a plain TestSuite.
|
| 147 |
+
We need to set an attribute on the TestCase objects to
|
| 148 |
+
remember they should not be run in parallel.
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
def __init__(self, tests=()):
|
| 152 |
+
super(SerialSuite, self).__init__(tests)
|
| 153 |
+
self.resource_infos = []
|
| 154 |
+
|
| 155 |
+
def addTest(self, test):
|
| 156 |
+
if not isinstance(test, unittest.TestCase):
|
| 157 |
+
# It's a sub-suite, recurse
|
| 158 |
+
for t in test:
|
| 159 |
+
self.addTest(t)
|
| 160 |
+
else:
|
| 161 |
+
# It's a test case, mark it serial
|
| 162 |
+
test._numba_parallel_test_ = False
|
| 163 |
+
super(SerialSuite, self).addTest(test)
|
| 164 |
+
|
| 165 |
+
def run(self, result):
|
| 166 |
+
# Run each test with memory tracking
|
| 167 |
+
for test in self:
|
| 168 |
+
if result.shouldStop:
|
| 169 |
+
break
|
| 170 |
+
memtrack = memoryutils.MemoryTracker(test.id())
|
| 171 |
+
with memtrack.monitor():
|
| 172 |
+
test(result)
|
| 173 |
+
self.resource_infos.append(memtrack.get_summary())
|
| 174 |
+
return result
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
class BasicTestRunner(runner.TextTestRunner):
|
| 178 |
+
def __init__(self, useslice, **kwargs):
|
| 179 |
+
runner.TextTestRunner.__init__(self, **kwargs)
|
| 180 |
+
self.useslice = parse_slice(useslice)
|
| 181 |
+
|
| 182 |
+
def run(self, test):
|
| 183 |
+
run = list(filter(self.useslice, _flatten_suite(test)))
|
| 184 |
+
run.sort(key=cuda_sensitive_mtime)
|
| 185 |
+
wrapped = unittest.TestSuite(run)
|
| 186 |
+
return super(BasicTestRunner, self).run(wrapped)
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
# "unittest.main" is really the TestProgram class!
|
| 190 |
+
# (defined in a module named itself "unittest.main"...)
|
| 191 |
+
|
| 192 |
+
class NumbaTestProgram(unittest.main):
|
| 193 |
+
"""
|
| 194 |
+
A TestProgram subclass adding the following options:
|
| 195 |
+
* a -R option to enable reference leak detection
|
| 196 |
+
* a --profile option to enable profiling of the test run
|
| 197 |
+
* a -m option for parallel execution
|
| 198 |
+
* a -l option to (only) list tests
|
| 199 |
+
|
| 200 |
+
Currently the options are only added in 3.4+.
|
| 201 |
+
"""
|
| 202 |
+
|
| 203 |
+
refleak = False
|
| 204 |
+
profile = False
|
| 205 |
+
multiprocess = False
|
| 206 |
+
useslice = None
|
| 207 |
+
list = False
|
| 208 |
+
tags = None
|
| 209 |
+
exclude_tags = None
|
| 210 |
+
random_select = None
|
| 211 |
+
random_seed = 42
|
| 212 |
+
|
| 213 |
+
def __init__(self, *args, **kwargs):
|
| 214 |
+
topleveldir = kwargs.pop('topleveldir', None)
|
| 215 |
+
kwargs['testLoader'] = TestLoader(topleveldir)
|
| 216 |
+
|
| 217 |
+
# HACK to force unittest not to change warning display options
|
| 218 |
+
# (so that NumbaWarnings don't appear all over the place)
|
| 219 |
+
sys.warnoptions.append(':x')
|
| 220 |
+
self.nomultiproc = kwargs.pop('nomultiproc', False)
|
| 221 |
+
super(NumbaTestProgram, self).__init__(*args, **kwargs)
|
| 222 |
+
|
| 223 |
+
def _getParentArgParser(self):
|
| 224 |
+
# NOTE: this hook only exists on Python 3.4+. The options won't be
|
| 225 |
+
# added in earlier versions (which use optparse - 3.3 - or getopt()
|
| 226 |
+
# - 2.x).
|
| 227 |
+
parser = super(NumbaTestProgram, self)._getParentArgParser()
|
| 228 |
+
if self.testRunner is None:
|
| 229 |
+
parser.add_argument('-R', '--refleak', dest='refleak',
|
| 230 |
+
action='store_true',
|
| 231 |
+
help='Detect reference / memory leaks')
|
| 232 |
+
parser.add_argument('-m', '--multiprocess', dest='multiprocess',
|
| 233 |
+
nargs='?',
|
| 234 |
+
type=int,
|
| 235 |
+
const=multiprocessing.cpu_count(),
|
| 236 |
+
help='Parallelize tests')
|
| 237 |
+
parser.add_argument('-l', '--list', dest='list',
|
| 238 |
+
action='store_true',
|
| 239 |
+
help='List tests without running them')
|
| 240 |
+
parser.add_argument('--tags', dest='tags', type=str,
|
| 241 |
+
help='Comma-separated list of tags to select '
|
| 242 |
+
'a subset of the test suite')
|
| 243 |
+
parser.add_argument('--exclude-tags', dest='exclude_tags', type=str,
|
| 244 |
+
help='Comma-separated list of tags to de-select '
|
| 245 |
+
'a subset of the test suite')
|
| 246 |
+
parser.add_argument('--random', dest='random_select', type=float,
|
| 247 |
+
help='Random proportion of tests to select')
|
| 248 |
+
parser.add_argument('--profile', dest='profile',
|
| 249 |
+
action='store_true',
|
| 250 |
+
help='Profile the test run')
|
| 251 |
+
parser.add_argument('-j', '--slice', dest='useslice', nargs='?',
|
| 252 |
+
type=str, const="None",
|
| 253 |
+
help='Shard the test sequence')
|
| 254 |
+
|
| 255 |
+
def git_diff_str(x):
|
| 256 |
+
if x != 'ancestor':
|
| 257 |
+
raise ValueError("invalid option for --gitdiff")
|
| 258 |
+
return x
|
| 259 |
+
|
| 260 |
+
parser.add_argument('-g', '--gitdiff', dest='gitdiff', type=git_diff_str,
|
| 261 |
+
default=False, nargs='?',
|
| 262 |
+
help=('Run tests from changes made against '
|
| 263 |
+
'origin/release0.66 as identified by `git diff`. '
|
| 264 |
+
'If set to "ancestor", the diff compares '
|
| 265 |
+
'against the common ancestor.'))
|
| 266 |
+
return parser
|
| 267 |
+
|
| 268 |
+
def _handle_tags(self, argv, tagstr):
|
| 269 |
+
found = None
|
| 270 |
+
for x in argv:
|
| 271 |
+
if tagstr in x:
|
| 272 |
+
if found is None:
|
| 273 |
+
found = x
|
| 274 |
+
else:
|
| 275 |
+
raise ValueError("argument %s supplied repeatedly" % tagstr)
|
| 276 |
+
|
| 277 |
+
if found is not None:
|
| 278 |
+
posn = argv.index(found)
|
| 279 |
+
try:
|
| 280 |
+
if found == tagstr: # --tagstr <arg>
|
| 281 |
+
tag_args = argv[posn + 1].strip()
|
| 282 |
+
argv.remove(tag_args)
|
| 283 |
+
else: # --tagstr=<arg>
|
| 284 |
+
if '=' in found:
|
| 285 |
+
tag_args = found.split('=')[1].strip()
|
| 286 |
+
else:
|
| 287 |
+
raise AssertionError('unreachable')
|
| 288 |
+
except IndexError:
|
| 289 |
+
# at end of arg list, raise
|
| 290 |
+
msg = "%s requires at least one tag to be specified"
|
| 291 |
+
raise ValueError(msg % tagstr)
|
| 292 |
+
# see if next arg is "end options" or some other flag
|
| 293 |
+
if tag_args.startswith('-'):
|
| 294 |
+
raise ValueError("tag starts with '-', probably a syntax error")
|
| 295 |
+
# see if tag is something like "=<tagname>" which is likely a syntax
|
| 296 |
+
# error of form `--tags =<tagname>`, note the space prior to `=`.
|
| 297 |
+
if '=' in tag_args:
|
| 298 |
+
msg = "%s argument contains '=', probably a syntax error"
|
| 299 |
+
raise ValueError(msg % tagstr)
|
| 300 |
+
attr = tagstr[2:].replace('-', '_')
|
| 301 |
+
setattr(self, attr, tag_args)
|
| 302 |
+
argv.remove(found)
|
| 303 |
+
|
| 304 |
+
|
| 305 |
+
def parseArgs(self, argv):
|
| 306 |
+
if '-l' in argv:
|
| 307 |
+
argv.remove('-l')
|
| 308 |
+
self.list = True
|
| 309 |
+
|
| 310 |
+
super(NumbaTestProgram, self).parseArgs(argv)
|
| 311 |
+
|
| 312 |
+
# If at this point self.test doesn't exist, it is because
|
| 313 |
+
# no test ID was given in argv. Use the default instead.
|
| 314 |
+
if not hasattr(self, 'test') or not self.test.countTestCases():
|
| 315 |
+
self.testNames = (self.defaultTest,)
|
| 316 |
+
self.createTests()
|
| 317 |
+
|
| 318 |
+
if self.tags:
|
| 319 |
+
tags = [s.strip() for s in self.tags.split(',')]
|
| 320 |
+
self.test = _choose_tagged_tests(self.test, tags, mode='include')
|
| 321 |
+
|
| 322 |
+
if self.exclude_tags:
|
| 323 |
+
tags = [s.strip() for s in self.exclude_tags.split(',')]
|
| 324 |
+
self.test = _choose_tagged_tests(self.test, tags, mode='exclude')
|
| 325 |
+
|
| 326 |
+
if self.random_select:
|
| 327 |
+
self.test = _choose_random_tests(self.test, self.random_select,
|
| 328 |
+
self.random_seed)
|
| 329 |
+
|
| 330 |
+
if self.gitdiff is not False:
|
| 331 |
+
self.test = _choose_gitdiff_tests(
|
| 332 |
+
self.test,
|
| 333 |
+
use_common_ancestor=(self.gitdiff == 'ancestor'),
|
| 334 |
+
)
|
| 335 |
+
|
| 336 |
+
if self.verbosity <= 0:
|
| 337 |
+
# We aren't interested in informational messages / warnings when
|
| 338 |
+
# running with '-q'.
|
| 339 |
+
self.buffer = True
|
| 340 |
+
|
| 341 |
+
def _do_discovery(self, argv, Loader=None):
|
| 342 |
+
# Disable unittest's implicit test discovery when parsing
|
| 343 |
+
# CLI arguments, as it can select other tests than Numba's
|
| 344 |
+
# (e.g. some test_xxx module that may happen to be directly
|
| 345 |
+
# reachable from sys.path)
|
| 346 |
+
return
|
| 347 |
+
|
| 348 |
+
def runTests(self):
|
| 349 |
+
if self.refleak:
|
| 350 |
+
self.testRunner = RefleakTestRunner
|
| 351 |
+
|
| 352 |
+
if not hasattr(sys, "gettotalrefcount"):
|
| 353 |
+
warnings.warn("detecting reference leaks requires a debug build "
|
| 354 |
+
"of Python, only memory leaks will be detected")
|
| 355 |
+
|
| 356 |
+
elif self.list:
|
| 357 |
+
self.testRunner = TestLister(self.useslice)
|
| 358 |
+
|
| 359 |
+
elif self.testRunner is None:
|
| 360 |
+
self.testRunner = BasicTestRunner(self.useslice,
|
| 361 |
+
verbosity=self.verbosity,
|
| 362 |
+
failfast=self.failfast,
|
| 363 |
+
buffer=self.buffer)
|
| 364 |
+
|
| 365 |
+
if self.multiprocess and not self.nomultiproc:
|
| 366 |
+
if self.multiprocess < 1:
|
| 367 |
+
msg = ("Value specified for the number of processes to use in "
|
| 368 |
+
"running the suite must be > 0")
|
| 369 |
+
raise ValueError(msg)
|
| 370 |
+
self.testRunner = ParallelTestRunner(runner.TextTestRunner,
|
| 371 |
+
self.multiprocess,
|
| 372 |
+
self.useslice,
|
| 373 |
+
verbosity=self.verbosity,
|
| 374 |
+
failfast=self.failfast,
|
| 375 |
+
buffer=self.buffer)
|
| 376 |
+
|
| 377 |
+
def run_tests_real():
|
| 378 |
+
super(NumbaTestProgram, self).runTests()
|
| 379 |
+
|
| 380 |
+
if self.profile:
|
| 381 |
+
filename = os.path.splitext(
|
| 382 |
+
os.path.basename(sys.modules['__main__'].__file__)
|
| 383 |
+
)[0] + '.prof'
|
| 384 |
+
p = cProfile.Profile(timer=time.perf_counter) # 3.3+
|
| 385 |
+
p.enable()
|
| 386 |
+
try:
|
| 387 |
+
p.runcall(run_tests_real)
|
| 388 |
+
finally:
|
| 389 |
+
p.disable()
|
| 390 |
+
print("Writing test profile data into %r" % (filename,))
|
| 391 |
+
p.dump_stats(filename)
|
| 392 |
+
else:
|
| 393 |
+
run_tests_real()
|
| 394 |
+
|
| 395 |
+
|
| 396 |
+
# These are tests which are generated and injected into the test suite, what
|
| 397 |
+
# gets injected depends on features of the test environment, e.g. TBB presence
|
| 398 |
+
# it's important for doing the CI "slice tests" that these are run at the end
|
| 399 |
+
# See notes in `_flatten_suite` for why. Simple substring matching is used to
|
| 400 |
+
# determine a match.
|
| 401 |
+
_GENERATED = (
|
| 402 |
+
"numba.cuda.tests.cudapy.test_libdevice.TestLibdeviceCompilation",
|
| 403 |
+
"numba.tests.test_num_threads",
|
| 404 |
+
"numba.tests.test_parallel_backend",
|
| 405 |
+
"numba.tests.test_svml",
|
| 406 |
+
"numba.tests.test_ufuncs",
|
| 407 |
+
)
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
def _flatten_suite_inner(test):
|
| 411 |
+
"""
|
| 412 |
+
Workhorse for _flatten_suite
|
| 413 |
+
"""
|
| 414 |
+
tests = []
|
| 415 |
+
if isinstance(test, (unittest.TestSuite, list, tuple)):
|
| 416 |
+
for x in test:
|
| 417 |
+
tests.extend(_flatten_suite_inner(x))
|
| 418 |
+
else:
|
| 419 |
+
tests.append(test)
|
| 420 |
+
return tests
|
| 421 |
+
|
| 422 |
+
|
| 423 |
+
def _flatten_suite(test):
|
| 424 |
+
"""
|
| 425 |
+
Expand nested suite into list of test cases.
|
| 426 |
+
"""
|
| 427 |
+
tests = _flatten_suite_inner(test)
|
| 428 |
+
# Strip out generated tests and stick them at the end, this is to make sure
|
| 429 |
+
# that tests appear in a consistent order regardless of features available.
|
| 430 |
+
# This is so that a slice through the test suite e.g. (1::N) would likely be
|
| 431 |
+
# consistent up to the point of the generated tests, which rely on specific
|
| 432 |
+
# features.
|
| 433 |
+
generated = set()
|
| 434 |
+
for t in tests:
|
| 435 |
+
for g in _GENERATED:
|
| 436 |
+
if g in str(t):
|
| 437 |
+
generated.add(t)
|
| 438 |
+
normal = set(tests) - generated
|
| 439 |
+
def key(x):
|
| 440 |
+
return x.__module__, type(x).__name__, x._testMethodName
|
| 441 |
+
tests = sorted(normal, key=key)
|
| 442 |
+
tests.extend(sorted(list(generated), key=key))
|
| 443 |
+
return tests
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def _choose_gitdiff_tests(tests, *, use_common_ancestor=False):
|
| 447 |
+
try:
|
| 448 |
+
from git import Repo
|
| 449 |
+
except ImportError:
|
| 450 |
+
raise ValueError("gitpython needed for git functionality")
|
| 451 |
+
repo = Repo('.')
|
| 452 |
+
path = os.path.join('numba', 'tests')
|
| 453 |
+
if use_common_ancestor:
|
| 454 |
+
print(f"Git diff by common ancestor")
|
| 455 |
+
target = 'origin/release0.66...HEAD'
|
| 456 |
+
else:
|
| 457 |
+
target = 'origin/release0.66..HEAD'
|
| 458 |
+
gdiff_paths = repo.git.diff(target, path, name_only=True).split()
|
| 459 |
+
# normalise the paths as they are unix style from repo.git.diff
|
| 460 |
+
gdiff_paths = [os.path.normpath(x) for x in gdiff_paths]
|
| 461 |
+
selected = []
|
| 462 |
+
gdiff_paths = [os.path.join(repo.working_dir, x) for x in gdiff_paths]
|
| 463 |
+
for test in _flatten_suite(tests):
|
| 464 |
+
assert isinstance(test, unittest.TestCase)
|
| 465 |
+
fname = inspect.getsourcefile(test.__class__)
|
| 466 |
+
if fname in gdiff_paths:
|
| 467 |
+
selected.append(test)
|
| 468 |
+
print("Git diff identified %s tests" % len(selected))
|
| 469 |
+
return unittest.TestSuite(selected)
|
| 470 |
+
|
| 471 |
+
def _choose_tagged_tests(tests, tags, mode='include'):
|
| 472 |
+
"""
|
| 473 |
+
Select tests that are tagged/not tagged with at least one of the given tags.
|
| 474 |
+
Set mode to 'include' to include the tests with tags, or 'exclude' to
|
| 475 |
+
exclude the tests with the tags.
|
| 476 |
+
"""
|
| 477 |
+
selected = []
|
| 478 |
+
tags = set(tags)
|
| 479 |
+
for test in _flatten_suite(tests):
|
| 480 |
+
assert isinstance(test, unittest.TestCase)
|
| 481 |
+
func = getattr(test, test._testMethodName)
|
| 482 |
+
try:
|
| 483 |
+
# Look up the method's underlying function (Python 2)
|
| 484 |
+
func = func.im_func
|
| 485 |
+
except AttributeError:
|
| 486 |
+
pass
|
| 487 |
+
|
| 488 |
+
found_tags = getattr(func, 'tags', None)
|
| 489 |
+
# only include the test if the tags *are* present
|
| 490 |
+
if mode == 'include':
|
| 491 |
+
if found_tags is not None and found_tags & tags:
|
| 492 |
+
selected.append(test)
|
| 493 |
+
elif mode == 'exclude':
|
| 494 |
+
# only include the test if the tags *are not* present
|
| 495 |
+
if found_tags is None or not (found_tags & tags):
|
| 496 |
+
selected.append(test)
|
| 497 |
+
else:
|
| 498 |
+
raise ValueError("Invalid 'mode' supplied: %s." % mode)
|
| 499 |
+
return unittest.TestSuite(selected)
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
def _choose_random_tests(tests, ratio, seed):
|
| 503 |
+
"""
|
| 504 |
+
Choose a given proportion of tests at random.
|
| 505 |
+
"""
|
| 506 |
+
rnd = random.Random()
|
| 507 |
+
rnd.seed(seed)
|
| 508 |
+
if isinstance(tests, unittest.TestSuite):
|
| 509 |
+
tests = _flatten_suite(tests)
|
| 510 |
+
tests = rnd.sample(tests, int(len(tests) * ratio))
|
| 511 |
+
tests = sorted(tests, key=lambda case: case.id())
|
| 512 |
+
return unittest.TestSuite(tests)
|
| 513 |
+
|
| 514 |
+
|
| 515 |
+
# The reference leak detection code is liberally taken and adapted from
|
| 516 |
+
# Python's own Lib/test/regrtest.py.
|
| 517 |
+
|
| 518 |
+
def _refleak_cleanup():
|
| 519 |
+
# Collect cyclic trash and read memory statistics immediately after.
|
| 520 |
+
func1 = sys.getallocatedblocks
|
| 521 |
+
try:
|
| 522 |
+
func2 = sys.gettotalrefcount
|
| 523 |
+
except AttributeError:
|
| 524 |
+
func2 = lambda: 42
|
| 525 |
+
|
| 526 |
+
# Flush standard output, so that buffered data is sent to the OS and
|
| 527 |
+
# associated Python objects are reclaimed.
|
| 528 |
+
for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
|
| 529 |
+
if stream is not None:
|
| 530 |
+
stream.flush()
|
| 531 |
+
|
| 532 |
+
sys._clear_type_cache()
|
| 533 |
+
# This also clears the various internal CPython freelists.
|
| 534 |
+
gc.collect()
|
| 535 |
+
return func1(), func2()
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
class ReferenceLeakError(RuntimeError):
|
| 539 |
+
pass
|
| 540 |
+
|
| 541 |
+
|
| 542 |
+
class IntPool(collections.defaultdict):
|
| 543 |
+
|
| 544 |
+
def __missing__(self, key):
|
| 545 |
+
return key
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
class RefleakTestResult(runner.TextTestResult):
|
| 549 |
+
|
| 550 |
+
warmup = 3
|
| 551 |
+
repetitions = 6
|
| 552 |
+
|
| 553 |
+
def _huntLeaks(self, test):
|
| 554 |
+
self.stream.flush()
|
| 555 |
+
|
| 556 |
+
repcount = self.repetitions
|
| 557 |
+
nwarmup = self.warmup
|
| 558 |
+
rc_deltas = [0] * (repcount - nwarmup)
|
| 559 |
+
alloc_deltas = [0] * (repcount - nwarmup)
|
| 560 |
+
# Preallocate ints likely to be stored in rc_deltas and alloc_deltas,
|
| 561 |
+
# to make sys.getallocatedblocks() less flaky.
|
| 562 |
+
_int_pool = IntPool()
|
| 563 |
+
for i in range(-200, 200):
|
| 564 |
+
_int_pool[i]
|
| 565 |
+
|
| 566 |
+
for i in range(repcount):
|
| 567 |
+
# Use a pristine, silent result object to avoid recursion
|
| 568 |
+
res = result.TestResult()
|
| 569 |
+
test.run(res)
|
| 570 |
+
# Poorly-written tests may fail when run several times.
|
| 571 |
+
# In this case, abort the refleak run and report the failure.
|
| 572 |
+
if not res.wasSuccessful():
|
| 573 |
+
self.failures.extend(res.failures)
|
| 574 |
+
self.errors.extend(res.errors)
|
| 575 |
+
raise AssertionError
|
| 576 |
+
del res
|
| 577 |
+
alloc_after, rc_after = _refleak_cleanup()
|
| 578 |
+
if i >= nwarmup:
|
| 579 |
+
rc_deltas[i - nwarmup] = _int_pool[rc_after - rc_before]
|
| 580 |
+
alloc_deltas[i - nwarmup] = _int_pool[alloc_after - alloc_before]
|
| 581 |
+
alloc_before, rc_before = alloc_after, rc_after
|
| 582 |
+
return rc_deltas, alloc_deltas
|
| 583 |
+
|
| 584 |
+
def addSuccess(self, test):
|
| 585 |
+
try:
|
| 586 |
+
rc_deltas, alloc_deltas = self._huntLeaks(test)
|
| 587 |
+
except AssertionError:
|
| 588 |
+
# Test failed when repeated
|
| 589 |
+
assert not self.wasSuccessful()
|
| 590 |
+
return
|
| 591 |
+
|
| 592 |
+
# These checkers return False on success, True on failure
|
| 593 |
+
def check_rc_deltas(deltas):
|
| 594 |
+
return any(deltas)
|
| 595 |
+
|
| 596 |
+
def check_alloc_deltas(deltas):
|
| 597 |
+
# At least 1/3rd of 0s
|
| 598 |
+
if 3 * deltas.count(0) < len(deltas):
|
| 599 |
+
return True
|
| 600 |
+
# Nothing else than 1s, 0s and -1s
|
| 601 |
+
if not set(deltas) <= set((1, 0, -1)):
|
| 602 |
+
return True
|
| 603 |
+
return False
|
| 604 |
+
|
| 605 |
+
failed = False
|
| 606 |
+
|
| 607 |
+
for deltas, item_name, checker in [
|
| 608 |
+
(rc_deltas, 'references', check_rc_deltas),
|
| 609 |
+
(alloc_deltas, 'memory blocks', check_alloc_deltas)]:
|
| 610 |
+
if checker(deltas):
|
| 611 |
+
msg = '%s leaked %s %s, sum=%s' % (
|
| 612 |
+
test, deltas, item_name, sum(deltas))
|
| 613 |
+
failed = True
|
| 614 |
+
try:
|
| 615 |
+
raise ReferenceLeakError(msg)
|
| 616 |
+
except Exception:
|
| 617 |
+
exc_info = sys.exc_info()
|
| 618 |
+
if self.showAll:
|
| 619 |
+
self.stream.write("%s = %r " % (item_name, deltas))
|
| 620 |
+
self.addFailure(test, exc_info)
|
| 621 |
+
|
| 622 |
+
if not failed:
|
| 623 |
+
super(RefleakTestResult, self).addSuccess(test)
|
| 624 |
+
|
| 625 |
+
|
| 626 |
+
class RefleakTestRunner(runner.TextTestRunner):
|
| 627 |
+
resultclass = RefleakTestResult
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
class ParallelTestResult(runner.TextTestResult):
|
| 631 |
+
"""
|
| 632 |
+
A TestResult able to inject results from other results.
|
| 633 |
+
"""
|
| 634 |
+
|
| 635 |
+
def add_results(self, result):
|
| 636 |
+
"""
|
| 637 |
+
Add the results from the other *result* to this result.
|
| 638 |
+
"""
|
| 639 |
+
self.stream.write(result.stream.getvalue())
|
| 640 |
+
self.stream.flush()
|
| 641 |
+
self.testsRun += result.testsRun
|
| 642 |
+
self.failures.extend(result.failures)
|
| 643 |
+
self.errors.extend(result.errors)
|
| 644 |
+
self.skipped.extend(result.skipped)
|
| 645 |
+
self.expectedFailures.extend(result.expectedFailures)
|
| 646 |
+
self.unexpectedSuccesses.extend(result.unexpectedSuccesses)
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
class _MinimalResult(object):
|
| 650 |
+
"""
|
| 651 |
+
A minimal, picklable TestResult-alike object.
|
| 652 |
+
"""
|
| 653 |
+
|
| 654 |
+
__slots__ = (
|
| 655 |
+
'failures', 'errors', 'skipped', 'expectedFailures',
|
| 656 |
+
'unexpectedSuccesses', 'stream', 'shouldStop', 'testsRun',
|
| 657 |
+
'test_id', 'resource_info')
|
| 658 |
+
|
| 659 |
+
def fixup_case(self, case):
|
| 660 |
+
"""
|
| 661 |
+
Remove any unpicklable attributes from TestCase instance *case*.
|
| 662 |
+
"""
|
| 663 |
+
# Python 3.3 doesn't reset this one.
|
| 664 |
+
case._outcomeForDoCleanups = None
|
| 665 |
+
|
| 666 |
+
def __init__(self, original_result, test_id=None, resource_info=None):
|
| 667 |
+
for attr in self.__slots__:
|
| 668 |
+
setattr(self, attr, getattr(original_result, attr, None))
|
| 669 |
+
for case, _ in self.expectedFailures:
|
| 670 |
+
self.fixup_case(case)
|
| 671 |
+
for case, _ in self.errors:
|
| 672 |
+
self.fixup_case(case)
|
| 673 |
+
for case, _ in self.failures:
|
| 674 |
+
self.fixup_case(case)
|
| 675 |
+
self.test_id = test_id
|
| 676 |
+
self.resource_info = resource_info
|
| 677 |
+
|
| 678 |
+
|
| 679 |
+
class _FakeStringIO(object):
|
| 680 |
+
"""
|
| 681 |
+
A trivial picklable StringIO-alike for Python 2.
|
| 682 |
+
"""
|
| 683 |
+
|
| 684 |
+
def __init__(self, value):
|
| 685 |
+
self._value = value
|
| 686 |
+
|
| 687 |
+
def getvalue(self):
|
| 688 |
+
return self._value
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
class _MinimalRunner(object):
|
| 692 |
+
"""
|
| 693 |
+
A minimal picklable object able to instantiate a runner in a
|
| 694 |
+
child process and run a test case with it.
|
| 695 |
+
"""
|
| 696 |
+
|
| 697 |
+
def __init__(self, runner_cls, runner_args):
|
| 698 |
+
self.runner_cls = runner_cls
|
| 699 |
+
self.runner_args = runner_args
|
| 700 |
+
|
| 701 |
+
# Python 2 doesn't know how to pickle instance methods, so we use __call__
|
| 702 |
+
# instead.
|
| 703 |
+
|
| 704 |
+
def __call__(self, test):
|
| 705 |
+
# Executed in child process
|
| 706 |
+
kwargs = self.runner_args
|
| 707 |
+
# Force recording of output in a buffer (it will be printed out
|
| 708 |
+
# by the parent).
|
| 709 |
+
kwargs['stream'] = StringIO()
|
| 710 |
+
runner = self.runner_cls(**kwargs)
|
| 711 |
+
result = runner._makeResult()
|
| 712 |
+
# Avoid child tracebacks when Ctrl-C is pressed.
|
| 713 |
+
signals.installHandler()
|
| 714 |
+
signals.registerResult(result)
|
| 715 |
+
result.failfast = runner.failfast
|
| 716 |
+
result.buffer = runner.buffer
|
| 717 |
+
# Create a per-process memory tracker to avoid global state issues
|
| 718 |
+
memtrack = memoryutils.MemoryTracker(test.id())
|
| 719 |
+
with memtrack.monitor():
|
| 720 |
+
with self.cleanup_object(test):
|
| 721 |
+
test(result)
|
| 722 |
+
# HACK as cStringIO.StringIO isn't picklable in 2.x
|
| 723 |
+
result.stream = _FakeStringIO(result.stream.getvalue())
|
| 724 |
+
return _MinimalResult(result, test.id(),
|
| 725 |
+
resource_info=memtrack.get_summary())
|
| 726 |
+
|
| 727 |
+
@contextlib.contextmanager
|
| 728 |
+
def cleanup_object(self, test):
|
| 729 |
+
"""
|
| 730 |
+
A context manager which cleans up unwanted attributes on a test case
|
| 731 |
+
(or any other object).
|
| 732 |
+
"""
|
| 733 |
+
vanilla_attrs = set(test.__dict__)
|
| 734 |
+
try:
|
| 735 |
+
yield test
|
| 736 |
+
finally:
|
| 737 |
+
spurious_attrs = set(test.__dict__) - vanilla_attrs
|
| 738 |
+
for name in spurious_attrs:
|
| 739 |
+
del test.__dict__[name]
|
| 740 |
+
|
| 741 |
+
|
| 742 |
+
def _split_nonparallel_tests(test, sliced):
|
| 743 |
+
"""
|
| 744 |
+
Split test suite into parallel and serial tests.
|
| 745 |
+
"""
|
| 746 |
+
ptests = []
|
| 747 |
+
stests = []
|
| 748 |
+
|
| 749 |
+
flat = [*filter(sliced, _flatten_suite(test))]
|
| 750 |
+
|
| 751 |
+
def is_parallelizable_test_case(test):
|
| 752 |
+
# Guard for the fake test case created by unittest when test
|
| 753 |
+
# discovery fails, as it isn't picklable (e.g. "LoadTestsFailure")
|
| 754 |
+
method_name = test._testMethodName
|
| 755 |
+
method = getattr(test, method_name)
|
| 756 |
+
if method.__name__ != method_name and method.__name__ == "testFailure":
|
| 757 |
+
return False
|
| 758 |
+
# Was parallel execution explicitly disabled?
|
| 759 |
+
return getattr(test, "_numba_parallel_test_", True)
|
| 760 |
+
|
| 761 |
+
for t in flat:
|
| 762 |
+
if is_parallelizable_test_case(t):
|
| 763 |
+
ptests.append(t)
|
| 764 |
+
else:
|
| 765 |
+
stests.append(t)
|
| 766 |
+
|
| 767 |
+
return ptests, stests
|
| 768 |
+
|
| 769 |
+
# A test can't run longer than 10 minutes
|
| 770 |
+
_TIMEOUT = 1200
|
| 771 |
+
|
| 772 |
+
class ParallelTestRunner(runner.TextTestRunner):
|
| 773 |
+
"""
|
| 774 |
+
A test runner which delegates the actual running to a pool of child
|
| 775 |
+
processes.
|
| 776 |
+
"""
|
| 777 |
+
|
| 778 |
+
resultclass = ParallelTestResult
|
| 779 |
+
timeout = _TIMEOUT
|
| 780 |
+
|
| 781 |
+
def __init__(self, runner_cls, nprocs, useslice, **kwargs):
|
| 782 |
+
runner.TextTestRunner.__init__(self, **kwargs)
|
| 783 |
+
self.runner_cls = runner_cls
|
| 784 |
+
self.nprocs = nprocs
|
| 785 |
+
self.useslice = parse_slice(useslice)
|
| 786 |
+
self.runner_args = kwargs
|
| 787 |
+
self.resource_infos = []
|
| 788 |
+
|
| 789 |
+
def _run_inner(self, result):
|
| 790 |
+
# We hijack TextTestRunner.run()'s inner logic by passing this
|
| 791 |
+
# method as if it were a test case.
|
| 792 |
+
child_runner = _MinimalRunner(self.runner_cls, self.runner_args)
|
| 793 |
+
|
| 794 |
+
# Split the tests and recycle the worker process to tame memory usage.
|
| 795 |
+
chunk_size = 100
|
| 796 |
+
splitted_tests = [self._ptests[i:i + chunk_size]
|
| 797 |
+
for i in range(0, len(self._ptests), chunk_size)]
|
| 798 |
+
|
| 799 |
+
spawnctx = multiprocessing.get_context("spawn")
|
| 800 |
+
try:
|
| 801 |
+
for tests in splitted_tests:
|
| 802 |
+
pool = spawnctx.Pool(self.nprocs)
|
| 803 |
+
try:
|
| 804 |
+
self._run_parallel_tests(result, pool, child_runner, tests)
|
| 805 |
+
except Exception:
|
| 806 |
+
# On exception, kill still active workers immediately
|
| 807 |
+
pool.terminate()
|
| 808 |
+
# Make sure exception is reported and not ignored
|
| 809 |
+
raise
|
| 810 |
+
else:
|
| 811 |
+
# Close the pool cleanly unless asked to early out
|
| 812 |
+
if result.shouldStop:
|
| 813 |
+
pool.terminate()
|
| 814 |
+
break
|
| 815 |
+
else:
|
| 816 |
+
pool.close()
|
| 817 |
+
finally:
|
| 818 |
+
# Always join the pool (this is necessary for coverage.py)
|
| 819 |
+
pool.join()
|
| 820 |
+
if not result.shouldStop:
|
| 821 |
+
# Run serial tests with memory tracking
|
| 822 |
+
stests = SerialSuite(self._stests)
|
| 823 |
+
stests.run(result)
|
| 824 |
+
# Add serial test resource infos to the main collection
|
| 825 |
+
self.resource_infos.extend(stests.resource_infos)
|
| 826 |
+
return result
|
| 827 |
+
finally:
|
| 828 |
+
# Always display the resource infos
|
| 829 |
+
if memoryutils.IS_SUPPORTED:
|
| 830 |
+
try:
|
| 831 |
+
print("=== Resource Infos ===")
|
| 832 |
+
for ri in self.resource_infos:
|
| 833 |
+
print(ri)
|
| 834 |
+
except Exception:
|
| 835 |
+
print("ERROR: Ignored exception in priting resource infos")
|
| 836 |
+
traceback.print_exc()
|
| 837 |
+
finally:
|
| 838 |
+
print("=== End Resource Infos ===")
|
| 839 |
+
|
| 840 |
+
def _run_parallel_tests(self, result, pool, child_runner, tests):
|
| 841 |
+
remaining_ids = set(t.id() for t in tests)
|
| 842 |
+
tests.sort(key=cuda_sensitive_mtime)
|
| 843 |
+
it = pool.imap_unordered(child_runner, tests)
|
| 844 |
+
while True:
|
| 845 |
+
try:
|
| 846 |
+
child_result = it.__next__(self.timeout)
|
| 847 |
+
except StopIteration:
|
| 848 |
+
return
|
| 849 |
+
except TimeoutError as e:
|
| 850 |
+
# Diagnose the names of unfinished tests
|
| 851 |
+
msg = ("Tests didn't finish before timeout (or crashed):\n%s"
|
| 852 |
+
% "".join("- %r\n" % tid for tid in sorted(remaining_ids))
|
| 853 |
+
)
|
| 854 |
+
e.args = (msg,) + e.args[1:]
|
| 855 |
+
raise e
|
| 856 |
+
else:
|
| 857 |
+
result.add_results(child_result)
|
| 858 |
+
self.resource_infos.append(child_result.resource_info)
|
| 859 |
+
remaining_ids.discard(child_result.test_id)
|
| 860 |
+
if child_result.shouldStop:
|
| 861 |
+
result.shouldStop = True
|
| 862 |
+
return
|
| 863 |
+
|
| 864 |
+
def run(self, test):
|
| 865 |
+
self._ptests, self._stests = _split_nonparallel_tests(test,
|
| 866 |
+
self.useslice)
|
| 867 |
+
print("Parallel: %s. Serial: %s" % (len(self._ptests),
|
| 868 |
+
len(self._stests)))
|
| 869 |
+
# This will call self._run_inner() on the created result object,
|
| 870 |
+
# and print out the detailed test results at the end.
|
| 871 |
+
return super(ParallelTestRunner, self).run(self._run_inner)
|
.venv/lib/python3.11/site-packages/numba/testing/notebook.py
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from unittest import TestCase
|
| 2 |
+
|
| 3 |
+
from ipykernel.tests import utils
|
| 4 |
+
from nbformat.converter import convert
|
| 5 |
+
from nbformat.reader import reads
|
| 6 |
+
|
| 7 |
+
import re
|
| 8 |
+
import json
|
| 9 |
+
from copy import copy
|
| 10 |
+
import unittest
|
| 11 |
+
|
| 12 |
+
try:
|
| 13 |
+
# py3
|
| 14 |
+
from queue import Empty
|
| 15 |
+
|
| 16 |
+
def isstr(s):
|
| 17 |
+
return isinstance(s, str)
|
| 18 |
+
except ImportError:
|
| 19 |
+
# py2
|
| 20 |
+
from Queue import Empty
|
| 21 |
+
|
| 22 |
+
def isstr(s):
|
| 23 |
+
return isinstance(s, basestring) # noqa
|
| 24 |
+
|
| 25 |
+
class NotebookTest(TestCase):
|
| 26 |
+
"""Validate a notebook. All code cells are executed in order. The output is either checked
|
| 27 |
+
for errors (if no reference output is present), or is compared against expected output.
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
Useful references:
|
| 31 |
+
http://nbformat.readthedocs.org/en/latest/format_description.html
|
| 32 |
+
http://jupyter-client.readthedocs.org/en/latest/messaging.html
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
IGNORE_TYPES = ["execute_request", "execute_input", "status", "pyin"]
|
| 37 |
+
STRIP_KEYS = ["execution_count", "traceback", "prompt_number", "source"]
|
| 38 |
+
NBFORMAT_VERSION = 4
|
| 39 |
+
|
| 40 |
+
def _test_notebook(self, notebook, test):
|
| 41 |
+
|
| 42 |
+
with open(notebook) as f:
|
| 43 |
+
nb = convert(reads(f.read()), self.NBFORMAT_VERSION)
|
| 44 |
+
_, kernel = utils.start_new_kernel()
|
| 45 |
+
for i, c in enumerate([c for c in nb.cells if c.cell_type == 'code']):
|
| 46 |
+
self._test_notebook_cell(self.sanitize_cell(c), i, kernel, test)
|
| 47 |
+
|
| 48 |
+
def _test_notebook_cell(self, cell, i, kernel, test):
|
| 49 |
+
|
| 50 |
+
if hasattr(cell, 'source'): # nbformat 4.0 and later
|
| 51 |
+
code = cell.source
|
| 52 |
+
else:
|
| 53 |
+
code = cell.input
|
| 54 |
+
iopub = kernel.iopub_channel
|
| 55 |
+
kernel.execute(code)
|
| 56 |
+
outputs = []
|
| 57 |
+
msg = None
|
| 58 |
+
no_error = True
|
| 59 |
+
first_error = -1
|
| 60 |
+
error_msg = ''
|
| 61 |
+
while self.should_continue(msg):
|
| 62 |
+
try:
|
| 63 |
+
msg = iopub.get_msg(block=True, timeout=1)
|
| 64 |
+
except Empty:
|
| 65 |
+
continue
|
| 66 |
+
if msg['msg_type'] not in self.IGNORE_TYPES:
|
| 67 |
+
if msg['msg_type'] == 'error':
|
| 68 |
+
error_msg = ' ' + msg['content']['ename'] + '\n ' + msg['content']['evalue']
|
| 69 |
+
no_error = False
|
| 70 |
+
if first_error == -1:
|
| 71 |
+
first_error = i
|
| 72 |
+
i = len(outputs)
|
| 73 |
+
expected = i < len(cell.outputs) and cell.outputs[i] or []
|
| 74 |
+
o = self.transform_message(msg, expected)
|
| 75 |
+
outputs.append(o)
|
| 76 |
+
|
| 77 |
+
if (test == 'check_error'):
|
| 78 |
+
self.assertTrue(no_error, 'Executing cell %d resulted in an error:\n%s'%(first_error, error_msg))
|
| 79 |
+
else:
|
| 80 |
+
# Compare computed output against stored output.
|
| 81 |
+
# TODO: This doesn't work right now as the generated output is too diverse to
|
| 82 |
+
# be verifiable.
|
| 83 |
+
scrub = lambda x: self.dump_canonical(list(self.scrub_outputs(x)))
|
| 84 |
+
scrubbed = scrub(outputs)
|
| 85 |
+
expected = scrub(cell.outputs)
|
| 86 |
+
#print('output=%s'%outputs)
|
| 87 |
+
#print('expected=%s'%expected)
|
| 88 |
+
#self.assertEqual(scrubbed, expected, "\n{}\n\n{}".format(scrubbed, expected))
|
| 89 |
+
|
| 90 |
+
def dump_canonical(self, obj):
|
| 91 |
+
return json.dumps(obj, indent=2, sort_keys=True)
|
| 92 |
+
|
| 93 |
+
def scrub_outputs(self, outputs):
|
| 94 |
+
"""
|
| 95 |
+
remove all scrubs from output data and text
|
| 96 |
+
"""
|
| 97 |
+
for output in outputs:
|
| 98 |
+
out = copy(output)
|
| 99 |
+
|
| 100 |
+
for scrub, sub in []:#self.scrubs.items():
|
| 101 |
+
def _scrubLines(lines):
|
| 102 |
+
if isstr(lines):
|
| 103 |
+
return re.sub(scrub, sub, lines)
|
| 104 |
+
else:
|
| 105 |
+
return [re.sub(scrub, sub, line) for line in lines]
|
| 106 |
+
|
| 107 |
+
if "text" in out:
|
| 108 |
+
out["text"] = _scrubLines(out["text"])
|
| 109 |
+
|
| 110 |
+
if "data" in out:
|
| 111 |
+
if isinstance(out["data"], dict):
|
| 112 |
+
for mime, data in out["data"].items():
|
| 113 |
+
out["data"][mime] = _scrubLines(data)
|
| 114 |
+
else:
|
| 115 |
+
out["data"] = _scrubLines(out["data"])
|
| 116 |
+
yield out
|
| 117 |
+
|
| 118 |
+
def strip_keys(self, d):
|
| 119 |
+
"""
|
| 120 |
+
remove keys from STRIP_KEYS to ensure comparability
|
| 121 |
+
"""
|
| 122 |
+
for key in self.STRIP_KEYS:
|
| 123 |
+
d.pop(key, None)
|
| 124 |
+
return d
|
| 125 |
+
|
| 126 |
+
def sanitize_cell(self, cell):
|
| 127 |
+
"""
|
| 128 |
+
remove non-reproducible things
|
| 129 |
+
"""
|
| 130 |
+
for output in cell.outputs:
|
| 131 |
+
self.strip_keys(output)
|
| 132 |
+
return cell
|
| 133 |
+
|
| 134 |
+
def transform_message(self, msg, expected):
|
| 135 |
+
"""
|
| 136 |
+
transform a message into something like the notebook
|
| 137 |
+
"""
|
| 138 |
+
SWAP_KEYS = {
|
| 139 |
+
"output_type": {
|
| 140 |
+
"pyout": "execute_result",
|
| 141 |
+
"pyerr": "error"
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
output = {
|
| 146 |
+
u"output_type": msg["msg_type"]
|
| 147 |
+
}
|
| 148 |
+
output.update(msg["content"])
|
| 149 |
+
|
| 150 |
+
output = self.strip_keys(output)
|
| 151 |
+
for key, swaps in SWAP_KEYS.items():
|
| 152 |
+
if key in output and output[key] in swaps:
|
| 153 |
+
output[key] = swaps[output[key]]
|
| 154 |
+
|
| 155 |
+
if "data" in output and "data" not in expected:
|
| 156 |
+
output["text"] = output["data"]
|
| 157 |
+
del output["data"]
|
| 158 |
+
|
| 159 |
+
return output
|
| 160 |
+
|
| 161 |
+
def should_continue(self, msg):
|
| 162 |
+
"""
|
| 163 |
+
determine whether the current message is the last for this cell
|
| 164 |
+
"""
|
| 165 |
+
if msg is None:
|
| 166 |
+
return True
|
| 167 |
+
|
| 168 |
+
return not (msg["msg_type"] == "status" and
|
| 169 |
+
msg["content"]["execution_state"] == "idle")
|
| 170 |
+
|
| 171 |
+
|
.venv/lib/python3.11/site-packages/numba/tests/__init__.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gc
|
| 2 |
+
from os.path import dirname, join
|
| 3 |
+
import multiprocessing
|
| 4 |
+
import sys
|
| 5 |
+
import time
|
| 6 |
+
import unittest
|
| 7 |
+
import warnings
|
| 8 |
+
|
| 9 |
+
from unittest.suite import TestSuite
|
| 10 |
+
from numba.testing import load_testsuite
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
try:
|
| 14 |
+
import faulthandler
|
| 15 |
+
except ImportError:
|
| 16 |
+
faulthandler = None
|
| 17 |
+
else:
|
| 18 |
+
try:
|
| 19 |
+
# May fail in IPython Notebook with UnsupportedOperation
|
| 20 |
+
faulthandler.enable()
|
| 21 |
+
except Exception as e:
|
| 22 |
+
msg = "Failed to enable faulthandler due to:\n{err}"
|
| 23 |
+
warnings.warn(msg.format(err=e))
|
| 24 |
+
|
| 25 |
+
def load_tests(loader, tests, pattern):
|
| 26 |
+
suite = TestSuite()
|
| 27 |
+
suite.addTests(load_testsuite(loader, dirname(__file__)))
|
| 28 |
+
# Numba CUDA tests are located in a separate directory:
|
| 29 |
+
cuda_dir = join(dirname(dirname(__file__)), 'cuda/tests')
|
| 30 |
+
suite.addTests(loader.discover(cuda_dir))
|
| 31 |
+
|
| 32 |
+
return suite
|
| 33 |
+
|
.venv/lib/python3.11/site-packages/numba/tests/annotation_usecases.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Usecases with Python 3 function annotations. This is a separate module
|
| 3 |
+
in order to avoid syntax errors with Python 2.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class AnnotatedClass:
|
| 8 |
+
"""
|
| 9 |
+
A class with annotated methods.
|
| 10 |
+
"""
|
| 11 |
+
|
| 12 |
+
def __init__(self, v: int):
|
| 13 |
+
self.x = v
|
| 14 |
+
|
| 15 |
+
def add(self, v: int) -> int:
|
| 16 |
+
return self.x + v
|
.venv/lib/python3.11/site-packages/numba/tests/cache_usecases.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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test_dispatcher.py.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
import numpy as np
|
| 11 |
+
|
| 12 |
+
from numba import jit, prange
|
| 13 |
+
from numba.core import types
|
| 14 |
+
|
| 15 |
+
from numba.tests.ctypes_usecases import c_sin
|
| 16 |
+
from numba.tests.support import TestCase, captured_stderr
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@jit(cache=True, nopython=True)
|
| 20 |
+
def simple_usecase(x):
|
| 21 |
+
return x
|
| 22 |
+
|
| 23 |
+
def simple_usecase_caller(x):
|
| 24 |
+
return simple_usecase(x)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@jit(cache=True, nopython=True)
|
| 28 |
+
def add_usecase(x, y):
|
| 29 |
+
return x + y + Z
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
@jit(cache=True, forceobj=True)
|
| 33 |
+
def add_objmode_usecase(x, y):
|
| 34 |
+
object()
|
| 35 |
+
return x + y + Z
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@jit(nopython=True)
|
| 39 |
+
def add_nocache_usecase(x, y):
|
| 40 |
+
return x + y + Z
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@jit(cache=True, nopython=True)
|
| 44 |
+
def inner(x, y):
|
| 45 |
+
return x + y + Z
|
| 46 |
+
|
| 47 |
+
@jit(cache=True, nopython=True)
|
| 48 |
+
def outer(x, y):
|
| 49 |
+
return inner(-y, x)
|
| 50 |
+
|
| 51 |
+
@jit(cache=False, nopython=True)
|
| 52 |
+
def outer_uncached(x, y):
|
| 53 |
+
return inner(-y, x)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
@jit(cache=True, forceobj=True)
|
| 57 |
+
def looplifted(n):
|
| 58 |
+
object()
|
| 59 |
+
res = 0
|
| 60 |
+
for i in range(n):
|
| 61 |
+
res = res + i
|
| 62 |
+
return res
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
@jit(cache=True, nopython=True)
|
| 66 |
+
def use_c_sin(x):
|
| 67 |
+
return c_sin(x)
|
| 68 |
+
|
| 69 |
+
@jit(cache=True, nopython=True)
|
| 70 |
+
def use_c_sin_nest1(x):
|
| 71 |
+
return use_c_sin(x)
|
| 72 |
+
|
| 73 |
+
@jit(cache=True, nopython=True)
|
| 74 |
+
def use_c_sin_nest2(x):
|
| 75 |
+
return use_c_sin_nest1(x)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
@jit(cache=True, nopython=True)
|
| 79 |
+
def ambiguous_function(x):
|
| 80 |
+
return x + 2
|
| 81 |
+
|
| 82 |
+
renamed_function1 = ambiguous_function
|
| 83 |
+
|
| 84 |
+
@jit(cache=True, nopython=True)
|
| 85 |
+
def ambiguous_function(x):
|
| 86 |
+
return x + 6
|
| 87 |
+
|
| 88 |
+
renamed_function2 = ambiguous_function
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def make_closure(x):
|
| 92 |
+
@jit(cache=True, nopython=True)
|
| 93 |
+
def closure(y):
|
| 94 |
+
return x + y
|
| 95 |
+
|
| 96 |
+
return closure
|
| 97 |
+
|
| 98 |
+
closure1 = make_closure(3)
|
| 99 |
+
closure2 = make_closure(5)
|
| 100 |
+
closure3 = make_closure(7)
|
| 101 |
+
closure4 = make_closure(9)
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
biggie = np.arange(10**6)
|
| 105 |
+
|
| 106 |
+
@jit(cache=True, nopython=True)
|
| 107 |
+
def use_big_array():
|
| 108 |
+
return biggie
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
Z = 1
|
| 112 |
+
|
| 113 |
+
# Exercise returning a record instance. This used to hardcode the dtype
|
| 114 |
+
# pointer's value in the bitcode.
|
| 115 |
+
|
| 116 |
+
packed_record_type = np.dtype([('a', np.int8), ('b', np.float64)])
|
| 117 |
+
aligned_record_type = np.dtype([('a', np.int8), ('b', np.float64)], align=True)
|
| 118 |
+
|
| 119 |
+
packed_arr = np.empty(2, dtype=packed_record_type)
|
| 120 |
+
for i in range(packed_arr.size):
|
| 121 |
+
packed_arr[i]['a'] = i + 1
|
| 122 |
+
packed_arr[i]['b'] = i + 42.5
|
| 123 |
+
|
| 124 |
+
aligned_arr = np.array(packed_arr, dtype=aligned_record_type)
|
| 125 |
+
|
| 126 |
+
@jit(cache=True, nopython=True)
|
| 127 |
+
def record_return(ary, i):
|
| 128 |
+
return ary[i]
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
class _TestModule(TestCase):
|
| 132 |
+
"""
|
| 133 |
+
Tests for functionality of this module's functions.
|
| 134 |
+
Note this does not define any "test_*" method, instead check_module()
|
| 135 |
+
should be called by hand.
|
| 136 |
+
"""
|
| 137 |
+
|
| 138 |
+
def check_module(self, mod):
|
| 139 |
+
self.assertPreciseEqual(mod.add_usecase(2, 3), 6)
|
| 140 |
+
self.assertPreciseEqual(mod.add_objmode_usecase(2, 3), 6)
|
| 141 |
+
self.assertPreciseEqual(mod.outer_uncached(3, 2), 2)
|
| 142 |
+
self.assertPreciseEqual(mod.outer(3, 2), 2)
|
| 143 |
+
|
| 144 |
+
packed_rec = mod.record_return(mod.packed_arr, 1)
|
| 145 |
+
self.assertPreciseEqual(tuple(packed_rec), (2, 43.5))
|
| 146 |
+
aligned_rec = mod.record_return(mod.aligned_arr, 1)
|
| 147 |
+
self.assertPreciseEqual(tuple(aligned_rec), (2, 43.5))
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
@jit(cache=True)
|
| 151 |
+
def first_class_function_mul(x):
|
| 152 |
+
return x * x
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
@jit(cache=True)
|
| 156 |
+
def first_class_function_add(x):
|
| 157 |
+
return x + x
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
@jit(cache=True)
|
| 161 |
+
def first_class_function_usecase(f, x):
|
| 162 |
+
return f(x)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def self_test():
|
| 166 |
+
mod = sys.modules[__name__]
|
| 167 |
+
_TestModule().check_module(mod)
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
@jit(parallel=True, cache=True, nopython=True)
|
| 171 |
+
def parfor_usecase(ary):
|
| 172 |
+
return ary * ary + ary
|
.venv/lib/python3.11/site-packages/numba/tests/cffi_usecases.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import sys
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
import numba.core.typing.cffi_utils as cffi_support
|
| 6 |
+
from numba.tests.support import import_dynamic, temp_directory
|
| 7 |
+
from numba.core.types import complex128
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def load_inline_module():
|
| 11 |
+
"""
|
| 12 |
+
Create an inline module, return the corresponding ffi and dll objects.
|
| 13 |
+
"""
|
| 14 |
+
from cffi import FFI
|
| 15 |
+
|
| 16 |
+
# We can't rely on libc availability on Windows anymore, so we use our
|
| 17 |
+
# own compiled wrappers (see https://bugs.python.org/issue23606).
|
| 18 |
+
|
| 19 |
+
defs = """
|
| 20 |
+
double _numba_test_sin(double x);
|
| 21 |
+
double _numba_test_cos(double x);
|
| 22 |
+
double _numba_test_funcptr(double (*func)(double));
|
| 23 |
+
bool _numba_test_boolean(void);
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
ffi = FFI()
|
| 27 |
+
ffi.cdef(defs)
|
| 28 |
+
# Load the _helperlib namespace
|
| 29 |
+
from numba import _helperlib
|
| 30 |
+
return ffi, ffi.dlopen(_helperlib.__file__)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def load_ool_module():
|
| 34 |
+
"""
|
| 35 |
+
Compile an out-of-line module, return the corresponding ffi and
|
| 36 |
+
module objects.
|
| 37 |
+
"""
|
| 38 |
+
from cffi import FFI
|
| 39 |
+
|
| 40 |
+
numba_complex = """
|
| 41 |
+
typedef struct _numba_complex {
|
| 42 |
+
double real;
|
| 43 |
+
double imag;
|
| 44 |
+
} numba_complex;
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
bool_define = """
|
| 48 |
+
#ifdef _MSC_VER
|
| 49 |
+
#define false 0
|
| 50 |
+
#define true 1
|
| 51 |
+
#define bool int
|
| 52 |
+
#else
|
| 53 |
+
#include <stdbool.h>
|
| 54 |
+
#endif
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
defs = numba_complex + """
|
| 58 |
+
bool boolean(void);
|
| 59 |
+
double sin(double x);
|
| 60 |
+
double cos(double x);
|
| 61 |
+
int foo(int a, int b, int c);
|
| 62 |
+
void vsSin(int n, float* x, float* y);
|
| 63 |
+
void vdSin(int n, double* x, double* y);
|
| 64 |
+
void vector_real(numba_complex *c, double *real, int n);
|
| 65 |
+
void vector_imag(numba_complex *c, double *imag, int n);
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
source = numba_complex + bool_define + """
|
| 69 |
+
static bool boolean(void)
|
| 70 |
+
{
|
| 71 |
+
return true;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
static int foo(int a, int b, int c)
|
| 75 |
+
{
|
| 76 |
+
return a + b * c;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
void vsSin(int n, float* x, float* y) {
|
| 80 |
+
int i;
|
| 81 |
+
for (i=0; i<n; i++)
|
| 82 |
+
y[i] = sin(x[i]);
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
void vdSin(int n, double* x, double* y) {
|
| 86 |
+
int i;
|
| 87 |
+
for (i=0; i<n; i++)
|
| 88 |
+
y[i] = sin(x[i]);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
static void vector_real(numba_complex *c, double *real, int n) {
|
| 92 |
+
int i;
|
| 93 |
+
for (i = 0; i < n; i++)
|
| 94 |
+
real[i] = c[i].real;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
static void vector_imag(numba_complex *c, double *imag, int n) {
|
| 98 |
+
int i;
|
| 99 |
+
for (i = 0; i < n; i++)
|
| 100 |
+
imag[i] = c[i].imag;
|
| 101 |
+
}
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
ffi = FFI()
|
| 105 |
+
ffi.set_source('cffi_usecases_ool', source)
|
| 106 |
+
ffi.cdef(defs, override=True)
|
| 107 |
+
tmpdir = temp_directory('test_cffi')
|
| 108 |
+
ffi.compile(tmpdir=tmpdir)
|
| 109 |
+
sys.path.append(tmpdir)
|
| 110 |
+
try:
|
| 111 |
+
mod = import_dynamic('cffi_usecases_ool')
|
| 112 |
+
cffi_support.register_module(mod)
|
| 113 |
+
cffi_support.register_type(mod.ffi.typeof('struct _numba_complex'),
|
| 114 |
+
complex128)
|
| 115 |
+
return mod.ffi, mod
|
| 116 |
+
finally:
|
| 117 |
+
sys.path.remove(tmpdir)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def init():
|
| 121 |
+
"""
|
| 122 |
+
Initialize module globals. This can invoke external utilities, hence not
|
| 123 |
+
being executed implicitly at module import.
|
| 124 |
+
"""
|
| 125 |
+
global ffi, cffi_sin, cffi_cos, cffi_bool
|
| 126 |
+
|
| 127 |
+
if ffi is None:
|
| 128 |
+
ffi, dll = load_inline_module()
|
| 129 |
+
cffi_sin = dll._numba_test_sin
|
| 130 |
+
cffi_cos = dll._numba_test_cos
|
| 131 |
+
cffi_bool = dll._numba_test_boolean
|
| 132 |
+
del dll
|
| 133 |
+
|
| 134 |
+
def init_ool():
|
| 135 |
+
"""
|
| 136 |
+
Same as init() for OOL mode.
|
| 137 |
+
"""
|
| 138 |
+
global ffi_ool, cffi_sin_ool, cffi_cos_ool, cffi_foo, cffi_bool_ool
|
| 139 |
+
global vsSin, vdSin, vector_real, vector_imag
|
| 140 |
+
|
| 141 |
+
if ffi_ool is None:
|
| 142 |
+
ffi_ool, mod = load_ool_module()
|
| 143 |
+
cffi_sin_ool = mod.lib.sin
|
| 144 |
+
cffi_cos_ool = mod.lib.cos
|
| 145 |
+
cffi_foo = mod.lib.foo
|
| 146 |
+
cffi_bool_ool = mod.lib.boolean
|
| 147 |
+
vsSin = mod.lib.vsSin
|
| 148 |
+
vdSin = mod.lib.vdSin
|
| 149 |
+
vector_real = mod.lib.vector_real
|
| 150 |
+
vector_imag = mod.lib.vector_imag
|
| 151 |
+
del mod
|
| 152 |
+
|
| 153 |
+
ffi = ffi_ool = None
|
| 154 |
+
|
| 155 |
+
|
| 156 |
+
def use_cffi_sin(x):
|
| 157 |
+
return cffi_sin(x) * 2
|
| 158 |
+
|
| 159 |
+
def use_two_funcs(x):
|
| 160 |
+
return cffi_sin(x) - cffi_cos(x)
|
| 161 |
+
|
| 162 |
+
def use_cffi_sin_ool(x):
|
| 163 |
+
return cffi_sin_ool(x) * 2
|
| 164 |
+
|
| 165 |
+
def use_cffi_boolean_true():
|
| 166 |
+
return cffi_bool_ool()
|
| 167 |
+
|
| 168 |
+
def use_two_funcs_ool(x):
|
| 169 |
+
return cffi_sin_ool(x) - cffi_cos_ool(x)
|
| 170 |
+
|
| 171 |
+
def use_func_pointer(fa, fb, x):
|
| 172 |
+
if x > 0:
|
| 173 |
+
return fa(x)
|
| 174 |
+
else:
|
| 175 |
+
return fb(x)
|
| 176 |
+
|
| 177 |
+
def use_user_defined_symbols():
|
| 178 |
+
return cffi_foo(1, 2, 3)
|
| 179 |
+
|
| 180 |
+
# The from_buffer method is member of cffi.FFI, and also of CompiledFFI objects
|
| 181 |
+
# (cffi_usecases_ool.ffi is a CompiledFFI object) so we use both in these
|
| 182 |
+
# functions.
|
| 183 |
+
|
| 184 |
+
def vector_sin_float32(x, y):
|
| 185 |
+
vsSin(len(x), ffi.from_buffer(x), ffi_ool.from_buffer(y))
|
| 186 |
+
|
| 187 |
+
def vector_sin_float64(x, y):
|
| 188 |
+
vdSin(len(x), ffi.from_buffer(x), ffi_ool.from_buffer(y))
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
# For testing pointer to structs from buffers
|
| 192 |
+
|
| 193 |
+
def vector_extract_real(x, y):
|
| 194 |
+
vector_real(ffi.from_buffer(x), ffi.from_buffer(y), len(x))
|
| 195 |
+
|
| 196 |
+
def vector_extract_imag(x, y):
|
| 197 |
+
vector_imag(ffi.from_buffer(x), ffi.from_buffer(y), len(x))
|
.venv/lib/python3.11/site-packages/numba/tests/cfunc_cache_usecases.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This file will be copied to a temporary directory in order to
|
| 3 |
+
exercise caching compiled C callbacks.
|
| 4 |
+
|
| 5 |
+
See test_cfunc.py.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import sys
|
| 9 |
+
|
| 10 |
+
from numba import cfunc, jit
|
| 11 |
+
from numba.tests.support import TestCase, captured_stderr
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
Z = 1
|
| 15 |
+
|
| 16 |
+
add_sig = "float64(float64, float64)"
|
| 17 |
+
|
| 18 |
+
div_sig = "float64(int64, int64)"
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@cfunc(add_sig, cache=True, nopython=True)
|
| 22 |
+
def add_usecase(x, y):
|
| 23 |
+
return x + y + Z
|
| 24 |
+
|
| 25 |
+
@cfunc(add_sig, nopython=True)
|
| 26 |
+
def add_nocache_usecase(x, y):
|
| 27 |
+
return x + y + Z
|
| 28 |
+
|
| 29 |
+
@cfunc(div_sig, cache=True, nopython=True)
|
| 30 |
+
def div_usecase(a, b):
|
| 31 |
+
return a / b
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
@jit(nopython=True)
|
| 35 |
+
def inner(x, y):
|
| 36 |
+
return x + y + Z
|
| 37 |
+
|
| 38 |
+
@cfunc(add_sig, cache=True, nopython=True)
|
| 39 |
+
def outer(x, y):
|
| 40 |
+
return inner(-y, x)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
class _TestModule(TestCase):
|
| 44 |
+
"""
|
| 45 |
+
Tests for functionality of this module's cfuncs.
|
| 46 |
+
Note this does not define any "test_*" method, instead check_module()
|
| 47 |
+
should be called by hand.
|
| 48 |
+
"""
|
| 49 |
+
|
| 50 |
+
def check_module(self, mod):
|
| 51 |
+
f = mod.add_usecase
|
| 52 |
+
self.assertPreciseEqual(f.ctypes(2.0, 3.0), 6.0)
|
| 53 |
+
f = mod.add_nocache_usecase
|
| 54 |
+
self.assertPreciseEqual(f.ctypes(2.0, 3.0), 6.0)
|
| 55 |
+
f = mod.outer
|
| 56 |
+
self.assertPreciseEqual(f.ctypes(5.0, 2.0), 4.0)
|
| 57 |
+
|
| 58 |
+
f = mod.div_usecase
|
| 59 |
+
with captured_stderr() as err:
|
| 60 |
+
self.assertPreciseEqual(f.ctypes(7, 2), 3.5)
|
| 61 |
+
self.assertEqual(err.getvalue(), "")
|
| 62 |
+
with captured_stderr() as err:
|
| 63 |
+
f.ctypes(7, 0)
|
| 64 |
+
err = err.getvalue()
|
| 65 |
+
self.assertIn("ZeroDivisionError", err)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def self_test():
|
| 69 |
+
mod = sys.modules[__name__]
|
| 70 |
+
_TestModule().check_module(mod)
|
.venv/lib/python3.11/site-packages/numba/tests/chained_assign_usecases.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from numba import jit
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
@jit
|
| 6 |
+
def inc(a):
|
| 7 |
+
for i in range(len(a)):
|
| 8 |
+
a[i] += 1
|
| 9 |
+
return a
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@jit
|
| 13 |
+
def inc1(a):
|
| 14 |
+
a[0] += 1
|
| 15 |
+
return a[0]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@jit
|
| 19 |
+
def inc2(a):
|
| 20 |
+
a[0] += 1
|
| 21 |
+
return a[0], a[0] + 1
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def chain1(a):
|
| 25 |
+
x = y = z = inc(a)
|
| 26 |
+
return x + y + z
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def chain2(v):
|
| 30 |
+
a = np.zeros(2)
|
| 31 |
+
a[0] = x = a[1] = v
|
| 32 |
+
return a[0] + a[1] + (x / 2)
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def unpack1(x, y):
|
| 36 |
+
a, b = x, y
|
| 37 |
+
return a + b / 2
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def unpack2(x, y):
|
| 41 |
+
a, b = c, d = inc1(x), inc1(y)
|
| 42 |
+
return a + c / 2, b + d / 2
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def chain3(x, y):
|
| 46 |
+
a = (b, c) = (inc1(x), inc1(y))
|
| 47 |
+
(d, e) = f = (inc1(x), inc1(y))
|
| 48 |
+
return (a[0] + b / 2 + d + f[0]), (a[1] + c + e / 2 + f[1])
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def unpack3(x):
|
| 52 |
+
a, b = inc2(x)
|
| 53 |
+
return a + b / 2
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def unpack4(x):
|
| 57 |
+
a, b = c, d = inc2(x)
|
| 58 |
+
return a + c / 2, b + d / 2
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def unpack5(x):
|
| 62 |
+
a = b, c = inc2(x)
|
| 63 |
+
d, e = f = inc2(x)
|
| 64 |
+
return (a[0] + b / 2 + d + f[0]), (a[1] + c + e / 2 + f[1])
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
def unpack6(x, y):
|
| 68 |
+
(a, b), (c, d) = (x, y), (y + 1, x + 1)
|
| 69 |
+
return a + c / 2, b / 2 + d
|
.venv/lib/python3.11/site-packages/numba/tests/cloudpickle_main_class.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Expected to run this module as __main__
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
# Cloudpickle will think this is a dynamic class when this module is __main__
|
| 5 |
+
class Klass:
|
| 6 |
+
classvar = None
|
.venv/lib/python3.11/site-packages/numba/tests/compile_with_pycc.py
ADDED
|
@@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|
| 8 |
+
from numba.tests.support import has_blas
|
| 9 |
+
from numba import typed
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
#
|
| 13 |
+
# New API
|
| 14 |
+
#
|
| 15 |
+
|
| 16 |
+
cc = CC('pycc_test_simple')
|
| 17 |
+
cc.use_nrt = False
|
| 18 |
+
|
| 19 |
+
# Note the first signature omits the return type
|
| 20 |
+
@cc.export('multf', (float32, float32))
|
| 21 |
+
@cc.export('multi', 'i4(i4, i4)')
|
| 22 |
+
def mult(a, b):
|
| 23 |
+
return a * b
|
| 24 |
+
|
| 25 |
+
# Test imported C globals such as Py_None, PyExc_ZeroDivisionError
|
| 26 |
+
@cc.export('get_none', 'none()')
|
| 27 |
+
def get_none():
|
| 28 |
+
return None
|
| 29 |
+
|
| 30 |
+
@cc.export('div', 'f8(f8, f8)')
|
| 31 |
+
def div(x, y):
|
| 32 |
+
return x / y
|
| 33 |
+
|
| 34 |
+
_two = 2
|
| 35 |
+
|
| 36 |
+
# This one can't be compiled by the legacy API as it doesn't execute
|
| 37 |
+
# the script in a proper module.
|
| 38 |
+
@cc.export('square', 'i8(i8)')
|
| 39 |
+
def square(u):
|
| 40 |
+
return u ** _two
|
| 41 |
+
|
| 42 |
+
# These ones need helperlib
|
| 43 |
+
cc_helperlib = CC('pycc_test_helperlib')
|
| 44 |
+
cc_helperlib.use_nrt = False
|
| 45 |
+
|
| 46 |
+
@cc_helperlib.export('power', 'i8(i8, i8)')
|
| 47 |
+
def power(u, v):
|
| 48 |
+
return u ** v
|
| 49 |
+
|
| 50 |
+
@cc_helperlib.export('sqrt', 'c16(c16)')
|
| 51 |
+
def sqrt(u):
|
| 52 |
+
return cmath.sqrt(u)
|
| 53 |
+
|
| 54 |
+
@cc_helperlib.export('size', 'i8(f8[:])')
|
| 55 |
+
def size(arr):
|
| 56 |
+
return arr.size
|
| 57 |
+
|
| 58 |
+
# Exercise linking to Numpy math functions
|
| 59 |
+
@cc_helperlib.export('np_sqrt', 'f8(f8)')
|
| 60 |
+
def np_sqrt(u):
|
| 61 |
+
return np.sqrt(u)
|
| 62 |
+
|
| 63 |
+
@cc_helperlib.export('spacing', 'f8(f8)')
|
| 64 |
+
def np_spacing(u):
|
| 65 |
+
return np.spacing(u)
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# This one clashes with libc random() unless pycc is careful with naming.
|
| 69 |
+
@cc_helperlib.export('random', 'f8(i4)')
|
| 70 |
+
def random_impl(seed):
|
| 71 |
+
if seed != -1:
|
| 72 |
+
np.random.seed(seed)
|
| 73 |
+
return np.random.random()
|
| 74 |
+
|
| 75 |
+
# These ones need NRT
|
| 76 |
+
cc_nrt = CC('pycc_test_nrt')
|
| 77 |
+
|
| 78 |
+
@cc_nrt.export('zero_scalar', 'f8(i4)')
|
| 79 |
+
def zero_scalar(n):
|
| 80 |
+
arr = np.zeros(n)
|
| 81 |
+
return arr[-1]
|
| 82 |
+
|
| 83 |
+
if has_blas:
|
| 84 |
+
# This one also needs BLAS
|
| 85 |
+
@cc_nrt.export('vector_dot', 'f8(i4)')
|
| 86 |
+
def vector_dot(n):
|
| 87 |
+
a = np.linspace(1, n, n)
|
| 88 |
+
return np.dot(a, a)
|
| 89 |
+
|
| 90 |
+
# This one needs an environment
|
| 91 |
+
@cc_nrt.export('zeros', 'f8[:](i4)')
|
| 92 |
+
def zeros(n):
|
| 93 |
+
return np.zeros(n)
|
| 94 |
+
|
| 95 |
+
# requires list dtor, #issue3535
|
| 96 |
+
@cc_nrt.export('np_argsort', 'intp[:](float64[:])')
|
| 97 |
+
def np_argsort(arr):
|
| 98 |
+
return np.argsort(arr)
|
| 99 |
+
|
| 100 |
+
#
|
| 101 |
+
# Legacy API
|
| 102 |
+
#
|
| 103 |
+
|
| 104 |
+
exportmany(['multf f4(f4,f4)', 'multi i4(i4,i4)'])(mult)
|
| 105 |
+
# Needs to link to helperlib to due with complex arguments
|
| 106 |
+
# export('multc c16(c16,c16)')(mult)
|
| 107 |
+
export('mult f8(f8, f8)')(mult)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
@cc_nrt.export('dict_usecase', 'intp[:](intp[:])')
|
| 111 |
+
def dict_usecase(arr):
|
| 112 |
+
d = typed.Dict()
|
| 113 |
+
for i in range(arr.size):
|
| 114 |
+
d[i] = arr[i]
|
| 115 |
+
out = np.zeros_like(arr)
|
| 116 |
+
for k, v in d.items():
|
| 117 |
+
out[k] = k * v
|
| 118 |
+
return out
|
| 119 |
+
|
| 120 |
+
# checks for issue #6386
|
| 121 |
+
@cc_nrt.export('internal_str_dict', i8(unicode_type))
|
| 122 |
+
def internal_str_dict(x):
|
| 123 |
+
d = typed.Dict.empty(unicode_type,i8)
|
| 124 |
+
if(x not in d):
|
| 125 |
+
d[x] = len(d)
|
| 126 |
+
return len(d)
|
| 127 |
+
|
| 128 |
+
@cc_nrt.export('hash_str', i8(unicode_type))
|
| 129 |
+
def internal_str_dict(x):
|
| 130 |
+
return hash(x)
|
| 131 |
+
|
| 132 |
+
@cc_nrt.export('hash_literal_str_A', i8())
|
| 133 |
+
def internal_str_dict():
|
| 134 |
+
return hash("A")
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
# For testing dynamic exception symbol collision/linkage
|
| 138 |
+
|
| 139 |
+
cc_dynexc = CC('pycc_test_dynamic_exc')
|
| 140 |
+
|
| 141 |
+
@cc_dynexc.export('do_setitem1', 'void(f8[:, :], f8[:, :])')
|
| 142 |
+
def do_setitem1(a, b):
|
| 143 |
+
a[:, :] = b
|
| 144 |
+
|
| 145 |
+
@cc_dynexc.export('do_setitem2', 'void(f8[:, :], f8[:, :])')
|
| 146 |
+
def do_setitem2(a, b):
|
| 147 |
+
a[:, :] = b
|
.venv/lib/python3.11/site-packages/numba/tests/complex_usecases.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import cmath
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
def div_usecase(x, y):
|
| 5 |
+
return x / y
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def real_usecase(x):
|
| 9 |
+
return x.real
|
| 10 |
+
|
| 11 |
+
def imag_usecase(x):
|
| 12 |
+
return x.imag
|
| 13 |
+
|
| 14 |
+
def conjugate_usecase(x):
|
| 15 |
+
return x.conjugate()
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def acos_usecase(x):
|
| 19 |
+
return cmath.acos(x)
|
| 20 |
+
|
| 21 |
+
def cos_usecase(x):
|
| 22 |
+
return cmath.cos(x)
|
| 23 |
+
|
| 24 |
+
def asin_usecase(x):
|
| 25 |
+
return cmath.asin(x)
|
| 26 |
+
|
| 27 |
+
def sin_usecase(x):
|
| 28 |
+
return cmath.sin(x)
|
| 29 |
+
|
| 30 |
+
def atan_usecase(x):
|
| 31 |
+
return cmath.atan(x)
|
| 32 |
+
|
| 33 |
+
def tan_usecase(x):
|
| 34 |
+
return cmath.tan(x)
|
| 35 |
+
|
| 36 |
+
def acosh_usecase(x):
|
| 37 |
+
return cmath.acosh(x)
|
| 38 |
+
|
| 39 |
+
def cosh_usecase(x):
|
| 40 |
+
return cmath.cosh(x)
|
| 41 |
+
|
| 42 |
+
def asinh_usecase(x):
|
| 43 |
+
return cmath.asinh(x)
|
| 44 |
+
|
| 45 |
+
def sinh_usecase(x):
|
| 46 |
+
return cmath.sinh(x)
|
| 47 |
+
|
| 48 |
+
def atanh_usecase(x):
|
| 49 |
+
return cmath.atanh(x)
|
| 50 |
+
|
| 51 |
+
def tanh_usecase(x):
|
| 52 |
+
return cmath.tanh(x)
|
| 53 |
+
|
| 54 |
+
def exp_usecase(x):
|
| 55 |
+
return cmath.exp(x)
|
| 56 |
+
|
| 57 |
+
def isfinite_usecase(x):
|
| 58 |
+
return cmath.isfinite(x)
|
| 59 |
+
|
| 60 |
+
def isinf_usecase(x):
|
| 61 |
+
return cmath.isinf(x)
|
| 62 |
+
|
| 63 |
+
def isnan_usecase(x):
|
| 64 |
+
return cmath.isnan(x)
|
| 65 |
+
|
| 66 |
+
def log_usecase(x):
|
| 67 |
+
return cmath.log(x)
|
| 68 |
+
|
| 69 |
+
def log_base_usecase(x, base):
|
| 70 |
+
return cmath.log(x, base)
|
| 71 |
+
|
| 72 |
+
def log10_usecase(x):
|
| 73 |
+
return cmath.log10(x)
|
| 74 |
+
|
| 75 |
+
def phase_usecase(x):
|
| 76 |
+
return cmath.phase(x)
|
| 77 |
+
|
| 78 |
+
def polar_usecase(x):
|
| 79 |
+
return cmath.polar(x)
|
| 80 |
+
|
| 81 |
+
_two = 2.0
|
| 82 |
+
|
| 83 |
+
def polar_as_complex_usecase(x):
|
| 84 |
+
# HACK: clear errno by invoking float.__pow__
|
| 85 |
+
# (workaround for http://bugs.python.org/issue24489)
|
| 86 |
+
_two ** _two
|
| 87 |
+
return complex(*cmath.polar(x))
|
| 88 |
+
|
| 89 |
+
def rect_usecase(r, phi):
|
| 90 |
+
return cmath.rect(r, phi)
|
| 91 |
+
|
| 92 |
+
def sqrt_usecase(x):
|
| 93 |
+
return cmath.sqrt(x)
|
.venv/lib/python3.11/site-packages/numba/tests/ctypes_usecases.py
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ctypes import *
|
| 2 |
+
import sys
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
is_windows = sys.platform.startswith('win32')
|
| 8 |
+
|
| 9 |
+
# We can't rely on libc availability on Windows anymore, so we use our
|
| 10 |
+
# own compiled wrappers (see https://bugs.python.org/issue23606).
|
| 11 |
+
|
| 12 |
+
from numba import _helperlib
|
| 13 |
+
libnumba = CDLL(_helperlib.__file__)
|
| 14 |
+
del _helperlib
|
| 15 |
+
|
| 16 |
+
# A typed C function (cdecl under Windows)
|
| 17 |
+
|
| 18 |
+
c_sin = libnumba._numba_test_sin
|
| 19 |
+
c_sin.argtypes = [c_double]
|
| 20 |
+
c_sin.restype = c_double
|
| 21 |
+
|
| 22 |
+
def use_c_sin(x):
|
| 23 |
+
return c_sin(x)
|
| 24 |
+
|
| 25 |
+
c_cos = libnumba._numba_test_cos
|
| 26 |
+
c_cos.argtypes = [c_double]
|
| 27 |
+
c_cos.restype = c_double
|
| 28 |
+
|
| 29 |
+
def use_two_funcs(x):
|
| 30 |
+
return c_sin(x) - c_cos(x)
|
| 31 |
+
|
| 32 |
+
# Typed C functions accepting an array pointer
|
| 33 |
+
# (either as a "void *" or as a typed pointer)
|
| 34 |
+
|
| 35 |
+
c_vsquare = libnumba._numba_test_vsquare
|
| 36 |
+
c_vsquare.argtypes = [c_int, c_void_p, c_void_p]
|
| 37 |
+
|
| 38 |
+
c_vcube = libnumba._numba_test_vsquare
|
| 39 |
+
c_vcube.argtypes = [c_int, POINTER(c_double), POINTER(c_double)]
|
| 40 |
+
|
| 41 |
+
def use_c_vsquare(x):
|
| 42 |
+
out = np.empty_like(x)
|
| 43 |
+
c_vsquare(x.size, x.ctypes, out.ctypes)
|
| 44 |
+
return out
|
| 45 |
+
|
| 46 |
+
def use_c_vcube(x):
|
| 47 |
+
out = np.empty_like(x)
|
| 48 |
+
c_vcube(x.size, x.ctypes, out.ctypes)
|
| 49 |
+
return out
|
| 50 |
+
|
| 51 |
+
# An untyped C function
|
| 52 |
+
|
| 53 |
+
c_untyped = libnumba._numba_test_exp
|
| 54 |
+
|
| 55 |
+
def use_c_untyped(x):
|
| 56 |
+
return c_untyped(x)
|
| 57 |
+
|
| 58 |
+
# A C function wrapped in a CFUNCTYPE
|
| 59 |
+
|
| 60 |
+
ctype_wrapping = CFUNCTYPE(c_double, c_double)(use_c_sin)
|
| 61 |
+
|
| 62 |
+
def use_ctype_wrapping(x):
|
| 63 |
+
return ctype_wrapping(x)
|
| 64 |
+
|
| 65 |
+
# A Python API function
|
| 66 |
+
|
| 67 |
+
savethread = pythonapi.PyEval_SaveThread
|
| 68 |
+
savethread.argtypes = []
|
| 69 |
+
savethread.restype = c_void_p
|
| 70 |
+
|
| 71 |
+
restorethread = pythonapi.PyEval_RestoreThread
|
| 72 |
+
restorethread.argtypes = [c_void_p]
|
| 73 |
+
restorethread.restype = None
|
| 74 |
+
|
| 75 |
+
if is_windows:
|
| 76 |
+
# A function with the stdcall calling convention
|
| 77 |
+
c_sleep = windll.kernel32.Sleep
|
| 78 |
+
c_sleep.argtypes = [c_uint]
|
| 79 |
+
c_sleep.restype = None
|
| 80 |
+
|
| 81 |
+
def use_c_sleep(x):
|
| 82 |
+
c_sleep(x)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def use_c_pointer(x):
|
| 86 |
+
"""
|
| 87 |
+
Running in Python will cause a segfault.
|
| 88 |
+
"""
|
| 89 |
+
threadstate = savethread()
|
| 90 |
+
x += 1
|
| 91 |
+
restorethread(threadstate)
|
| 92 |
+
return x
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def use_func_pointer(fa, fb, x):
|
| 96 |
+
if x > 0:
|
| 97 |
+
return fa(x)
|
| 98 |
+
else:
|
| 99 |
+
return fb(x)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
mydct = {'what': 1232121}
|
| 103 |
+
|
| 104 |
+
def call_me_maybe(arr):
|
| 105 |
+
return mydct[arr[0].decode('ascii')]
|
| 106 |
+
|
| 107 |
+
# Create a callback into the python interpreter
|
| 108 |
+
py_call_back = CFUNCTYPE(c_int, py_object)(call_me_maybe)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def take_array_ptr(ptr):
|
| 112 |
+
return ptr
|
| 113 |
+
|
| 114 |
+
c_take_array_ptr = CFUNCTYPE(c_void_p, c_void_p)(take_array_ptr)
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from os.path import dirname
|
| 2 |
+
import unittest
|
| 3 |
+
from unittest.suite import TestSuite
|
| 4 |
+
|
| 5 |
+
from numba.testing import load_testsuite
|
| 6 |
+
|
| 7 |
+
def load_tests(loader, tests, pattern):
|
| 8 |
+
suite = TestSuite()
|
| 9 |
+
suite.addTests(load_testsuite(loader, dirname(__file__)))
|
| 10 |
+
return suite
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_examples.py
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import sys
|
| 5 |
+
import unittest
|
| 6 |
+
|
| 7 |
+
from numba.tests.support import TestCase, captured_stdout
|
| 8 |
+
from numba.core.config import IS_WIN32
|
| 9 |
+
from numba.np.numpy_support import numpy_version
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
class MatplotlibBlocker:
|
| 13 |
+
'''Blocks the import of matplotlib, so that doc examples that attempt to
|
| 14 |
+
plot the output don't result in plots popping up and blocking testing.'''
|
| 15 |
+
|
| 16 |
+
def find_spec(self, fullname, path, target=None):
|
| 17 |
+
if fullname == 'matplotlib':
|
| 18 |
+
msg = 'Blocked import of matplotlib for test suite run'
|
| 19 |
+
raise ImportError(msg)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class DocsExamplesTest(TestCase):
|
| 23 |
+
|
| 24 |
+
def __init__(self, *args, **kwargs):
|
| 25 |
+
super().__init__(*args, **kwargs)
|
| 26 |
+
self._mpl_blocker = MatplotlibBlocker()
|
| 27 |
+
|
| 28 |
+
def setUp(self):
|
| 29 |
+
sys.meta_path.insert(0, self._mpl_blocker)
|
| 30 |
+
|
| 31 |
+
def tearDown(self):
|
| 32 |
+
sys.meta_path.remove(self._mpl_blocker)
|
| 33 |
+
|
| 34 |
+
def test_mandelbrot(self):
|
| 35 |
+
with captured_stdout():
|
| 36 |
+
# magictoken.ex_mandelbrot.begin
|
| 37 |
+
from timeit import default_timer as timer
|
| 38 |
+
try:
|
| 39 |
+
from matplotlib.pylab import imshow, show
|
| 40 |
+
have_mpl = True
|
| 41 |
+
except ImportError:
|
| 42 |
+
have_mpl = False
|
| 43 |
+
import numpy as np
|
| 44 |
+
from numba import jit
|
| 45 |
+
|
| 46 |
+
@jit(nopython=True)
|
| 47 |
+
def mandel(x, y, max_iters):
|
| 48 |
+
"""
|
| 49 |
+
Given the real and imaginary parts of a complex number,
|
| 50 |
+
determine if it is a candidate for membership in the Mandelbrot
|
| 51 |
+
set given a fixed number of iterations.
|
| 52 |
+
"""
|
| 53 |
+
i = 0
|
| 54 |
+
c = complex(x,y)
|
| 55 |
+
z = 0.0j
|
| 56 |
+
for i in range(max_iters):
|
| 57 |
+
z = z * z + c
|
| 58 |
+
if (z.real * z.real + z.imag * z.imag) >= 4:
|
| 59 |
+
return i
|
| 60 |
+
|
| 61 |
+
return 255
|
| 62 |
+
|
| 63 |
+
@jit(nopython=True)
|
| 64 |
+
def create_fractal(min_x, max_x, min_y, max_y, image, iters):
|
| 65 |
+
height = image.shape[0]
|
| 66 |
+
width = image.shape[1]
|
| 67 |
+
|
| 68 |
+
pixel_size_x = (max_x - min_x) / width
|
| 69 |
+
pixel_size_y = (max_y - min_y) / height
|
| 70 |
+
for x in range(width):
|
| 71 |
+
real = min_x + x * pixel_size_x
|
| 72 |
+
for y in range(height):
|
| 73 |
+
imag = min_y + y * pixel_size_y
|
| 74 |
+
color = mandel(real, imag, iters)
|
| 75 |
+
image[y, x] = color
|
| 76 |
+
|
| 77 |
+
return image
|
| 78 |
+
|
| 79 |
+
image = np.zeros((500 * 2, 750 * 2), dtype=np.uint8)
|
| 80 |
+
s = timer()
|
| 81 |
+
create_fractal(-2.0, 1.0, -1.0, 1.0, image, 20)
|
| 82 |
+
e = timer()
|
| 83 |
+
print(e - s)
|
| 84 |
+
if have_mpl:
|
| 85 |
+
imshow(image)
|
| 86 |
+
show()
|
| 87 |
+
# magictoken.ex_mandelbrot.end
|
| 88 |
+
|
| 89 |
+
def test_moving_average(self):
|
| 90 |
+
with captured_stdout():
|
| 91 |
+
# magictoken.ex_moving_average.begin
|
| 92 |
+
import numpy as np
|
| 93 |
+
|
| 94 |
+
from numba import guvectorize
|
| 95 |
+
|
| 96 |
+
@guvectorize(['void(float64[:], intp[:], float64[:])'],
|
| 97 |
+
'(n),()->(n)')
|
| 98 |
+
def move_mean(a, window_arr, out):
|
| 99 |
+
window_width = window_arr[0]
|
| 100 |
+
asum = 0.0
|
| 101 |
+
count = 0
|
| 102 |
+
for i in range(window_width):
|
| 103 |
+
asum += a[i]
|
| 104 |
+
count += 1
|
| 105 |
+
out[i] = asum / count
|
| 106 |
+
for i in range(window_width, len(a)):
|
| 107 |
+
asum += a[i] - a[i - window_width]
|
| 108 |
+
out[i] = asum / count
|
| 109 |
+
|
| 110 |
+
arr = np.arange(20, dtype=np.float64).reshape(2, 10)
|
| 111 |
+
print(arr)
|
| 112 |
+
print(move_mean(arr, 3))
|
| 113 |
+
# magictoken.ex_moving_average.end
|
| 114 |
+
|
| 115 |
+
def test_nogil(self):
|
| 116 |
+
with captured_stdout():
|
| 117 |
+
# magictoken.ex_no_gil.begin
|
| 118 |
+
import math
|
| 119 |
+
import threading
|
| 120 |
+
from timeit import repeat
|
| 121 |
+
|
| 122 |
+
import numpy as np
|
| 123 |
+
from numba import jit
|
| 124 |
+
|
| 125 |
+
nthreads = 4
|
| 126 |
+
size = 10**6
|
| 127 |
+
|
| 128 |
+
def func_np(a, b):
|
| 129 |
+
"""
|
| 130 |
+
Control function using Numpy.
|
| 131 |
+
"""
|
| 132 |
+
return np.exp(2.1 * a + 3.2 * b)
|
| 133 |
+
|
| 134 |
+
@jit('void(double[:], double[:], double[:])', nopython=True,
|
| 135 |
+
nogil=True)
|
| 136 |
+
def inner_func_nb(result, a, b):
|
| 137 |
+
"""
|
| 138 |
+
Function under test.
|
| 139 |
+
"""
|
| 140 |
+
for i in range(len(result)):
|
| 141 |
+
result[i] = math.exp(2.1 * a[i] + 3.2 * b[i])
|
| 142 |
+
|
| 143 |
+
def timefunc(correct, s, func, *args, **kwargs):
|
| 144 |
+
"""
|
| 145 |
+
Benchmark *func* and print out its runtime.
|
| 146 |
+
"""
|
| 147 |
+
print(s.ljust(20), end=" ")
|
| 148 |
+
# Make sure the function is compiled before the benchmark is
|
| 149 |
+
# started
|
| 150 |
+
res = func(*args, **kwargs)
|
| 151 |
+
if correct is not None:
|
| 152 |
+
assert np.allclose(res, correct), (res, correct)
|
| 153 |
+
# time it
|
| 154 |
+
print('{:>5.0f} ms'.format(min(repeat(
|
| 155 |
+
lambda: func(*args, **kwargs), number=5, repeat=2)) * 1000))
|
| 156 |
+
return res
|
| 157 |
+
|
| 158 |
+
def make_singlethread(inner_func):
|
| 159 |
+
"""
|
| 160 |
+
Run the given function inside a single thread.
|
| 161 |
+
"""
|
| 162 |
+
def func(*args):
|
| 163 |
+
length = len(args[0])
|
| 164 |
+
result = np.empty(length, dtype=np.float64)
|
| 165 |
+
inner_func(result, *args)
|
| 166 |
+
return result
|
| 167 |
+
return func
|
| 168 |
+
|
| 169 |
+
def make_multithread(inner_func, numthreads):
|
| 170 |
+
"""
|
| 171 |
+
Run the given function inside *numthreads* threads, splitting
|
| 172 |
+
its arguments into equal-sized chunks.
|
| 173 |
+
"""
|
| 174 |
+
def func_mt(*args):
|
| 175 |
+
length = len(args[0])
|
| 176 |
+
result = np.empty(length, dtype=np.float64)
|
| 177 |
+
args = (result,) + args
|
| 178 |
+
chunklen = (length + numthreads - 1) // numthreads
|
| 179 |
+
# Create argument tuples for each input chunk
|
| 180 |
+
chunks = [[arg[i * chunklen:(i + 1) * chunklen] for arg in
|
| 181 |
+
args] for i in range(numthreads)]
|
| 182 |
+
# Spawn one thread per chunk
|
| 183 |
+
threads = [threading.Thread(target=inner_func, args=chunk)
|
| 184 |
+
for chunk in chunks]
|
| 185 |
+
for thread in threads:
|
| 186 |
+
thread.start()
|
| 187 |
+
for thread in threads:
|
| 188 |
+
thread.join()
|
| 189 |
+
return result
|
| 190 |
+
return func_mt
|
| 191 |
+
|
| 192 |
+
func_nb = make_singlethread(inner_func_nb)
|
| 193 |
+
func_nb_mt = make_multithread(inner_func_nb, nthreads)
|
| 194 |
+
|
| 195 |
+
a = np.random.rand(size)
|
| 196 |
+
b = np.random.rand(size)
|
| 197 |
+
|
| 198 |
+
correct = timefunc(None, "numpy (1 thread)", func_np, a, b)
|
| 199 |
+
timefunc(correct, "numba (1 thread)", func_nb, a, b)
|
| 200 |
+
timefunc(correct, "numba (%d threads)" % nthreads, func_nb_mt, a, b)
|
| 201 |
+
# magictoken.ex_no_gil.end
|
| 202 |
+
|
| 203 |
+
def test_vectorize_one_signature(self):
|
| 204 |
+
with captured_stdout():
|
| 205 |
+
# magictoken.ex_vectorize_one_signature.begin
|
| 206 |
+
from numba import vectorize, float64
|
| 207 |
+
|
| 208 |
+
@vectorize([float64(float64, float64)])
|
| 209 |
+
def f(x, y):
|
| 210 |
+
return x + y
|
| 211 |
+
# magictoken.ex_vectorize_one_signature.end
|
| 212 |
+
|
| 213 |
+
def test_vectorize_multiple_signatures(self):
|
| 214 |
+
with captured_stdout():
|
| 215 |
+
# magictoken.ex_vectorize_multiple_signatures.begin
|
| 216 |
+
from numba import vectorize, int32, int64, float32, float64
|
| 217 |
+
import numpy as np
|
| 218 |
+
|
| 219 |
+
@vectorize([int32(int32, int32),
|
| 220 |
+
int64(int64, int64),
|
| 221 |
+
float32(float32, float32),
|
| 222 |
+
float64(float64, float64)])
|
| 223 |
+
def f(x, y):
|
| 224 |
+
return x + y
|
| 225 |
+
# magictoken.ex_vectorize_multiple_signatures.end
|
| 226 |
+
|
| 227 |
+
# magictoken.ex_vectorize_return_call_one.begin
|
| 228 |
+
a = np.arange(6)
|
| 229 |
+
result = f(a, a)
|
| 230 |
+
# result == array([ 0, 2, 4, 6, 8, 10])
|
| 231 |
+
# magictoken.ex_vectorize_return_call_one.end
|
| 232 |
+
|
| 233 |
+
self.assertIsInstance(result, np.ndarray)
|
| 234 |
+
correct = np.array([0, 2, 4, 6, 8, 10])
|
| 235 |
+
np.testing.assert_array_equal(result, correct)
|
| 236 |
+
|
| 237 |
+
# magictoken.ex_vectorize_return_call_two.begin
|
| 238 |
+
a = np.linspace(0, 1, 6)
|
| 239 |
+
result = f(a, a)
|
| 240 |
+
# Now, result == array([0. , 0.4, 0.8, 1.2, 1.6, 2. ])
|
| 241 |
+
# magictoken.ex_vectorize_return_call_two.end
|
| 242 |
+
|
| 243 |
+
self.assertIsInstance(result, np.ndarray)
|
| 244 |
+
correct = np.array([0., 0.4, 0.8, 1.2, 1.6, 2. ])
|
| 245 |
+
np.testing.assert_allclose(result, correct)
|
| 246 |
+
|
| 247 |
+
# magictoken.ex_vectorize_return_call_three.begin
|
| 248 |
+
a = np.arange(12).reshape(3, 4)
|
| 249 |
+
# a == array([[ 0, 1, 2, 3],
|
| 250 |
+
# [ 4, 5, 6, 7],
|
| 251 |
+
# [ 8, 9, 10, 11]])
|
| 252 |
+
|
| 253 |
+
result1 = f.reduce(a, axis=0)
|
| 254 |
+
# result1 == array([12, 15, 18, 21])
|
| 255 |
+
|
| 256 |
+
result2 = f.reduce(a, axis=1)
|
| 257 |
+
# result2 == array([ 6, 22, 38])
|
| 258 |
+
|
| 259 |
+
result3 = f.accumulate(a)
|
| 260 |
+
# result3 == array([[ 0, 1, 2, 3],
|
| 261 |
+
# [ 4, 6, 8, 10],
|
| 262 |
+
# [12, 15, 18, 21]])
|
| 263 |
+
|
| 264 |
+
result4 = f.accumulate(a, axis=1)
|
| 265 |
+
# result3 == array([[ 0, 1, 3, 6],
|
| 266 |
+
# [ 4, 9, 15, 22],
|
| 267 |
+
# [ 8, 17, 27, 38]])
|
| 268 |
+
# magictoken.ex_vectorize_return_call_three.end
|
| 269 |
+
|
| 270 |
+
self.assertIsInstance(result1, np.ndarray)
|
| 271 |
+
correct = np.array([12, 15, 18, 21])
|
| 272 |
+
np.testing.assert_array_equal(result1, correct)
|
| 273 |
+
|
| 274 |
+
self.assertIsInstance(result2, np.ndarray)
|
| 275 |
+
correct = np.array([6, 22, 38])
|
| 276 |
+
np.testing.assert_array_equal(result2, correct)
|
| 277 |
+
|
| 278 |
+
self.assertIsInstance(result3, np.ndarray)
|
| 279 |
+
correct = np.array([
|
| 280 |
+
[0, 1, 2, 3],
|
| 281 |
+
[4, 6, 8, 10],
|
| 282 |
+
[12, 15, 18, 21]
|
| 283 |
+
])
|
| 284 |
+
np.testing.assert_array_equal(result3, correct)
|
| 285 |
+
|
| 286 |
+
self.assertIsInstance(result4, np.ndarray)
|
| 287 |
+
correct = np.array([
|
| 288 |
+
[0, 1, 3, 6],
|
| 289 |
+
[4, 9, 15, 22],
|
| 290 |
+
[8, 17, 27, 38]
|
| 291 |
+
])
|
| 292 |
+
np.testing.assert_array_equal(result4, correct)
|
| 293 |
+
|
| 294 |
+
def test_guvectorize(self):
|
| 295 |
+
with captured_stdout():
|
| 296 |
+
# magictoken.ex_guvectorize.begin
|
| 297 |
+
from numba import guvectorize, int64
|
| 298 |
+
import numpy as np
|
| 299 |
+
|
| 300 |
+
@guvectorize([(int64[:], int64, int64[:])], '(n),()->(n)')
|
| 301 |
+
def g(x, y, res):
|
| 302 |
+
for i in range(x.shape[0]):
|
| 303 |
+
res[i] = x[i] + y
|
| 304 |
+
# magictoken.ex_guvectorize.end
|
| 305 |
+
|
| 306 |
+
# magictoken.ex_guvectorize_call_one.begin
|
| 307 |
+
a = np.arange(5)
|
| 308 |
+
result = g(a, 2)
|
| 309 |
+
# result == array([2, 3, 4, 5, 6])
|
| 310 |
+
# magictoken.ex_guvectorize_call_one.end
|
| 311 |
+
|
| 312 |
+
self.assertIsInstance(result, np.ndarray)
|
| 313 |
+
correct = np.array([2, 3, 4, 5, 6])
|
| 314 |
+
np.testing.assert_array_equal(result, correct)
|
| 315 |
+
|
| 316 |
+
# magictoken.ex_guvectorize_call_two.begin
|
| 317 |
+
a = np.arange(6).reshape(2, 3)
|
| 318 |
+
# a == array([[0, 1, 2],
|
| 319 |
+
# [3, 4, 5]])
|
| 320 |
+
|
| 321 |
+
result1 = g(a, 10)
|
| 322 |
+
# result1 == array([[10, 11, 12],
|
| 323 |
+
# [13, 14, 15]])
|
| 324 |
+
|
| 325 |
+
result2 = g(a, np.array([10, 20]))
|
| 326 |
+
g(a, np.array([10, 20]))
|
| 327 |
+
# result2 == array([[10, 11, 12],
|
| 328 |
+
# [23, 24, 25]])
|
| 329 |
+
# magictoken.ex_guvectorize_call_two.end
|
| 330 |
+
|
| 331 |
+
self.assertIsInstance(result1, np.ndarray)
|
| 332 |
+
correct = np.array([[10, 11, 12], [13, 14, 15]])
|
| 333 |
+
np.testing.assert_array_equal(result1, correct)
|
| 334 |
+
|
| 335 |
+
self.assertIsInstance(result2, np.ndarray)
|
| 336 |
+
correct = np.array([[10, 11, 12], [23, 24, 25]])
|
| 337 |
+
np.testing.assert_array_equal(result2, correct)
|
| 338 |
+
|
| 339 |
+
def test_guvectorize_scalar_return(self):
|
| 340 |
+
with captured_stdout():
|
| 341 |
+
# magictoken.ex_guvectorize_scalar_return.begin
|
| 342 |
+
from numba import guvectorize, int64
|
| 343 |
+
import numpy as np
|
| 344 |
+
|
| 345 |
+
@guvectorize([(int64[:], int64, int64[:])], '(n),()->()')
|
| 346 |
+
def g(x, y, res):
|
| 347 |
+
acc = 0
|
| 348 |
+
for i in range(x.shape[0]):
|
| 349 |
+
acc += x[i] + y
|
| 350 |
+
res[0] = acc
|
| 351 |
+
# magictoken.ex_guvectorize_scalar_return.end
|
| 352 |
+
|
| 353 |
+
# magictoken.ex_guvectorize_scalar_return_call.begin
|
| 354 |
+
a = np.arange(5)
|
| 355 |
+
result = g(a, 2)
|
| 356 |
+
# At this point, result == 20.
|
| 357 |
+
# magictoken.ex_guvectorize_scalar_return_call.end
|
| 358 |
+
|
| 359 |
+
self.assertIsInstance(result, np.integer)
|
| 360 |
+
self.assertEqual(result, 20)
|
| 361 |
+
|
| 362 |
+
def test_guvectorize_jit(self):
|
| 363 |
+
with captured_stdout():
|
| 364 |
+
# magictoken.gufunc_jit.begin
|
| 365 |
+
import numpy as np
|
| 366 |
+
|
| 367 |
+
from numba import jit, guvectorize
|
| 368 |
+
|
| 369 |
+
@guvectorize('(n)->(n)')
|
| 370 |
+
def copy(x, res):
|
| 371 |
+
for i in range(x.shape[0]):
|
| 372 |
+
res[i] = x[i]
|
| 373 |
+
|
| 374 |
+
@jit(nopython=True)
|
| 375 |
+
def jit_fn(x, res):
|
| 376 |
+
copy(x, res)
|
| 377 |
+
# magictoken.gufunc_jit.end
|
| 378 |
+
|
| 379 |
+
# magictoken.gufunc_jit_call.begin
|
| 380 |
+
x = np.arange(5, dtype='i4')
|
| 381 |
+
res = np.zeros_like(x)
|
| 382 |
+
jit_fn(x, res)
|
| 383 |
+
# At this point, res == np.array([0, 1, 2, 3, 4], 'i4').
|
| 384 |
+
# magictoken.gufunc_jit_call.end
|
| 385 |
+
self.assertPreciseEqual(x, res)
|
| 386 |
+
|
| 387 |
+
def test_guvectorize_jit_fail(self):
|
| 388 |
+
with captured_stdout():
|
| 389 |
+
# magictoken.gufunc_jit_fail.begin
|
| 390 |
+
import numpy as np
|
| 391 |
+
from numba import jit, guvectorize
|
| 392 |
+
|
| 393 |
+
@guvectorize('(n)->(n)')
|
| 394 |
+
def copy(x, res):
|
| 395 |
+
for i in range(x.shape[0]):
|
| 396 |
+
res[i] = x[i]
|
| 397 |
+
|
| 398 |
+
@jit(nopython=True)
|
| 399 |
+
def jit_fn(x, res):
|
| 400 |
+
copy(x, res)
|
| 401 |
+
|
| 402 |
+
x = np.ones((1, 5))
|
| 403 |
+
res = np.empty((5,))
|
| 404 |
+
with self.assertRaises(ValueError) as raises:
|
| 405 |
+
jit_fn(x, res)
|
| 406 |
+
# magictoken.gufunc_jit_fail.end
|
| 407 |
+
self.assertIn('Loop and array shapes are incompatible',
|
| 408 |
+
str(raises.exception))
|
| 409 |
+
|
| 410 |
+
def test_guvectorize_overwrite(self):
|
| 411 |
+
with captured_stdout():
|
| 412 |
+
# magictoken.ex_guvectorize_overwrite.begin
|
| 413 |
+
from numba import guvectorize, float64
|
| 414 |
+
import numpy as np
|
| 415 |
+
|
| 416 |
+
@guvectorize([(float64[:], float64[:])], '()->()')
|
| 417 |
+
def init_values(invals, outvals):
|
| 418 |
+
invals[0] = 6.5
|
| 419 |
+
outvals[0] = 4.2
|
| 420 |
+
# magictoken.ex_guvectorize_overwrite.end
|
| 421 |
+
|
| 422 |
+
# magictoken.ex_guvectorize_overwrite_call_one.begin
|
| 423 |
+
invals = np.zeros(shape=(3, 3), dtype=np.float64)
|
| 424 |
+
# invals == array([[6.5, 6.5, 6.5],
|
| 425 |
+
# [6.5, 6.5, 6.5],
|
| 426 |
+
# [6.5, 6.5, 6.5]])
|
| 427 |
+
|
| 428 |
+
outvals = init_values(invals)
|
| 429 |
+
# outvals == array([[4.2, 4.2, 4.2],
|
| 430 |
+
# [4.2, 4.2, 4.2],
|
| 431 |
+
# [4.2, 4.2, 4.2]])
|
| 432 |
+
# magictoken.ex_guvectorize_overwrite_call_one.end
|
| 433 |
+
|
| 434 |
+
self.assertIsInstance(invals, np.ndarray)
|
| 435 |
+
correct = np.array([
|
| 436 |
+
[6.5, 6.5, 6.5],
|
| 437 |
+
[6.5, 6.5, 6.5],
|
| 438 |
+
[6.5, 6.5, 6.5]])
|
| 439 |
+
np.testing.assert_array_equal(invals, correct)
|
| 440 |
+
|
| 441 |
+
self.assertIsInstance(outvals, np.ndarray)
|
| 442 |
+
correct = np.array([
|
| 443 |
+
[4.2, 4.2, 4.2],
|
| 444 |
+
[4.2, 4.2, 4.2],
|
| 445 |
+
[4.2, 4.2, 4.2]])
|
| 446 |
+
np.testing.assert_array_equal(outvals, correct)
|
| 447 |
+
|
| 448 |
+
# magictoken.ex_guvectorize_overwrite_call_two.begin
|
| 449 |
+
invals = np.zeros(shape=(3, 3), dtype=np.float32)
|
| 450 |
+
# invals == array([[0., 0., 0.],
|
| 451 |
+
# [0., 0., 0.],
|
| 452 |
+
# [0., 0., 0.]], dtype=float32)
|
| 453 |
+
outvals = init_values(invals)
|
| 454 |
+
# outvals == array([[4.2, 4.2, 4.2],
|
| 455 |
+
# [4.2, 4.2, 4.2],
|
| 456 |
+
# [4.2, 4.2, 4.2]])
|
| 457 |
+
print(invals)
|
| 458 |
+
# invals == array([[0., 0., 0.],
|
| 459 |
+
# [0., 0., 0.],
|
| 460 |
+
# [0., 0., 0.]], dtype=float32)
|
| 461 |
+
# magictoken.ex_guvectorize_overwrite_call_two.end
|
| 462 |
+
|
| 463 |
+
self.assertIsInstance(invals, np.ndarray)
|
| 464 |
+
correct = np.array([
|
| 465 |
+
[0., 0., 0.],
|
| 466 |
+
[0., 0., 0.],
|
| 467 |
+
[0., 0., 0.]], dtype=np.float32)
|
| 468 |
+
np.testing.assert_array_equal(invals, correct)
|
| 469 |
+
|
| 470 |
+
self.assertIsInstance(outvals, np.ndarray)
|
| 471 |
+
correct = np.array([
|
| 472 |
+
[4.2, 4.2, 4.2],
|
| 473 |
+
[4.2, 4.2, 4.2],
|
| 474 |
+
[4.2, 4.2, 4.2]])
|
| 475 |
+
np.testing.assert_array_equal(outvals, correct)
|
| 476 |
+
|
| 477 |
+
# magictoken.ex_guvectorize_overwrite_call_three.begin
|
| 478 |
+
@guvectorize(
|
| 479 |
+
[(float64[:], float64[:])],
|
| 480 |
+
'()->()',
|
| 481 |
+
writable_args=('invals',)
|
| 482 |
+
)
|
| 483 |
+
def init_values(invals, outvals):
|
| 484 |
+
invals[0] = 6.5
|
| 485 |
+
outvals[0] = 4.2
|
| 486 |
+
|
| 487 |
+
invals = np.zeros(shape=(3, 3), dtype=np.float32)
|
| 488 |
+
# invals == array([[0., 0., 0.],
|
| 489 |
+
# [0., 0., 0.],
|
| 490 |
+
# [0., 0., 0.]], dtype=float32)
|
| 491 |
+
outvals = init_values(invals)
|
| 492 |
+
# outvals == array([[4.2, 4.2, 4.2],
|
| 493 |
+
# [4.2, 4.2, 4.2],
|
| 494 |
+
# [4.2, 4.2, 4.2]])
|
| 495 |
+
print(invals)
|
| 496 |
+
# invals == array([[6.5, 6.5, 6.5],
|
| 497 |
+
# [6.5, 6.5, 6.5],
|
| 498 |
+
# [6.5, 6.5, 6.5]], dtype=float32)
|
| 499 |
+
# magictoken.ex_guvectorize_overwrite_call_three.end
|
| 500 |
+
|
| 501 |
+
self.assertIsInstance(invals, np.ndarray)
|
| 502 |
+
correct = np.array([
|
| 503 |
+
[6.5, 6.5, 6.5],
|
| 504 |
+
[6.5, 6.5, 6.5],
|
| 505 |
+
[6.5, 6.5, 6.5]])
|
| 506 |
+
np.testing.assert_array_equal(invals, correct)
|
| 507 |
+
|
| 508 |
+
self.assertIsInstance(outvals, np.ndarray)
|
| 509 |
+
correct = np.array([
|
| 510 |
+
[4.2, 4.2, 4.2],
|
| 511 |
+
[4.2, 4.2, 4.2],
|
| 512 |
+
[4.2, 4.2, 4.2]])
|
| 513 |
+
np.testing.assert_array_equal(outvals, correct)
|
| 514 |
+
|
| 515 |
+
def test_vectorize_dynamic(self):
|
| 516 |
+
with captured_stdout():
|
| 517 |
+
# magictoken.ex_vectorize_dynamic.begin
|
| 518 |
+
from numba import vectorize
|
| 519 |
+
|
| 520 |
+
@vectorize
|
| 521 |
+
def f(x, y):
|
| 522 |
+
return x * y
|
| 523 |
+
# magictoken.ex_vectorize_dynamic.end
|
| 524 |
+
|
| 525 |
+
# magictoken.ex_vectorize_dynamic_call_one.begin
|
| 526 |
+
result = f(3,4)
|
| 527 |
+
# result == 12
|
| 528 |
+
|
| 529 |
+
print(f.types)
|
| 530 |
+
# ['ll->l']
|
| 531 |
+
# magictoken.ex_vectorize_dynamic_call_one.end
|
| 532 |
+
|
| 533 |
+
self.assertEqual(result, 12)
|
| 534 |
+
if IS_WIN32:
|
| 535 |
+
if numpy_version < (2, 0):
|
| 536 |
+
correct = ['ll->q']
|
| 537 |
+
else:
|
| 538 |
+
correct = ['qq->q']
|
| 539 |
+
else:
|
| 540 |
+
correct = ['ll->l']
|
| 541 |
+
self.assertEqual(f.types, correct)
|
| 542 |
+
|
| 543 |
+
# magictoken.ex_vectorize_dynamic_call_two.begin
|
| 544 |
+
result = f(1.,2.)
|
| 545 |
+
# result == 2.0
|
| 546 |
+
|
| 547 |
+
print(f.types)
|
| 548 |
+
# ['ll->l', 'dd->d']
|
| 549 |
+
# magictoken.ex_vectorize_dynamic_call_two.end
|
| 550 |
+
|
| 551 |
+
self.assertEqual(result, 2.0)
|
| 552 |
+
if IS_WIN32:
|
| 553 |
+
if numpy_version < (2, 0):
|
| 554 |
+
correct = ['ll->q', 'dd->d']
|
| 555 |
+
else:
|
| 556 |
+
correct = ['qq->q', 'dd->d']
|
| 557 |
+
else:
|
| 558 |
+
correct = ['ll->l', 'dd->d']
|
| 559 |
+
self.assertEqual(f.types, correct)
|
| 560 |
+
|
| 561 |
+
# magictoken.ex_vectorize_dynamic_call_three.begin
|
| 562 |
+
result = f(1,2.)
|
| 563 |
+
# result == 2.0
|
| 564 |
+
|
| 565 |
+
print(f.types)
|
| 566 |
+
# ['ll->l', 'dd->d']
|
| 567 |
+
# magictoken.ex_vectorize_dynamic_call_three.end
|
| 568 |
+
|
| 569 |
+
self.assertEqual(result, 2.0)
|
| 570 |
+
if IS_WIN32:
|
| 571 |
+
if numpy_version < (2, 0):
|
| 572 |
+
correct = ['ll->q', 'dd->d']
|
| 573 |
+
else:
|
| 574 |
+
correct = ['qq->q', 'dd->d']
|
| 575 |
+
else:
|
| 576 |
+
correct = ['ll->l', 'dd->d']
|
| 577 |
+
self.assertEqual(f.types, correct)
|
| 578 |
+
|
| 579 |
+
# magictoken.ex_vectorize_dynamic_call_four.begin
|
| 580 |
+
@vectorize
|
| 581 |
+
def g(a, b):
|
| 582 |
+
return a / b
|
| 583 |
+
|
| 584 |
+
print(g(2.,3.))
|
| 585 |
+
# 0.66666666666666663
|
| 586 |
+
|
| 587 |
+
print(g(2,3))
|
| 588 |
+
# 0.66666666666666663
|
| 589 |
+
|
| 590 |
+
print(g.types)
|
| 591 |
+
# ['dd->d']
|
| 592 |
+
# magictoken.ex_vectorize_dynamic_call_four.end
|
| 593 |
+
|
| 594 |
+
correct = ['dd->d']
|
| 595 |
+
self.assertEqual(g.types, correct)
|
| 596 |
+
|
| 597 |
+
def test_guvectorize_dynamic(self):
|
| 598 |
+
with captured_stdout():
|
| 599 |
+
# magictoken.ex_guvectorize_dynamic.begin
|
| 600 |
+
from numba import guvectorize
|
| 601 |
+
import numpy as np
|
| 602 |
+
|
| 603 |
+
@guvectorize('(n),()->(n)')
|
| 604 |
+
def g(x, y, res):
|
| 605 |
+
for i in range(x.shape[0]):
|
| 606 |
+
res[i] = x[i] + y
|
| 607 |
+
# magictoken.ex_guvectorize_dynamic.end
|
| 608 |
+
|
| 609 |
+
# magictoken.ex_guvectorize_dynamic_call_one.begin
|
| 610 |
+
x = np.arange(5, dtype=np.int64)
|
| 611 |
+
y = 10
|
| 612 |
+
res = np.zeros_like(x)
|
| 613 |
+
g(x, y, res)
|
| 614 |
+
# res == array([10, 11, 12, 13, 14])
|
| 615 |
+
print(g.types)
|
| 616 |
+
# ['ll->l']
|
| 617 |
+
# magictoken.ex_guvectorize_dynamic_call_one.end
|
| 618 |
+
|
| 619 |
+
correct = np.array([10, 11, 12, 13, 14])
|
| 620 |
+
np.testing.assert_array_equal(res, correct)
|
| 621 |
+
if IS_WIN32:
|
| 622 |
+
correct = ['qq->q']
|
| 623 |
+
else:
|
| 624 |
+
correct = ['ll->l']
|
| 625 |
+
self.assertEqual(g.types, correct)
|
| 626 |
+
|
| 627 |
+
# magictoken.ex_guvectorize_dynamic_call_two.begin
|
| 628 |
+
x = np.arange(5, dtype=np.double)
|
| 629 |
+
y = 2.2
|
| 630 |
+
res = np.zeros_like(x)
|
| 631 |
+
g(x, y, res)
|
| 632 |
+
# res == array([2.2, 3.2, 4.2, 5.2, 6.2])
|
| 633 |
+
# magictoken.ex_guvectorize_dynamic_call_two.end
|
| 634 |
+
|
| 635 |
+
# magictoken.ex_guvectorize_dynamic_call_three.begin
|
| 636 |
+
print(g.types) # shorthand for g.ufunc.types
|
| 637 |
+
# ['ll->l', 'dd->d']
|
| 638 |
+
# magictoken.ex_guvectorize_dynamic_call_three.end
|
| 639 |
+
|
| 640 |
+
if IS_WIN32:
|
| 641 |
+
correct = ['qq->q', 'dd->d']
|
| 642 |
+
else:
|
| 643 |
+
correct = ['ll->l', 'dd->d']
|
| 644 |
+
self.assertEqual(g.types, correct)
|
| 645 |
+
|
| 646 |
+
# magictoken.ex_guvectorize_dynamic_call_four.begin
|
| 647 |
+
x = np.arange(5, dtype=np.int64)
|
| 648 |
+
y = 2
|
| 649 |
+
res = np.zeros_like(x)
|
| 650 |
+
g(x, y, res)
|
| 651 |
+
print(res)
|
| 652 |
+
# res == array([2, 3, 4, 5, 6])
|
| 653 |
+
# magictoken.ex_guvectorize_dynamic_call_four.end
|
| 654 |
+
|
| 655 |
+
correct = np.array([2, 3, 4, 5, 6])
|
| 656 |
+
np.testing.assert_array_equal(res, correct)
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
if __name__ == '__main__':
|
| 660 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_interval_example.py
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This test is used by `docs/source/extending/interval-example.rst`.
|
| 3 |
+
|
| 4 |
+
The "magictoken" comments are used as markers for the beginning and ending of
|
| 5 |
+
example code.
|
| 6 |
+
"""
|
| 7 |
+
import unittest
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class IntervalExampleTest(unittest.TestCase):
|
| 11 |
+
|
| 12 |
+
def test_interval_class_usage(self):
|
| 13 |
+
# magictoken.interval_py_class.begin
|
| 14 |
+
class Interval(object):
|
| 15 |
+
"""
|
| 16 |
+
A half-open interval on the real number line.
|
| 17 |
+
"""
|
| 18 |
+
def __init__(self, lo, hi):
|
| 19 |
+
self.lo = lo
|
| 20 |
+
self.hi = hi
|
| 21 |
+
|
| 22 |
+
def __repr__(self):
|
| 23 |
+
return 'Interval(%f, %f)' % (self.lo, self.hi)
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def width(self):
|
| 27 |
+
return self.hi - self.lo
|
| 28 |
+
# magictoken.interval_py_class.end
|
| 29 |
+
|
| 30 |
+
# magictoken.interval_type_class.begin
|
| 31 |
+
from numba import types
|
| 32 |
+
|
| 33 |
+
class IntervalType(types.Type):
|
| 34 |
+
def __init__(self):
|
| 35 |
+
super(IntervalType, self).__init__(name='Interval')
|
| 36 |
+
|
| 37 |
+
interval_type = IntervalType()
|
| 38 |
+
# magictoken.interval_type_class.end
|
| 39 |
+
|
| 40 |
+
# magictoken.interval_typeof_register.begin
|
| 41 |
+
from numba.extending import typeof_impl
|
| 42 |
+
|
| 43 |
+
@typeof_impl.register(Interval)
|
| 44 |
+
def typeof_index(val, c):
|
| 45 |
+
return interval_type
|
| 46 |
+
# magictoken.interval_typeof_register.end
|
| 47 |
+
|
| 48 |
+
# magictoken.numba_type_register.begin
|
| 49 |
+
from numba.extending import as_numba_type
|
| 50 |
+
|
| 51 |
+
as_numba_type.register(Interval, interval_type)
|
| 52 |
+
# magictoken.numba_type_register.end
|
| 53 |
+
|
| 54 |
+
# magictoken.numba_type_callable.begin
|
| 55 |
+
from numba.extending import type_callable
|
| 56 |
+
|
| 57 |
+
@type_callable(Interval)
|
| 58 |
+
def type_interval(context):
|
| 59 |
+
def typer(lo, hi):
|
| 60 |
+
if isinstance(lo, types.Float) and isinstance(hi, types.Float):
|
| 61 |
+
return interval_type
|
| 62 |
+
return typer
|
| 63 |
+
# magictoken.numba_type_callable.end
|
| 64 |
+
|
| 65 |
+
# magictoken.interval_model.begin
|
| 66 |
+
from numba.extending import models, register_model
|
| 67 |
+
|
| 68 |
+
@register_model(IntervalType)
|
| 69 |
+
class IntervalModel(models.StructModel):
|
| 70 |
+
def __init__(self, dmm, fe_type):
|
| 71 |
+
members = [('lo', types.float64),
|
| 72 |
+
('hi', types.float64),]
|
| 73 |
+
models.StructModel.__init__(self, dmm, fe_type, members)
|
| 74 |
+
# magictoken.interval_model.end
|
| 75 |
+
|
| 76 |
+
# magictoken.interval_attribute_wrapper.begin
|
| 77 |
+
from numba.extending import make_attribute_wrapper
|
| 78 |
+
|
| 79 |
+
make_attribute_wrapper(IntervalType, 'lo', 'lo')
|
| 80 |
+
make_attribute_wrapper(IntervalType, 'hi', 'hi')
|
| 81 |
+
# magictoken.interval_attribute_wrapper.end
|
| 82 |
+
|
| 83 |
+
# magictoken.interval_overload_attribute.begin
|
| 84 |
+
from numba.extending import overload_attribute
|
| 85 |
+
|
| 86 |
+
@overload_attribute(IntervalType, "width")
|
| 87 |
+
def get_width(interval):
|
| 88 |
+
def getter(interval):
|
| 89 |
+
return interval.hi - interval.lo
|
| 90 |
+
return getter
|
| 91 |
+
# magictoken.interval_overload_attribute.end
|
| 92 |
+
|
| 93 |
+
# magictoken.interval_lower_builtin.begin
|
| 94 |
+
from numba.extending import lower_builtin
|
| 95 |
+
from numba.core import cgutils
|
| 96 |
+
|
| 97 |
+
@lower_builtin(Interval, types.Float, types.Float)
|
| 98 |
+
def impl_interval(context, builder, sig, args):
|
| 99 |
+
typ = sig.return_type
|
| 100 |
+
lo, hi = args
|
| 101 |
+
interval = cgutils.create_struct_proxy(typ)(context, builder)
|
| 102 |
+
interval.lo = lo
|
| 103 |
+
interval.hi = hi
|
| 104 |
+
return interval._getvalue()
|
| 105 |
+
# magictoken.interval_lower_builtin.end
|
| 106 |
+
|
| 107 |
+
# magictoken.interval_unbox.begin
|
| 108 |
+
from numba.extending import unbox, NativeValue
|
| 109 |
+
from contextlib import ExitStack
|
| 110 |
+
|
| 111 |
+
@unbox(IntervalType)
|
| 112 |
+
def unbox_interval(typ, obj, c):
|
| 113 |
+
"""
|
| 114 |
+
Convert a Interval object to a native interval structure.
|
| 115 |
+
"""
|
| 116 |
+
is_error_ptr = cgutils.alloca_once_value(c.builder, cgutils.false_bit)
|
| 117 |
+
interval = cgutils.create_struct_proxy(typ)(c.context, c.builder)
|
| 118 |
+
|
| 119 |
+
with ExitStack() as stack:
|
| 120 |
+
lo_obj = c.pyapi.object_getattr_string(obj, "lo")
|
| 121 |
+
with cgutils.early_exit_if_null(c.builder, stack, lo_obj):
|
| 122 |
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
| 123 |
+
lo_native = c.unbox(types.float64, lo_obj)
|
| 124 |
+
c.pyapi.decref(lo_obj)
|
| 125 |
+
with cgutils.early_exit_if(c.builder, stack, lo_native.is_error):
|
| 126 |
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
| 127 |
+
|
| 128 |
+
hi_obj = c.pyapi.object_getattr_string(obj, "hi")
|
| 129 |
+
with cgutils.early_exit_if_null(c.builder, stack, hi_obj):
|
| 130 |
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
| 131 |
+
hi_native = c.unbox(types.float64, hi_obj)
|
| 132 |
+
c.pyapi.decref(hi_obj)
|
| 133 |
+
with cgutils.early_exit_if(c.builder, stack, hi_native.is_error):
|
| 134 |
+
c.builder.store(cgutils.true_bit, is_error_ptr)
|
| 135 |
+
|
| 136 |
+
interval.lo = lo_native.value
|
| 137 |
+
interval.hi = hi_native.value
|
| 138 |
+
|
| 139 |
+
return NativeValue(interval._getvalue(), is_error=c.builder.load(is_error_ptr))
|
| 140 |
+
# magictoken.interval_unbox.end
|
| 141 |
+
|
| 142 |
+
# magictoken.interval_box.begin
|
| 143 |
+
from numba.extending import box
|
| 144 |
+
|
| 145 |
+
@box(IntervalType)
|
| 146 |
+
def box_interval(typ, val, c):
|
| 147 |
+
"""
|
| 148 |
+
Convert a native interval structure to an Interval object.
|
| 149 |
+
"""
|
| 150 |
+
ret_ptr = cgutils.alloca_once(c.builder, c.pyapi.pyobj)
|
| 151 |
+
fail_obj = c.pyapi.get_null_object()
|
| 152 |
+
|
| 153 |
+
with ExitStack() as stack:
|
| 154 |
+
interval = cgutils.create_struct_proxy(typ)(c.context, c.builder, value=val)
|
| 155 |
+
lo_obj = c.box(types.float64, interval.lo)
|
| 156 |
+
with cgutils.early_exit_if_null(c.builder, stack, lo_obj):
|
| 157 |
+
c.builder.store(fail_obj, ret_ptr)
|
| 158 |
+
|
| 159 |
+
hi_obj = c.box(types.float64, interval.hi)
|
| 160 |
+
with cgutils.early_exit_if_null(c.builder, stack, hi_obj):
|
| 161 |
+
c.pyapi.decref(lo_obj)
|
| 162 |
+
c.builder.store(fail_obj, ret_ptr)
|
| 163 |
+
|
| 164 |
+
class_obj = c.pyapi.unserialize(c.pyapi.serialize_object(Interval))
|
| 165 |
+
with cgutils.early_exit_if_null(c.builder, stack, class_obj):
|
| 166 |
+
c.pyapi.decref(lo_obj)
|
| 167 |
+
c.pyapi.decref(hi_obj)
|
| 168 |
+
c.builder.store(fail_obj, ret_ptr)
|
| 169 |
+
|
| 170 |
+
# NOTE: The result of this call is not checked as the clean up
|
| 171 |
+
# has to occur regardless of whether it is successful. If it
|
| 172 |
+
# fails `res` is set to NULL and a Python exception is set.
|
| 173 |
+
res = c.pyapi.call_function_objargs(class_obj, (lo_obj, hi_obj))
|
| 174 |
+
c.pyapi.decref(lo_obj)
|
| 175 |
+
c.pyapi.decref(hi_obj)
|
| 176 |
+
c.pyapi.decref(class_obj)
|
| 177 |
+
c.builder.store(res, ret_ptr)
|
| 178 |
+
|
| 179 |
+
return c.builder.load(ret_ptr)
|
| 180 |
+
# magictoken.interval_box.end
|
| 181 |
+
|
| 182 |
+
# magictoken.interval_usage.begin
|
| 183 |
+
from numba import njit
|
| 184 |
+
|
| 185 |
+
@njit
|
| 186 |
+
def inside_interval(interval, x):
|
| 187 |
+
return interval.lo <= x < interval.hi
|
| 188 |
+
|
| 189 |
+
@njit
|
| 190 |
+
def interval_width(interval):
|
| 191 |
+
return interval.width
|
| 192 |
+
|
| 193 |
+
@njit
|
| 194 |
+
def sum_intervals(i, j):
|
| 195 |
+
return Interval(i.lo + j.lo, i.hi + j.hi)
|
| 196 |
+
# magictoken.interval_usage.end
|
| 197 |
+
|
| 198 |
+
def check_equal_intervals(x, y):
|
| 199 |
+
self.assertIsInstance(x, Interval)
|
| 200 |
+
self.assertIsInstance(y, Interval)
|
| 201 |
+
self.assertEqual(x.lo, y.lo)
|
| 202 |
+
self.assertEqual(x.hi, y.hi)
|
| 203 |
+
|
| 204 |
+
a = Interval(2, 3)
|
| 205 |
+
b = Interval(4, 5)
|
| 206 |
+
c = Interval(6, 8)
|
| 207 |
+
|
| 208 |
+
# Test box-unbox
|
| 209 |
+
return_func = njit(lambda x: x)
|
| 210 |
+
check_equal_intervals(a, return_func(a))
|
| 211 |
+
|
| 212 |
+
# Test .width attribute
|
| 213 |
+
self.assertEqual(a.width, interval_width(a))
|
| 214 |
+
|
| 215 |
+
# Test exceptions
|
| 216 |
+
class NotAFloat:
|
| 217 |
+
def __float__(self):
|
| 218 |
+
raise RuntimeError("I am not a float")
|
| 219 |
+
|
| 220 |
+
# TODO: This should produce a `RuntimeError`, but the `unbox` handler for `float` ignores
|
| 221 |
+
# the error raised by `__float__`, leading to a subsequent `TypeError` cause by passing
|
| 222 |
+
# `NULL` to `PyFloat_AsDouble`.
|
| 223 |
+
# This isn't the fault of the `Interval` extension that is being testing
|
| 224 |
+
# in this file.
|
| 225 |
+
with self.assertRaises(TypeError):
|
| 226 |
+
interval_width(Interval(2, NotAFloat()))
|
| 227 |
+
|
| 228 |
+
bad_interval = Interval(1, 2)
|
| 229 |
+
del bad_interval.hi
|
| 230 |
+
|
| 231 |
+
with self.assertRaises(AttributeError):
|
| 232 |
+
interval_width(bad_interval)
|
| 233 |
+
|
| 234 |
+
# Test .lo and .hi usage
|
| 235 |
+
self.assertFalse(inside_interval(a, 5))
|
| 236 |
+
|
| 237 |
+
# Test native Interval constructor
|
| 238 |
+
check_equal_intervals(c, sum_intervals(a, b))
|
| 239 |
+
|
| 240 |
+
|
| 241 |
+
if __name__ == '__main__':
|
| 242 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_jitclass.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import TestCase
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class DocsJitclassUsageTest(TestCase):
|
| 9 |
+
|
| 10 |
+
def test_ex_jitclass(self):
|
| 11 |
+
# magictoken.ex_jitclass.begin
|
| 12 |
+
import numpy as np
|
| 13 |
+
from numba import int32, float32 # import the types
|
| 14 |
+
from numba.experimental import jitclass
|
| 15 |
+
|
| 16 |
+
spec = [
|
| 17 |
+
('value', int32), # a simple scalar field
|
| 18 |
+
('array', float32[:]), # an array field
|
| 19 |
+
]
|
| 20 |
+
|
| 21 |
+
@jitclass(spec)
|
| 22 |
+
class Bag(object):
|
| 23 |
+
def __init__(self, value):
|
| 24 |
+
self.value = value
|
| 25 |
+
self.array = np.zeros(value, dtype=np.float32)
|
| 26 |
+
|
| 27 |
+
@property
|
| 28 |
+
def size(self):
|
| 29 |
+
return self.array.size
|
| 30 |
+
|
| 31 |
+
def increment(self, val):
|
| 32 |
+
for i in range(self.size):
|
| 33 |
+
self.array[i] += val
|
| 34 |
+
return self.array
|
| 35 |
+
|
| 36 |
+
@staticmethod
|
| 37 |
+
def add(x, y):
|
| 38 |
+
return x + y
|
| 39 |
+
|
| 40 |
+
n = 21
|
| 41 |
+
mybag = Bag(n)
|
| 42 |
+
# magictoken.ex_jitclass.end
|
| 43 |
+
|
| 44 |
+
self.assertTrue(isinstance(mybag, Bag))
|
| 45 |
+
self.assertPreciseEqual(mybag.value, n)
|
| 46 |
+
np.testing.assert_allclose(mybag.array, np.zeros(n, dtype=np.float32))
|
| 47 |
+
self.assertPreciseEqual(mybag.size, n)
|
| 48 |
+
np.testing.assert_allclose(mybag.increment(3),
|
| 49 |
+
3 * np.ones(n, dtype=np.float32))
|
| 50 |
+
np.testing.assert_allclose(mybag.increment(6),
|
| 51 |
+
9 * np.ones(n, dtype=np.float32))
|
| 52 |
+
self.assertPreciseEqual(mybag.add(1, 1), 2)
|
| 53 |
+
self.assertPreciseEqual(Bag.add(1, 2), 3)
|
| 54 |
+
|
| 55 |
+
def test_ex_jitclass_type_hints(self):
|
| 56 |
+
# magictoken.ex_jitclass_type_hints.begin
|
| 57 |
+
from typing import List
|
| 58 |
+
from numba.experimental import jitclass
|
| 59 |
+
from numba.typed import List as NumbaList
|
| 60 |
+
|
| 61 |
+
@jitclass
|
| 62 |
+
class Counter:
|
| 63 |
+
value: int
|
| 64 |
+
|
| 65 |
+
def __init__(self):
|
| 66 |
+
self.value = 0
|
| 67 |
+
|
| 68 |
+
def get(self) -> int:
|
| 69 |
+
ret = self.value
|
| 70 |
+
self.value += 1
|
| 71 |
+
return ret
|
| 72 |
+
|
| 73 |
+
@jitclass
|
| 74 |
+
class ListLoopIterator:
|
| 75 |
+
counter: Counter
|
| 76 |
+
items: List[float]
|
| 77 |
+
|
| 78 |
+
def __init__(self, items: List[float]):
|
| 79 |
+
self.items = items
|
| 80 |
+
self.counter = Counter()
|
| 81 |
+
|
| 82 |
+
def get(self) -> float:
|
| 83 |
+
idx = self.counter.get() % len(self.items)
|
| 84 |
+
return self.items[idx]
|
| 85 |
+
|
| 86 |
+
items = NumbaList([3.14, 2.718, 0.123, -4.])
|
| 87 |
+
loop_itr = ListLoopIterator(items)
|
| 88 |
+
# magictoken.ex_jitclass_type_hints.end
|
| 89 |
+
|
| 90 |
+
for idx in range(10):
|
| 91 |
+
self.assertEqual(loop_itr.counter.value, idx)
|
| 92 |
+
self.assertAlmostEqual(loop_itr.get(), items[idx % len(items)])
|
| 93 |
+
self.assertEqual(loop_itr.counter.value, idx + 1)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
if __name__ == '__main__':
|
| 97 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_literal_container_usage.py
ADDED
|
@@ -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|
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import captured_stdout
|
| 6 |
+
from numba import typed
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class DocsLiteralContainerUsageTest(unittest.TestCase):
|
| 10 |
+
|
| 11 |
+
def test_ex_literal_dict_compile_time_consts(self):
|
| 12 |
+
with captured_stdout():
|
| 13 |
+
# magictoken.test_ex_literal_dict_compile_time_consts.begin
|
| 14 |
+
import numpy as np
|
| 15 |
+
from numba import njit, types
|
| 16 |
+
from numba.extending import overload
|
| 17 |
+
|
| 18 |
+
# overload this function
|
| 19 |
+
def specialize(x):
|
| 20 |
+
pass
|
| 21 |
+
|
| 22 |
+
@overload(specialize)
|
| 23 |
+
def ol_specialize(x):
|
| 24 |
+
ld = x.literal_value
|
| 25 |
+
const_expr = []
|
| 26 |
+
for k, v in ld.items():
|
| 27 |
+
if isinstance(v, types.Literal):
|
| 28 |
+
lv = v.literal_value
|
| 29 |
+
if lv == 'cat':
|
| 30 |
+
const_expr.append("Meow!")
|
| 31 |
+
elif lv == 'dog':
|
| 32 |
+
const_expr.append("Woof!")
|
| 33 |
+
elif isinstance(lv, int):
|
| 34 |
+
const_expr.append(k.literal_value * lv)
|
| 35 |
+
else: # it's an array
|
| 36 |
+
const_expr.append("Array(dim={dim}".format(dim=v.ndim))
|
| 37 |
+
const_strings = tuple(const_expr)
|
| 38 |
+
|
| 39 |
+
def impl(x):
|
| 40 |
+
return const_strings
|
| 41 |
+
return impl
|
| 42 |
+
|
| 43 |
+
@njit
|
| 44 |
+
def foo():
|
| 45 |
+
pets_ints_and_array = {'a': 1,
|
| 46 |
+
'b': 2,
|
| 47 |
+
'c': 'cat',
|
| 48 |
+
'd': 'dog',
|
| 49 |
+
'e': np.ones(5,)}
|
| 50 |
+
return specialize(pets_ints_and_array)
|
| 51 |
+
|
| 52 |
+
result = foo()
|
| 53 |
+
print(result) # ('a', 'bb', 'Meow!', 'Woof!', 'Array(dim=1')
|
| 54 |
+
# magictoken.test_ex_literal_dict_compile_time_consts.end
|
| 55 |
+
|
| 56 |
+
self.assertEqual(result, ('a', 'bb', 'Meow!', 'Woof!', 'Array(dim=1'))
|
| 57 |
+
|
| 58 |
+
def test_ex_initial_value_dict_compile_time_consts(self):
|
| 59 |
+
with captured_stdout():
|
| 60 |
+
# magictoken.test_ex_initial_value_dict_compile_time_consts.begin
|
| 61 |
+
from numba import njit, literally
|
| 62 |
+
from numba.extending import overload
|
| 63 |
+
|
| 64 |
+
# overload this function
|
| 65 |
+
def specialize(x):
|
| 66 |
+
pass
|
| 67 |
+
|
| 68 |
+
@overload(specialize)
|
| 69 |
+
def ol_specialize(x):
|
| 70 |
+
iv = x.initial_value
|
| 71 |
+
if iv is None:
|
| 72 |
+
return lambda x: literally(x) # Force literal dispatch
|
| 73 |
+
assert iv == {'a': 1, 'b': 2, 'c': 3} # INITIAL VALUE
|
| 74 |
+
return lambda x: literally(x)
|
| 75 |
+
|
| 76 |
+
@njit
|
| 77 |
+
def foo():
|
| 78 |
+
d = {'a': 1, 'b': 2, 'c': 3}
|
| 79 |
+
d['c'] = 20 # no impact on .initial_value
|
| 80 |
+
d['d'] = 30 # no impact on .initial_value
|
| 81 |
+
return specialize(d)
|
| 82 |
+
|
| 83 |
+
result = foo()
|
| 84 |
+
print(result) # {a: 1, b: 2, c: 20, d: 30} # NOT INITIAL VALUE!
|
| 85 |
+
# magictoken.test_ex_initial_value_dict_compile_time_consts.end
|
| 86 |
+
|
| 87 |
+
expected = typed.Dict()
|
| 88 |
+
for k, v in {'a': 1, 'b': 2, 'c': 20, 'd': 30}.items():
|
| 89 |
+
expected[k] = v
|
| 90 |
+
self.assertEqual(result, expected)
|
| 91 |
+
|
| 92 |
+
def test_ex_literal_list(self):
|
| 93 |
+
with captured_stdout():
|
| 94 |
+
# magictoken.test_ex_literal_list.begin
|
| 95 |
+
from numba import njit
|
| 96 |
+
from numba.extending import overload
|
| 97 |
+
|
| 98 |
+
# overload this function
|
| 99 |
+
def specialize(x):
|
| 100 |
+
pass
|
| 101 |
+
|
| 102 |
+
@overload(specialize)
|
| 103 |
+
def ol_specialize(x):
|
| 104 |
+
l = x.literal_value
|
| 105 |
+
const_expr = []
|
| 106 |
+
for v in l:
|
| 107 |
+
const_expr.append(str(v))
|
| 108 |
+
const_strings = tuple(const_expr)
|
| 109 |
+
|
| 110 |
+
def impl(x):
|
| 111 |
+
return const_strings
|
| 112 |
+
return impl
|
| 113 |
+
|
| 114 |
+
@njit
|
| 115 |
+
def foo():
|
| 116 |
+
const_list = ['a', 10, 1j, ['another', 'list']]
|
| 117 |
+
return specialize(const_list)
|
| 118 |
+
|
| 119 |
+
result = foo()
|
| 120 |
+
print(result) # ('Literal[str](a)', 'Literal[int](10)', 'complex128', 'list(unicode_type)') # noqa E501
|
| 121 |
+
# magictoken.test_ex_literal_list.end
|
| 122 |
+
|
| 123 |
+
expected = ('Literal[str](a)', 'Literal[int](10)', 'complex128',
|
| 124 |
+
"list(unicode_type)<iv=['another', 'list']>")
|
| 125 |
+
self.assertEqual(result, expected)
|
| 126 |
+
|
| 127 |
+
def test_ex_initial_value_list_compile_time_consts(self):
|
| 128 |
+
with captured_stdout():
|
| 129 |
+
# magictoken.test_ex_initial_value_list_compile_time_consts.begin
|
| 130 |
+
from numba import njit, literally
|
| 131 |
+
from numba.extending import overload
|
| 132 |
+
|
| 133 |
+
# overload this function
|
| 134 |
+
def specialize(x):
|
| 135 |
+
pass
|
| 136 |
+
|
| 137 |
+
@overload(specialize)
|
| 138 |
+
def ol_specialize(x):
|
| 139 |
+
iv = x.initial_value
|
| 140 |
+
if iv is None:
|
| 141 |
+
return lambda x: literally(x) # Force literal dispatch
|
| 142 |
+
assert iv == [1, 2, 3] # INITIAL VALUE
|
| 143 |
+
return lambda x: x
|
| 144 |
+
|
| 145 |
+
@njit
|
| 146 |
+
def foo():
|
| 147 |
+
l = [1, 2, 3]
|
| 148 |
+
l[2] = 20 # no impact on .initial_value
|
| 149 |
+
l.append(30) # no impact on .initial_value
|
| 150 |
+
return specialize(l)
|
| 151 |
+
|
| 152 |
+
result = foo()
|
| 153 |
+
print(result) # [1, 2, 20, 30] # NOT INITIAL VALUE!
|
| 154 |
+
# magictoken.test_ex_initial_value_list_compile_time_consts.end
|
| 155 |
+
|
| 156 |
+
expected = [1, 2, 20, 30]
|
| 157 |
+
self.assertEqual(result, expected)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
if __name__ == '__main__':
|
| 161 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_literally_usage.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 2 |
+
|
| 3 |
+
import unittest
|
| 4 |
+
from numba.tests.support import captured_stdout
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class DocsLiterallyUsageTest(unittest.TestCase):
|
| 8 |
+
|
| 9 |
+
def test_literally_usage(self):
|
| 10 |
+
with captured_stdout() as stdout:
|
| 11 |
+
# magictoken.ex_literally_usage.begin
|
| 12 |
+
import numba
|
| 13 |
+
|
| 14 |
+
def power(x, n):
|
| 15 |
+
raise NotImplementedError
|
| 16 |
+
|
| 17 |
+
@numba.extending.overload(power)
|
| 18 |
+
def ov_power(x, n):
|
| 19 |
+
if isinstance(n, numba.types.Literal):
|
| 20 |
+
# only if `n` is a literal
|
| 21 |
+
if n.literal_value == 2:
|
| 22 |
+
# special case: square
|
| 23 |
+
print("square")
|
| 24 |
+
return lambda x, n: x * x
|
| 25 |
+
elif n.literal_value == 3:
|
| 26 |
+
# special case: cubic
|
| 27 |
+
print("cubic")
|
| 28 |
+
return lambda x, n: x * x * x
|
| 29 |
+
else:
|
| 30 |
+
# If `n` is not literal, request literal dispatch
|
| 31 |
+
return lambda x, n: numba.literally(n)
|
| 32 |
+
|
| 33 |
+
print("generic")
|
| 34 |
+
return lambda x, n: x ** n
|
| 35 |
+
|
| 36 |
+
@numba.njit
|
| 37 |
+
def test_power(x, n):
|
| 38 |
+
return power(x, n)
|
| 39 |
+
|
| 40 |
+
# should print "square" and "9"
|
| 41 |
+
print(test_power(3, 2))
|
| 42 |
+
|
| 43 |
+
# should print "cubic" and "27"
|
| 44 |
+
print(test_power(3, 3))
|
| 45 |
+
|
| 46 |
+
# should print "generic" and "81"
|
| 47 |
+
print(test_power(3, 4))
|
| 48 |
+
|
| 49 |
+
# magictoken.ex_literally_usage.end
|
| 50 |
+
assert test_power(3, 2) == 3 ** 2
|
| 51 |
+
assert test_power(3, 3) == 3 ** 3
|
| 52 |
+
assert test_power(3, 4) == 3 ** 4
|
| 53 |
+
|
| 54 |
+
self.assertEqual('square\n9\ncubic\n27\ngeneric\n81\n',
|
| 55 |
+
stdout.getvalue())
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
if __name__ == '__main__':
|
| 59 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_llvm_pass_timings.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 2 |
+
|
| 3 |
+
import unittest
|
| 4 |
+
from numba.tests.support import captured_stdout, override_config
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class DocsLLVMPassTimings(unittest.TestCase):
|
| 8 |
+
|
| 9 |
+
def test_pass_timings(self):
|
| 10 |
+
with override_config('LLVM_PASS_TIMINGS', True):
|
| 11 |
+
with captured_stdout() as stdout:
|
| 12 |
+
# magictoken.ex_llvm_pass_timings.begin
|
| 13 |
+
import numba
|
| 14 |
+
|
| 15 |
+
@numba.njit
|
| 16 |
+
def foo(n):
|
| 17 |
+
c = 0
|
| 18 |
+
for i in range(n):
|
| 19 |
+
for j in range(i):
|
| 20 |
+
c += j
|
| 21 |
+
return c
|
| 22 |
+
|
| 23 |
+
foo(10)
|
| 24 |
+
md = foo.get_metadata(foo.signatures[0])
|
| 25 |
+
print(md['llvm_pass_timings'])
|
| 26 |
+
# magictoken.ex_llvm_pass_timings.end
|
| 27 |
+
self.assertIn("Finalize object", stdout.getvalue())
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
if __name__ == '__main__':
|
| 31 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_numpy_generators.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 2 |
+
|
| 3 |
+
import unittest
|
| 4 |
+
import numpy as np
|
| 5 |
+
import numba
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class NumpyGeneratorUsageTest(unittest.TestCase):
|
| 9 |
+
|
| 10 |
+
def test_numpy_gen_usage(self):
|
| 11 |
+
# magictoken.npgen_usage.begin
|
| 12 |
+
x = np.random.default_rng(1)
|
| 13 |
+
y = np.random.default_rng(1)
|
| 14 |
+
|
| 15 |
+
size = 10
|
| 16 |
+
|
| 17 |
+
@numba.njit
|
| 18 |
+
def do_stuff(gen):
|
| 19 |
+
return gen.random(size=int(size / 2))
|
| 20 |
+
|
| 21 |
+
original = x.random(size=size)
|
| 22 |
+
# [0.51182162 0.9504637 0.14415961 0.94864945 0.31183145
|
| 23 |
+
# 0.42332645 0.82770259 0.40919914 0.54959369 0.02755911]
|
| 24 |
+
|
| 25 |
+
numba_func_res = do_stuff(y)
|
| 26 |
+
# [0.51182162 0.9504637 0.14415961 0.94864945 0.31183145]
|
| 27 |
+
|
| 28 |
+
after_numba = y.random(size=int(size / 2))
|
| 29 |
+
# [0.42332645 0.82770259 0.40919914 0.54959369 0.02755911]
|
| 30 |
+
|
| 31 |
+
# magictoken.npgen_usage.end
|
| 32 |
+
numba_res = np.concatenate((numba_func_res, after_numba))
|
| 33 |
+
for _np_res, _nb_res in zip(original, numba_res):
|
| 34 |
+
self.assertEqual(_np_res, _nb_res)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
if __name__ == '__main__':
|
| 38 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_parallel_chunksize.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import captured_stdout, skip_parfors_unsupported
|
| 6 |
+
from numba import set_parallel_chunksize
|
| 7 |
+
from numba.tests.support import TestCase
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
@skip_parfors_unsupported
|
| 11 |
+
class ChunksizeExamplesTest(TestCase):
|
| 12 |
+
|
| 13 |
+
_numba_parallel_test_ = False
|
| 14 |
+
|
| 15 |
+
def setUp(self):
|
| 16 |
+
set_parallel_chunksize(0)
|
| 17 |
+
|
| 18 |
+
def tearDown(self):
|
| 19 |
+
set_parallel_chunksize(0)
|
| 20 |
+
|
| 21 |
+
def test_unbalanced_example(self):
|
| 22 |
+
with captured_stdout():
|
| 23 |
+
# magictoken.ex_unbalanced.begin
|
| 24 |
+
from numba import (njit,
|
| 25 |
+
prange,
|
| 26 |
+
)
|
| 27 |
+
import numpy as np
|
| 28 |
+
|
| 29 |
+
@njit(parallel=True)
|
| 30 |
+
def func1():
|
| 31 |
+
n = 100
|
| 32 |
+
vals = np.empty(n)
|
| 33 |
+
# The work in each iteration of the following prange
|
| 34 |
+
# loop is proportional to its index.
|
| 35 |
+
for i in prange(n):
|
| 36 |
+
cur = i + 1
|
| 37 |
+
for j in range(i):
|
| 38 |
+
if cur % 2 == 0:
|
| 39 |
+
cur //= 2
|
| 40 |
+
else:
|
| 41 |
+
cur = cur * 3 + 1
|
| 42 |
+
vals[i] = cur
|
| 43 |
+
return vals
|
| 44 |
+
|
| 45 |
+
result = func1()
|
| 46 |
+
# magictoken.ex_unbalanced.end
|
| 47 |
+
self.assertPreciseEqual(result, func1.py_func())
|
| 48 |
+
|
| 49 |
+
def test_chunksize_manual(self):
|
| 50 |
+
with captured_stdout():
|
| 51 |
+
# magictoken.ex_chunksize_manual.begin
|
| 52 |
+
from numba import (njit,
|
| 53 |
+
prange,
|
| 54 |
+
set_parallel_chunksize,
|
| 55 |
+
get_parallel_chunksize,
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
@njit(parallel=True)
|
| 59 |
+
def func1(n):
|
| 60 |
+
acc = 0
|
| 61 |
+
print(get_parallel_chunksize()) # Will print 4.
|
| 62 |
+
for i in prange(n):
|
| 63 |
+
print(get_parallel_chunksize()) # Will print 0.
|
| 64 |
+
acc += i
|
| 65 |
+
print(get_parallel_chunksize()) # Will print 4.
|
| 66 |
+
return acc
|
| 67 |
+
|
| 68 |
+
@njit(parallel=True)
|
| 69 |
+
def func2(n):
|
| 70 |
+
acc = 0
|
| 71 |
+
# This version gets the previous chunksize explicitly.
|
| 72 |
+
old_chunksize = get_parallel_chunksize()
|
| 73 |
+
set_parallel_chunksize(8)
|
| 74 |
+
for i in prange(n):
|
| 75 |
+
acc += i
|
| 76 |
+
set_parallel_chunksize(old_chunksize)
|
| 77 |
+
return acc
|
| 78 |
+
|
| 79 |
+
# This version saves the previous chunksize as returned
|
| 80 |
+
# by set_parallel_chunksize.
|
| 81 |
+
old_chunksize = set_parallel_chunksize(4)
|
| 82 |
+
result1 = func1(12)
|
| 83 |
+
result2 = func2(12)
|
| 84 |
+
result3 = func1(12)
|
| 85 |
+
set_parallel_chunksize(old_chunksize)
|
| 86 |
+
# magictoken.ex_chunksize_manual.end
|
| 87 |
+
self.assertPreciseEqual(result1, func1.py_func(12))
|
| 88 |
+
self.assertPreciseEqual(result2, func2.py_func(12))
|
| 89 |
+
self.assertPreciseEqual(result3, func1.py_func(12))
|
| 90 |
+
|
| 91 |
+
def test_chunksize_with(self):
|
| 92 |
+
with captured_stdout():
|
| 93 |
+
# magictoken.ex_chunksize_with.begin
|
| 94 |
+
from numba import njit, prange, parallel_chunksize
|
| 95 |
+
|
| 96 |
+
@njit(parallel=True)
|
| 97 |
+
def func1(n):
|
| 98 |
+
acc = 0
|
| 99 |
+
for i in prange(n):
|
| 100 |
+
acc += i
|
| 101 |
+
return acc
|
| 102 |
+
|
| 103 |
+
@njit(parallel=True)
|
| 104 |
+
def func2(n):
|
| 105 |
+
acc = 0
|
| 106 |
+
with parallel_chunksize(8):
|
| 107 |
+
for i in prange(n):
|
| 108 |
+
acc += i
|
| 109 |
+
return acc
|
| 110 |
+
|
| 111 |
+
with parallel_chunksize(4):
|
| 112 |
+
result1 = func1(12)
|
| 113 |
+
result2 = func2(12)
|
| 114 |
+
result3 = func1(12)
|
| 115 |
+
# magictoken.ex_chunksize_with.end
|
| 116 |
+
self.assertPreciseEqual(result1, func1.py_func(12))
|
| 117 |
+
self.assertPreciseEqual(result2, func2.py_func(12))
|
| 118 |
+
self.assertPreciseEqual(result3, func1.py_func(12))
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
if __name__ == '__main__':
|
| 122 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_rec_array.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import unittest
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class TestExample(unittest.TestCase):
|
| 5 |
+
|
| 6 |
+
def test_documentation_example1(self):
|
| 7 |
+
# magictoken.ex_rec_arr_const_index.begin
|
| 8 |
+
import numpy as np
|
| 9 |
+
from numba import njit
|
| 10 |
+
|
| 11 |
+
arr = np.array([(1, 2)], dtype=[('a1', 'f8'), ('a2', 'f8')])
|
| 12 |
+
fields_gl = ('a1', 'a2')
|
| 13 |
+
|
| 14 |
+
@njit
|
| 15 |
+
def get_field_sum(rec):
|
| 16 |
+
fields_lc = ('a1', 'a2')
|
| 17 |
+
field_name1 = fields_lc[0]
|
| 18 |
+
field_name2 = fields_gl[1]
|
| 19 |
+
return rec[field_name1] + rec[field_name2]
|
| 20 |
+
|
| 21 |
+
get_field_sum(arr[0]) # returns 3
|
| 22 |
+
# magictoken.ex_rec_arr_const_index.end
|
| 23 |
+
self.assertEqual(get_field_sum(arr[0]), 3)
|
| 24 |
+
|
| 25 |
+
def test_documentation_example2(self):
|
| 26 |
+
# magictoken.ex_rec_arr_lit_unroll_index.begin
|
| 27 |
+
import numpy as np
|
| 28 |
+
from numba import njit, literal_unroll
|
| 29 |
+
|
| 30 |
+
arr = np.array([(1, 2)], dtype=[('a1', 'f8'), ('a2', 'f8')])
|
| 31 |
+
fields_gl = ('a1', 'a2')
|
| 32 |
+
|
| 33 |
+
@njit
|
| 34 |
+
def get_field_sum(rec):
|
| 35 |
+
out = 0
|
| 36 |
+
for f in literal_unroll(fields_gl):
|
| 37 |
+
out += rec[f]
|
| 38 |
+
return out
|
| 39 |
+
|
| 40 |
+
get_field_sum(arr[0]) # returns 3
|
| 41 |
+
# magictoken.ex_rec_arr_lit_unroll_index.end
|
| 42 |
+
self.assertEqual(get_field_sum(arr[0]), 3)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
if __name__ == '__main__':
|
| 46 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_structref_usage.py
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 2 |
+
|
| 3 |
+
import unittest
|
| 4 |
+
|
| 5 |
+
# magictoken.ex_structref_type_definition.begin
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
from numba import njit
|
| 9 |
+
from numba.core import types
|
| 10 |
+
from numba.experimental import structref
|
| 11 |
+
|
| 12 |
+
from numba.tests.support import skip_unless_scipy
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
# Define a StructRef.
|
| 16 |
+
# `structref.register` associates the type with the default data model.
|
| 17 |
+
# This will also install getters and setters to the fields of
|
| 18 |
+
# the StructRef.
|
| 19 |
+
@structref.register
|
| 20 |
+
class MyStructType(types.StructRef):
|
| 21 |
+
def preprocess_fields(self, fields):
|
| 22 |
+
# This method is called by the type constructor for additional
|
| 23 |
+
# preprocessing on the fields.
|
| 24 |
+
# Here, we don't want the struct to take Literal types.
|
| 25 |
+
return tuple((name, types.unliteral(typ)) for name, typ in fields)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
# Define a Python type that can be use as a proxy to the StructRef
|
| 29 |
+
# allocated inside Numba. Users can construct the StructRef via
|
| 30 |
+
# the constructor for this type in python code and jit-code.
|
| 31 |
+
class MyStruct(structref.StructRefProxy):
|
| 32 |
+
def __new__(cls, name, vector):
|
| 33 |
+
# Overriding the __new__ method is optional, doing so
|
| 34 |
+
# allows Python code to use keyword arguments,
|
| 35 |
+
# or add other customized behavior.
|
| 36 |
+
# The default __new__ takes `*args`.
|
| 37 |
+
# IMPORTANT: Users should not override __init__.
|
| 38 |
+
return structref.StructRefProxy.__new__(cls, name, vector)
|
| 39 |
+
|
| 40 |
+
# By default, the proxy type does not reflect the attributes or
|
| 41 |
+
# methods to the Python side. It is up to users to define
|
| 42 |
+
# these. (This may be automated in the future.)
|
| 43 |
+
|
| 44 |
+
@property
|
| 45 |
+
def name(self):
|
| 46 |
+
# To access a field, we can define a function that simply
|
| 47 |
+
# return the field in jit-code.
|
| 48 |
+
# The definition of MyStruct_get_name is shown later.
|
| 49 |
+
return MyStruct_get_name(self)
|
| 50 |
+
|
| 51 |
+
@property
|
| 52 |
+
def vector(self):
|
| 53 |
+
# The definition of MyStruct_get_vector is shown later.
|
| 54 |
+
return MyStruct_get_vector(self)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@njit
|
| 58 |
+
def MyStruct_get_name(self):
|
| 59 |
+
# In jit-code, the StructRef's attribute is exposed via
|
| 60 |
+
# structref.register
|
| 61 |
+
return self.name
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
@njit
|
| 65 |
+
def MyStruct_get_vector(self):
|
| 66 |
+
return self.vector
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
# This associates the proxy with MyStructType for the given set of
|
| 70 |
+
# fields. Notice how we are not constraining the type of each field.
|
| 71 |
+
# Field types remain generic.
|
| 72 |
+
structref.define_proxy(MyStruct, MyStructType, ["name", "vector"])
|
| 73 |
+
# magictoken.ex_structref_type_definition.end
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@skip_unless_scipy
|
| 77 |
+
class TestStructRefUsage(unittest.TestCase):
|
| 78 |
+
def test_type_definition(self):
|
| 79 |
+
np.random.seed(0)
|
| 80 |
+
# Redirect print
|
| 81 |
+
buf = []
|
| 82 |
+
|
| 83 |
+
def print(*args):
|
| 84 |
+
buf.append(args)
|
| 85 |
+
|
| 86 |
+
# magictoken.ex_structref_type_definition_test.begin
|
| 87 |
+
# Let's test our new StructRef.
|
| 88 |
+
|
| 89 |
+
# Define one in Python
|
| 90 |
+
alice = MyStruct("Alice", vector=np.random.random(3))
|
| 91 |
+
|
| 92 |
+
# Define one in jit-code
|
| 93 |
+
@njit
|
| 94 |
+
def make_bob():
|
| 95 |
+
bob = MyStruct("unnamed", vector=np.zeros(3))
|
| 96 |
+
# Mutate the attributes
|
| 97 |
+
bob.name = "Bob"
|
| 98 |
+
bob.vector = np.random.random(3)
|
| 99 |
+
return bob
|
| 100 |
+
|
| 101 |
+
bob = make_bob()
|
| 102 |
+
|
| 103 |
+
# Out: Alice: [0.5488135 0.71518937 0.60276338]
|
| 104 |
+
print(f"{alice.name}: {alice.vector}")
|
| 105 |
+
# Out: Bob: [0.88325739 0.73527629 0.87746707]
|
| 106 |
+
print(f"{bob.name}: {bob.vector}")
|
| 107 |
+
|
| 108 |
+
# Define a jit function to operate on the structs.
|
| 109 |
+
@njit
|
| 110 |
+
def distance(a, b):
|
| 111 |
+
return np.linalg.norm(a.vector - b.vector)
|
| 112 |
+
|
| 113 |
+
# Out: 0.4332647200356598
|
| 114 |
+
print(distance(alice, bob))
|
| 115 |
+
# magictoken.ex_structref_type_definition_test.end
|
| 116 |
+
|
| 117 |
+
self.assertEqual(len(buf), 3)
|
| 118 |
+
|
| 119 |
+
def test_overload_method(self):
|
| 120 |
+
# magictoken.ex_structref_method.begin
|
| 121 |
+
from numba.core.extending import overload_method
|
| 122 |
+
from numba.core.errors import TypingError
|
| 123 |
+
|
| 124 |
+
# Use @overload_method to add a method for
|
| 125 |
+
# MyStructType.distance(other)
|
| 126 |
+
# where *other* is an instance of MyStructType.
|
| 127 |
+
@overload_method(MyStructType, "distance")
|
| 128 |
+
def ol_distance(self, other):
|
| 129 |
+
# Guard that *other* is an instance of MyStructType
|
| 130 |
+
if not isinstance(other, MyStructType):
|
| 131 |
+
raise TypingError(
|
| 132 |
+
f"*other* must be a {MyStructType}; got {other}"
|
| 133 |
+
)
|
| 134 |
+
|
| 135 |
+
def impl(self, other):
|
| 136 |
+
return np.linalg.norm(self.vector - other.vector)
|
| 137 |
+
|
| 138 |
+
return impl
|
| 139 |
+
|
| 140 |
+
# Test
|
| 141 |
+
@njit
|
| 142 |
+
def test():
|
| 143 |
+
alice = MyStruct("Alice", vector=np.random.random(3))
|
| 144 |
+
bob = MyStruct("Bob", vector=np.random.random(3))
|
| 145 |
+
# Use the method
|
| 146 |
+
return alice.distance(bob)
|
| 147 |
+
# magictoken.ex_structref_method.end
|
| 148 |
+
|
| 149 |
+
self.assertIsInstance(test(), float)
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_dict_usage.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import captured_stdout
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class DocsTypedDictUsageTest(unittest.TestCase):
|
| 9 |
+
|
| 10 |
+
def test_ex_typed_dict_from_cpython(self):
|
| 11 |
+
with captured_stdout():
|
| 12 |
+
# magictoken.ex_typed_dict_from_cpython.begin
|
| 13 |
+
import numpy as np
|
| 14 |
+
from numba import njit
|
| 15 |
+
from numba.core import types
|
| 16 |
+
from numba.typed import Dict
|
| 17 |
+
|
| 18 |
+
# The Dict.empty() constructs a typed dictionary.
|
| 19 |
+
# The key and value typed must be explicitly declared.
|
| 20 |
+
d = Dict.empty(
|
| 21 |
+
key_type=types.unicode_type,
|
| 22 |
+
value_type=types.float64[:],
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# The typed-dict can be used from the interpreter.
|
| 26 |
+
d['posx'] = np.asarray([1, 0.5, 2], dtype='f8')
|
| 27 |
+
d['posy'] = np.asarray([1.5, 3.5, 2], dtype='f8')
|
| 28 |
+
d['velx'] = np.asarray([0.5, 0, 0.7], dtype='f8')
|
| 29 |
+
d['vely'] = np.asarray([0.2, -0.2, 0.1], dtype='f8')
|
| 30 |
+
|
| 31 |
+
# Here's a function that expects a typed-dict as the argument
|
| 32 |
+
@njit
|
| 33 |
+
def move(d):
|
| 34 |
+
# inplace operations on the arrays
|
| 35 |
+
d['posx'] += d['velx']
|
| 36 |
+
d['posy'] += d['vely']
|
| 37 |
+
|
| 38 |
+
print('posx: ', d['posx']) # Out: posx: [1. 0.5 2. ]
|
| 39 |
+
print('posy: ', d['posy']) # Out: posy: [1.5 3.5 2. ]
|
| 40 |
+
|
| 41 |
+
# Call move(d) to inplace update the arrays in the typed-dict.
|
| 42 |
+
move(d)
|
| 43 |
+
|
| 44 |
+
print('posx: ', d['posx']) # Out: posx: [1.5 0.5 2.7]
|
| 45 |
+
print('posy: ', d['posy']) # Out: posy: [1.7 3.3 2.1]
|
| 46 |
+
# magictoken.ex_typed_dict_from_cpython.end
|
| 47 |
+
|
| 48 |
+
# Test
|
| 49 |
+
np.testing.assert_array_equal(d['posx'], [1.5, 0.5, 2.7])
|
| 50 |
+
np.testing.assert_array_equal(d['posy'], [1.7, 3.3, 2.1])
|
| 51 |
+
|
| 52 |
+
def test_ex_typed_dict_njit(self):
|
| 53 |
+
with captured_stdout():
|
| 54 |
+
# magictoken.ex_typed_dict_njit.begin
|
| 55 |
+
import numpy as np
|
| 56 |
+
from numba import njit
|
| 57 |
+
from numba.core import types
|
| 58 |
+
from numba.typed import Dict
|
| 59 |
+
|
| 60 |
+
# Make array type. Type-expression is not supported in jit
|
| 61 |
+
# functions.
|
| 62 |
+
float_array = types.float64[:]
|
| 63 |
+
|
| 64 |
+
@njit
|
| 65 |
+
def foo():
|
| 66 |
+
# Make dictionary
|
| 67 |
+
d = Dict.empty(
|
| 68 |
+
key_type=types.unicode_type,
|
| 69 |
+
value_type=float_array,
|
| 70 |
+
)
|
| 71 |
+
# Fill the dictionary
|
| 72 |
+
d["posx"] = np.arange(3).astype(np.float64)
|
| 73 |
+
d["posy"] = np.arange(3, 6).astype(np.float64)
|
| 74 |
+
return d
|
| 75 |
+
|
| 76 |
+
d = foo()
|
| 77 |
+
# Print the dictionary
|
| 78 |
+
print(d) # Out: {posx: [0. 1. 2.], posy: [3. 4. 5.]}
|
| 79 |
+
# magictoken.ex_typed_dict_njit.end
|
| 80 |
+
np.testing.assert_array_equal(d['posx'], [0, 1, 2])
|
| 81 |
+
np.testing.assert_array_equal(d['posy'], [3, 4, 5])
|
| 82 |
+
|
| 83 |
+
def test_ex_inferred_dict_njit(self):
|
| 84 |
+
with captured_stdout():
|
| 85 |
+
# magictoken.ex_inferred_dict_njit.begin
|
| 86 |
+
from numba import njit
|
| 87 |
+
import numpy as np
|
| 88 |
+
|
| 89 |
+
@njit
|
| 90 |
+
def foo():
|
| 91 |
+
d = dict()
|
| 92 |
+
k = {1: np.arange(1), 2: np.arange(2)}
|
| 93 |
+
# The following tells the compiler what the key type and the
|
| 94 |
+
# value
|
| 95 |
+
# type are for `d`.
|
| 96 |
+
d[3] = np.arange(3)
|
| 97 |
+
d[5] = np.arange(5)
|
| 98 |
+
return d, k
|
| 99 |
+
|
| 100 |
+
d, k = foo()
|
| 101 |
+
print(d) # {3: [0 1 2], 5: [0 1 2 3 4]}
|
| 102 |
+
print(k) # {1: [0], 2: [0 1]}
|
| 103 |
+
# magictoken.ex_inferred_dict_njit.end
|
| 104 |
+
np.testing.assert_array_equal(d[3], [0, 1, 2])
|
| 105 |
+
np.testing.assert_array_equal(d[5], [0, 1, 2, 3, 4])
|
| 106 |
+
np.testing.assert_array_equal(k[1], [0])
|
| 107 |
+
np.testing.assert_array_equal(k[2], [0, 1])
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
if __name__ == '__main__':
|
| 111 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_list_usage.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import captured_stdout
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class DocsTypedListUsageTest(unittest.TestCase):
|
| 9 |
+
|
| 10 |
+
def test_ex_inferred_list_jit(self):
|
| 11 |
+
with captured_stdout():
|
| 12 |
+
|
| 13 |
+
# magictoken.ex_inferred_list_jit.begin
|
| 14 |
+
from numba import njit
|
| 15 |
+
from numba.typed import List
|
| 16 |
+
|
| 17 |
+
@njit
|
| 18 |
+
def foo():
|
| 19 |
+
# Instantiate a typed-list
|
| 20 |
+
l = List()
|
| 21 |
+
# Append a value to it, this will set the type to int32/int64
|
| 22 |
+
# (depending on platform)
|
| 23 |
+
l.append(42)
|
| 24 |
+
# The usual list operations, getitem, pop and length are
|
| 25 |
+
# supported
|
| 26 |
+
print(l[0]) # 42
|
| 27 |
+
l[0] = 23
|
| 28 |
+
print(l[0]) # 23
|
| 29 |
+
print(len(l)) # 1
|
| 30 |
+
l.pop()
|
| 31 |
+
print(len(l)) # 0
|
| 32 |
+
return l
|
| 33 |
+
|
| 34 |
+
foo()
|
| 35 |
+
|
| 36 |
+
# magictoken.ex_inferred_list_jit.end
|
| 37 |
+
|
| 38 |
+
def test_ex_inferred_list(self):
|
| 39 |
+
with captured_stdout():
|
| 40 |
+
# magictoken.ex_inferred_list.begin
|
| 41 |
+
from numba import njit
|
| 42 |
+
from numba.typed import List
|
| 43 |
+
|
| 44 |
+
@njit
|
| 45 |
+
def foo(mylist):
|
| 46 |
+
for i in range(10, 20):
|
| 47 |
+
mylist.append(i)
|
| 48 |
+
return mylist
|
| 49 |
+
|
| 50 |
+
# Instantiate a typed-list, outside of a jit context
|
| 51 |
+
l = List()
|
| 52 |
+
# Append a value to it, this will set the type to int32/int64
|
| 53 |
+
# (depending on platform)
|
| 54 |
+
l.append(42)
|
| 55 |
+
# The usual list operations, getitem, pop and length are supported
|
| 56 |
+
print(l[0]) # 42
|
| 57 |
+
l[0] = 23
|
| 58 |
+
print(l[0]) # 23
|
| 59 |
+
print(len(l)) # 1
|
| 60 |
+
l.pop()
|
| 61 |
+
print(len(l)) # 0
|
| 62 |
+
|
| 63 |
+
# And you can use the typed-list as an argument for a jit compiled
|
| 64 |
+
# function
|
| 65 |
+
l = foo(l)
|
| 66 |
+
print(len(l)) # 10
|
| 67 |
+
|
| 68 |
+
# You can also directly construct a typed-list from an existing
|
| 69 |
+
# Python list
|
| 70 |
+
py_list = [2, 3, 5]
|
| 71 |
+
numba_list = List(py_list)
|
| 72 |
+
print(len(numba_list)) # 3
|
| 73 |
+
|
| 74 |
+
# magictoken.ex_inferred_list.end
|
| 75 |
+
|
| 76 |
+
def test_ex_nested_list(self):
|
| 77 |
+
with captured_stdout():
|
| 78 |
+
# magictoken.ex_nested_list.begin
|
| 79 |
+
from numba.typed import List
|
| 80 |
+
|
| 81 |
+
# typed-lists can be nested in typed-lists
|
| 82 |
+
mylist = List()
|
| 83 |
+
for i in range(10):
|
| 84 |
+
l = List()
|
| 85 |
+
for i in range(10):
|
| 86 |
+
l.append(i)
|
| 87 |
+
mylist.append(l)
|
| 88 |
+
# mylist is now a list of 10 lists, each containing 10 integers
|
| 89 |
+
print(mylist)
|
| 90 |
+
|
| 91 |
+
# magictoken.ex_nested_list.end
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
if __name__ == '__main__':
|
| 95 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doc_examples/test_typed_set_usage.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Contents in this file are referenced from the sphinx-generated docs.
|
| 2 |
+
# "magictoken" is used for markers as beginning and ending of example text.
|
| 3 |
+
|
| 4 |
+
import unittest
|
| 5 |
+
from numba.tests.support import captured_stdout
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
class DocsTypedSetUsageTest(unittest.TestCase):
|
| 9 |
+
|
| 10 |
+
def test_ex_typed_set_from_cpython(self):
|
| 11 |
+
with captured_stdout():
|
| 12 |
+
# magictoken.ex_typed_set_from_cpython.begin
|
| 13 |
+
import numpy as np
|
| 14 |
+
from numba import njit
|
| 15 |
+
from numba.core import types
|
| 16 |
+
from numba.typed import Set
|
| 17 |
+
|
| 18 |
+
# The Set.empty() constructs a typed set.
|
| 19 |
+
# The key typed must be explicitly declared.
|
| 20 |
+
s = Set.empty(types.unicode_type)
|
| 21 |
+
|
| 22 |
+
# The typed-set can be used from the interpreter.
|
| 23 |
+
s.add("One")
|
| 24 |
+
s.add("Two")
|
| 25 |
+
s.add("Three")
|
| 26 |
+
|
| 27 |
+
# Here's a function that expects a typed-set as the argument
|
| 28 |
+
@njit
|
| 29 |
+
def remove_elem(s, elem):
|
| 30 |
+
s.discard(elem)
|
| 31 |
+
|
| 32 |
+
print(len(s)) # Out: 3
|
| 33 |
+
|
| 34 |
+
# Call remove_elem(s) to remove an element in the typed-set.
|
| 35 |
+
remove_elem(s, "Three")
|
| 36 |
+
|
| 37 |
+
print(len(s)) # Out: 2
|
| 38 |
+
# magictoken.ex_typed_set_from_cpython.end
|
| 39 |
+
|
| 40 |
+
# Test
|
| 41 |
+
np.testing.assert_equal(len(s), 2)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == '__main__':
|
| 45 |
+
unittest.main()
|
.venv/lib/python3.11/site-packages/numba/tests/doctest_usecase.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Test that all docstrings are the same:
|
| 3 |
+
|
| 4 |
+
>>> len({f.__doc__ for f in (a, b, c, d)})
|
| 5 |
+
1
|
| 6 |
+
"""
|
| 7 |
+
from numba import guvectorize, int64, njit, vectorize
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def a():
|
| 11 |
+
""">>> x = 1"""
|
| 12 |
+
return 1
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
@njit
|
| 16 |
+
def b():
|
| 17 |
+
""">>> x = 1"""
|
| 18 |
+
return 1
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
@guvectorize([(int64[:], int64, int64[:])], "(n),()->(n)")
|
| 22 |
+
def c(x, y, res):
|
| 23 |
+
""">>> x = 1"""
|
| 24 |
+
for i in range(x.shape[0]):
|
| 25 |
+
res[i] = x[i] + y
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@vectorize([int64(int64, int64)])
|
| 29 |
+
def d(x, y):
|
| 30 |
+
""">>> x = 1"""
|
| 31 |
+
return x + y
|