Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/__init__.py +180 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/__init__.pyi +2 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs.py +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs.pyi +3 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs_scalars.py +389 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs_scalars.pyi +16 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_asarray.py +135 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_asarray.pyi +41 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype.py +374 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype.pyi +58 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype_ctypes.py +120 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype_ctypes.pyi +83 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_exceptions.py +172 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_exceptions.pyi +73 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_internal.py +963 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_internal.pyi +72 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_machar.py +356 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_machar.pyi +73 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_methods.py +256 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_methods.pyi +24 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_tests.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_tests.cp310-win_amd64.pyd +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_umath.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_operand_flag_tests.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_operand_flag_tests.cp310-win_amd64.pyd +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_rational_tests.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_rational_tests.cp310-win_amd64.pyd +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_simd.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_simd.pyi +25 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_string_helpers.py +100 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_string_helpers.pyi +12 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_struct_ufunc_tests.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_struct_ufunc_tests.cp310-win_amd64.pyd +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_type_aliases.py +119 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_type_aliases.pyi +96 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_ufunc_config.py +483 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_ufunc_config.pyi +39 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_umath_tests.cp310-win_amd64.lib +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/_umath_tests.cp310-win_amd64.pyd +0 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__multiarray_api.c +376 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__multiarray_api.h +1613 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__ufunc_api.c +54 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__ufunc_api.h +340 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_neighborhood_iterator_imp.h +90 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_numpyconfig.h +33 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_public_dtype_api_table.h +86 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/arrayobject.h +7 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/arrayscalars.h +196 -0
- pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/dtype_api.h +480 -0
.gitattributes
CHANGED
|
@@ -52,3 +52,4 @@ pythonProject/.venv/Lib/site-packages/diffusers/utils/__pycache__/dummy_torch_an
|
|
| 52 |
pythonProject/.venv/Lib/site-packages/functorch/_C.cp310-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 53 |
pythonProject/.venv/Lib/site-packages/huggingface_hub/inference/__pycache__/_client.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 54 |
pythonProject/.venv/Lib/site-packages/numpy/fft/_pocketfft_umath.cp310-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 52 |
pythonProject/.venv/Lib/site-packages/functorch/_C.cp310-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 53 |
pythonProject/.venv/Lib/site-packages/huggingface_hub/inference/__pycache__/_client.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
|
| 54 |
pythonProject/.venv/Lib/site-packages/numpy/fft/_pocketfft_umath.cp310-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
pythonProject/.venv/Lib/site-packages/numpy/random/_common.cp310-win_amd64.pyd filter=lfs diff=lfs merge=lfs -text
|
pythonProject/.venv/Lib/site-packages/numpy/_core/__init__.py
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ufuncs, dtypes, etc.
|
| 3 |
+
|
| 4 |
+
Please note that this module is private. All functions and objects
|
| 5 |
+
are available in the main ``numpy`` namespace - use that instead.
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
from numpy.version import version as __version__
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# disables OpenBLAS affinity setting of the main thread that limits
|
| 15 |
+
# python threads or processes to one core
|
| 16 |
+
env_added = []
|
| 17 |
+
for envkey in ['OPENBLAS_MAIN_FREE', 'GOTOBLAS_MAIN_FREE']:
|
| 18 |
+
if envkey not in os.environ:
|
| 19 |
+
os.environ[envkey] = '1'
|
| 20 |
+
env_added.append(envkey)
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
from . import multiarray
|
| 24 |
+
except ImportError as exc:
|
| 25 |
+
import sys
|
| 26 |
+
msg = """
|
| 27 |
+
|
| 28 |
+
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
|
| 29 |
+
|
| 30 |
+
Importing the numpy C-extensions failed. This error can happen for
|
| 31 |
+
many reasons, often due to issues with your setup or how NumPy was
|
| 32 |
+
installed.
|
| 33 |
+
|
| 34 |
+
We have compiled some common reasons and troubleshooting tips at:
|
| 35 |
+
|
| 36 |
+
https://numpy.org/devdocs/user/troubleshooting-importerror.html
|
| 37 |
+
|
| 38 |
+
Please note and check the following:
|
| 39 |
+
|
| 40 |
+
* The Python version is: Python%d.%d from "%s"
|
| 41 |
+
* The NumPy version is: "%s"
|
| 42 |
+
|
| 43 |
+
and make sure that they are the versions you expect.
|
| 44 |
+
Please carefully study the documentation linked above for further help.
|
| 45 |
+
|
| 46 |
+
Original error was: %s
|
| 47 |
+
""" % (sys.version_info[0], sys.version_info[1], sys.executable,
|
| 48 |
+
__version__, exc)
|
| 49 |
+
raise ImportError(msg)
|
| 50 |
+
finally:
|
| 51 |
+
for envkey in env_added:
|
| 52 |
+
del os.environ[envkey]
|
| 53 |
+
del envkey
|
| 54 |
+
del env_added
|
| 55 |
+
del os
|
| 56 |
+
|
| 57 |
+
from . import umath
|
| 58 |
+
|
| 59 |
+
# Check that multiarray,umath are pure python modules wrapping
|
| 60 |
+
# _multiarray_umath and not either of the old c-extension modules
|
| 61 |
+
if not (hasattr(multiarray, '_multiarray_umath') and
|
| 62 |
+
hasattr(umath, '_multiarray_umath')):
|
| 63 |
+
import sys
|
| 64 |
+
path = sys.modules['numpy'].__path__
|
| 65 |
+
msg = ("Something is wrong with the numpy installation. "
|
| 66 |
+
"While importing we detected an older version of "
|
| 67 |
+
"numpy in {}. One method of fixing this is to repeatedly uninstall "
|
| 68 |
+
"numpy until none is found, then reinstall this version.")
|
| 69 |
+
raise ImportError(msg.format(path))
|
| 70 |
+
|
| 71 |
+
from . import numerictypes as nt
|
| 72 |
+
from .numerictypes import sctypes, sctypeDict
|
| 73 |
+
multiarray.set_typeDict(nt.sctypeDict)
|
| 74 |
+
from . import numeric
|
| 75 |
+
from .numeric import *
|
| 76 |
+
from . import fromnumeric
|
| 77 |
+
from .fromnumeric import *
|
| 78 |
+
from .records import record, recarray
|
| 79 |
+
# Note: module name memmap is overwritten by a class with same name
|
| 80 |
+
from .memmap import *
|
| 81 |
+
from . import function_base
|
| 82 |
+
from .function_base import *
|
| 83 |
+
from . import _machar
|
| 84 |
+
from . import getlimits
|
| 85 |
+
from .getlimits import *
|
| 86 |
+
from . import shape_base
|
| 87 |
+
from .shape_base import *
|
| 88 |
+
from . import einsumfunc
|
| 89 |
+
from .einsumfunc import *
|
| 90 |
+
del nt
|
| 91 |
+
|
| 92 |
+
from .numeric import absolute as abs
|
| 93 |
+
|
| 94 |
+
# do this after everything else, to minimize the chance of this misleadingly
|
| 95 |
+
# appearing in an import-time traceback
|
| 96 |
+
from . import _add_newdocs
|
| 97 |
+
from . import _add_newdocs_scalars
|
| 98 |
+
# add these for module-freeze analysis (like PyInstaller)
|
| 99 |
+
from . import _dtype_ctypes
|
| 100 |
+
from . import _internal
|
| 101 |
+
from . import _dtype
|
| 102 |
+
from . import _methods
|
| 103 |
+
|
| 104 |
+
acos = numeric.arccos
|
| 105 |
+
acosh = numeric.arccosh
|
| 106 |
+
asin = numeric.arcsin
|
| 107 |
+
asinh = numeric.arcsinh
|
| 108 |
+
atan = numeric.arctan
|
| 109 |
+
atanh = numeric.arctanh
|
| 110 |
+
atan2 = numeric.arctan2
|
| 111 |
+
concat = numeric.concatenate
|
| 112 |
+
bitwise_left_shift = numeric.left_shift
|
| 113 |
+
bitwise_invert = numeric.invert
|
| 114 |
+
bitwise_right_shift = numeric.right_shift
|
| 115 |
+
permute_dims = numeric.transpose
|
| 116 |
+
pow = numeric.power
|
| 117 |
+
|
| 118 |
+
__all__ = [
|
| 119 |
+
"abs", "acos", "acosh", "asin", "asinh", "atan", "atanh", "atan2",
|
| 120 |
+
"bitwise_invert", "bitwise_left_shift", "bitwise_right_shift", "concat",
|
| 121 |
+
"pow", "permute_dims", "memmap", "sctypeDict", "record", "recarray"
|
| 122 |
+
]
|
| 123 |
+
__all__ += numeric.__all__
|
| 124 |
+
__all__ += function_base.__all__
|
| 125 |
+
__all__ += getlimits.__all__
|
| 126 |
+
__all__ += shape_base.__all__
|
| 127 |
+
__all__ += einsumfunc.__all__
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def _ufunc_reduce(func):
|
| 131 |
+
# Report the `__name__`. pickle will try to find the module. Note that
|
| 132 |
+
# pickle supports for this `__name__` to be a `__qualname__`. It may
|
| 133 |
+
# make sense to add a `__qualname__` to ufuncs, to allow this more
|
| 134 |
+
# explicitly (Numba has ufuncs as attributes).
|
| 135 |
+
# See also: https://github.com/dask/distributed/issues/3450
|
| 136 |
+
return func.__name__
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def _DType_reconstruct(scalar_type):
|
| 140 |
+
# This is a work-around to pickle type(np.dtype(np.float64)), etc.
|
| 141 |
+
# and it should eventually be replaced with a better solution, e.g. when
|
| 142 |
+
# DTypes become HeapTypes.
|
| 143 |
+
return type(dtype(scalar_type))
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
def _DType_reduce(DType):
|
| 147 |
+
# As types/classes, most DTypes can simply be pickled by their name:
|
| 148 |
+
if not DType._legacy or DType.__module__ == "numpy.dtypes":
|
| 149 |
+
return DType.__name__
|
| 150 |
+
|
| 151 |
+
# However, user defined legacy dtypes (like rational) do not end up in
|
| 152 |
+
# `numpy.dtypes` as module and do not have a public class at all.
|
| 153 |
+
# For these, we pickle them by reconstructing them from the scalar type:
|
| 154 |
+
scalar_type = DType.type
|
| 155 |
+
return _DType_reconstruct, (scalar_type,)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def __getattr__(name):
|
| 159 |
+
# Deprecated 2022-11-22, NumPy 1.25.
|
| 160 |
+
if name == "MachAr":
|
| 161 |
+
import warnings
|
| 162 |
+
warnings.warn(
|
| 163 |
+
"The `np._core.MachAr` is considered private API (NumPy 1.24)",
|
| 164 |
+
DeprecationWarning, stacklevel=2,
|
| 165 |
+
)
|
| 166 |
+
return _machar.MachAr
|
| 167 |
+
raise AttributeError(f"Module {__name__!r} has no attribute {name!r}")
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
import copyreg
|
| 171 |
+
|
| 172 |
+
copyreg.pickle(ufunc, _ufunc_reduce)
|
| 173 |
+
copyreg.pickle(type(dtype), _DType_reduce, _DType_reconstruct)
|
| 174 |
+
|
| 175 |
+
# Unclutter namespace (must keep _*_reconstruct for unpickling)
|
| 176 |
+
del copyreg, _ufunc_reduce, _DType_reduce
|
| 177 |
+
|
| 178 |
+
from numpy._pytesttester import PytestTester
|
| 179 |
+
test = PytestTester(__name__)
|
| 180 |
+
del PytestTester
|
pythonProject/.venv/Lib/site-packages/numpy/_core/__init__.pyi
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NOTE: The `np._core` namespace is deliberately kept empty due to it
|
| 2 |
+
# being private
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs.pyi
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .overrides import get_array_function_like_doc as get_array_function_like_doc
|
| 2 |
+
|
| 3 |
+
def refer_to_array_attribute(attr: str, method: bool = True) -> tuple[str, str]: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs_scalars.py
ADDED
|
@@ -0,0 +1,389 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
This file is separate from ``_add_newdocs.py`` so that it can be mocked out by
|
| 3 |
+
our sphinx ``conf.py`` during doc builds, where we want to avoid showing
|
| 4 |
+
platform-dependent information.
|
| 5 |
+
"""
|
| 6 |
+
import sys
|
| 7 |
+
import os
|
| 8 |
+
from numpy._core import dtype
|
| 9 |
+
from numpy._core import numerictypes as _numerictypes
|
| 10 |
+
from numpy._core.function_base import add_newdoc
|
| 11 |
+
|
| 12 |
+
##############################################################################
|
| 13 |
+
#
|
| 14 |
+
# Documentation for concrete scalar classes
|
| 15 |
+
#
|
| 16 |
+
##############################################################################
|
| 17 |
+
|
| 18 |
+
def numeric_type_aliases(aliases):
|
| 19 |
+
def type_aliases_gen():
|
| 20 |
+
for alias, doc in aliases:
|
| 21 |
+
try:
|
| 22 |
+
alias_type = getattr(_numerictypes, alias)
|
| 23 |
+
except AttributeError:
|
| 24 |
+
# The set of aliases that actually exist varies between platforms
|
| 25 |
+
pass
|
| 26 |
+
else:
|
| 27 |
+
yield (alias_type, alias, doc)
|
| 28 |
+
return list(type_aliases_gen())
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
possible_aliases = numeric_type_aliases([
|
| 32 |
+
('int8', '8-bit signed integer (``-128`` to ``127``)'),
|
| 33 |
+
('int16', '16-bit signed integer (``-32_768`` to ``32_767``)'),
|
| 34 |
+
('int32', '32-bit signed integer (``-2_147_483_648`` to ``2_147_483_647``)'),
|
| 35 |
+
('int64', '64-bit signed integer (``-9_223_372_036_854_775_808`` to ``9_223_372_036_854_775_807``)'),
|
| 36 |
+
('intp', 'Signed integer large enough to fit pointer, compatible with C ``intptr_t``'),
|
| 37 |
+
('uint8', '8-bit unsigned integer (``0`` to ``255``)'),
|
| 38 |
+
('uint16', '16-bit unsigned integer (``0`` to ``65_535``)'),
|
| 39 |
+
('uint32', '32-bit unsigned integer (``0`` to ``4_294_967_295``)'),
|
| 40 |
+
('uint64', '64-bit unsigned integer (``0`` to ``18_446_744_073_709_551_615``)'),
|
| 41 |
+
('uintp', 'Unsigned integer large enough to fit pointer, compatible with C ``uintptr_t``'),
|
| 42 |
+
('float16', '16-bit-precision floating-point number type: sign bit, 5 bits exponent, 10 bits mantissa'),
|
| 43 |
+
('float32', '32-bit-precision floating-point number type: sign bit, 8 bits exponent, 23 bits mantissa'),
|
| 44 |
+
('float64', '64-bit precision floating-point number type: sign bit, 11 bits exponent, 52 bits mantissa'),
|
| 45 |
+
('float96', '96-bit extended-precision floating-point number type'),
|
| 46 |
+
('float128', '128-bit extended-precision floating-point number type'),
|
| 47 |
+
('complex64', 'Complex number type composed of 2 32-bit-precision floating-point numbers'),
|
| 48 |
+
('complex128', 'Complex number type composed of 2 64-bit-precision floating-point numbers'),
|
| 49 |
+
('complex192', 'Complex number type composed of 2 96-bit extended-precision floating-point numbers'),
|
| 50 |
+
('complex256', 'Complex number type composed of 2 128-bit extended-precision floating-point numbers'),
|
| 51 |
+
])
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _get_platform_and_machine():
|
| 55 |
+
try:
|
| 56 |
+
system, _, _, _, machine = os.uname()
|
| 57 |
+
except AttributeError:
|
| 58 |
+
system = sys.platform
|
| 59 |
+
if system == 'win32':
|
| 60 |
+
machine = os.environ.get('PROCESSOR_ARCHITEW6432', '') \
|
| 61 |
+
or os.environ.get('PROCESSOR_ARCHITECTURE', '')
|
| 62 |
+
else:
|
| 63 |
+
machine = 'unknown'
|
| 64 |
+
return system, machine
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
_system, _machine = _get_platform_and_machine()
|
| 68 |
+
_doc_alias_string = f":Alias on this platform ({_system} {_machine}):"
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def add_newdoc_for_scalar_type(obj, fixed_aliases, doc):
|
| 72 |
+
# note: `:field: value` is rST syntax which renders as field lists.
|
| 73 |
+
o = getattr(_numerictypes, obj)
|
| 74 |
+
|
| 75 |
+
character_code = dtype(o).char
|
| 76 |
+
canonical_name_doc = "" if obj == o.__name__ else \
|
| 77 |
+
f":Canonical name: `numpy.{obj}`\n "
|
| 78 |
+
if fixed_aliases:
|
| 79 |
+
alias_doc = ''.join(f":Alias: `numpy.{alias}`\n "
|
| 80 |
+
for alias in fixed_aliases)
|
| 81 |
+
else:
|
| 82 |
+
alias_doc = ''
|
| 83 |
+
alias_doc += ''.join(f"{_doc_alias_string} `numpy.{alias}`: {doc}.\n "
|
| 84 |
+
for (alias_type, alias, doc) in possible_aliases if alias_type is o)
|
| 85 |
+
|
| 86 |
+
docstring = f"""
|
| 87 |
+
{doc.strip()}
|
| 88 |
+
|
| 89 |
+
:Character code: ``'{character_code}'``
|
| 90 |
+
{canonical_name_doc}{alias_doc}
|
| 91 |
+
"""
|
| 92 |
+
|
| 93 |
+
add_newdoc('numpy._core.numerictypes', obj, docstring)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
_bool_docstring = (
|
| 97 |
+
"""
|
| 98 |
+
Boolean type (True or False), stored as a byte.
|
| 99 |
+
|
| 100 |
+
.. warning::
|
| 101 |
+
|
| 102 |
+
The :class:`bool` type is not a subclass of the :class:`int_` type
|
| 103 |
+
(the :class:`bool` is not even a number type). This is different
|
| 104 |
+
than Python's default implementation of :class:`bool` as a
|
| 105 |
+
sub-class of :class:`int`.
|
| 106 |
+
"""
|
| 107 |
+
)
|
| 108 |
+
|
| 109 |
+
add_newdoc_for_scalar_type('bool', [], _bool_docstring)
|
| 110 |
+
|
| 111 |
+
add_newdoc_for_scalar_type('bool_', [], _bool_docstring)
|
| 112 |
+
|
| 113 |
+
add_newdoc_for_scalar_type('byte', [],
|
| 114 |
+
"""
|
| 115 |
+
Signed integer type, compatible with C ``char``.
|
| 116 |
+
""")
|
| 117 |
+
|
| 118 |
+
add_newdoc_for_scalar_type('short', [],
|
| 119 |
+
"""
|
| 120 |
+
Signed integer type, compatible with C ``short``.
|
| 121 |
+
""")
|
| 122 |
+
|
| 123 |
+
add_newdoc_for_scalar_type('intc', [],
|
| 124 |
+
"""
|
| 125 |
+
Signed integer type, compatible with C ``int``.
|
| 126 |
+
""")
|
| 127 |
+
|
| 128 |
+
# TODO: These docs probably need an if to highlight the default rather than
|
| 129 |
+
# the C-types (and be correct).
|
| 130 |
+
add_newdoc_for_scalar_type('int_', [],
|
| 131 |
+
"""
|
| 132 |
+
Default signed integer type, 64bit on 64bit systems and 32bit on 32bit
|
| 133 |
+
systems.
|
| 134 |
+
""")
|
| 135 |
+
|
| 136 |
+
add_newdoc_for_scalar_type('longlong', [],
|
| 137 |
+
"""
|
| 138 |
+
Signed integer type, compatible with C ``long long``.
|
| 139 |
+
""")
|
| 140 |
+
|
| 141 |
+
add_newdoc_for_scalar_type('ubyte', [],
|
| 142 |
+
"""
|
| 143 |
+
Unsigned integer type, compatible with C ``unsigned char``.
|
| 144 |
+
""")
|
| 145 |
+
|
| 146 |
+
add_newdoc_for_scalar_type('ushort', [],
|
| 147 |
+
"""
|
| 148 |
+
Unsigned integer type, compatible with C ``unsigned short``.
|
| 149 |
+
""")
|
| 150 |
+
|
| 151 |
+
add_newdoc_for_scalar_type('uintc', [],
|
| 152 |
+
"""
|
| 153 |
+
Unsigned integer type, compatible with C ``unsigned int``.
|
| 154 |
+
""")
|
| 155 |
+
|
| 156 |
+
add_newdoc_for_scalar_type('uint', [],
|
| 157 |
+
"""
|
| 158 |
+
Unsigned signed integer type, 64bit on 64bit systems and 32bit on 32bit
|
| 159 |
+
systems.
|
| 160 |
+
""")
|
| 161 |
+
|
| 162 |
+
add_newdoc_for_scalar_type('ulonglong', [],
|
| 163 |
+
"""
|
| 164 |
+
Signed integer type, compatible with C ``unsigned long long``.
|
| 165 |
+
""")
|
| 166 |
+
|
| 167 |
+
add_newdoc_for_scalar_type('half', [],
|
| 168 |
+
"""
|
| 169 |
+
Half-precision floating-point number type.
|
| 170 |
+
""")
|
| 171 |
+
|
| 172 |
+
add_newdoc_for_scalar_type('single', [],
|
| 173 |
+
"""
|
| 174 |
+
Single-precision floating-point number type, compatible with C ``float``.
|
| 175 |
+
""")
|
| 176 |
+
|
| 177 |
+
add_newdoc_for_scalar_type('double', [],
|
| 178 |
+
"""
|
| 179 |
+
Double-precision floating-point number type, compatible with Python
|
| 180 |
+
:class:`float` and C ``double``.
|
| 181 |
+
""")
|
| 182 |
+
|
| 183 |
+
add_newdoc_for_scalar_type('longdouble', [],
|
| 184 |
+
"""
|
| 185 |
+
Extended-precision floating-point number type, compatible with C
|
| 186 |
+
``long double`` but not necessarily with IEEE 754 quadruple-precision.
|
| 187 |
+
""")
|
| 188 |
+
|
| 189 |
+
add_newdoc_for_scalar_type('csingle', [],
|
| 190 |
+
"""
|
| 191 |
+
Complex number type composed of two single-precision floating-point
|
| 192 |
+
numbers.
|
| 193 |
+
""")
|
| 194 |
+
|
| 195 |
+
add_newdoc_for_scalar_type('cdouble', [],
|
| 196 |
+
"""
|
| 197 |
+
Complex number type composed of two double-precision floating-point
|
| 198 |
+
numbers, compatible with Python :class:`complex`.
|
| 199 |
+
""")
|
| 200 |
+
|
| 201 |
+
add_newdoc_for_scalar_type('clongdouble', [],
|
| 202 |
+
"""
|
| 203 |
+
Complex number type composed of two extended-precision floating-point
|
| 204 |
+
numbers.
|
| 205 |
+
""")
|
| 206 |
+
|
| 207 |
+
add_newdoc_for_scalar_type('object_', [],
|
| 208 |
+
"""
|
| 209 |
+
Any Python object.
|
| 210 |
+
""")
|
| 211 |
+
|
| 212 |
+
add_newdoc_for_scalar_type('str_', [],
|
| 213 |
+
r"""
|
| 214 |
+
A unicode string.
|
| 215 |
+
|
| 216 |
+
This type strips trailing null codepoints.
|
| 217 |
+
|
| 218 |
+
>>> s = np.str_("abc\x00")
|
| 219 |
+
>>> s
|
| 220 |
+
'abc'
|
| 221 |
+
|
| 222 |
+
Unlike the builtin :class:`str`, this supports the
|
| 223 |
+
:ref:`python:bufferobjects`, exposing its contents as UCS4:
|
| 224 |
+
|
| 225 |
+
>>> m = memoryview(np.str_("abc"))
|
| 226 |
+
>>> m.format
|
| 227 |
+
'3w'
|
| 228 |
+
>>> m.tobytes()
|
| 229 |
+
b'a\x00\x00\x00b\x00\x00\x00c\x00\x00\x00'
|
| 230 |
+
""")
|
| 231 |
+
|
| 232 |
+
add_newdoc_for_scalar_type('bytes_', [],
|
| 233 |
+
r"""
|
| 234 |
+
A byte string.
|
| 235 |
+
|
| 236 |
+
When used in arrays, this type strips trailing null bytes.
|
| 237 |
+
""")
|
| 238 |
+
|
| 239 |
+
add_newdoc_for_scalar_type('void', [],
|
| 240 |
+
r"""
|
| 241 |
+
np.void(length_or_data, /, dtype=None)
|
| 242 |
+
|
| 243 |
+
Create a new structured or unstructured void scalar.
|
| 244 |
+
|
| 245 |
+
Parameters
|
| 246 |
+
----------
|
| 247 |
+
length_or_data : int, array-like, bytes-like, object
|
| 248 |
+
One of multiple meanings (see notes). The length or
|
| 249 |
+
bytes data of an unstructured void. Or alternatively,
|
| 250 |
+
the data to be stored in the new scalar when `dtype`
|
| 251 |
+
is provided.
|
| 252 |
+
This can be an array-like, in which case an array may
|
| 253 |
+
be returned.
|
| 254 |
+
dtype : dtype, optional
|
| 255 |
+
If provided the dtype of the new scalar. This dtype must
|
| 256 |
+
be "void" dtype (i.e. a structured or unstructured void,
|
| 257 |
+
see also :ref:`defining-structured-types`).
|
| 258 |
+
|
| 259 |
+
.. versionadded:: 1.24
|
| 260 |
+
|
| 261 |
+
Notes
|
| 262 |
+
-----
|
| 263 |
+
For historical reasons and because void scalars can represent both
|
| 264 |
+
arbitrary byte data and structured dtypes, the void constructor
|
| 265 |
+
has three calling conventions:
|
| 266 |
+
|
| 267 |
+
1. ``np.void(5)`` creates a ``dtype="V5"`` scalar filled with five
|
| 268 |
+
``\0`` bytes. The 5 can be a Python or NumPy integer.
|
| 269 |
+
2. ``np.void(b"bytes-like")`` creates a void scalar from the byte string.
|
| 270 |
+
The dtype itemsize will match the byte string length, here ``"V10"``.
|
| 271 |
+
3. When a ``dtype=`` is passed the call is roughly the same as an
|
| 272 |
+
array creation. However, a void scalar rather than array is returned.
|
| 273 |
+
|
| 274 |
+
Please see the examples which show all three different conventions.
|
| 275 |
+
|
| 276 |
+
Examples
|
| 277 |
+
--------
|
| 278 |
+
>>> np.void(5)
|
| 279 |
+
np.void(b'\x00\x00\x00\x00\x00')
|
| 280 |
+
>>> np.void(b'abcd')
|
| 281 |
+
np.void(b'\x61\x62\x63\x64')
|
| 282 |
+
>>> np.void((3.2, b'eggs'), dtype="d,S5")
|
| 283 |
+
np.void((3.2, b'eggs'), dtype=[('f0', '<f8'), ('f1', 'S5')])
|
| 284 |
+
>>> np.void(3, dtype=[('x', np.int8), ('y', np.int8)])
|
| 285 |
+
np.void((3, 3), dtype=[('x', 'i1'), ('y', 'i1')])
|
| 286 |
+
|
| 287 |
+
""")
|
| 288 |
+
|
| 289 |
+
add_newdoc_for_scalar_type('datetime64', [],
|
| 290 |
+
"""
|
| 291 |
+
If created from a 64-bit integer, it represents an offset from
|
| 292 |
+
``1970-01-01T00:00:00``.
|
| 293 |
+
If created from string, the string can be in ISO 8601 date
|
| 294 |
+
or datetime format.
|
| 295 |
+
|
| 296 |
+
When parsing a string to create a datetime object, if the string contains
|
| 297 |
+
a trailing timezone (A 'Z' or a timezone offset), the timezone will be
|
| 298 |
+
dropped and a User Warning is given.
|
| 299 |
+
|
| 300 |
+
Datetime64 objects should be considered to be UTC and therefore have an
|
| 301 |
+
offset of +0000.
|
| 302 |
+
|
| 303 |
+
>>> np.datetime64(10, 'Y')
|
| 304 |
+
np.datetime64('1980')
|
| 305 |
+
>>> np.datetime64('1980', 'Y')
|
| 306 |
+
np.datetime64('1980')
|
| 307 |
+
>>> np.datetime64(10, 'D')
|
| 308 |
+
np.datetime64('1970-01-11')
|
| 309 |
+
|
| 310 |
+
See :ref:`arrays.datetime` for more information.
|
| 311 |
+
""")
|
| 312 |
+
|
| 313 |
+
add_newdoc_for_scalar_type('timedelta64', [],
|
| 314 |
+
"""
|
| 315 |
+
A timedelta stored as a 64-bit integer.
|
| 316 |
+
|
| 317 |
+
See :ref:`arrays.datetime` for more information.
|
| 318 |
+
""")
|
| 319 |
+
|
| 320 |
+
add_newdoc('numpy._core.numerictypes', "integer", ('is_integer',
|
| 321 |
+
"""
|
| 322 |
+
integer.is_integer() -> bool
|
| 323 |
+
|
| 324 |
+
Return ``True`` if the number is finite with integral value.
|
| 325 |
+
|
| 326 |
+
.. versionadded:: 1.22
|
| 327 |
+
|
| 328 |
+
Examples
|
| 329 |
+
--------
|
| 330 |
+
>>> import numpy as np
|
| 331 |
+
>>> np.int64(-2).is_integer()
|
| 332 |
+
True
|
| 333 |
+
>>> np.uint32(5).is_integer()
|
| 334 |
+
True
|
| 335 |
+
"""))
|
| 336 |
+
|
| 337 |
+
# TODO: work out how to put this on the base class, np.floating
|
| 338 |
+
for float_name in ('half', 'single', 'double', 'longdouble'):
|
| 339 |
+
add_newdoc('numpy._core.numerictypes', float_name, ('as_integer_ratio',
|
| 340 |
+
"""
|
| 341 |
+
{ftype}.as_integer_ratio() -> (int, int)
|
| 342 |
+
|
| 343 |
+
Return a pair of integers, whose ratio is exactly equal to the original
|
| 344 |
+
floating point number, and with a positive denominator.
|
| 345 |
+
Raise `OverflowError` on infinities and a `ValueError` on NaNs.
|
| 346 |
+
|
| 347 |
+
>>> np.{ftype}(10.0).as_integer_ratio()
|
| 348 |
+
(10, 1)
|
| 349 |
+
>>> np.{ftype}(0.0).as_integer_ratio()
|
| 350 |
+
(0, 1)
|
| 351 |
+
>>> np.{ftype}(-.25).as_integer_ratio()
|
| 352 |
+
(-1, 4)
|
| 353 |
+
""".format(ftype=float_name)))
|
| 354 |
+
|
| 355 |
+
add_newdoc('numpy._core.numerictypes', float_name, ('is_integer',
|
| 356 |
+
f"""
|
| 357 |
+
{float_name}.is_integer() -> bool
|
| 358 |
+
|
| 359 |
+
Return ``True`` if the floating point number is finite with integral
|
| 360 |
+
value, and ``False`` otherwise.
|
| 361 |
+
|
| 362 |
+
.. versionadded:: 1.22
|
| 363 |
+
|
| 364 |
+
Examples
|
| 365 |
+
--------
|
| 366 |
+
>>> np.{float_name}(-2.0).is_integer()
|
| 367 |
+
True
|
| 368 |
+
>>> np.{float_name}(3.2).is_integer()
|
| 369 |
+
False
|
| 370 |
+
"""))
|
| 371 |
+
|
| 372 |
+
for int_name in ('int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32',
|
| 373 |
+
'int64', 'uint64', 'int64', 'uint64', 'int64', 'uint64'):
|
| 374 |
+
# Add negative examples for signed cases by checking typecode
|
| 375 |
+
add_newdoc('numpy._core.numerictypes', int_name, ('bit_count',
|
| 376 |
+
f"""
|
| 377 |
+
{int_name}.bit_count() -> int
|
| 378 |
+
|
| 379 |
+
Computes the number of 1-bits in the absolute value of the input.
|
| 380 |
+
Analogous to the builtin `int.bit_count` or ``popcount`` in C++.
|
| 381 |
+
|
| 382 |
+
Examples
|
| 383 |
+
--------
|
| 384 |
+
>>> np.{int_name}(127).bit_count()
|
| 385 |
+
7""" +
|
| 386 |
+
(f"""
|
| 387 |
+
>>> np.{int_name}(-127).bit_count()
|
| 388 |
+
7
|
| 389 |
+
""" if dtype(int_name).char.islower() else "")))
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_add_newdocs_scalars.pyi
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterable
|
| 2 |
+
from typing import Final
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
possible_aliases: Final[list[tuple[type[np.number], str, str]]] = ...
|
| 7 |
+
_system: Final[str] = ...
|
| 8 |
+
_machine: Final[str] = ...
|
| 9 |
+
_doc_alias_string: Final[str] = ...
|
| 10 |
+
_bool_docstring: Final[str] = ...
|
| 11 |
+
int_name: str = ...
|
| 12 |
+
float_name: str = ...
|
| 13 |
+
|
| 14 |
+
def numeric_type_aliases(aliases: list[tuple[str, str]]) -> list[tuple[type[np.number], str, str]]: ...
|
| 15 |
+
def add_newdoc_for_scalar_type(obj: str, fixed_aliases: Iterable[str], doc: str) -> None: ...
|
| 16 |
+
def _get_platform_and_machine() -> tuple[str, str]: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_asarray.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Functions in the ``as*array`` family that promote array-likes into arrays.
|
| 3 |
+
|
| 4 |
+
`require` fits this category despite its name not matching this pattern.
|
| 5 |
+
"""
|
| 6 |
+
from .overrides import (
|
| 7 |
+
array_function_dispatch,
|
| 8 |
+
finalize_array_function_like,
|
| 9 |
+
set_module,
|
| 10 |
+
)
|
| 11 |
+
from .multiarray import array, asanyarray
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
__all__ = ["require"]
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
POSSIBLE_FLAGS = {
|
| 18 |
+
'C': 'C', 'C_CONTIGUOUS': 'C', 'CONTIGUOUS': 'C',
|
| 19 |
+
'F': 'F', 'F_CONTIGUOUS': 'F', 'FORTRAN': 'F',
|
| 20 |
+
'A': 'A', 'ALIGNED': 'A',
|
| 21 |
+
'W': 'W', 'WRITEABLE': 'W',
|
| 22 |
+
'O': 'O', 'OWNDATA': 'O',
|
| 23 |
+
'E': 'E', 'ENSUREARRAY': 'E'
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@finalize_array_function_like
|
| 28 |
+
@set_module('numpy')
|
| 29 |
+
def require(a, dtype=None, requirements=None, *, like=None):
|
| 30 |
+
"""
|
| 31 |
+
Return an ndarray of the provided type that satisfies requirements.
|
| 32 |
+
|
| 33 |
+
This function is useful to be sure that an array with the correct flags
|
| 34 |
+
is returned for passing to compiled code (perhaps through ctypes).
|
| 35 |
+
|
| 36 |
+
Parameters
|
| 37 |
+
----------
|
| 38 |
+
a : array_like
|
| 39 |
+
The object to be converted to a type-and-requirement-satisfying array.
|
| 40 |
+
dtype : data-type
|
| 41 |
+
The required data-type. If None preserve the current dtype. If your
|
| 42 |
+
application requires the data to be in native byteorder, include
|
| 43 |
+
a byteorder specification as a part of the dtype specification.
|
| 44 |
+
requirements : str or sequence of str
|
| 45 |
+
The requirements list can be any of the following
|
| 46 |
+
|
| 47 |
+
* 'F_CONTIGUOUS' ('F') - ensure a Fortran-contiguous array
|
| 48 |
+
* 'C_CONTIGUOUS' ('C') - ensure a C-contiguous array
|
| 49 |
+
* 'ALIGNED' ('A') - ensure a data-type aligned array
|
| 50 |
+
* 'WRITEABLE' ('W') - ensure a writable array
|
| 51 |
+
* 'OWNDATA' ('O') - ensure an array that owns its own data
|
| 52 |
+
* 'ENSUREARRAY', ('E') - ensure a base array, instead of a subclass
|
| 53 |
+
${ARRAY_FUNCTION_LIKE}
|
| 54 |
+
|
| 55 |
+
.. versionadded:: 1.20.0
|
| 56 |
+
|
| 57 |
+
Returns
|
| 58 |
+
-------
|
| 59 |
+
out : ndarray
|
| 60 |
+
Array with specified requirements and type if given.
|
| 61 |
+
|
| 62 |
+
See Also
|
| 63 |
+
--------
|
| 64 |
+
asarray : Convert input to an ndarray.
|
| 65 |
+
asanyarray : Convert to an ndarray, but pass through ndarray subclasses.
|
| 66 |
+
ascontiguousarray : Convert input to a contiguous array.
|
| 67 |
+
asfortranarray : Convert input to an ndarray with column-major
|
| 68 |
+
memory order.
|
| 69 |
+
ndarray.flags : Information about the memory layout of the array.
|
| 70 |
+
|
| 71 |
+
Notes
|
| 72 |
+
-----
|
| 73 |
+
The returned array will be guaranteed to have the listed requirements
|
| 74 |
+
by making a copy if needed.
|
| 75 |
+
|
| 76 |
+
Examples
|
| 77 |
+
--------
|
| 78 |
+
>>> import numpy as np
|
| 79 |
+
>>> x = np.arange(6).reshape(2,3)
|
| 80 |
+
>>> x.flags
|
| 81 |
+
C_CONTIGUOUS : True
|
| 82 |
+
F_CONTIGUOUS : False
|
| 83 |
+
OWNDATA : False
|
| 84 |
+
WRITEABLE : True
|
| 85 |
+
ALIGNED : True
|
| 86 |
+
WRITEBACKIFCOPY : False
|
| 87 |
+
|
| 88 |
+
>>> y = np.require(x, dtype=np.float32, requirements=['A', 'O', 'W', 'F'])
|
| 89 |
+
>>> y.flags
|
| 90 |
+
C_CONTIGUOUS : False
|
| 91 |
+
F_CONTIGUOUS : True
|
| 92 |
+
OWNDATA : True
|
| 93 |
+
WRITEABLE : True
|
| 94 |
+
ALIGNED : True
|
| 95 |
+
WRITEBACKIFCOPY : False
|
| 96 |
+
|
| 97 |
+
"""
|
| 98 |
+
if like is not None:
|
| 99 |
+
return _require_with_like(
|
| 100 |
+
like,
|
| 101 |
+
a,
|
| 102 |
+
dtype=dtype,
|
| 103 |
+
requirements=requirements,
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
if not requirements:
|
| 107 |
+
return asanyarray(a, dtype=dtype)
|
| 108 |
+
|
| 109 |
+
requirements = {POSSIBLE_FLAGS[x.upper()] for x in requirements}
|
| 110 |
+
|
| 111 |
+
if 'E' in requirements:
|
| 112 |
+
requirements.remove('E')
|
| 113 |
+
subok = False
|
| 114 |
+
else:
|
| 115 |
+
subok = True
|
| 116 |
+
|
| 117 |
+
order = 'A'
|
| 118 |
+
if requirements >= {'C', 'F'}:
|
| 119 |
+
raise ValueError('Cannot specify both "C" and "F" order')
|
| 120 |
+
elif 'F' in requirements:
|
| 121 |
+
order = 'F'
|
| 122 |
+
requirements.remove('F')
|
| 123 |
+
elif 'C' in requirements:
|
| 124 |
+
order = 'C'
|
| 125 |
+
requirements.remove('C')
|
| 126 |
+
|
| 127 |
+
arr = array(a, dtype=dtype, order=order, copy=None, subok=subok)
|
| 128 |
+
|
| 129 |
+
for prop in requirements:
|
| 130 |
+
if not arr.flags[prop]:
|
| 131 |
+
return arr.copy(order)
|
| 132 |
+
return arr
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
_require_with_like = array_function_dispatch()(require)
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_asarray.pyi
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterable
|
| 2 |
+
from typing import Any, TypeAlias, TypeVar, overload, Literal
|
| 3 |
+
|
| 4 |
+
from numpy._typing import NDArray, DTypeLike, _SupportsArrayFunc
|
| 5 |
+
|
| 6 |
+
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any])
|
| 7 |
+
|
| 8 |
+
_Requirements: TypeAlias = Literal[
|
| 9 |
+
"C", "C_CONTIGUOUS", "CONTIGUOUS",
|
| 10 |
+
"F", "F_CONTIGUOUS", "FORTRAN",
|
| 11 |
+
"A", "ALIGNED",
|
| 12 |
+
"W", "WRITEABLE",
|
| 13 |
+
"O", "OWNDATA"
|
| 14 |
+
]
|
| 15 |
+
_E: TypeAlias = Literal["E", "ENSUREARRAY"]
|
| 16 |
+
_RequirementsWithE: TypeAlias = _Requirements | _E
|
| 17 |
+
|
| 18 |
+
@overload
|
| 19 |
+
def require(
|
| 20 |
+
a: _ArrayType,
|
| 21 |
+
dtype: None = ...,
|
| 22 |
+
requirements: None | _Requirements | Iterable[_Requirements] = ...,
|
| 23 |
+
*,
|
| 24 |
+
like: _SupportsArrayFunc = ...
|
| 25 |
+
) -> _ArrayType: ...
|
| 26 |
+
@overload
|
| 27 |
+
def require(
|
| 28 |
+
a: object,
|
| 29 |
+
dtype: DTypeLike = ...,
|
| 30 |
+
requirements: _E | Iterable[_RequirementsWithE] = ...,
|
| 31 |
+
*,
|
| 32 |
+
like: _SupportsArrayFunc = ...
|
| 33 |
+
) -> NDArray[Any]: ...
|
| 34 |
+
@overload
|
| 35 |
+
def require(
|
| 36 |
+
a: object,
|
| 37 |
+
dtype: DTypeLike = ...,
|
| 38 |
+
requirements: None | _Requirements | Iterable[_Requirements] = ...,
|
| 39 |
+
*,
|
| 40 |
+
like: _SupportsArrayFunc = ...
|
| 41 |
+
) -> NDArray[Any]: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype.py
ADDED
|
@@ -0,0 +1,374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A place for code to be called from the implementation of np.dtype
|
| 3 |
+
|
| 4 |
+
String handling is much easier to do correctly in python.
|
| 5 |
+
"""
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
_kind_to_stem = {
|
| 10 |
+
'u': 'uint',
|
| 11 |
+
'i': 'int',
|
| 12 |
+
'c': 'complex',
|
| 13 |
+
'f': 'float',
|
| 14 |
+
'b': 'bool',
|
| 15 |
+
'V': 'void',
|
| 16 |
+
'O': 'object',
|
| 17 |
+
'M': 'datetime',
|
| 18 |
+
'm': 'timedelta',
|
| 19 |
+
'S': 'bytes',
|
| 20 |
+
'U': 'str',
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _kind_name(dtype):
|
| 25 |
+
try:
|
| 26 |
+
return _kind_to_stem[dtype.kind]
|
| 27 |
+
except KeyError as e:
|
| 28 |
+
raise RuntimeError(
|
| 29 |
+
"internal dtype error, unknown kind {!r}"
|
| 30 |
+
.format(dtype.kind)
|
| 31 |
+
) from None
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def __str__(dtype):
|
| 35 |
+
if dtype.fields is not None:
|
| 36 |
+
return _struct_str(dtype, include_align=True)
|
| 37 |
+
elif dtype.subdtype:
|
| 38 |
+
return _subarray_str(dtype)
|
| 39 |
+
elif issubclass(dtype.type, np.flexible) or not dtype.isnative:
|
| 40 |
+
return dtype.str
|
| 41 |
+
else:
|
| 42 |
+
return dtype.name
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def __repr__(dtype):
|
| 46 |
+
arg_str = _construction_repr(dtype, include_align=False)
|
| 47 |
+
if dtype.isalignedstruct:
|
| 48 |
+
arg_str = arg_str + ", align=True"
|
| 49 |
+
return "dtype({})".format(arg_str)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _unpack_field(dtype, offset, title=None):
|
| 53 |
+
"""
|
| 54 |
+
Helper function to normalize the items in dtype.fields.
|
| 55 |
+
|
| 56 |
+
Call as:
|
| 57 |
+
|
| 58 |
+
dtype, offset, title = _unpack_field(*dtype.fields[name])
|
| 59 |
+
"""
|
| 60 |
+
return dtype, offset, title
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _isunsized(dtype):
|
| 64 |
+
# PyDataType_ISUNSIZED
|
| 65 |
+
return dtype.itemsize == 0
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def _construction_repr(dtype, include_align=False, short=False):
|
| 69 |
+
"""
|
| 70 |
+
Creates a string repr of the dtype, excluding the 'dtype()' part
|
| 71 |
+
surrounding the object. This object may be a string, a list, or
|
| 72 |
+
a dict depending on the nature of the dtype. This
|
| 73 |
+
is the object passed as the first parameter to the dtype
|
| 74 |
+
constructor, and if no additional constructor parameters are
|
| 75 |
+
given, will reproduce the exact memory layout.
|
| 76 |
+
|
| 77 |
+
Parameters
|
| 78 |
+
----------
|
| 79 |
+
short : bool
|
| 80 |
+
If true, this creates a shorter repr using 'kind' and 'itemsize',
|
| 81 |
+
instead of the longer type name.
|
| 82 |
+
|
| 83 |
+
include_align : bool
|
| 84 |
+
If true, this includes the 'align=True' parameter
|
| 85 |
+
inside the struct dtype construction dict when needed. Use this flag
|
| 86 |
+
if you want a proper repr string without the 'dtype()' part around it.
|
| 87 |
+
|
| 88 |
+
If false, this does not preserve the
|
| 89 |
+
'align=True' parameter or sticky NPY_ALIGNED_STRUCT flag for
|
| 90 |
+
struct arrays like the regular repr does, because the 'align'
|
| 91 |
+
flag is not part of first dtype constructor parameter. This
|
| 92 |
+
mode is intended for a full 'repr', where the 'align=True' is
|
| 93 |
+
provided as the second parameter.
|
| 94 |
+
"""
|
| 95 |
+
if dtype.fields is not None:
|
| 96 |
+
return _struct_str(dtype, include_align=include_align)
|
| 97 |
+
elif dtype.subdtype:
|
| 98 |
+
return _subarray_str(dtype)
|
| 99 |
+
else:
|
| 100 |
+
return _scalar_str(dtype, short=short)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def _scalar_str(dtype, short):
|
| 104 |
+
byteorder = _byte_order_str(dtype)
|
| 105 |
+
|
| 106 |
+
if dtype.type == np.bool:
|
| 107 |
+
if short:
|
| 108 |
+
return "'?'"
|
| 109 |
+
else:
|
| 110 |
+
return "'bool'"
|
| 111 |
+
|
| 112 |
+
elif dtype.type == np.object_:
|
| 113 |
+
# The object reference may be different sizes on different
|
| 114 |
+
# platforms, so it should never include the itemsize here.
|
| 115 |
+
return "'O'"
|
| 116 |
+
|
| 117 |
+
elif dtype.type == np.bytes_:
|
| 118 |
+
if _isunsized(dtype):
|
| 119 |
+
return "'S'"
|
| 120 |
+
else:
|
| 121 |
+
return "'S%d'" % dtype.itemsize
|
| 122 |
+
|
| 123 |
+
elif dtype.type == np.str_:
|
| 124 |
+
if _isunsized(dtype):
|
| 125 |
+
return "'%sU'" % byteorder
|
| 126 |
+
else:
|
| 127 |
+
return "'%sU%d'" % (byteorder, dtype.itemsize / 4)
|
| 128 |
+
|
| 129 |
+
elif dtype.type == str:
|
| 130 |
+
return "'T'"
|
| 131 |
+
|
| 132 |
+
elif not type(dtype)._legacy:
|
| 133 |
+
return f"'{byteorder}{type(dtype).__name__}{dtype.itemsize * 8}'"
|
| 134 |
+
|
| 135 |
+
# unlike the other types, subclasses of void are preserved - but
|
| 136 |
+
# historically the repr does not actually reveal the subclass
|
| 137 |
+
elif issubclass(dtype.type, np.void):
|
| 138 |
+
if _isunsized(dtype):
|
| 139 |
+
return "'V'"
|
| 140 |
+
else:
|
| 141 |
+
return "'V%d'" % dtype.itemsize
|
| 142 |
+
|
| 143 |
+
elif dtype.type == np.datetime64:
|
| 144 |
+
return "'%sM8%s'" % (byteorder, _datetime_metadata_str(dtype))
|
| 145 |
+
|
| 146 |
+
elif dtype.type == np.timedelta64:
|
| 147 |
+
return "'%sm8%s'" % (byteorder, _datetime_metadata_str(dtype))
|
| 148 |
+
|
| 149 |
+
elif np.issubdtype(dtype, np.number):
|
| 150 |
+
# Short repr with endianness, like '<f8'
|
| 151 |
+
if short or dtype.byteorder not in ('=', '|'):
|
| 152 |
+
return "'%s%c%d'" % (byteorder, dtype.kind, dtype.itemsize)
|
| 153 |
+
|
| 154 |
+
# Longer repr, like 'float64'
|
| 155 |
+
else:
|
| 156 |
+
return "'%s%d'" % (_kind_name(dtype), 8*dtype.itemsize)
|
| 157 |
+
|
| 158 |
+
elif dtype.isbuiltin == 2:
|
| 159 |
+
return dtype.type.__name__
|
| 160 |
+
|
| 161 |
+
else:
|
| 162 |
+
raise RuntimeError(
|
| 163 |
+
"Internal error: NumPy dtype unrecognized type number")
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def _byte_order_str(dtype):
|
| 167 |
+
""" Normalize byteorder to '<' or '>' """
|
| 168 |
+
# hack to obtain the native and swapped byte order characters
|
| 169 |
+
swapped = np.dtype(int).newbyteorder('S')
|
| 170 |
+
native = swapped.newbyteorder('S')
|
| 171 |
+
|
| 172 |
+
byteorder = dtype.byteorder
|
| 173 |
+
if byteorder == '=':
|
| 174 |
+
return native.byteorder
|
| 175 |
+
if byteorder == 'S':
|
| 176 |
+
# TODO: this path can never be reached
|
| 177 |
+
return swapped.byteorder
|
| 178 |
+
elif byteorder == '|':
|
| 179 |
+
return ''
|
| 180 |
+
else:
|
| 181 |
+
return byteorder
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
def _datetime_metadata_str(dtype):
|
| 185 |
+
# TODO: this duplicates the C metastr_to_unicode functionality
|
| 186 |
+
unit, count = np.datetime_data(dtype)
|
| 187 |
+
if unit == 'generic':
|
| 188 |
+
return ''
|
| 189 |
+
elif count == 1:
|
| 190 |
+
return '[{}]'.format(unit)
|
| 191 |
+
else:
|
| 192 |
+
return '[{}{}]'.format(count, unit)
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def _struct_dict_str(dtype, includealignedflag):
|
| 196 |
+
# unpack the fields dictionary into ls
|
| 197 |
+
names = dtype.names
|
| 198 |
+
fld_dtypes = []
|
| 199 |
+
offsets = []
|
| 200 |
+
titles = []
|
| 201 |
+
for name in names:
|
| 202 |
+
fld_dtype, offset, title = _unpack_field(*dtype.fields[name])
|
| 203 |
+
fld_dtypes.append(fld_dtype)
|
| 204 |
+
offsets.append(offset)
|
| 205 |
+
titles.append(title)
|
| 206 |
+
|
| 207 |
+
# Build up a string to make the dictionary
|
| 208 |
+
|
| 209 |
+
if np._core.arrayprint._get_legacy_print_mode() <= 121:
|
| 210 |
+
colon = ":"
|
| 211 |
+
fieldsep = ","
|
| 212 |
+
else:
|
| 213 |
+
colon = ": "
|
| 214 |
+
fieldsep = ", "
|
| 215 |
+
|
| 216 |
+
# First, the names
|
| 217 |
+
ret = "{'names'%s[" % colon
|
| 218 |
+
ret += fieldsep.join(repr(name) for name in names)
|
| 219 |
+
|
| 220 |
+
# Second, the formats
|
| 221 |
+
ret += "], 'formats'%s[" % colon
|
| 222 |
+
ret += fieldsep.join(
|
| 223 |
+
_construction_repr(fld_dtype, short=True) for fld_dtype in fld_dtypes)
|
| 224 |
+
|
| 225 |
+
# Third, the offsets
|
| 226 |
+
ret += "], 'offsets'%s[" % colon
|
| 227 |
+
ret += fieldsep.join("%d" % offset for offset in offsets)
|
| 228 |
+
|
| 229 |
+
# Fourth, the titles
|
| 230 |
+
if any(title is not None for title in titles):
|
| 231 |
+
ret += "], 'titles'%s[" % colon
|
| 232 |
+
ret += fieldsep.join(repr(title) for title in titles)
|
| 233 |
+
|
| 234 |
+
# Fifth, the itemsize
|
| 235 |
+
ret += "], 'itemsize'%s%d" % (colon, dtype.itemsize)
|
| 236 |
+
|
| 237 |
+
if (includealignedflag and dtype.isalignedstruct):
|
| 238 |
+
# Finally, the aligned flag
|
| 239 |
+
ret += ", 'aligned'%sTrue}" % colon
|
| 240 |
+
else:
|
| 241 |
+
ret += "}"
|
| 242 |
+
|
| 243 |
+
return ret
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def _aligned_offset(offset, alignment):
|
| 247 |
+
# round up offset:
|
| 248 |
+
return - (-offset // alignment) * alignment
|
| 249 |
+
|
| 250 |
+
|
| 251 |
+
def _is_packed(dtype):
|
| 252 |
+
"""
|
| 253 |
+
Checks whether the structured data type in 'dtype'
|
| 254 |
+
has a simple layout, where all the fields are in order,
|
| 255 |
+
and follow each other with no alignment padding.
|
| 256 |
+
|
| 257 |
+
When this returns true, the dtype can be reconstructed
|
| 258 |
+
from a list of the field names and dtypes with no additional
|
| 259 |
+
dtype parameters.
|
| 260 |
+
|
| 261 |
+
Duplicates the C `is_dtype_struct_simple_unaligned_layout` function.
|
| 262 |
+
"""
|
| 263 |
+
align = dtype.isalignedstruct
|
| 264 |
+
max_alignment = 1
|
| 265 |
+
total_offset = 0
|
| 266 |
+
for name in dtype.names:
|
| 267 |
+
fld_dtype, fld_offset, title = _unpack_field(*dtype.fields[name])
|
| 268 |
+
|
| 269 |
+
if align:
|
| 270 |
+
total_offset = _aligned_offset(total_offset, fld_dtype.alignment)
|
| 271 |
+
max_alignment = max(max_alignment, fld_dtype.alignment)
|
| 272 |
+
|
| 273 |
+
if fld_offset != total_offset:
|
| 274 |
+
return False
|
| 275 |
+
total_offset += fld_dtype.itemsize
|
| 276 |
+
|
| 277 |
+
if align:
|
| 278 |
+
total_offset = _aligned_offset(total_offset, max_alignment)
|
| 279 |
+
|
| 280 |
+
return total_offset == dtype.itemsize
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
def _struct_list_str(dtype):
|
| 284 |
+
items = []
|
| 285 |
+
for name in dtype.names:
|
| 286 |
+
fld_dtype, fld_offset, title = _unpack_field(*dtype.fields[name])
|
| 287 |
+
|
| 288 |
+
item = "("
|
| 289 |
+
if title is not None:
|
| 290 |
+
item += "({!r}, {!r}), ".format(title, name)
|
| 291 |
+
else:
|
| 292 |
+
item += "{!r}, ".format(name)
|
| 293 |
+
# Special case subarray handling here
|
| 294 |
+
if fld_dtype.subdtype is not None:
|
| 295 |
+
base, shape = fld_dtype.subdtype
|
| 296 |
+
item += "{}, {}".format(
|
| 297 |
+
_construction_repr(base, short=True),
|
| 298 |
+
shape
|
| 299 |
+
)
|
| 300 |
+
else:
|
| 301 |
+
item += _construction_repr(fld_dtype, short=True)
|
| 302 |
+
|
| 303 |
+
item += ")"
|
| 304 |
+
items.append(item)
|
| 305 |
+
|
| 306 |
+
return "[" + ", ".join(items) + "]"
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
def _struct_str(dtype, include_align):
|
| 310 |
+
# The list str representation can't include the 'align=' flag,
|
| 311 |
+
# so if it is requested and the struct has the aligned flag set,
|
| 312 |
+
# we must use the dict str instead.
|
| 313 |
+
if not (include_align and dtype.isalignedstruct) and _is_packed(dtype):
|
| 314 |
+
sub = _struct_list_str(dtype)
|
| 315 |
+
|
| 316 |
+
else:
|
| 317 |
+
sub = _struct_dict_str(dtype, include_align)
|
| 318 |
+
|
| 319 |
+
# If the data type isn't the default, void, show it
|
| 320 |
+
if dtype.type != np.void:
|
| 321 |
+
return "({t.__module__}.{t.__name__}, {f})".format(t=dtype.type, f=sub)
|
| 322 |
+
else:
|
| 323 |
+
return sub
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def _subarray_str(dtype):
|
| 327 |
+
base, shape = dtype.subdtype
|
| 328 |
+
return "({}, {})".format(
|
| 329 |
+
_construction_repr(base, short=True),
|
| 330 |
+
shape
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
def _name_includes_bit_suffix(dtype):
|
| 335 |
+
if dtype.type == np.object_:
|
| 336 |
+
# pointer size varies by system, best to omit it
|
| 337 |
+
return False
|
| 338 |
+
elif dtype.type == np.bool:
|
| 339 |
+
# implied
|
| 340 |
+
return False
|
| 341 |
+
elif dtype.type is None:
|
| 342 |
+
return True
|
| 343 |
+
elif np.issubdtype(dtype, np.flexible) and _isunsized(dtype):
|
| 344 |
+
# unspecified
|
| 345 |
+
return False
|
| 346 |
+
else:
|
| 347 |
+
return True
|
| 348 |
+
|
| 349 |
+
|
| 350 |
+
def _name_get(dtype):
|
| 351 |
+
# provides dtype.name.__get__, documented as returning a "bit name"
|
| 352 |
+
|
| 353 |
+
if dtype.isbuiltin == 2:
|
| 354 |
+
# user dtypes don't promise to do anything special
|
| 355 |
+
return dtype.type.__name__
|
| 356 |
+
|
| 357 |
+
if not type(dtype)._legacy:
|
| 358 |
+
name = type(dtype).__name__
|
| 359 |
+
|
| 360 |
+
elif issubclass(dtype.type, np.void):
|
| 361 |
+
# historically, void subclasses preserve their name, eg `record64`
|
| 362 |
+
name = dtype.type.__name__
|
| 363 |
+
else:
|
| 364 |
+
name = _kind_name(dtype)
|
| 365 |
+
|
| 366 |
+
# append bit counts
|
| 367 |
+
if _name_includes_bit_suffix(dtype):
|
| 368 |
+
name += "{}".format(dtype.itemsize * 8)
|
| 369 |
+
|
| 370 |
+
# append metadata to datetimes
|
| 371 |
+
if dtype.type in (np.datetime64, np.timedelta64):
|
| 372 |
+
name += _datetime_metadata_str(dtype)
|
| 373 |
+
|
| 374 |
+
return name
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype.pyi
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Any, Final, TypeAlias, TypedDict, overload, type_check_only
|
| 2 |
+
from typing import Literal as L
|
| 3 |
+
|
| 4 |
+
from typing_extensions import ReadOnly, TypeVar
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
###
|
| 9 |
+
|
| 10 |
+
_T = TypeVar("_T")
|
| 11 |
+
|
| 12 |
+
_Name: TypeAlias = L["uint", "int", "complex", "float", "bool", "void", "object", "datetime", "timedelta", "bytes", "str"]
|
| 13 |
+
|
| 14 |
+
@type_check_only
|
| 15 |
+
class _KindToStemType(TypedDict):
|
| 16 |
+
u: ReadOnly[L["uint"]]
|
| 17 |
+
i: ReadOnly[L["int"]]
|
| 18 |
+
c: ReadOnly[L["complex"]]
|
| 19 |
+
f: ReadOnly[L["float"]]
|
| 20 |
+
b: ReadOnly[L["bool"]]
|
| 21 |
+
V: ReadOnly[L["void"]]
|
| 22 |
+
O: ReadOnly[L["object"]]
|
| 23 |
+
M: ReadOnly[L["datetime"]]
|
| 24 |
+
m: ReadOnly[L["timedelta"]]
|
| 25 |
+
S: ReadOnly[L["bytes"]]
|
| 26 |
+
U: ReadOnly[L["str"]]
|
| 27 |
+
|
| 28 |
+
###
|
| 29 |
+
|
| 30 |
+
_kind_to_stem: Final[_KindToStemType] = ...
|
| 31 |
+
|
| 32 |
+
#
|
| 33 |
+
def _kind_name(dtype: np.dtype[Any]) -> _Name: ...
|
| 34 |
+
def __str__(dtype: np.dtype[Any]) -> str: ...
|
| 35 |
+
def __repr__(dtype: np.dtype[Any]) -> str: ...
|
| 36 |
+
|
| 37 |
+
#
|
| 38 |
+
def _isunsized(dtype: np.dtype[Any]) -> bool: ...
|
| 39 |
+
def _is_packed(dtype: np.dtype[Any]) -> bool: ...
|
| 40 |
+
def _name_includes_bit_suffix(dtype: np.dtype[Any]) -> bool: ...
|
| 41 |
+
|
| 42 |
+
#
|
| 43 |
+
def _construction_repr(dtype: np.dtype[Any], include_align: bool = False, short: bool = False) -> str: ...
|
| 44 |
+
def _scalar_str(dtype: np.dtype[Any], short: bool) -> str: ...
|
| 45 |
+
def _byte_order_str(dtype: np.dtype[Any]) -> str: ...
|
| 46 |
+
def _datetime_metadata_str(dtype: np.dtype[Any]) -> str: ...
|
| 47 |
+
def _struct_dict_str(dtype: np.dtype[Any], includealignedflag: bool) -> str: ...
|
| 48 |
+
def _struct_list_str(dtype: np.dtype[Any]) -> str: ...
|
| 49 |
+
def _struct_str(dtype: np.dtype[Any], include_align: bool) -> str: ...
|
| 50 |
+
def _subarray_str(dtype: np.dtype[Any]) -> str: ...
|
| 51 |
+
def _name_get(dtype: np.dtype[Any]) -> str: ...
|
| 52 |
+
|
| 53 |
+
#
|
| 54 |
+
@overload
|
| 55 |
+
def _unpack_field(dtype: np.dtype[Any], offset: int, title: _T) -> tuple[np.dtype[Any], int, _T]: ...
|
| 56 |
+
@overload
|
| 57 |
+
def _unpack_field(dtype: np.dtype[Any], offset: int, title: None = None) -> tuple[np.dtype[Any], int, None]: ...
|
| 58 |
+
def _aligned_offset(offset: int, alignment: int) -> int: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype_ctypes.py
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Conversion from ctypes to dtype.
|
| 3 |
+
|
| 4 |
+
In an ideal world, we could achieve this through the PEP3118 buffer protocol,
|
| 5 |
+
something like::
|
| 6 |
+
|
| 7 |
+
def dtype_from_ctypes_type(t):
|
| 8 |
+
# needed to ensure that the shape of `t` is within memoryview.format
|
| 9 |
+
class DummyStruct(ctypes.Structure):
|
| 10 |
+
_fields_ = [('a', t)]
|
| 11 |
+
|
| 12 |
+
# empty to avoid memory allocation
|
| 13 |
+
ctype_0 = (DummyStruct * 0)()
|
| 14 |
+
mv = memoryview(ctype_0)
|
| 15 |
+
|
| 16 |
+
# convert the struct, and slice back out the field
|
| 17 |
+
return _dtype_from_pep3118(mv.format)['a']
|
| 18 |
+
|
| 19 |
+
Unfortunately, this fails because:
|
| 20 |
+
|
| 21 |
+
* ctypes cannot handle length-0 arrays with PEP3118 (bpo-32782)
|
| 22 |
+
* PEP3118 cannot represent unions, but both numpy and ctypes can
|
| 23 |
+
* ctypes cannot handle big-endian structs with PEP3118 (bpo-32780)
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
# We delay-import ctypes for distributions that do not include it.
|
| 27 |
+
# While this module is not used unless the user passes in ctypes
|
| 28 |
+
# members, it is eagerly imported from numpy/_core/__init__.py.
|
| 29 |
+
import numpy as np
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def _from_ctypes_array(t):
|
| 33 |
+
return np.dtype((dtype_from_ctypes_type(t._type_), (t._length_,)))
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def _from_ctypes_structure(t):
|
| 37 |
+
for item in t._fields_:
|
| 38 |
+
if len(item) > 2:
|
| 39 |
+
raise TypeError(
|
| 40 |
+
"ctypes bitfields have no dtype equivalent")
|
| 41 |
+
|
| 42 |
+
if hasattr(t, "_pack_"):
|
| 43 |
+
import ctypes
|
| 44 |
+
formats = []
|
| 45 |
+
offsets = []
|
| 46 |
+
names = []
|
| 47 |
+
current_offset = 0
|
| 48 |
+
for fname, ftyp in t._fields_:
|
| 49 |
+
names.append(fname)
|
| 50 |
+
formats.append(dtype_from_ctypes_type(ftyp))
|
| 51 |
+
# Each type has a default offset, this is platform dependent
|
| 52 |
+
# for some types.
|
| 53 |
+
effective_pack = min(t._pack_, ctypes.alignment(ftyp))
|
| 54 |
+
current_offset = (
|
| 55 |
+
(current_offset + effective_pack - 1) // effective_pack
|
| 56 |
+
) * effective_pack
|
| 57 |
+
offsets.append(current_offset)
|
| 58 |
+
current_offset += ctypes.sizeof(ftyp)
|
| 59 |
+
|
| 60 |
+
return np.dtype(dict(
|
| 61 |
+
formats=formats,
|
| 62 |
+
offsets=offsets,
|
| 63 |
+
names=names,
|
| 64 |
+
itemsize=ctypes.sizeof(t)))
|
| 65 |
+
else:
|
| 66 |
+
fields = []
|
| 67 |
+
for fname, ftyp in t._fields_:
|
| 68 |
+
fields.append((fname, dtype_from_ctypes_type(ftyp)))
|
| 69 |
+
|
| 70 |
+
# by default, ctypes structs are aligned
|
| 71 |
+
return np.dtype(fields, align=True)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def _from_ctypes_scalar(t):
|
| 75 |
+
"""
|
| 76 |
+
Return the dtype type with endianness included if it's the case
|
| 77 |
+
"""
|
| 78 |
+
if getattr(t, '__ctype_be__', None) is t:
|
| 79 |
+
return np.dtype('>' + t._type_)
|
| 80 |
+
elif getattr(t, '__ctype_le__', None) is t:
|
| 81 |
+
return np.dtype('<' + t._type_)
|
| 82 |
+
else:
|
| 83 |
+
return np.dtype(t._type_)
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def _from_ctypes_union(t):
|
| 87 |
+
import ctypes
|
| 88 |
+
formats = []
|
| 89 |
+
offsets = []
|
| 90 |
+
names = []
|
| 91 |
+
for fname, ftyp in t._fields_:
|
| 92 |
+
names.append(fname)
|
| 93 |
+
formats.append(dtype_from_ctypes_type(ftyp))
|
| 94 |
+
offsets.append(0) # Union fields are offset to 0
|
| 95 |
+
|
| 96 |
+
return np.dtype(dict(
|
| 97 |
+
formats=formats,
|
| 98 |
+
offsets=offsets,
|
| 99 |
+
names=names,
|
| 100 |
+
itemsize=ctypes.sizeof(t)))
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def dtype_from_ctypes_type(t):
|
| 104 |
+
"""
|
| 105 |
+
Construct a dtype object from a ctypes type
|
| 106 |
+
"""
|
| 107 |
+
import _ctypes
|
| 108 |
+
if issubclass(t, _ctypes.Array):
|
| 109 |
+
return _from_ctypes_array(t)
|
| 110 |
+
elif issubclass(t, _ctypes._Pointer):
|
| 111 |
+
raise TypeError("ctypes pointers have no dtype equivalent")
|
| 112 |
+
elif issubclass(t, _ctypes.Structure):
|
| 113 |
+
return _from_ctypes_structure(t)
|
| 114 |
+
elif issubclass(t, _ctypes.Union):
|
| 115 |
+
return _from_ctypes_union(t)
|
| 116 |
+
elif isinstance(getattr(t, '_type_', None), str):
|
| 117 |
+
return _from_ctypes_scalar(t)
|
| 118 |
+
else:
|
| 119 |
+
raise NotImplementedError(
|
| 120 |
+
"Unknown ctypes type {}".format(t.__name__))
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_dtype_ctypes.pyi
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import _ctypes
|
| 2 |
+
import ctypes as ct
|
| 3 |
+
from typing import Any, overload
|
| 4 |
+
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
#
|
| 8 |
+
@overload
|
| 9 |
+
def dtype_from_ctypes_type(t: type[_ctypes.Array[Any] | _ctypes.Structure]) -> np.dtype[np.void]: ...
|
| 10 |
+
@overload
|
| 11 |
+
def dtype_from_ctypes_type(t: type[ct.c_bool]) -> np.dtype[np.bool]: ...
|
| 12 |
+
@overload
|
| 13 |
+
def dtype_from_ctypes_type(t: type[ct.c_int8 | ct.c_byte]) -> np.dtype[np.int8]: ...
|
| 14 |
+
@overload
|
| 15 |
+
def dtype_from_ctypes_type(t: type[ct.c_uint8 | ct.c_ubyte]) -> np.dtype[np.uint8]: ...
|
| 16 |
+
@overload
|
| 17 |
+
def dtype_from_ctypes_type(t: type[ct.c_int16 | ct.c_short]) -> np.dtype[np.int16]: ...
|
| 18 |
+
@overload
|
| 19 |
+
def dtype_from_ctypes_type(t: type[ct.c_uint16 | ct.c_ushort]) -> np.dtype[np.uint16]: ...
|
| 20 |
+
@overload
|
| 21 |
+
def dtype_from_ctypes_type(t: type[ct.c_int32 | ct.c_int]) -> np.dtype[np.int32]: ...
|
| 22 |
+
@overload
|
| 23 |
+
def dtype_from_ctypes_type(t: type[ct.c_uint32 | ct.c_uint]) -> np.dtype[np.uint32]: ...
|
| 24 |
+
@overload
|
| 25 |
+
def dtype_from_ctypes_type(t: type[ct.c_ssize_t | ct.c_long]) -> np.dtype[np.int32 | np.int64]: ...
|
| 26 |
+
@overload
|
| 27 |
+
def dtype_from_ctypes_type(t: type[ct.c_size_t | ct.c_ulong]) -> np.dtype[np.uint32 | np.uint64]: ...
|
| 28 |
+
@overload
|
| 29 |
+
def dtype_from_ctypes_type(t: type[ct.c_int64 | ct.c_longlong]) -> np.dtype[np.int64]: ...
|
| 30 |
+
@overload
|
| 31 |
+
def dtype_from_ctypes_type(t: type[ct.c_uint64 | ct.c_ulonglong]) -> np.dtype[np.uint64]: ...
|
| 32 |
+
@overload
|
| 33 |
+
def dtype_from_ctypes_type(t: type[ct.c_float]) -> np.dtype[np.float32]: ...
|
| 34 |
+
@overload
|
| 35 |
+
def dtype_from_ctypes_type(t: type[ct.c_double]) -> np.dtype[np.float64]: ...
|
| 36 |
+
@overload
|
| 37 |
+
def dtype_from_ctypes_type(t: type[ct.c_longdouble]) -> np.dtype[np.longdouble]: ...
|
| 38 |
+
@overload
|
| 39 |
+
def dtype_from_ctypes_type(t: type[ct.c_char]) -> np.dtype[np.bytes_]: ...
|
| 40 |
+
@overload
|
| 41 |
+
def dtype_from_ctypes_type(t: type[ct.py_object[Any]]) -> np.dtype[np.object_]: ...
|
| 42 |
+
|
| 43 |
+
# NOTE: the complex ctypes on python>=3.14 are not yet supported at runtim, see
|
| 44 |
+
# https://github.com/numpy/numpy/issues/28360
|
| 45 |
+
|
| 46 |
+
#
|
| 47 |
+
def _from_ctypes_array(t: type[_ctypes.Array[Any]]) -> np.dtype[np.void]: ...
|
| 48 |
+
def _from_ctypes_structure(t: type[_ctypes.Structure]) -> np.dtype[np.void]: ...
|
| 49 |
+
def _from_ctypes_union(t: type[_ctypes.Union]) -> np.dtype[np.void]: ...
|
| 50 |
+
|
| 51 |
+
# keep in sync with `dtype_from_ctypes_type` (minus the first overload)
|
| 52 |
+
@overload
|
| 53 |
+
def _from_ctypes_scalar(t: type[ct.c_bool]) -> np.dtype[np.bool]: ...
|
| 54 |
+
@overload
|
| 55 |
+
def _from_ctypes_scalar(t: type[ct.c_int8 | ct.c_byte]) -> np.dtype[np.int8]: ...
|
| 56 |
+
@overload
|
| 57 |
+
def _from_ctypes_scalar(t: type[ct.c_uint8 | ct.c_ubyte]) -> np.dtype[np.uint8]: ...
|
| 58 |
+
@overload
|
| 59 |
+
def _from_ctypes_scalar(t: type[ct.c_int16 | ct.c_short]) -> np.dtype[np.int16]: ...
|
| 60 |
+
@overload
|
| 61 |
+
def _from_ctypes_scalar(t: type[ct.c_uint16 | ct.c_ushort]) -> np.dtype[np.uint16]: ...
|
| 62 |
+
@overload
|
| 63 |
+
def _from_ctypes_scalar(t: type[ct.c_int32 | ct.c_int]) -> np.dtype[np.int32]: ...
|
| 64 |
+
@overload
|
| 65 |
+
def _from_ctypes_scalar(t: type[ct.c_uint32 | ct.c_uint]) -> np.dtype[np.uint32]: ...
|
| 66 |
+
@overload
|
| 67 |
+
def _from_ctypes_scalar(t: type[ct.c_ssize_t | ct.c_long]) -> np.dtype[np.int32 | np.int64]: ...
|
| 68 |
+
@overload
|
| 69 |
+
def _from_ctypes_scalar(t: type[ct.c_size_t | ct.c_ulong]) -> np.dtype[np.uint32 | np.uint64]: ...
|
| 70 |
+
@overload
|
| 71 |
+
def _from_ctypes_scalar(t: type[ct.c_int64 | ct.c_longlong]) -> np.dtype[np.int64]: ...
|
| 72 |
+
@overload
|
| 73 |
+
def _from_ctypes_scalar(t: type[ct.c_uint64 | ct.c_ulonglong]) -> np.dtype[np.uint64]: ...
|
| 74 |
+
@overload
|
| 75 |
+
def _from_ctypes_scalar(t: type[ct.c_float]) -> np.dtype[np.float32]: ...
|
| 76 |
+
@overload
|
| 77 |
+
def _from_ctypes_scalar(t: type[ct.c_double]) -> np.dtype[np.float64]: ...
|
| 78 |
+
@overload
|
| 79 |
+
def _from_ctypes_scalar(t: type[ct.c_longdouble]) -> np.dtype[np.longdouble]: ...
|
| 80 |
+
@overload
|
| 81 |
+
def _from_ctypes_scalar(t: type[ct.c_char]) -> np.dtype[np.bytes_]: ...
|
| 82 |
+
@overload
|
| 83 |
+
def _from_ctypes_scalar(t: type[ct.py_object[Any]]) -> np.dtype[np.object_]: ...
|
pythonProject/.ven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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Various richly-typed exceptions, that also help us deal with string formatting
|
| 3 |
+
in python where it's easier.
|
| 4 |
+
|
| 5 |
+
By putting the formatting in `__str__`, we also avoid paying the cost for
|
| 6 |
+
users who silence the exceptions.
|
| 7 |
+
"""
|
| 8 |
+
from .._utils import set_module
|
| 9 |
+
|
| 10 |
+
def _unpack_tuple(tup):
|
| 11 |
+
if len(tup) == 1:
|
| 12 |
+
return tup[0]
|
| 13 |
+
else:
|
| 14 |
+
return tup
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def _display_as_base(cls):
|
| 18 |
+
"""
|
| 19 |
+
A decorator that makes an exception class look like its base.
|
| 20 |
+
|
| 21 |
+
We use this to hide subclasses that are implementation details - the user
|
| 22 |
+
should catch the base type, which is what the traceback will show them.
|
| 23 |
+
|
| 24 |
+
Classes decorated with this decorator are subject to removal without a
|
| 25 |
+
deprecation warning.
|
| 26 |
+
"""
|
| 27 |
+
assert issubclass(cls, Exception)
|
| 28 |
+
cls.__name__ = cls.__base__.__name__
|
| 29 |
+
return cls
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
class UFuncTypeError(TypeError):
|
| 33 |
+
""" Base class for all ufunc exceptions """
|
| 34 |
+
def __init__(self, ufunc):
|
| 35 |
+
self.ufunc = ufunc
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@_display_as_base
|
| 39 |
+
class _UFuncNoLoopError(UFuncTypeError):
|
| 40 |
+
""" Thrown when a ufunc loop cannot be found """
|
| 41 |
+
def __init__(self, ufunc, dtypes):
|
| 42 |
+
super().__init__(ufunc)
|
| 43 |
+
self.dtypes = tuple(dtypes)
|
| 44 |
+
|
| 45 |
+
def __str__(self):
|
| 46 |
+
return (
|
| 47 |
+
"ufunc {!r} did not contain a loop with signature matching types "
|
| 48 |
+
"{!r} -> {!r}"
|
| 49 |
+
).format(
|
| 50 |
+
self.ufunc.__name__,
|
| 51 |
+
_unpack_tuple(self.dtypes[:self.ufunc.nin]),
|
| 52 |
+
_unpack_tuple(self.dtypes[self.ufunc.nin:])
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
@_display_as_base
|
| 57 |
+
class _UFuncBinaryResolutionError(_UFuncNoLoopError):
|
| 58 |
+
""" Thrown when a binary resolution fails """
|
| 59 |
+
def __init__(self, ufunc, dtypes):
|
| 60 |
+
super().__init__(ufunc, dtypes)
|
| 61 |
+
assert len(self.dtypes) == 2
|
| 62 |
+
|
| 63 |
+
def __str__(self):
|
| 64 |
+
return (
|
| 65 |
+
"ufunc {!r} cannot use operands with types {!r} and {!r}"
|
| 66 |
+
).format(
|
| 67 |
+
self.ufunc.__name__, *self.dtypes
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
@_display_as_base
|
| 72 |
+
class _UFuncCastingError(UFuncTypeError):
|
| 73 |
+
def __init__(self, ufunc, casting, from_, to):
|
| 74 |
+
super().__init__(ufunc)
|
| 75 |
+
self.casting = casting
|
| 76 |
+
self.from_ = from_
|
| 77 |
+
self.to = to
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@_display_as_base
|
| 81 |
+
class _UFuncInputCastingError(_UFuncCastingError):
|
| 82 |
+
""" Thrown when a ufunc input cannot be casted """
|
| 83 |
+
def __init__(self, ufunc, casting, from_, to, i):
|
| 84 |
+
super().__init__(ufunc, casting, from_, to)
|
| 85 |
+
self.in_i = i
|
| 86 |
+
|
| 87 |
+
def __str__(self):
|
| 88 |
+
# only show the number if more than one input exists
|
| 89 |
+
i_str = "{} ".format(self.in_i) if self.ufunc.nin != 1 else ""
|
| 90 |
+
return (
|
| 91 |
+
"Cannot cast ufunc {!r} input {}from {!r} to {!r} with casting "
|
| 92 |
+
"rule {!r}"
|
| 93 |
+
).format(
|
| 94 |
+
self.ufunc.__name__, i_str, self.from_, self.to, self.casting
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
@_display_as_base
|
| 99 |
+
class _UFuncOutputCastingError(_UFuncCastingError):
|
| 100 |
+
""" Thrown when a ufunc output cannot be casted """
|
| 101 |
+
def __init__(self, ufunc, casting, from_, to, i):
|
| 102 |
+
super().__init__(ufunc, casting, from_, to)
|
| 103 |
+
self.out_i = i
|
| 104 |
+
|
| 105 |
+
def __str__(self):
|
| 106 |
+
# only show the number if more than one output exists
|
| 107 |
+
i_str = "{} ".format(self.out_i) if self.ufunc.nout != 1 else ""
|
| 108 |
+
return (
|
| 109 |
+
"Cannot cast ufunc {!r} output {}from {!r} to {!r} with casting "
|
| 110 |
+
"rule {!r}"
|
| 111 |
+
).format(
|
| 112 |
+
self.ufunc.__name__, i_str, self.from_, self.to, self.casting
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
@_display_as_base
|
| 117 |
+
class _ArrayMemoryError(MemoryError):
|
| 118 |
+
""" Thrown when an array cannot be allocated"""
|
| 119 |
+
def __init__(self, shape, dtype):
|
| 120 |
+
self.shape = shape
|
| 121 |
+
self.dtype = dtype
|
| 122 |
+
|
| 123 |
+
@property
|
| 124 |
+
def _total_size(self):
|
| 125 |
+
num_bytes = self.dtype.itemsize
|
| 126 |
+
for dim in self.shape:
|
| 127 |
+
num_bytes *= dim
|
| 128 |
+
return num_bytes
|
| 129 |
+
|
| 130 |
+
@staticmethod
|
| 131 |
+
def _size_to_string(num_bytes):
|
| 132 |
+
""" Convert a number of bytes into a binary size string """
|
| 133 |
+
|
| 134 |
+
# https://en.wikipedia.org/wiki/Binary_prefix
|
| 135 |
+
LOG2_STEP = 10
|
| 136 |
+
STEP = 1024
|
| 137 |
+
units = ['bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB']
|
| 138 |
+
|
| 139 |
+
unit_i = max(num_bytes.bit_length() - 1, 1) // LOG2_STEP
|
| 140 |
+
unit_val = 1 << (unit_i * LOG2_STEP)
|
| 141 |
+
n_units = num_bytes / unit_val
|
| 142 |
+
del unit_val
|
| 143 |
+
|
| 144 |
+
# ensure we pick a unit that is correct after rounding
|
| 145 |
+
if round(n_units) == STEP:
|
| 146 |
+
unit_i += 1
|
| 147 |
+
n_units /= STEP
|
| 148 |
+
|
| 149 |
+
# deal with sizes so large that we don't have units for them
|
| 150 |
+
if unit_i >= len(units):
|
| 151 |
+
new_unit_i = len(units) - 1
|
| 152 |
+
n_units *= 1 << ((unit_i - new_unit_i) * LOG2_STEP)
|
| 153 |
+
unit_i = new_unit_i
|
| 154 |
+
|
| 155 |
+
unit_name = units[unit_i]
|
| 156 |
+
# format with a sensible number of digits
|
| 157 |
+
if unit_i == 0:
|
| 158 |
+
# no decimal point on bytes
|
| 159 |
+
return '{:.0f} {}'.format(n_units, unit_name)
|
| 160 |
+
elif round(n_units) < 1000:
|
| 161 |
+
# 3 significant figures, if none are dropped to the left of the .
|
| 162 |
+
return '{:#.3g} {}'.format(n_units, unit_name)
|
| 163 |
+
else:
|
| 164 |
+
# just give all the digits otherwise
|
| 165 |
+
return '{:#.0f} {}'.format(n_units, unit_name)
|
| 166 |
+
|
| 167 |
+
def __str__(self):
|
| 168 |
+
size_str = self._size_to_string(self._total_size)
|
| 169 |
+
return (
|
| 170 |
+
"Unable to allocate {} for an array with shape {} and data type {}"
|
| 171 |
+
.format(size_str, self.shape, self.dtype)
|
| 172 |
+
)
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_exceptions.pyi
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterable
|
| 2 |
+
from typing import Any, Final, overload
|
| 3 |
+
|
| 4 |
+
from typing_extensions import TypeVar, Unpack
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
from numpy import _CastingKind
|
| 8 |
+
from numpy._utils import set_module as set_module
|
| 9 |
+
|
| 10 |
+
###
|
| 11 |
+
|
| 12 |
+
_T = TypeVar("_T")
|
| 13 |
+
_TupleT = TypeVar("_TupleT", bound=tuple[()] | tuple[Any, Any, Unpack[tuple[Any, ...]]])
|
| 14 |
+
_ExceptionT = TypeVar("_ExceptionT", bound=Exception)
|
| 15 |
+
|
| 16 |
+
###
|
| 17 |
+
|
| 18 |
+
class UFuncTypeError(TypeError):
|
| 19 |
+
ufunc: Final[np.ufunc]
|
| 20 |
+
def __init__(self, /, ufunc: np.ufunc) -> None: ...
|
| 21 |
+
|
| 22 |
+
class _UFuncNoLoopError(UFuncTypeError):
|
| 23 |
+
dtypes: tuple[np.dtype[Any], ...]
|
| 24 |
+
def __init__(self, /, ufunc: np.ufunc, dtypes: Iterable[np.dtype[Any]]) -> None: ...
|
| 25 |
+
|
| 26 |
+
class _UFuncBinaryResolutionError(_UFuncNoLoopError):
|
| 27 |
+
dtypes: tuple[np.dtype[Any], np.dtype[Any]]
|
| 28 |
+
def __init__(self, /, ufunc: np.ufunc, dtypes: Iterable[np.dtype[Any]]) -> None: ...
|
| 29 |
+
|
| 30 |
+
class _UFuncCastingError(UFuncTypeError):
|
| 31 |
+
casting: Final[_CastingKind]
|
| 32 |
+
from_: Final[np.dtype[Any]]
|
| 33 |
+
to: Final[np.dtype[Any]]
|
| 34 |
+
def __init__(self, /, ufunc: np.ufunc, casting: _CastingKind, from_: np.dtype[Any], to: np.dtype[Any]) -> None: ...
|
| 35 |
+
|
| 36 |
+
class _UFuncInputCastingError(_UFuncCastingError):
|
| 37 |
+
in_i: Final[int]
|
| 38 |
+
def __init__(
|
| 39 |
+
self,
|
| 40 |
+
/,
|
| 41 |
+
ufunc: np.ufunc,
|
| 42 |
+
casting: _CastingKind,
|
| 43 |
+
from_: np.dtype[Any],
|
| 44 |
+
to: np.dtype[Any],
|
| 45 |
+
i: int,
|
| 46 |
+
) -> None: ...
|
| 47 |
+
|
| 48 |
+
class _UFuncOutputCastingError(_UFuncCastingError):
|
| 49 |
+
out_i: Final[int]
|
| 50 |
+
def __init__(
|
| 51 |
+
self,
|
| 52 |
+
/,
|
| 53 |
+
ufunc: np.ufunc,
|
| 54 |
+
casting: _CastingKind,
|
| 55 |
+
from_: np.dtype[Any],
|
| 56 |
+
to: np.dtype[Any],
|
| 57 |
+
i: int,
|
| 58 |
+
) -> None: ...
|
| 59 |
+
|
| 60 |
+
class _ArrayMemoryError(MemoryError):
|
| 61 |
+
shape: tuple[int, ...]
|
| 62 |
+
dtype: np.dtype[Any]
|
| 63 |
+
def __init__(self, /, shape: tuple[int, ...], dtype: np.dtype[Any]) -> None: ...
|
| 64 |
+
@property
|
| 65 |
+
def _total_size(self) -> int: ...
|
| 66 |
+
@staticmethod
|
| 67 |
+
def _size_to_string(num_bytes: int) -> str: ...
|
| 68 |
+
|
| 69 |
+
@overload
|
| 70 |
+
def _unpack_tuple(tup: tuple[_T]) -> _T: ...
|
| 71 |
+
@overload
|
| 72 |
+
def _unpack_tuple(tup: _TupleT) -> _TupleT: ...
|
| 73 |
+
def _display_as_base(cls: type[_ExceptionT]) -> type[_ExceptionT]: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_internal.py
ADDED
|
@@ -0,0 +1,963 @@
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
A place for internal code
|
| 3 |
+
|
| 4 |
+
Some things are more easily handled Python.
|
| 5 |
+
|
| 6 |
+
"""
|
| 7 |
+
import ast
|
| 8 |
+
import math
|
| 9 |
+
import re
|
| 10 |
+
import sys
|
| 11 |
+
import warnings
|
| 12 |
+
|
| 13 |
+
from ..exceptions import DTypePromotionError
|
| 14 |
+
from .multiarray import dtype, array, ndarray, promote_types, StringDType
|
| 15 |
+
from numpy import _NoValue
|
| 16 |
+
try:
|
| 17 |
+
import ctypes
|
| 18 |
+
except ImportError:
|
| 19 |
+
ctypes = None
|
| 20 |
+
|
| 21 |
+
IS_PYPY = sys.implementation.name == 'pypy'
|
| 22 |
+
|
| 23 |
+
if sys.byteorder == 'little':
|
| 24 |
+
_nbo = '<'
|
| 25 |
+
else:
|
| 26 |
+
_nbo = '>'
|
| 27 |
+
|
| 28 |
+
def _makenames_list(adict, align):
|
| 29 |
+
allfields = []
|
| 30 |
+
|
| 31 |
+
for fname, obj in adict.items():
|
| 32 |
+
n = len(obj)
|
| 33 |
+
if not isinstance(obj, tuple) or n not in (2, 3):
|
| 34 |
+
raise ValueError("entry not a 2- or 3- tuple")
|
| 35 |
+
if n > 2 and obj[2] == fname:
|
| 36 |
+
continue
|
| 37 |
+
num = int(obj[1])
|
| 38 |
+
if num < 0:
|
| 39 |
+
raise ValueError("invalid offset.")
|
| 40 |
+
format = dtype(obj[0], align=align)
|
| 41 |
+
if n > 2:
|
| 42 |
+
title = obj[2]
|
| 43 |
+
else:
|
| 44 |
+
title = None
|
| 45 |
+
allfields.append((fname, format, num, title))
|
| 46 |
+
# sort by offsets
|
| 47 |
+
allfields.sort(key=lambda x: x[2])
|
| 48 |
+
names = [x[0] for x in allfields]
|
| 49 |
+
formats = [x[1] for x in allfields]
|
| 50 |
+
offsets = [x[2] for x in allfields]
|
| 51 |
+
titles = [x[3] for x in allfields]
|
| 52 |
+
|
| 53 |
+
return names, formats, offsets, titles
|
| 54 |
+
|
| 55 |
+
# Called in PyArray_DescrConverter function when
|
| 56 |
+
# a dictionary without "names" and "formats"
|
| 57 |
+
# fields is used as a data-type descriptor.
|
| 58 |
+
def _usefields(adict, align):
|
| 59 |
+
try:
|
| 60 |
+
names = adict[-1]
|
| 61 |
+
except KeyError:
|
| 62 |
+
names = None
|
| 63 |
+
if names is None:
|
| 64 |
+
names, formats, offsets, titles = _makenames_list(adict, align)
|
| 65 |
+
else:
|
| 66 |
+
formats = []
|
| 67 |
+
offsets = []
|
| 68 |
+
titles = []
|
| 69 |
+
for name in names:
|
| 70 |
+
res = adict[name]
|
| 71 |
+
formats.append(res[0])
|
| 72 |
+
offsets.append(res[1])
|
| 73 |
+
if len(res) > 2:
|
| 74 |
+
titles.append(res[2])
|
| 75 |
+
else:
|
| 76 |
+
titles.append(None)
|
| 77 |
+
|
| 78 |
+
return dtype({"names": names,
|
| 79 |
+
"formats": formats,
|
| 80 |
+
"offsets": offsets,
|
| 81 |
+
"titles": titles}, align)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
# construct an array_protocol descriptor list
|
| 85 |
+
# from the fields attribute of a descriptor
|
| 86 |
+
# This calls itself recursively but should eventually hit
|
| 87 |
+
# a descriptor that has no fields and then return
|
| 88 |
+
# a simple typestring
|
| 89 |
+
|
| 90 |
+
def _array_descr(descriptor):
|
| 91 |
+
fields = descriptor.fields
|
| 92 |
+
if fields is None:
|
| 93 |
+
subdtype = descriptor.subdtype
|
| 94 |
+
if subdtype is None:
|
| 95 |
+
if descriptor.metadata is None:
|
| 96 |
+
return descriptor.str
|
| 97 |
+
else:
|
| 98 |
+
new = descriptor.metadata.copy()
|
| 99 |
+
if new:
|
| 100 |
+
return (descriptor.str, new)
|
| 101 |
+
else:
|
| 102 |
+
return descriptor.str
|
| 103 |
+
else:
|
| 104 |
+
return (_array_descr(subdtype[0]), subdtype[1])
|
| 105 |
+
|
| 106 |
+
names = descriptor.names
|
| 107 |
+
ordered_fields = [fields[x] + (x,) for x in names]
|
| 108 |
+
result = []
|
| 109 |
+
offset = 0
|
| 110 |
+
for field in ordered_fields:
|
| 111 |
+
if field[1] > offset:
|
| 112 |
+
num = field[1] - offset
|
| 113 |
+
result.append(('', f'|V{num}'))
|
| 114 |
+
offset += num
|
| 115 |
+
elif field[1] < offset:
|
| 116 |
+
raise ValueError(
|
| 117 |
+
"dtype.descr is not defined for types with overlapping or "
|
| 118 |
+
"out-of-order fields")
|
| 119 |
+
if len(field) > 3:
|
| 120 |
+
name = (field[2], field[3])
|
| 121 |
+
else:
|
| 122 |
+
name = field[2]
|
| 123 |
+
if field[0].subdtype:
|
| 124 |
+
tup = (name, _array_descr(field[0].subdtype[0]),
|
| 125 |
+
field[0].subdtype[1])
|
| 126 |
+
else:
|
| 127 |
+
tup = (name, _array_descr(field[0]))
|
| 128 |
+
offset += field[0].itemsize
|
| 129 |
+
result.append(tup)
|
| 130 |
+
|
| 131 |
+
if descriptor.itemsize > offset:
|
| 132 |
+
num = descriptor.itemsize - offset
|
| 133 |
+
result.append(('', f'|V{num}'))
|
| 134 |
+
|
| 135 |
+
return result
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
# format_re was originally from numarray by J. Todd Miller
|
| 139 |
+
|
| 140 |
+
format_re = re.compile(r'(?P<order1>[<>|=]?)'
|
| 141 |
+
r'(?P<repeats> *[(]?[ ,0-9]*[)]? *)'
|
| 142 |
+
r'(?P<order2>[<>|=]?)'
|
| 143 |
+
r'(?P<dtype>[A-Za-z0-9.?]*(?:\[[a-zA-Z0-9,.]+\])?)')
|
| 144 |
+
sep_re = re.compile(r'\s*,\s*')
|
| 145 |
+
space_re = re.compile(r'\s+$')
|
| 146 |
+
|
| 147 |
+
# astr is a string (perhaps comma separated)
|
| 148 |
+
|
| 149 |
+
_convorder = {'=': _nbo}
|
| 150 |
+
|
| 151 |
+
def _commastring(astr):
|
| 152 |
+
startindex = 0
|
| 153 |
+
result = []
|
| 154 |
+
islist = False
|
| 155 |
+
while startindex < len(astr):
|
| 156 |
+
mo = format_re.match(astr, pos=startindex)
|
| 157 |
+
try:
|
| 158 |
+
(order1, repeats, order2, dtype) = mo.groups()
|
| 159 |
+
except (TypeError, AttributeError):
|
| 160 |
+
raise ValueError(
|
| 161 |
+
f'format number {len(result)+1} of "{astr}" is not recognized'
|
| 162 |
+
) from None
|
| 163 |
+
startindex = mo.end()
|
| 164 |
+
# Separator or ending padding
|
| 165 |
+
if startindex < len(astr):
|
| 166 |
+
if space_re.match(astr, pos=startindex):
|
| 167 |
+
startindex = len(astr)
|
| 168 |
+
else:
|
| 169 |
+
mo = sep_re.match(astr, pos=startindex)
|
| 170 |
+
if not mo:
|
| 171 |
+
raise ValueError(
|
| 172 |
+
'format number %d of "%s" is not recognized' %
|
| 173 |
+
(len(result)+1, astr))
|
| 174 |
+
startindex = mo.end()
|
| 175 |
+
islist = True
|
| 176 |
+
|
| 177 |
+
if order2 == '':
|
| 178 |
+
order = order1
|
| 179 |
+
elif order1 == '':
|
| 180 |
+
order = order2
|
| 181 |
+
else:
|
| 182 |
+
order1 = _convorder.get(order1, order1)
|
| 183 |
+
order2 = _convorder.get(order2, order2)
|
| 184 |
+
if (order1 != order2):
|
| 185 |
+
raise ValueError(
|
| 186 |
+
'inconsistent byte-order specification %s and %s' %
|
| 187 |
+
(order1, order2))
|
| 188 |
+
order = order1
|
| 189 |
+
|
| 190 |
+
if order in ('|', '=', _nbo):
|
| 191 |
+
order = ''
|
| 192 |
+
dtype = order + dtype
|
| 193 |
+
if repeats == '':
|
| 194 |
+
newitem = dtype
|
| 195 |
+
else:
|
| 196 |
+
if (repeats[0] == "(" and repeats[-1] == ")"
|
| 197 |
+
and repeats[1:-1].strip() != ""
|
| 198 |
+
and "," not in repeats):
|
| 199 |
+
warnings.warn(
|
| 200 |
+
'Passing in a parenthesized single number for repeats '
|
| 201 |
+
'is deprecated; pass either a single number or indicate '
|
| 202 |
+
'a tuple with a comma, like "(2,)".', DeprecationWarning,
|
| 203 |
+
stacklevel=2)
|
| 204 |
+
newitem = (dtype, ast.literal_eval(repeats))
|
| 205 |
+
|
| 206 |
+
result.append(newitem)
|
| 207 |
+
|
| 208 |
+
return result if islist else result[0]
|
| 209 |
+
|
| 210 |
+
class dummy_ctype:
|
| 211 |
+
|
| 212 |
+
def __init__(self, cls):
|
| 213 |
+
self._cls = cls
|
| 214 |
+
|
| 215 |
+
def __mul__(self, other):
|
| 216 |
+
return self
|
| 217 |
+
|
| 218 |
+
def __call__(self, *other):
|
| 219 |
+
return self._cls(other)
|
| 220 |
+
|
| 221 |
+
def __eq__(self, other):
|
| 222 |
+
return self._cls == other._cls
|
| 223 |
+
|
| 224 |
+
def __ne__(self, other):
|
| 225 |
+
return self._cls != other._cls
|
| 226 |
+
|
| 227 |
+
def _getintp_ctype():
|
| 228 |
+
val = _getintp_ctype.cache
|
| 229 |
+
if val is not None:
|
| 230 |
+
return val
|
| 231 |
+
if ctypes is None:
|
| 232 |
+
import numpy as np
|
| 233 |
+
val = dummy_ctype(np.intp)
|
| 234 |
+
else:
|
| 235 |
+
char = dtype('n').char
|
| 236 |
+
if char == 'i':
|
| 237 |
+
val = ctypes.c_int
|
| 238 |
+
elif char == 'l':
|
| 239 |
+
val = ctypes.c_long
|
| 240 |
+
elif char == 'q':
|
| 241 |
+
val = ctypes.c_longlong
|
| 242 |
+
else:
|
| 243 |
+
val = ctypes.c_long
|
| 244 |
+
_getintp_ctype.cache = val
|
| 245 |
+
return val
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
_getintp_ctype.cache = None
|
| 249 |
+
|
| 250 |
+
# Used for .ctypes attribute of ndarray
|
| 251 |
+
|
| 252 |
+
class _missing_ctypes:
|
| 253 |
+
def cast(self, num, obj):
|
| 254 |
+
return num.value
|
| 255 |
+
|
| 256 |
+
class c_void_p:
|
| 257 |
+
def __init__(self, ptr):
|
| 258 |
+
self.value = ptr
|
| 259 |
+
|
| 260 |
+
|
| 261 |
+
class _ctypes:
|
| 262 |
+
def __init__(self, array, ptr=None):
|
| 263 |
+
self._arr = array
|
| 264 |
+
|
| 265 |
+
if ctypes:
|
| 266 |
+
self._ctypes = ctypes
|
| 267 |
+
self._data = self._ctypes.c_void_p(ptr)
|
| 268 |
+
else:
|
| 269 |
+
# fake a pointer-like object that holds onto the reference
|
| 270 |
+
self._ctypes = _missing_ctypes()
|
| 271 |
+
self._data = self._ctypes.c_void_p(ptr)
|
| 272 |
+
self._data._objects = array
|
| 273 |
+
|
| 274 |
+
if self._arr.ndim == 0:
|
| 275 |
+
self._zerod = True
|
| 276 |
+
else:
|
| 277 |
+
self._zerod = False
|
| 278 |
+
|
| 279 |
+
def data_as(self, obj):
|
| 280 |
+
"""
|
| 281 |
+
Return the data pointer cast to a particular c-types object.
|
| 282 |
+
For example, calling ``self._as_parameter_`` is equivalent to
|
| 283 |
+
``self.data_as(ctypes.c_void_p)``. Perhaps you want to use
|
| 284 |
+
the data as a pointer to a ctypes array of floating-point data:
|
| 285 |
+
``self.data_as(ctypes.POINTER(ctypes.c_double))``.
|
| 286 |
+
|
| 287 |
+
The returned pointer will keep a reference to the array.
|
| 288 |
+
"""
|
| 289 |
+
# _ctypes.cast function causes a circular reference of self._data in
|
| 290 |
+
# self._data._objects. Attributes of self._data cannot be released
|
| 291 |
+
# until gc.collect is called. Make a copy of the pointer first then
|
| 292 |
+
# let it hold the array reference. This is a workaround to circumvent
|
| 293 |
+
# the CPython bug https://bugs.python.org/issue12836.
|
| 294 |
+
ptr = self._ctypes.cast(self._data, obj)
|
| 295 |
+
ptr._arr = self._arr
|
| 296 |
+
return ptr
|
| 297 |
+
|
| 298 |
+
def shape_as(self, obj):
|
| 299 |
+
"""
|
| 300 |
+
Return the shape tuple as an array of some other c-types
|
| 301 |
+
type. For example: ``self.shape_as(ctypes.c_short)``.
|
| 302 |
+
"""
|
| 303 |
+
if self._zerod:
|
| 304 |
+
return None
|
| 305 |
+
return (obj*self._arr.ndim)(*self._arr.shape)
|
| 306 |
+
|
| 307 |
+
def strides_as(self, obj):
|
| 308 |
+
"""
|
| 309 |
+
Return the strides tuple as an array of some other
|
| 310 |
+
c-types type. For example: ``self.strides_as(ctypes.c_longlong)``.
|
| 311 |
+
"""
|
| 312 |
+
if self._zerod:
|
| 313 |
+
return None
|
| 314 |
+
return (obj*self._arr.ndim)(*self._arr.strides)
|
| 315 |
+
|
| 316 |
+
@property
|
| 317 |
+
def data(self):
|
| 318 |
+
"""
|
| 319 |
+
A pointer to the memory area of the array as a Python integer.
|
| 320 |
+
This memory area may contain data that is not aligned, or not in
|
| 321 |
+
correct byte-order. The memory area may not even be writeable.
|
| 322 |
+
The array flags and data-type of this array should be respected
|
| 323 |
+
when passing this attribute to arbitrary C-code to avoid trouble
|
| 324 |
+
that can include Python crashing. User Beware! The value of this
|
| 325 |
+
attribute is exactly the same as:
|
| 326 |
+
``self._array_interface_['data'][0]``.
|
| 327 |
+
|
| 328 |
+
Note that unlike ``data_as``, a reference won't be kept to the array:
|
| 329 |
+
code like ``ctypes.c_void_p((a + b).ctypes.data)`` will result in a
|
| 330 |
+
pointer to a deallocated array, and should be spelt
|
| 331 |
+
``(a + b).ctypes.data_as(ctypes.c_void_p)``
|
| 332 |
+
"""
|
| 333 |
+
return self._data.value
|
| 334 |
+
|
| 335 |
+
@property
|
| 336 |
+
def shape(self):
|
| 337 |
+
"""
|
| 338 |
+
(c_intp*self.ndim): A ctypes array of length self.ndim where
|
| 339 |
+
the basetype is the C-integer corresponding to ``dtype('p')`` on this
|
| 340 |
+
platform (see `~numpy.ctypeslib.c_intp`). This base-type could be
|
| 341 |
+
`ctypes.c_int`, `ctypes.c_long`, or `ctypes.c_longlong` depending on
|
| 342 |
+
the platform. The ctypes array contains the shape of
|
| 343 |
+
the underlying array.
|
| 344 |
+
"""
|
| 345 |
+
return self.shape_as(_getintp_ctype())
|
| 346 |
+
|
| 347 |
+
@property
|
| 348 |
+
def strides(self):
|
| 349 |
+
"""
|
| 350 |
+
(c_intp*self.ndim): A ctypes array of length self.ndim where
|
| 351 |
+
the basetype is the same as for the shape attribute. This ctypes
|
| 352 |
+
array contains the strides information from the underlying array.
|
| 353 |
+
This strides information is important for showing how many bytes
|
| 354 |
+
must be jumped to get to the next element in the array.
|
| 355 |
+
"""
|
| 356 |
+
return self.strides_as(_getintp_ctype())
|
| 357 |
+
|
| 358 |
+
@property
|
| 359 |
+
def _as_parameter_(self):
|
| 360 |
+
"""
|
| 361 |
+
Overrides the ctypes semi-magic method
|
| 362 |
+
|
| 363 |
+
Enables `c_func(some_array.ctypes)`
|
| 364 |
+
"""
|
| 365 |
+
return self.data_as(ctypes.c_void_p)
|
| 366 |
+
|
| 367 |
+
# Numpy 1.21.0, 2021-05-18
|
| 368 |
+
|
| 369 |
+
def get_data(self):
|
| 370 |
+
"""Deprecated getter for the `_ctypes.data` property.
|
| 371 |
+
|
| 372 |
+
.. deprecated:: 1.21
|
| 373 |
+
"""
|
| 374 |
+
warnings.warn('"get_data" is deprecated. Use "data" instead',
|
| 375 |
+
DeprecationWarning, stacklevel=2)
|
| 376 |
+
return self.data
|
| 377 |
+
|
| 378 |
+
def get_shape(self):
|
| 379 |
+
"""Deprecated getter for the `_ctypes.shape` property.
|
| 380 |
+
|
| 381 |
+
.. deprecated:: 1.21
|
| 382 |
+
"""
|
| 383 |
+
warnings.warn('"get_shape" is deprecated. Use "shape" instead',
|
| 384 |
+
DeprecationWarning, stacklevel=2)
|
| 385 |
+
return self.shape
|
| 386 |
+
|
| 387 |
+
def get_strides(self):
|
| 388 |
+
"""Deprecated getter for the `_ctypes.strides` property.
|
| 389 |
+
|
| 390 |
+
.. deprecated:: 1.21
|
| 391 |
+
"""
|
| 392 |
+
warnings.warn('"get_strides" is deprecated. Use "strides" instead',
|
| 393 |
+
DeprecationWarning, stacklevel=2)
|
| 394 |
+
return self.strides
|
| 395 |
+
|
| 396 |
+
def get_as_parameter(self):
|
| 397 |
+
"""Deprecated getter for the `_ctypes._as_parameter_` property.
|
| 398 |
+
|
| 399 |
+
.. deprecated:: 1.21
|
| 400 |
+
"""
|
| 401 |
+
warnings.warn(
|
| 402 |
+
'"get_as_parameter" is deprecated. Use "_as_parameter_" instead',
|
| 403 |
+
DeprecationWarning, stacklevel=2,
|
| 404 |
+
)
|
| 405 |
+
return self._as_parameter_
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
def _newnames(datatype, order):
|
| 409 |
+
"""
|
| 410 |
+
Given a datatype and an order object, return a new names tuple, with the
|
| 411 |
+
order indicated
|
| 412 |
+
"""
|
| 413 |
+
oldnames = datatype.names
|
| 414 |
+
nameslist = list(oldnames)
|
| 415 |
+
if isinstance(order, str):
|
| 416 |
+
order = [order]
|
| 417 |
+
seen = set()
|
| 418 |
+
if isinstance(order, (list, tuple)):
|
| 419 |
+
for name in order:
|
| 420 |
+
try:
|
| 421 |
+
nameslist.remove(name)
|
| 422 |
+
except ValueError:
|
| 423 |
+
if name in seen:
|
| 424 |
+
raise ValueError(f"duplicate field name: {name}") from None
|
| 425 |
+
else:
|
| 426 |
+
raise ValueError(f"unknown field name: {name}") from None
|
| 427 |
+
seen.add(name)
|
| 428 |
+
return tuple(list(order) + nameslist)
|
| 429 |
+
raise ValueError(f"unsupported order value: {order}")
|
| 430 |
+
|
| 431 |
+
def _copy_fields(ary):
|
| 432 |
+
"""Return copy of structured array with padding between fields removed.
|
| 433 |
+
|
| 434 |
+
Parameters
|
| 435 |
+
----------
|
| 436 |
+
ary : ndarray
|
| 437 |
+
Structured array from which to remove padding bytes
|
| 438 |
+
|
| 439 |
+
Returns
|
| 440 |
+
-------
|
| 441 |
+
ary_copy : ndarray
|
| 442 |
+
Copy of ary with padding bytes removed
|
| 443 |
+
"""
|
| 444 |
+
dt = ary.dtype
|
| 445 |
+
copy_dtype = {'names': dt.names,
|
| 446 |
+
'formats': [dt.fields[name][0] for name in dt.names]}
|
| 447 |
+
return array(ary, dtype=copy_dtype, copy=True)
|
| 448 |
+
|
| 449 |
+
def _promote_fields(dt1, dt2):
|
| 450 |
+
""" Perform type promotion for two structured dtypes.
|
| 451 |
+
|
| 452 |
+
Parameters
|
| 453 |
+
----------
|
| 454 |
+
dt1 : structured dtype
|
| 455 |
+
First dtype.
|
| 456 |
+
dt2 : structured dtype
|
| 457 |
+
Second dtype.
|
| 458 |
+
|
| 459 |
+
Returns
|
| 460 |
+
-------
|
| 461 |
+
out : dtype
|
| 462 |
+
The promoted dtype
|
| 463 |
+
|
| 464 |
+
Notes
|
| 465 |
+
-----
|
| 466 |
+
If one of the inputs is aligned, the result will be. The titles of
|
| 467 |
+
both descriptors must match (point to the same field).
|
| 468 |
+
"""
|
| 469 |
+
# Both must be structured and have the same names in the same order
|
| 470 |
+
if (dt1.names is None or dt2.names is None) or dt1.names != dt2.names:
|
| 471 |
+
raise DTypePromotionError(
|
| 472 |
+
f"field names `{dt1.names}` and `{dt2.names}` mismatch.")
|
| 473 |
+
|
| 474 |
+
# if both are identical, we can (maybe!) just return the same dtype.
|
| 475 |
+
identical = dt1 is dt2
|
| 476 |
+
new_fields = []
|
| 477 |
+
for name in dt1.names:
|
| 478 |
+
field1 = dt1.fields[name]
|
| 479 |
+
field2 = dt2.fields[name]
|
| 480 |
+
new_descr = promote_types(field1[0], field2[0])
|
| 481 |
+
identical = identical and new_descr is field1[0]
|
| 482 |
+
|
| 483 |
+
# Check that the titles match (if given):
|
| 484 |
+
if field1[2:] != field2[2:]:
|
| 485 |
+
raise DTypePromotionError(
|
| 486 |
+
f"field titles of field '{name}' mismatch")
|
| 487 |
+
if len(field1) == 2:
|
| 488 |
+
new_fields.append((name, new_descr))
|
| 489 |
+
else:
|
| 490 |
+
new_fields.append(((field1[2], name), new_descr))
|
| 491 |
+
|
| 492 |
+
res = dtype(new_fields, align=dt1.isalignedstruct or dt2.isalignedstruct)
|
| 493 |
+
|
| 494 |
+
# Might as well preserve identity (and metadata) if the dtype is identical
|
| 495 |
+
# and the itemsize, offsets are also unmodified. This could probably be
|
| 496 |
+
# sped up, but also probably just be removed entirely.
|
| 497 |
+
if identical and res.itemsize == dt1.itemsize:
|
| 498 |
+
for name in dt1.names:
|
| 499 |
+
if dt1.fields[name][1] != res.fields[name][1]:
|
| 500 |
+
return res # the dtype changed.
|
| 501 |
+
return dt1
|
| 502 |
+
|
| 503 |
+
return res
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
def _getfield_is_safe(oldtype, newtype, offset):
|
| 507 |
+
""" Checks safety of getfield for object arrays.
|
| 508 |
+
|
| 509 |
+
As in _view_is_safe, we need to check that memory containing objects is not
|
| 510 |
+
reinterpreted as a non-object datatype and vice versa.
|
| 511 |
+
|
| 512 |
+
Parameters
|
| 513 |
+
----------
|
| 514 |
+
oldtype : data-type
|
| 515 |
+
Data type of the original ndarray.
|
| 516 |
+
newtype : data-type
|
| 517 |
+
Data type of the field being accessed by ndarray.getfield
|
| 518 |
+
offset : int
|
| 519 |
+
Offset of the field being accessed by ndarray.getfield
|
| 520 |
+
|
| 521 |
+
Raises
|
| 522 |
+
------
|
| 523 |
+
TypeError
|
| 524 |
+
If the field access is invalid
|
| 525 |
+
|
| 526 |
+
"""
|
| 527 |
+
if newtype.hasobject or oldtype.hasobject:
|
| 528 |
+
if offset == 0 and newtype == oldtype:
|
| 529 |
+
return
|
| 530 |
+
if oldtype.names is not None:
|
| 531 |
+
for name in oldtype.names:
|
| 532 |
+
if (oldtype.fields[name][1] == offset and
|
| 533 |
+
oldtype.fields[name][0] == newtype):
|
| 534 |
+
return
|
| 535 |
+
raise TypeError("Cannot get/set field of an object array")
|
| 536 |
+
return
|
| 537 |
+
|
| 538 |
+
def _view_is_safe(oldtype, newtype):
|
| 539 |
+
""" Checks safety of a view involving object arrays, for example when
|
| 540 |
+
doing::
|
| 541 |
+
|
| 542 |
+
np.zeros(10, dtype=oldtype).view(newtype)
|
| 543 |
+
|
| 544 |
+
Parameters
|
| 545 |
+
----------
|
| 546 |
+
oldtype : data-type
|
| 547 |
+
Data type of original ndarray
|
| 548 |
+
newtype : data-type
|
| 549 |
+
Data type of the view
|
| 550 |
+
|
| 551 |
+
Raises
|
| 552 |
+
------
|
| 553 |
+
TypeError
|
| 554 |
+
If the new type is incompatible with the old type.
|
| 555 |
+
|
| 556 |
+
"""
|
| 557 |
+
|
| 558 |
+
# if the types are equivalent, there is no problem.
|
| 559 |
+
# for example: dtype((np.record, 'i4,i4')) == dtype((np.void, 'i4,i4'))
|
| 560 |
+
if oldtype == newtype:
|
| 561 |
+
return
|
| 562 |
+
|
| 563 |
+
if newtype.hasobject or oldtype.hasobject:
|
| 564 |
+
raise TypeError("Cannot change data-type for array of references.")
|
| 565 |
+
return
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
# Given a string containing a PEP 3118 format specifier,
|
| 569 |
+
# construct a NumPy dtype
|
| 570 |
+
|
| 571 |
+
_pep3118_native_map = {
|
| 572 |
+
'?': '?',
|
| 573 |
+
'c': 'S1',
|
| 574 |
+
'b': 'b',
|
| 575 |
+
'B': 'B',
|
| 576 |
+
'h': 'h',
|
| 577 |
+
'H': 'H',
|
| 578 |
+
'i': 'i',
|
| 579 |
+
'I': 'I',
|
| 580 |
+
'l': 'l',
|
| 581 |
+
'L': 'L',
|
| 582 |
+
'q': 'q',
|
| 583 |
+
'Q': 'Q',
|
| 584 |
+
'e': 'e',
|
| 585 |
+
'f': 'f',
|
| 586 |
+
'd': 'd',
|
| 587 |
+
'g': 'g',
|
| 588 |
+
'Zf': 'F',
|
| 589 |
+
'Zd': 'D',
|
| 590 |
+
'Zg': 'G',
|
| 591 |
+
's': 'S',
|
| 592 |
+
'w': 'U',
|
| 593 |
+
'O': 'O',
|
| 594 |
+
'x': 'V', # padding
|
| 595 |
+
}
|
| 596 |
+
_pep3118_native_typechars = ''.join(_pep3118_native_map.keys())
|
| 597 |
+
|
| 598 |
+
_pep3118_standard_map = {
|
| 599 |
+
'?': '?',
|
| 600 |
+
'c': 'S1',
|
| 601 |
+
'b': 'b',
|
| 602 |
+
'B': 'B',
|
| 603 |
+
'h': 'i2',
|
| 604 |
+
'H': 'u2',
|
| 605 |
+
'i': 'i4',
|
| 606 |
+
'I': 'u4',
|
| 607 |
+
'l': 'i4',
|
| 608 |
+
'L': 'u4',
|
| 609 |
+
'q': 'i8',
|
| 610 |
+
'Q': 'u8',
|
| 611 |
+
'e': 'f2',
|
| 612 |
+
'f': 'f',
|
| 613 |
+
'd': 'd',
|
| 614 |
+
'Zf': 'F',
|
| 615 |
+
'Zd': 'D',
|
| 616 |
+
's': 'S',
|
| 617 |
+
'w': 'U',
|
| 618 |
+
'O': 'O',
|
| 619 |
+
'x': 'V', # padding
|
| 620 |
+
}
|
| 621 |
+
_pep3118_standard_typechars = ''.join(_pep3118_standard_map.keys())
|
| 622 |
+
|
| 623 |
+
_pep3118_unsupported_map = {
|
| 624 |
+
'u': 'UCS-2 strings',
|
| 625 |
+
'&': 'pointers',
|
| 626 |
+
't': 'bitfields',
|
| 627 |
+
'X': 'function pointers',
|
| 628 |
+
}
|
| 629 |
+
|
| 630 |
+
class _Stream:
|
| 631 |
+
def __init__(self, s):
|
| 632 |
+
self.s = s
|
| 633 |
+
self.byteorder = '@'
|
| 634 |
+
|
| 635 |
+
def advance(self, n):
|
| 636 |
+
res = self.s[:n]
|
| 637 |
+
self.s = self.s[n:]
|
| 638 |
+
return res
|
| 639 |
+
|
| 640 |
+
def consume(self, c):
|
| 641 |
+
if self.s[:len(c)] == c:
|
| 642 |
+
self.advance(len(c))
|
| 643 |
+
return True
|
| 644 |
+
return False
|
| 645 |
+
|
| 646 |
+
def consume_until(self, c):
|
| 647 |
+
if callable(c):
|
| 648 |
+
i = 0
|
| 649 |
+
while i < len(self.s) and not c(self.s[i]):
|
| 650 |
+
i = i + 1
|
| 651 |
+
return self.advance(i)
|
| 652 |
+
else:
|
| 653 |
+
i = self.s.index(c)
|
| 654 |
+
res = self.advance(i)
|
| 655 |
+
self.advance(len(c))
|
| 656 |
+
return res
|
| 657 |
+
|
| 658 |
+
@property
|
| 659 |
+
def next(self):
|
| 660 |
+
return self.s[0]
|
| 661 |
+
|
| 662 |
+
def __bool__(self):
|
| 663 |
+
return bool(self.s)
|
| 664 |
+
|
| 665 |
+
|
| 666 |
+
def _dtype_from_pep3118(spec):
|
| 667 |
+
stream = _Stream(spec)
|
| 668 |
+
dtype, align = __dtype_from_pep3118(stream, is_subdtype=False)
|
| 669 |
+
return dtype
|
| 670 |
+
|
| 671 |
+
def __dtype_from_pep3118(stream, is_subdtype):
|
| 672 |
+
field_spec = dict(
|
| 673 |
+
names=[],
|
| 674 |
+
formats=[],
|
| 675 |
+
offsets=[],
|
| 676 |
+
itemsize=0
|
| 677 |
+
)
|
| 678 |
+
offset = 0
|
| 679 |
+
common_alignment = 1
|
| 680 |
+
is_padding = False
|
| 681 |
+
|
| 682 |
+
# Parse spec
|
| 683 |
+
while stream:
|
| 684 |
+
value = None
|
| 685 |
+
|
| 686 |
+
# End of structure, bail out to upper level
|
| 687 |
+
if stream.consume('}'):
|
| 688 |
+
break
|
| 689 |
+
|
| 690 |
+
# Sub-arrays (1)
|
| 691 |
+
shape = None
|
| 692 |
+
if stream.consume('('):
|
| 693 |
+
shape = stream.consume_until(')')
|
| 694 |
+
shape = tuple(map(int, shape.split(',')))
|
| 695 |
+
|
| 696 |
+
# Byte order
|
| 697 |
+
if stream.next in ('@', '=', '<', '>', '^', '!'):
|
| 698 |
+
byteorder = stream.advance(1)
|
| 699 |
+
if byteorder == '!':
|
| 700 |
+
byteorder = '>'
|
| 701 |
+
stream.byteorder = byteorder
|
| 702 |
+
|
| 703 |
+
# Byte order characters also control native vs. standard type sizes
|
| 704 |
+
if stream.byteorder in ('@', '^'):
|
| 705 |
+
type_map = _pep3118_native_map
|
| 706 |
+
type_map_chars = _pep3118_native_typechars
|
| 707 |
+
else:
|
| 708 |
+
type_map = _pep3118_standard_map
|
| 709 |
+
type_map_chars = _pep3118_standard_typechars
|
| 710 |
+
|
| 711 |
+
# Item sizes
|
| 712 |
+
itemsize_str = stream.consume_until(lambda c: not c.isdigit())
|
| 713 |
+
if itemsize_str:
|
| 714 |
+
itemsize = int(itemsize_str)
|
| 715 |
+
else:
|
| 716 |
+
itemsize = 1
|
| 717 |
+
|
| 718 |
+
# Data types
|
| 719 |
+
is_padding = False
|
| 720 |
+
|
| 721 |
+
if stream.consume('T{'):
|
| 722 |
+
value, align = __dtype_from_pep3118(
|
| 723 |
+
stream, is_subdtype=True)
|
| 724 |
+
elif stream.next in type_map_chars:
|
| 725 |
+
if stream.next == 'Z':
|
| 726 |
+
typechar = stream.advance(2)
|
| 727 |
+
else:
|
| 728 |
+
typechar = stream.advance(1)
|
| 729 |
+
|
| 730 |
+
is_padding = (typechar == 'x')
|
| 731 |
+
dtypechar = type_map[typechar]
|
| 732 |
+
if dtypechar in 'USV':
|
| 733 |
+
dtypechar += '%d' % itemsize
|
| 734 |
+
itemsize = 1
|
| 735 |
+
numpy_byteorder = {'@': '=', '^': '='}.get(
|
| 736 |
+
stream.byteorder, stream.byteorder)
|
| 737 |
+
value = dtype(numpy_byteorder + dtypechar)
|
| 738 |
+
align = value.alignment
|
| 739 |
+
elif stream.next in _pep3118_unsupported_map:
|
| 740 |
+
desc = _pep3118_unsupported_map[stream.next]
|
| 741 |
+
raise NotImplementedError(
|
| 742 |
+
"Unrepresentable PEP 3118 data type {!r} ({})"
|
| 743 |
+
.format(stream.next, desc))
|
| 744 |
+
else:
|
| 745 |
+
raise ValueError(
|
| 746 |
+
"Unknown PEP 3118 data type specifier %r" % stream.s
|
| 747 |
+
)
|
| 748 |
+
|
| 749 |
+
#
|
| 750 |
+
# Native alignment may require padding
|
| 751 |
+
#
|
| 752 |
+
# Here we assume that the presence of a '@' character implicitly
|
| 753 |
+
# implies that the start of the array is *already* aligned.
|
| 754 |
+
#
|
| 755 |
+
extra_offset = 0
|
| 756 |
+
if stream.byteorder == '@':
|
| 757 |
+
start_padding = (-offset) % align
|
| 758 |
+
intra_padding = (-value.itemsize) % align
|
| 759 |
+
|
| 760 |
+
offset += start_padding
|
| 761 |
+
|
| 762 |
+
if intra_padding != 0:
|
| 763 |
+
if itemsize > 1 or (shape is not None and _prod(shape) > 1):
|
| 764 |
+
# Inject internal padding to the end of the sub-item
|
| 765 |
+
value = _add_trailing_padding(value, intra_padding)
|
| 766 |
+
else:
|
| 767 |
+
# We can postpone the injection of internal padding,
|
| 768 |
+
# as the item appears at most once
|
| 769 |
+
extra_offset += intra_padding
|
| 770 |
+
|
| 771 |
+
# Update common alignment
|
| 772 |
+
common_alignment = _lcm(align, common_alignment)
|
| 773 |
+
|
| 774 |
+
# Convert itemsize to sub-array
|
| 775 |
+
if itemsize != 1:
|
| 776 |
+
value = dtype((value, (itemsize,)))
|
| 777 |
+
|
| 778 |
+
# Sub-arrays (2)
|
| 779 |
+
if shape is not None:
|
| 780 |
+
value = dtype((value, shape))
|
| 781 |
+
|
| 782 |
+
# Field name
|
| 783 |
+
if stream.consume(':'):
|
| 784 |
+
name = stream.consume_until(':')
|
| 785 |
+
else:
|
| 786 |
+
name = None
|
| 787 |
+
|
| 788 |
+
if not (is_padding and name is None):
|
| 789 |
+
if name is not None and name in field_spec['names']:
|
| 790 |
+
raise RuntimeError(
|
| 791 |
+
f"Duplicate field name '{name}' in PEP3118 format"
|
| 792 |
+
)
|
| 793 |
+
field_spec['names'].append(name)
|
| 794 |
+
field_spec['formats'].append(value)
|
| 795 |
+
field_spec['offsets'].append(offset)
|
| 796 |
+
|
| 797 |
+
offset += value.itemsize
|
| 798 |
+
offset += extra_offset
|
| 799 |
+
|
| 800 |
+
field_spec['itemsize'] = offset
|
| 801 |
+
|
| 802 |
+
# extra final padding for aligned types
|
| 803 |
+
if stream.byteorder == '@':
|
| 804 |
+
field_spec['itemsize'] += (-offset) % common_alignment
|
| 805 |
+
|
| 806 |
+
# Check if this was a simple 1-item type, and unwrap it
|
| 807 |
+
if (field_spec['names'] == [None]
|
| 808 |
+
and field_spec['offsets'][0] == 0
|
| 809 |
+
and field_spec['itemsize'] == field_spec['formats'][0].itemsize
|
| 810 |
+
and not is_subdtype):
|
| 811 |
+
ret = field_spec['formats'][0]
|
| 812 |
+
else:
|
| 813 |
+
_fix_names(field_spec)
|
| 814 |
+
ret = dtype(field_spec)
|
| 815 |
+
|
| 816 |
+
# Finished
|
| 817 |
+
return ret, common_alignment
|
| 818 |
+
|
| 819 |
+
def _fix_names(field_spec):
|
| 820 |
+
""" Replace names which are None with the next unused f%d name """
|
| 821 |
+
names = field_spec['names']
|
| 822 |
+
for i, name in enumerate(names):
|
| 823 |
+
if name is not None:
|
| 824 |
+
continue
|
| 825 |
+
|
| 826 |
+
j = 0
|
| 827 |
+
while True:
|
| 828 |
+
name = f'f{j}'
|
| 829 |
+
if name not in names:
|
| 830 |
+
break
|
| 831 |
+
j = j + 1
|
| 832 |
+
names[i] = name
|
| 833 |
+
|
| 834 |
+
def _add_trailing_padding(value, padding):
|
| 835 |
+
"""Inject the specified number of padding bytes at the end of a dtype"""
|
| 836 |
+
if value.fields is None:
|
| 837 |
+
field_spec = dict(
|
| 838 |
+
names=['f0'],
|
| 839 |
+
formats=[value],
|
| 840 |
+
offsets=[0],
|
| 841 |
+
itemsize=value.itemsize
|
| 842 |
+
)
|
| 843 |
+
else:
|
| 844 |
+
fields = value.fields
|
| 845 |
+
names = value.names
|
| 846 |
+
field_spec = dict(
|
| 847 |
+
names=names,
|
| 848 |
+
formats=[fields[name][0] for name in names],
|
| 849 |
+
offsets=[fields[name][1] for name in names],
|
| 850 |
+
itemsize=value.itemsize
|
| 851 |
+
)
|
| 852 |
+
|
| 853 |
+
field_spec['itemsize'] += padding
|
| 854 |
+
return dtype(field_spec)
|
| 855 |
+
|
| 856 |
+
def _prod(a):
|
| 857 |
+
p = 1
|
| 858 |
+
for x in a:
|
| 859 |
+
p *= x
|
| 860 |
+
return p
|
| 861 |
+
|
| 862 |
+
def _gcd(a, b):
|
| 863 |
+
"""Calculate the greatest common divisor of a and b"""
|
| 864 |
+
if not (math.isfinite(a) and math.isfinite(b)):
|
| 865 |
+
raise ValueError('Can only find greatest common divisor of '
|
| 866 |
+
f'finite arguments, found "{a}" and "{b}"')
|
| 867 |
+
while b:
|
| 868 |
+
a, b = b, a % b
|
| 869 |
+
return a
|
| 870 |
+
|
| 871 |
+
def _lcm(a, b):
|
| 872 |
+
return a // _gcd(a, b) * b
|
| 873 |
+
|
| 874 |
+
def array_ufunc_errmsg_formatter(dummy, ufunc, method, *inputs, **kwargs):
|
| 875 |
+
""" Format the error message for when __array_ufunc__ gives up. """
|
| 876 |
+
args_string = ', '.join(['{!r}'.format(arg) for arg in inputs] +
|
| 877 |
+
['{}={!r}'.format(k, v)
|
| 878 |
+
for k, v in kwargs.items()])
|
| 879 |
+
args = inputs + kwargs.get('out', ())
|
| 880 |
+
types_string = ', '.join(repr(type(arg).__name__) for arg in args)
|
| 881 |
+
return ('operand type(s) all returned NotImplemented from '
|
| 882 |
+
'__array_ufunc__({!r}, {!r}, {}): {}'
|
| 883 |
+
.format(ufunc, method, args_string, types_string))
|
| 884 |
+
|
| 885 |
+
|
| 886 |
+
def array_function_errmsg_formatter(public_api, types):
|
| 887 |
+
""" Format the error message for when __array_ufunc__ gives up. """
|
| 888 |
+
func_name = '{}.{}'.format(public_api.__module__, public_api.__name__)
|
| 889 |
+
return ("no implementation found for '{}' on types that implement "
|
| 890 |
+
'__array_function__: {}'.format(func_name, list(types)))
|
| 891 |
+
|
| 892 |
+
|
| 893 |
+
def _ufunc_doc_signature_formatter(ufunc):
|
| 894 |
+
"""
|
| 895 |
+
Builds a signature string which resembles PEP 457
|
| 896 |
+
|
| 897 |
+
This is used to construct the first line of the docstring
|
| 898 |
+
"""
|
| 899 |
+
|
| 900 |
+
# input arguments are simple
|
| 901 |
+
if ufunc.nin == 1:
|
| 902 |
+
in_args = 'x'
|
| 903 |
+
else:
|
| 904 |
+
in_args = ', '.join(f'x{i+1}' for i in range(ufunc.nin))
|
| 905 |
+
|
| 906 |
+
# output arguments are both keyword or positional
|
| 907 |
+
if ufunc.nout == 0:
|
| 908 |
+
out_args = ', /, out=()'
|
| 909 |
+
elif ufunc.nout == 1:
|
| 910 |
+
out_args = ', /, out=None'
|
| 911 |
+
else:
|
| 912 |
+
out_args = '[, {positional}], / [, out={default}]'.format(
|
| 913 |
+
positional=', '.join(
|
| 914 |
+
'out{}'.format(i+1) for i in range(ufunc.nout)),
|
| 915 |
+
default=repr((None,)*ufunc.nout)
|
| 916 |
+
)
|
| 917 |
+
|
| 918 |
+
# keyword only args depend on whether this is a gufunc
|
| 919 |
+
kwargs = (
|
| 920 |
+
", casting='same_kind'"
|
| 921 |
+
", order='K'"
|
| 922 |
+
", dtype=None"
|
| 923 |
+
", subok=True"
|
| 924 |
+
)
|
| 925 |
+
|
| 926 |
+
# NOTE: gufuncs may or may not support the `axis` parameter
|
| 927 |
+
if ufunc.signature is None:
|
| 928 |
+
kwargs = f", where=True{kwargs}[, signature]"
|
| 929 |
+
else:
|
| 930 |
+
kwargs += "[, signature, axes, axis]"
|
| 931 |
+
|
| 932 |
+
# join all the parts together
|
| 933 |
+
return '{name}({in_args}{out_args}, *{kwargs})'.format(
|
| 934 |
+
name=ufunc.__name__,
|
| 935 |
+
in_args=in_args,
|
| 936 |
+
out_args=out_args,
|
| 937 |
+
kwargs=kwargs
|
| 938 |
+
)
|
| 939 |
+
|
| 940 |
+
|
| 941 |
+
def npy_ctypes_check(cls):
|
| 942 |
+
# determine if a class comes from ctypes, in order to work around
|
| 943 |
+
# a bug in the buffer protocol for those objects, bpo-10746
|
| 944 |
+
try:
|
| 945 |
+
# ctypes class are new-style, so have an __mro__. This probably fails
|
| 946 |
+
# for ctypes classes with multiple inheritance.
|
| 947 |
+
if IS_PYPY:
|
| 948 |
+
# (..., _ctypes.basics._CData, Bufferable, object)
|
| 949 |
+
ctype_base = cls.__mro__[-3]
|
| 950 |
+
else:
|
| 951 |
+
# # (..., _ctypes._CData, object)
|
| 952 |
+
ctype_base = cls.__mro__[-2]
|
| 953 |
+
# right now, they're part of the _ctypes module
|
| 954 |
+
return '_ctypes' in ctype_base.__module__
|
| 955 |
+
except Exception:
|
| 956 |
+
return False
|
| 957 |
+
|
| 958 |
+
# used to handle the _NoValue default argument for na_object
|
| 959 |
+
# in the C implementation of the __reduce__ method for stringdtype
|
| 960 |
+
def _convert_to_stringdtype_kwargs(coerce, na_object=_NoValue):
|
| 961 |
+
if na_object is _NoValue:
|
| 962 |
+
return StringDType(coerce=coerce)
|
| 963 |
+
return StringDType(coerce=coerce, na_object=na_object)
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_internal.pyi
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ctypes as ct
|
| 2 |
+
import re
|
| 3 |
+
from collections.abc import Callable, Iterable
|
| 4 |
+
from typing import Any, Final, Generic, overload
|
| 5 |
+
|
| 6 |
+
from typing_extensions import Self, TypeVar, deprecated
|
| 7 |
+
|
| 8 |
+
import numpy as np
|
| 9 |
+
import numpy.typing as npt
|
| 10 |
+
from numpy.ctypeslib import c_intp
|
| 11 |
+
|
| 12 |
+
_CastT = TypeVar("_CastT", bound=ct._CanCastTo)
|
| 13 |
+
_T_co = TypeVar("_T_co", covariant=True)
|
| 14 |
+
_CT = TypeVar("_CT", bound=ct._CData)
|
| 15 |
+
_PT_co = TypeVar("_PT_co", bound=int | None, default=None, covariant=True)
|
| 16 |
+
|
| 17 |
+
###
|
| 18 |
+
|
| 19 |
+
IS_PYPY: Final[bool] = ...
|
| 20 |
+
|
| 21 |
+
format_re: Final[re.Pattern[str]] = ...
|
| 22 |
+
sep_re: Final[re.Pattern[str]] = ...
|
| 23 |
+
space_re: Final[re.Pattern[str]] = ...
|
| 24 |
+
|
| 25 |
+
###
|
| 26 |
+
|
| 27 |
+
# TODO: Let the likes of `shape_as` and `strides_as` return `None`
|
| 28 |
+
# for 0D arrays once we've got shape-support
|
| 29 |
+
|
| 30 |
+
class _ctypes(Generic[_PT_co]):
|
| 31 |
+
@overload
|
| 32 |
+
def __init__(self: _ctypes[None], /, array: npt.NDArray[Any], ptr: None = None) -> None: ...
|
| 33 |
+
@overload
|
| 34 |
+
def __init__(self, /, array: npt.NDArray[Any], ptr: _PT_co) -> None: ...
|
| 35 |
+
|
| 36 |
+
#
|
| 37 |
+
@property
|
| 38 |
+
def data(self) -> _PT_co: ...
|
| 39 |
+
@property
|
| 40 |
+
def shape(self) -> ct.Array[c_intp]: ...
|
| 41 |
+
@property
|
| 42 |
+
def strides(self) -> ct.Array[c_intp]: ...
|
| 43 |
+
@property
|
| 44 |
+
def _as_parameter_(self) -> ct.c_void_p: ...
|
| 45 |
+
|
| 46 |
+
#
|
| 47 |
+
def data_as(self, /, obj: type[_CastT]) -> _CastT: ...
|
| 48 |
+
def shape_as(self, /, obj: type[_CT]) -> ct.Array[_CT]: ...
|
| 49 |
+
def strides_as(self, /, obj: type[_CT]) -> ct.Array[_CT]: ...
|
| 50 |
+
|
| 51 |
+
#
|
| 52 |
+
@deprecated('"get_data" is deprecated. Use "data" instead')
|
| 53 |
+
def get_data(self, /) -> _PT_co: ...
|
| 54 |
+
@deprecated('"get_shape" is deprecated. Use "shape" instead')
|
| 55 |
+
def get_shape(self, /) -> ct.Array[c_intp]: ...
|
| 56 |
+
@deprecated('"get_strides" is deprecated. Use "strides" instead')
|
| 57 |
+
def get_strides(self, /) -> ct.Array[c_intp]: ...
|
| 58 |
+
@deprecated('"get_as_parameter" is deprecated. Use "_as_parameter_" instead')
|
| 59 |
+
def get_as_parameter(self, /) -> ct.c_void_p: ...
|
| 60 |
+
|
| 61 |
+
class dummy_ctype(Generic[_T_co]):
|
| 62 |
+
_cls: type[_T_co]
|
| 63 |
+
|
| 64 |
+
def __init__(self, /, cls: type[_T_co]) -> None: ...
|
| 65 |
+
def __eq__(self, other: Self, /) -> bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
|
| 66 |
+
def __ne__(self, other: Self, /) -> bool: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
|
| 67 |
+
def __mul__(self, other: object, /) -> Self: ...
|
| 68 |
+
def __call__(self, /, *other: object) -> _T_co: ...
|
| 69 |
+
|
| 70 |
+
def array_ufunc_errmsg_formatter(dummy: object, ufunc: np.ufunc, method: str, *inputs: object, **kwargs: object) -> str: ...
|
| 71 |
+
def array_function_errmsg_formatter(public_api: Callable[..., object], types: Iterable[str]) -> str: ...
|
| 72 |
+
def npy_ctypes_check(cls: type) -> bool: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_machar.py
ADDED
|
@@ -0,0 +1,356 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Machine arithmetic - determine the parameters of the
|
| 3 |
+
floating-point arithmetic system
|
| 4 |
+
|
| 5 |
+
Author: Pearu Peterson, September 2003
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
__all__ = ['MachAr']
|
| 9 |
+
|
| 10 |
+
from .fromnumeric import any
|
| 11 |
+
from ._ufunc_config import errstate
|
| 12 |
+
from .._utils import set_module
|
| 13 |
+
|
| 14 |
+
# Need to speed this up...especially for longdouble
|
| 15 |
+
|
| 16 |
+
# Deprecated 2021-10-20, NumPy 1.22
|
| 17 |
+
class MachAr:
|
| 18 |
+
"""
|
| 19 |
+
Diagnosing machine parameters.
|
| 20 |
+
|
| 21 |
+
Attributes
|
| 22 |
+
----------
|
| 23 |
+
ibeta : int
|
| 24 |
+
Radix in which numbers are represented.
|
| 25 |
+
it : int
|
| 26 |
+
Number of base-`ibeta` digits in the floating point mantissa M.
|
| 27 |
+
machep : int
|
| 28 |
+
Exponent of the smallest (most negative) power of `ibeta` that,
|
| 29 |
+
added to 1.0, gives something different from 1.0
|
| 30 |
+
eps : float
|
| 31 |
+
Floating-point number ``beta**machep`` (floating point precision)
|
| 32 |
+
negep : int
|
| 33 |
+
Exponent of the smallest power of `ibeta` that, subtracted
|
| 34 |
+
from 1.0, gives something different from 1.0.
|
| 35 |
+
epsneg : float
|
| 36 |
+
Floating-point number ``beta**negep``.
|
| 37 |
+
iexp : int
|
| 38 |
+
Number of bits in the exponent (including its sign and bias).
|
| 39 |
+
minexp : int
|
| 40 |
+
Smallest (most negative) power of `ibeta` consistent with there
|
| 41 |
+
being no leading zeros in the mantissa.
|
| 42 |
+
xmin : float
|
| 43 |
+
Floating-point number ``beta**minexp`` (the smallest [in
|
| 44 |
+
magnitude] positive floating point number with full precision).
|
| 45 |
+
maxexp : int
|
| 46 |
+
Smallest (positive) power of `ibeta` that causes overflow.
|
| 47 |
+
xmax : float
|
| 48 |
+
``(1-epsneg) * beta**maxexp`` (the largest [in magnitude]
|
| 49 |
+
usable floating value).
|
| 50 |
+
irnd : int
|
| 51 |
+
In ``range(6)``, information on what kind of rounding is done
|
| 52 |
+
in addition, and on how underflow is handled.
|
| 53 |
+
ngrd : int
|
| 54 |
+
Number of 'guard digits' used when truncating the product
|
| 55 |
+
of two mantissas to fit the representation.
|
| 56 |
+
epsilon : float
|
| 57 |
+
Same as `eps`.
|
| 58 |
+
tiny : float
|
| 59 |
+
An alias for `smallest_normal`, kept for backwards compatibility.
|
| 60 |
+
huge : float
|
| 61 |
+
Same as `xmax`.
|
| 62 |
+
precision : float
|
| 63 |
+
``- int(-log10(eps))``
|
| 64 |
+
resolution : float
|
| 65 |
+
``- 10**(-precision)``
|
| 66 |
+
smallest_normal : float
|
| 67 |
+
The smallest positive floating point number with 1 as leading bit in
|
| 68 |
+
the mantissa following IEEE-754. Same as `xmin`.
|
| 69 |
+
smallest_subnormal : float
|
| 70 |
+
The smallest positive floating point number with 0 as leading bit in
|
| 71 |
+
the mantissa following IEEE-754.
|
| 72 |
+
|
| 73 |
+
Parameters
|
| 74 |
+
----------
|
| 75 |
+
float_conv : function, optional
|
| 76 |
+
Function that converts an integer or integer array to a float
|
| 77 |
+
or float array. Default is `float`.
|
| 78 |
+
int_conv : function, optional
|
| 79 |
+
Function that converts a float or float array to an integer or
|
| 80 |
+
integer array. Default is `int`.
|
| 81 |
+
float_to_float : function, optional
|
| 82 |
+
Function that converts a float array to float. Default is `float`.
|
| 83 |
+
Note that this does not seem to do anything useful in the current
|
| 84 |
+
implementation.
|
| 85 |
+
float_to_str : function, optional
|
| 86 |
+
Function that converts a single float to a string. Default is
|
| 87 |
+
``lambda v:'%24.16e' %v``.
|
| 88 |
+
title : str, optional
|
| 89 |
+
Title that is printed in the string representation of `MachAr`.
|
| 90 |
+
|
| 91 |
+
See Also
|
| 92 |
+
--------
|
| 93 |
+
finfo : Machine limits for floating point types.
|
| 94 |
+
iinfo : Machine limits for integer types.
|
| 95 |
+
|
| 96 |
+
References
|
| 97 |
+
----------
|
| 98 |
+
.. [1] Press, Teukolsky, Vetterling and Flannery,
|
| 99 |
+
"Numerical Recipes in C++," 2nd ed,
|
| 100 |
+
Cambridge University Press, 2002, p. 31.
|
| 101 |
+
|
| 102 |
+
"""
|
| 103 |
+
|
| 104 |
+
def __init__(self, float_conv=float,int_conv=int,
|
| 105 |
+
float_to_float=float,
|
| 106 |
+
float_to_str=lambda v:'%24.16e' % v,
|
| 107 |
+
title='Python floating point number'):
|
| 108 |
+
"""
|
| 109 |
+
|
| 110 |
+
float_conv - convert integer to float (array)
|
| 111 |
+
int_conv - convert float (array) to integer
|
| 112 |
+
float_to_float - convert float array to float
|
| 113 |
+
float_to_str - convert array float to str
|
| 114 |
+
title - description of used floating point numbers
|
| 115 |
+
|
| 116 |
+
"""
|
| 117 |
+
# We ignore all errors here because we are purposely triggering
|
| 118 |
+
# underflow to detect the properties of the running arch.
|
| 119 |
+
with errstate(under='ignore'):
|
| 120 |
+
self._do_init(float_conv, int_conv, float_to_float, float_to_str, title)
|
| 121 |
+
|
| 122 |
+
def _do_init(self, float_conv, int_conv, float_to_float, float_to_str, title):
|
| 123 |
+
max_iterN = 10000
|
| 124 |
+
msg = "Did not converge after %d tries with %s"
|
| 125 |
+
one = float_conv(1)
|
| 126 |
+
two = one + one
|
| 127 |
+
zero = one - one
|
| 128 |
+
|
| 129 |
+
# Do we really need to do this? Aren't they 2 and 2.0?
|
| 130 |
+
# Determine ibeta and beta
|
| 131 |
+
a = one
|
| 132 |
+
for _ in range(max_iterN):
|
| 133 |
+
a = a + a
|
| 134 |
+
temp = a + one
|
| 135 |
+
temp1 = temp - a
|
| 136 |
+
if any(temp1 - one != zero):
|
| 137 |
+
break
|
| 138 |
+
else:
|
| 139 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 140 |
+
b = one
|
| 141 |
+
for _ in range(max_iterN):
|
| 142 |
+
b = b + b
|
| 143 |
+
temp = a + b
|
| 144 |
+
itemp = int_conv(temp-a)
|
| 145 |
+
if any(itemp != 0):
|
| 146 |
+
break
|
| 147 |
+
else:
|
| 148 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 149 |
+
ibeta = itemp
|
| 150 |
+
beta = float_conv(ibeta)
|
| 151 |
+
|
| 152 |
+
# Determine it and irnd
|
| 153 |
+
it = -1
|
| 154 |
+
b = one
|
| 155 |
+
for _ in range(max_iterN):
|
| 156 |
+
it = it + 1
|
| 157 |
+
b = b * beta
|
| 158 |
+
temp = b + one
|
| 159 |
+
temp1 = temp - b
|
| 160 |
+
if any(temp1 - one != zero):
|
| 161 |
+
break
|
| 162 |
+
else:
|
| 163 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 164 |
+
|
| 165 |
+
betah = beta / two
|
| 166 |
+
a = one
|
| 167 |
+
for _ in range(max_iterN):
|
| 168 |
+
a = a + a
|
| 169 |
+
temp = a + one
|
| 170 |
+
temp1 = temp - a
|
| 171 |
+
if any(temp1 - one != zero):
|
| 172 |
+
break
|
| 173 |
+
else:
|
| 174 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 175 |
+
temp = a + betah
|
| 176 |
+
irnd = 0
|
| 177 |
+
if any(temp-a != zero):
|
| 178 |
+
irnd = 1
|
| 179 |
+
tempa = a + beta
|
| 180 |
+
temp = tempa + betah
|
| 181 |
+
if irnd == 0 and any(temp-tempa != zero):
|
| 182 |
+
irnd = 2
|
| 183 |
+
|
| 184 |
+
# Determine negep and epsneg
|
| 185 |
+
negep = it + 3
|
| 186 |
+
betain = one / beta
|
| 187 |
+
a = one
|
| 188 |
+
for i in range(negep):
|
| 189 |
+
a = a * betain
|
| 190 |
+
b = a
|
| 191 |
+
for _ in range(max_iterN):
|
| 192 |
+
temp = one - a
|
| 193 |
+
if any(temp-one != zero):
|
| 194 |
+
break
|
| 195 |
+
a = a * beta
|
| 196 |
+
negep = negep - 1
|
| 197 |
+
# Prevent infinite loop on PPC with gcc 4.0:
|
| 198 |
+
if negep < 0:
|
| 199 |
+
raise RuntimeError("could not determine machine tolerance "
|
| 200 |
+
"for 'negep', locals() -> %s" % (locals()))
|
| 201 |
+
else:
|
| 202 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 203 |
+
negep = -negep
|
| 204 |
+
epsneg = a
|
| 205 |
+
|
| 206 |
+
# Determine machep and eps
|
| 207 |
+
machep = - it - 3
|
| 208 |
+
a = b
|
| 209 |
+
|
| 210 |
+
for _ in range(max_iterN):
|
| 211 |
+
temp = one + a
|
| 212 |
+
if any(temp-one != zero):
|
| 213 |
+
break
|
| 214 |
+
a = a * beta
|
| 215 |
+
machep = machep + 1
|
| 216 |
+
else:
|
| 217 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 218 |
+
eps = a
|
| 219 |
+
|
| 220 |
+
# Determine ngrd
|
| 221 |
+
ngrd = 0
|
| 222 |
+
temp = one + eps
|
| 223 |
+
if irnd == 0 and any(temp*one - one != zero):
|
| 224 |
+
ngrd = 1
|
| 225 |
+
|
| 226 |
+
# Determine iexp
|
| 227 |
+
i = 0
|
| 228 |
+
k = 1
|
| 229 |
+
z = betain
|
| 230 |
+
t = one + eps
|
| 231 |
+
nxres = 0
|
| 232 |
+
for _ in range(max_iterN):
|
| 233 |
+
y = z
|
| 234 |
+
z = y*y
|
| 235 |
+
a = z*one # Check here for underflow
|
| 236 |
+
temp = z*t
|
| 237 |
+
if any(a+a == zero) or any(abs(z) >= y):
|
| 238 |
+
break
|
| 239 |
+
temp1 = temp * betain
|
| 240 |
+
if any(temp1*beta == z):
|
| 241 |
+
break
|
| 242 |
+
i = i + 1
|
| 243 |
+
k = k + k
|
| 244 |
+
else:
|
| 245 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 246 |
+
if ibeta != 10:
|
| 247 |
+
iexp = i + 1
|
| 248 |
+
mx = k + k
|
| 249 |
+
else:
|
| 250 |
+
iexp = 2
|
| 251 |
+
iz = ibeta
|
| 252 |
+
while k >= iz:
|
| 253 |
+
iz = iz * ibeta
|
| 254 |
+
iexp = iexp + 1
|
| 255 |
+
mx = iz + iz - 1
|
| 256 |
+
|
| 257 |
+
# Determine minexp and xmin
|
| 258 |
+
for _ in range(max_iterN):
|
| 259 |
+
xmin = y
|
| 260 |
+
y = y * betain
|
| 261 |
+
a = y * one
|
| 262 |
+
temp = y * t
|
| 263 |
+
if any((a + a) != zero) and any(abs(y) < xmin):
|
| 264 |
+
k = k + 1
|
| 265 |
+
temp1 = temp * betain
|
| 266 |
+
if any(temp1*beta == y) and any(temp != y):
|
| 267 |
+
nxres = 3
|
| 268 |
+
xmin = y
|
| 269 |
+
break
|
| 270 |
+
else:
|
| 271 |
+
break
|
| 272 |
+
else:
|
| 273 |
+
raise RuntimeError(msg % (_, one.dtype))
|
| 274 |
+
minexp = -k
|
| 275 |
+
|
| 276 |
+
# Determine maxexp, xmax
|
| 277 |
+
if mx <= k + k - 3 and ibeta != 10:
|
| 278 |
+
mx = mx + mx
|
| 279 |
+
iexp = iexp + 1
|
| 280 |
+
maxexp = mx + minexp
|
| 281 |
+
irnd = irnd + nxres
|
| 282 |
+
if irnd >= 2:
|
| 283 |
+
maxexp = maxexp - 2
|
| 284 |
+
i = maxexp + minexp
|
| 285 |
+
if ibeta == 2 and not i:
|
| 286 |
+
maxexp = maxexp - 1
|
| 287 |
+
if i > 20:
|
| 288 |
+
maxexp = maxexp - 1
|
| 289 |
+
if any(a != y):
|
| 290 |
+
maxexp = maxexp - 2
|
| 291 |
+
xmax = one - epsneg
|
| 292 |
+
if any(xmax*one != xmax):
|
| 293 |
+
xmax = one - beta*epsneg
|
| 294 |
+
xmax = xmax / (xmin*beta*beta*beta)
|
| 295 |
+
i = maxexp + minexp + 3
|
| 296 |
+
for j in range(i):
|
| 297 |
+
if ibeta == 2:
|
| 298 |
+
xmax = xmax + xmax
|
| 299 |
+
else:
|
| 300 |
+
xmax = xmax * beta
|
| 301 |
+
|
| 302 |
+
smallest_subnormal = abs(xmin / beta ** (it))
|
| 303 |
+
|
| 304 |
+
self.ibeta = ibeta
|
| 305 |
+
self.it = it
|
| 306 |
+
self.negep = negep
|
| 307 |
+
self.epsneg = float_to_float(epsneg)
|
| 308 |
+
self._str_epsneg = float_to_str(epsneg)
|
| 309 |
+
self.machep = machep
|
| 310 |
+
self.eps = float_to_float(eps)
|
| 311 |
+
self._str_eps = float_to_str(eps)
|
| 312 |
+
self.ngrd = ngrd
|
| 313 |
+
self.iexp = iexp
|
| 314 |
+
self.minexp = minexp
|
| 315 |
+
self.xmin = float_to_float(xmin)
|
| 316 |
+
self._str_xmin = float_to_str(xmin)
|
| 317 |
+
self.maxexp = maxexp
|
| 318 |
+
self.xmax = float_to_float(xmax)
|
| 319 |
+
self._str_xmax = float_to_str(xmax)
|
| 320 |
+
self.irnd = irnd
|
| 321 |
+
|
| 322 |
+
self.title = title
|
| 323 |
+
# Commonly used parameters
|
| 324 |
+
self.epsilon = self.eps
|
| 325 |
+
self.tiny = self.xmin
|
| 326 |
+
self.huge = self.xmax
|
| 327 |
+
self.smallest_normal = self.xmin
|
| 328 |
+
self._str_smallest_normal = float_to_str(self.xmin)
|
| 329 |
+
self.smallest_subnormal = float_to_float(smallest_subnormal)
|
| 330 |
+
self._str_smallest_subnormal = float_to_str(smallest_subnormal)
|
| 331 |
+
|
| 332 |
+
import math
|
| 333 |
+
self.precision = int(-math.log10(float_to_float(self.eps)))
|
| 334 |
+
ten = two + two + two + two + two
|
| 335 |
+
resolution = ten ** (-self.precision)
|
| 336 |
+
self.resolution = float_to_float(resolution)
|
| 337 |
+
self._str_resolution = float_to_str(resolution)
|
| 338 |
+
|
| 339 |
+
def __str__(self):
|
| 340 |
+
fmt = (
|
| 341 |
+
'Machine parameters for %(title)s\n'
|
| 342 |
+
'---------------------------------------------------------------------\n'
|
| 343 |
+
'ibeta=%(ibeta)s it=%(it)s iexp=%(iexp)s ngrd=%(ngrd)s irnd=%(irnd)s\n'
|
| 344 |
+
'machep=%(machep)s eps=%(_str_eps)s (beta**machep == epsilon)\n'
|
| 345 |
+
'negep =%(negep)s epsneg=%(_str_epsneg)s (beta**epsneg)\n'
|
| 346 |
+
'minexp=%(minexp)s xmin=%(_str_xmin)s (beta**minexp == tiny)\n'
|
| 347 |
+
'maxexp=%(maxexp)s xmax=%(_str_xmax)s ((1-epsneg)*beta**maxexp == huge)\n'
|
| 348 |
+
'smallest_normal=%(smallest_normal)s '
|
| 349 |
+
'smallest_subnormal=%(smallest_subnormal)s\n'
|
| 350 |
+
'---------------------------------------------------------------------\n'
|
| 351 |
+
)
|
| 352 |
+
return fmt % self.__dict__
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
if __name__ == '__main__':
|
| 356 |
+
print(MachAr())
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_machar.pyi
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Iterable
|
| 2 |
+
from typing import Any, Final, overload
|
| 3 |
+
|
| 4 |
+
from typing_extensions import TypeVar, Unpack
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
from numpy import _CastingKind
|
| 8 |
+
from numpy._utils import set_module as set_module
|
| 9 |
+
|
| 10 |
+
###
|
| 11 |
+
|
| 12 |
+
_T = TypeVar("_T")
|
| 13 |
+
_TupleT = TypeVar("_TupleT", bound=tuple[()] | tuple[Any, Any, Unpack[tuple[Any, ...]]])
|
| 14 |
+
_ExceptionT = TypeVar("_ExceptionT", bound=Exception)
|
| 15 |
+
|
| 16 |
+
###
|
| 17 |
+
|
| 18 |
+
class UFuncTypeError(TypeError):
|
| 19 |
+
ufunc: Final[np.ufunc]
|
| 20 |
+
def __init__(self, /, ufunc: np.ufunc) -> None: ...
|
| 21 |
+
|
| 22 |
+
class _UFuncNoLoopError(UFuncTypeError):
|
| 23 |
+
dtypes: tuple[np.dtype[Any], ...]
|
| 24 |
+
def __init__(self, /, ufunc: np.ufunc, dtypes: Iterable[np.dtype[Any]]) -> None: ...
|
| 25 |
+
|
| 26 |
+
class _UFuncBinaryResolutionError(_UFuncNoLoopError):
|
| 27 |
+
dtypes: tuple[np.dtype[Any], np.dtype[Any]]
|
| 28 |
+
def __init__(self, /, ufunc: np.ufunc, dtypes: Iterable[np.dtype[Any]]) -> None: ...
|
| 29 |
+
|
| 30 |
+
class _UFuncCastingError(UFuncTypeError):
|
| 31 |
+
casting: Final[_CastingKind]
|
| 32 |
+
from_: Final[np.dtype[Any]]
|
| 33 |
+
to: Final[np.dtype[Any]]
|
| 34 |
+
def __init__(self, /, ufunc: np.ufunc, casting: _CastingKind, from_: np.dtype[Any], to: np.dtype[Any]) -> None: ...
|
| 35 |
+
|
| 36 |
+
class _UFuncInputCastingError(_UFuncCastingError):
|
| 37 |
+
in_i: Final[int]
|
| 38 |
+
def __init__(
|
| 39 |
+
self,
|
| 40 |
+
/,
|
| 41 |
+
ufunc: np.ufunc,
|
| 42 |
+
casting: _CastingKind,
|
| 43 |
+
from_: np.dtype[Any],
|
| 44 |
+
to: np.dtype[Any],
|
| 45 |
+
i: int,
|
| 46 |
+
) -> None: ...
|
| 47 |
+
|
| 48 |
+
class _UFuncOutputCastingError(_UFuncCastingError):
|
| 49 |
+
out_i: Final[int]
|
| 50 |
+
def __init__(
|
| 51 |
+
self,
|
| 52 |
+
/,
|
| 53 |
+
ufunc: np.ufunc,
|
| 54 |
+
casting: _CastingKind,
|
| 55 |
+
from_: np.dtype[Any],
|
| 56 |
+
to: np.dtype[Any],
|
| 57 |
+
i: int,
|
| 58 |
+
) -> None: ...
|
| 59 |
+
|
| 60 |
+
class _ArrayMemoryError(MemoryError):
|
| 61 |
+
shape: tuple[int, ...]
|
| 62 |
+
dtype: np.dtype[Any]
|
| 63 |
+
def __init__(self, /, shape: tuple[int, ...], dtype: np.dtype[Any]) -> None: ...
|
| 64 |
+
@property
|
| 65 |
+
def _total_size(self) -> int: ...
|
| 66 |
+
@staticmethod
|
| 67 |
+
def _size_to_string(num_bytes: int) -> str: ...
|
| 68 |
+
|
| 69 |
+
@overload
|
| 70 |
+
def _unpack_tuple(tup: tuple[_T]) -> _T: ...
|
| 71 |
+
@overload
|
| 72 |
+
def _unpack_tuple(tup: _TupleT) -> _TupleT: ...
|
| 73 |
+
def _display_as_base(cls: type[_ExceptionT]) -> type[_ExceptionT]: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_methods.py
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Array methods which are called by both the C-code for the method
|
| 3 |
+
and the Python code for the NumPy-namespace function
|
| 4 |
+
|
| 5 |
+
"""
|
| 6 |
+
import os
|
| 7 |
+
import pickle
|
| 8 |
+
import warnings
|
| 9 |
+
from contextlib import nullcontext
|
| 10 |
+
|
| 11 |
+
import numpy as np
|
| 12 |
+
from numpy._core import multiarray as mu
|
| 13 |
+
from numpy._core import umath as um
|
| 14 |
+
from numpy._core.multiarray import asanyarray
|
| 15 |
+
from numpy._core import numerictypes as nt
|
| 16 |
+
from numpy._core import _exceptions
|
| 17 |
+
from numpy._globals import _NoValue
|
| 18 |
+
|
| 19 |
+
# save those O(100) nanoseconds!
|
| 20 |
+
bool_dt = mu.dtype("bool")
|
| 21 |
+
umr_maximum = um.maximum.reduce
|
| 22 |
+
umr_minimum = um.minimum.reduce
|
| 23 |
+
umr_sum = um.add.reduce
|
| 24 |
+
umr_prod = um.multiply.reduce
|
| 25 |
+
umr_bitwise_count = um.bitwise_count
|
| 26 |
+
umr_any = um.logical_or.reduce
|
| 27 |
+
umr_all = um.logical_and.reduce
|
| 28 |
+
|
| 29 |
+
# Complex types to -> (2,)float view for fast-path computation in _var()
|
| 30 |
+
_complex_to_float = {
|
| 31 |
+
nt.dtype(nt.csingle) : nt.dtype(nt.single),
|
| 32 |
+
nt.dtype(nt.cdouble) : nt.dtype(nt.double),
|
| 33 |
+
}
|
| 34 |
+
# Special case for windows: ensure double takes precedence
|
| 35 |
+
if nt.dtype(nt.longdouble) != nt.dtype(nt.double):
|
| 36 |
+
_complex_to_float.update({
|
| 37 |
+
nt.dtype(nt.clongdouble) : nt.dtype(nt.longdouble),
|
| 38 |
+
})
|
| 39 |
+
|
| 40 |
+
# avoid keyword arguments to speed up parsing, saves about 15%-20% for very
|
| 41 |
+
# small reductions
|
| 42 |
+
def _amax(a, axis=None, out=None, keepdims=False,
|
| 43 |
+
initial=_NoValue, where=True):
|
| 44 |
+
return umr_maximum(a, axis, None, out, keepdims, initial, where)
|
| 45 |
+
|
| 46 |
+
def _amin(a, axis=None, out=None, keepdims=False,
|
| 47 |
+
initial=_NoValue, where=True):
|
| 48 |
+
return umr_minimum(a, axis, None, out, keepdims, initial, where)
|
| 49 |
+
|
| 50 |
+
def _sum(a, axis=None, dtype=None, out=None, keepdims=False,
|
| 51 |
+
initial=_NoValue, where=True):
|
| 52 |
+
return umr_sum(a, axis, dtype, out, keepdims, initial, where)
|
| 53 |
+
|
| 54 |
+
def _prod(a, axis=None, dtype=None, out=None, keepdims=False,
|
| 55 |
+
initial=_NoValue, where=True):
|
| 56 |
+
return umr_prod(a, axis, dtype, out, keepdims, initial, where)
|
| 57 |
+
|
| 58 |
+
def _any(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
|
| 59 |
+
# By default, return a boolean for any and all
|
| 60 |
+
if dtype is None:
|
| 61 |
+
dtype = bool_dt
|
| 62 |
+
# Parsing keyword arguments is currently fairly slow, so avoid it for now
|
| 63 |
+
if where is True:
|
| 64 |
+
return umr_any(a, axis, dtype, out, keepdims)
|
| 65 |
+
return umr_any(a, axis, dtype, out, keepdims, where=where)
|
| 66 |
+
|
| 67 |
+
def _all(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
|
| 68 |
+
# By default, return a boolean for any and all
|
| 69 |
+
if dtype is None:
|
| 70 |
+
dtype = bool_dt
|
| 71 |
+
# Parsing keyword arguments is currently fairly slow, so avoid it for now
|
| 72 |
+
if where is True:
|
| 73 |
+
return umr_all(a, axis, dtype, out, keepdims)
|
| 74 |
+
return umr_all(a, axis, dtype, out, keepdims, where=where)
|
| 75 |
+
|
| 76 |
+
def _count_reduce_items(arr, axis, keepdims=False, where=True):
|
| 77 |
+
# fast-path for the default case
|
| 78 |
+
if where is True:
|
| 79 |
+
# no boolean mask given, calculate items according to axis
|
| 80 |
+
if axis is None:
|
| 81 |
+
axis = tuple(range(arr.ndim))
|
| 82 |
+
elif not isinstance(axis, tuple):
|
| 83 |
+
axis = (axis,)
|
| 84 |
+
items = 1
|
| 85 |
+
for ax in axis:
|
| 86 |
+
items *= arr.shape[mu.normalize_axis_index(ax, arr.ndim)]
|
| 87 |
+
items = nt.intp(items)
|
| 88 |
+
else:
|
| 89 |
+
# TODO: Optimize case when `where` is broadcast along a non-reduction
|
| 90 |
+
# axis and full sum is more excessive than needed.
|
| 91 |
+
|
| 92 |
+
# guarded to protect circular imports
|
| 93 |
+
from numpy.lib._stride_tricks_impl import broadcast_to
|
| 94 |
+
# count True values in (potentially broadcasted) boolean mask
|
| 95 |
+
items = umr_sum(broadcast_to(where, arr.shape), axis, nt.intp, None,
|
| 96 |
+
keepdims)
|
| 97 |
+
return items
|
| 98 |
+
|
| 99 |
+
def _clip(a, min=None, max=None, out=None, **kwargs):
|
| 100 |
+
if a.dtype.kind in "iu":
|
| 101 |
+
# If min/max is a Python integer, deal with out-of-bound values here.
|
| 102 |
+
# (This enforces NEP 50 rules as no value based promotion is done.)
|
| 103 |
+
if type(min) is int and min <= np.iinfo(a.dtype).min:
|
| 104 |
+
min = None
|
| 105 |
+
if type(max) is int and max >= np.iinfo(a.dtype).max:
|
| 106 |
+
max = None
|
| 107 |
+
|
| 108 |
+
if min is None and max is None:
|
| 109 |
+
# return identity
|
| 110 |
+
return um.positive(a, out=out, **kwargs)
|
| 111 |
+
elif min is None:
|
| 112 |
+
return um.minimum(a, max, out=out, **kwargs)
|
| 113 |
+
elif max is None:
|
| 114 |
+
return um.maximum(a, min, out=out, **kwargs)
|
| 115 |
+
else:
|
| 116 |
+
return um.clip(a, min, max, out=out, **kwargs)
|
| 117 |
+
|
| 118 |
+
def _mean(a, axis=None, dtype=None, out=None, keepdims=False, *, where=True):
|
| 119 |
+
arr = asanyarray(a)
|
| 120 |
+
|
| 121 |
+
is_float16_result = False
|
| 122 |
+
|
| 123 |
+
rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)
|
| 124 |
+
if rcount == 0 if where is True else umr_any(rcount == 0, axis=None):
|
| 125 |
+
warnings.warn("Mean of empty slice.", RuntimeWarning, stacklevel=2)
|
| 126 |
+
|
| 127 |
+
# Cast bool, unsigned int, and int to float64 by default
|
| 128 |
+
if dtype is None:
|
| 129 |
+
if issubclass(arr.dtype.type, (nt.integer, nt.bool)):
|
| 130 |
+
dtype = mu.dtype('f8')
|
| 131 |
+
elif issubclass(arr.dtype.type, nt.float16):
|
| 132 |
+
dtype = mu.dtype('f4')
|
| 133 |
+
is_float16_result = True
|
| 134 |
+
|
| 135 |
+
ret = umr_sum(arr, axis, dtype, out, keepdims, where=where)
|
| 136 |
+
if isinstance(ret, mu.ndarray):
|
| 137 |
+
ret = um.true_divide(
|
| 138 |
+
ret, rcount, out=ret, casting='unsafe', subok=False)
|
| 139 |
+
if is_float16_result and out is None:
|
| 140 |
+
ret = arr.dtype.type(ret)
|
| 141 |
+
elif hasattr(ret, 'dtype'):
|
| 142 |
+
if is_float16_result:
|
| 143 |
+
ret = arr.dtype.type(ret / rcount)
|
| 144 |
+
else:
|
| 145 |
+
ret = ret.dtype.type(ret / rcount)
|
| 146 |
+
else:
|
| 147 |
+
ret = ret / rcount
|
| 148 |
+
|
| 149 |
+
return ret
|
| 150 |
+
|
| 151 |
+
def _var(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
|
| 152 |
+
where=True, mean=None):
|
| 153 |
+
arr = asanyarray(a)
|
| 154 |
+
|
| 155 |
+
rcount = _count_reduce_items(arr, axis, keepdims=keepdims, where=where)
|
| 156 |
+
# Make this warning show up on top.
|
| 157 |
+
if ddof >= rcount if where is True else umr_any(ddof >= rcount, axis=None):
|
| 158 |
+
warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning,
|
| 159 |
+
stacklevel=2)
|
| 160 |
+
|
| 161 |
+
# Cast bool, unsigned int, and int to float64 by default
|
| 162 |
+
if dtype is None and issubclass(arr.dtype.type, (nt.integer, nt.bool)):
|
| 163 |
+
dtype = mu.dtype('f8')
|
| 164 |
+
|
| 165 |
+
if mean is not None:
|
| 166 |
+
arrmean = mean
|
| 167 |
+
else:
|
| 168 |
+
# Compute the mean.
|
| 169 |
+
# Note that if dtype is not of inexact type then arraymean will
|
| 170 |
+
# not be either.
|
| 171 |
+
arrmean = umr_sum(arr, axis, dtype, keepdims=True, where=where)
|
| 172 |
+
# The shape of rcount has to match arrmean to not change the shape of
|
| 173 |
+
# out in broadcasting. Otherwise, it cannot be stored back to arrmean.
|
| 174 |
+
if rcount.ndim == 0:
|
| 175 |
+
# fast-path for default case when where is True
|
| 176 |
+
div = rcount
|
| 177 |
+
else:
|
| 178 |
+
# matching rcount to arrmean when where is specified as array
|
| 179 |
+
div = rcount.reshape(arrmean.shape)
|
| 180 |
+
if isinstance(arrmean, mu.ndarray):
|
| 181 |
+
arrmean = um.true_divide(arrmean, div, out=arrmean,
|
| 182 |
+
casting='unsafe', subok=False)
|
| 183 |
+
elif hasattr(arrmean, "dtype"):
|
| 184 |
+
arrmean = arrmean.dtype.type(arrmean / rcount)
|
| 185 |
+
else:
|
| 186 |
+
arrmean = arrmean / rcount
|
| 187 |
+
|
| 188 |
+
# Compute sum of squared deviations from mean
|
| 189 |
+
# Note that x may not be inexact and that we need it to be an array,
|
| 190 |
+
# not a scalar.
|
| 191 |
+
x = asanyarray(arr - arrmean)
|
| 192 |
+
|
| 193 |
+
if issubclass(arr.dtype.type, (nt.floating, nt.integer)):
|
| 194 |
+
x = um.multiply(x, x, out=x)
|
| 195 |
+
# Fast-paths for built-in complex types
|
| 196 |
+
elif x.dtype in _complex_to_float:
|
| 197 |
+
xv = x.view(dtype=(_complex_to_float[x.dtype], (2,)))
|
| 198 |
+
um.multiply(xv, xv, out=xv)
|
| 199 |
+
x = um.add(xv[..., 0], xv[..., 1], out=x.real).real
|
| 200 |
+
# Most general case; includes handling object arrays containing imaginary
|
| 201 |
+
# numbers and complex types with non-native byteorder
|
| 202 |
+
else:
|
| 203 |
+
x = um.multiply(x, um.conjugate(x), out=x).real
|
| 204 |
+
|
| 205 |
+
ret = umr_sum(x, axis, dtype, out, keepdims=keepdims, where=where)
|
| 206 |
+
|
| 207 |
+
# Compute degrees of freedom and make sure it is not negative.
|
| 208 |
+
rcount = um.maximum(rcount - ddof, 0)
|
| 209 |
+
|
| 210 |
+
# divide by degrees of freedom
|
| 211 |
+
if isinstance(ret, mu.ndarray):
|
| 212 |
+
ret = um.true_divide(
|
| 213 |
+
ret, rcount, out=ret, casting='unsafe', subok=False)
|
| 214 |
+
elif hasattr(ret, 'dtype'):
|
| 215 |
+
ret = ret.dtype.type(ret / rcount)
|
| 216 |
+
else:
|
| 217 |
+
ret = ret / rcount
|
| 218 |
+
|
| 219 |
+
return ret
|
| 220 |
+
|
| 221 |
+
def _std(a, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *,
|
| 222 |
+
where=True, mean=None):
|
| 223 |
+
ret = _var(a, axis=axis, dtype=dtype, out=out, ddof=ddof,
|
| 224 |
+
keepdims=keepdims, where=where, mean=mean)
|
| 225 |
+
|
| 226 |
+
if isinstance(ret, mu.ndarray):
|
| 227 |
+
ret = um.sqrt(ret, out=ret)
|
| 228 |
+
elif hasattr(ret, 'dtype'):
|
| 229 |
+
ret = ret.dtype.type(um.sqrt(ret))
|
| 230 |
+
else:
|
| 231 |
+
ret = um.sqrt(ret)
|
| 232 |
+
|
| 233 |
+
return ret
|
| 234 |
+
|
| 235 |
+
def _ptp(a, axis=None, out=None, keepdims=False):
|
| 236 |
+
return um.subtract(
|
| 237 |
+
umr_maximum(a, axis, None, out, keepdims),
|
| 238 |
+
umr_minimum(a, axis, None, None, keepdims),
|
| 239 |
+
out
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
def _dump(self, file, protocol=2):
|
| 243 |
+
if hasattr(file, 'write'):
|
| 244 |
+
ctx = nullcontext(file)
|
| 245 |
+
else:
|
| 246 |
+
ctx = open(os.fspath(file), "wb")
|
| 247 |
+
with ctx as f:
|
| 248 |
+
pickle.dump(self, f, protocol=protocol)
|
| 249 |
+
|
| 250 |
+
def _dumps(self, protocol=2):
|
| 251 |
+
return pickle.dumps(self, protocol=protocol)
|
| 252 |
+
|
| 253 |
+
def _bitwise_count(a, out=None, *, where=True, casting='same_kind',
|
| 254 |
+
order='K', dtype=None, subok=True):
|
| 255 |
+
return umr_bitwise_count(a, out, where=where, casting=casting,
|
| 256 |
+
order=order, dtype=dtype, subok=subok)
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_methods.pyi
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Callable
|
| 2 |
+
from typing import Any, TypeAlias
|
| 3 |
+
|
| 4 |
+
from typing_extensions import Concatenate
|
| 5 |
+
|
| 6 |
+
import numpy as np
|
| 7 |
+
|
| 8 |
+
from . import _exceptions as _exceptions
|
| 9 |
+
|
| 10 |
+
###
|
| 11 |
+
|
| 12 |
+
_Reduce2: TypeAlias = Callable[Concatenate[object, ...], Any]
|
| 13 |
+
|
| 14 |
+
###
|
| 15 |
+
|
| 16 |
+
bool_dt: np.dtype[np.bool] = ...
|
| 17 |
+
umr_maximum: _Reduce2 = ...
|
| 18 |
+
umr_minimum: _Reduce2 = ...
|
| 19 |
+
umr_sum: _Reduce2 = ...
|
| 20 |
+
umr_prod: _Reduce2 = ...
|
| 21 |
+
umr_bitwise_count = np.bitwise_count
|
| 22 |
+
umr_any: _Reduce2 = ...
|
| 23 |
+
umr_all: _Reduce2 = ...
|
| 24 |
+
_complex_to_float: dict[np.dtype[np.complexfloating], np.dtype[np.floating]] = ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_tests.cp310-win_amd64.lib
ADDED
|
Binary file (2.42 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_tests.cp310-win_amd64.pyd
ADDED
|
Binary file (63 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_multiarray_umath.cp310-win_amd64.lib
ADDED
|
Binary file (2.19 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_operand_flag_tests.cp310-win_amd64.lib
ADDED
|
Binary file (2.23 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_operand_flag_tests.cp310-win_amd64.pyd
ADDED
|
Binary file (11.8 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_rational_tests.cp310-win_amd64.lib
ADDED
|
Binary file (2.16 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_rational_tests.cp310-win_amd64.pyd
ADDED
|
Binary file (40.4 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_simd.cp310-win_amd64.lib
ADDED
|
Binary file (1.98 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_simd.pyi
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from types import ModuleType
|
| 2 |
+
from typing import TypedDict, type_check_only
|
| 3 |
+
|
| 4 |
+
# NOTE: these 5 are only defined on systems with an intel processor
|
| 5 |
+
SSE42: ModuleType | None = ...
|
| 6 |
+
FMA3: ModuleType | None = ...
|
| 7 |
+
AVX2: ModuleType | None = ...
|
| 8 |
+
AVX512F: ModuleType | None = ...
|
| 9 |
+
AVX512_SKX: ModuleType | None = ...
|
| 10 |
+
|
| 11 |
+
baseline: ModuleType | None = ...
|
| 12 |
+
|
| 13 |
+
@type_check_only
|
| 14 |
+
class SimdTargets(TypedDict):
|
| 15 |
+
SSE42: ModuleType | None
|
| 16 |
+
AVX2: ModuleType | None
|
| 17 |
+
FMA3: ModuleType | None
|
| 18 |
+
AVX512F: ModuleType | None
|
| 19 |
+
AVX512_SKX: ModuleType | None
|
| 20 |
+
baseline: ModuleType | None
|
| 21 |
+
|
| 22 |
+
targets: SimdTargets = ...
|
| 23 |
+
|
| 24 |
+
def clear_floatstatus() -> None: ...
|
| 25 |
+
def get_floatstatus() -> int: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_string_helpers.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
String-handling utilities to avoid locale-dependence.
|
| 3 |
+
|
| 4 |
+
Used primarily to generate type name aliases.
|
| 5 |
+
"""
|
| 6 |
+
# "import string" is costly to import!
|
| 7 |
+
# Construct the translation tables directly
|
| 8 |
+
# "A" = chr(65), "a" = chr(97)
|
| 9 |
+
_all_chars = tuple(map(chr, range(256)))
|
| 10 |
+
_ascii_upper = _all_chars[65:65+26]
|
| 11 |
+
_ascii_lower = _all_chars[97:97+26]
|
| 12 |
+
LOWER_TABLE = _all_chars[:65] + _ascii_lower + _all_chars[65+26:]
|
| 13 |
+
UPPER_TABLE = _all_chars[:97] + _ascii_upper + _all_chars[97+26:]
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def english_lower(s):
|
| 17 |
+
""" Apply English case rules to convert ASCII strings to all lower case.
|
| 18 |
+
|
| 19 |
+
This is an internal utility function to replace calls to str.lower() such
|
| 20 |
+
that we can avoid changing behavior with changing locales. In particular,
|
| 21 |
+
Turkish has distinct dotted and dotless variants of the Latin letter "I" in
|
| 22 |
+
both lowercase and uppercase. Thus, "I".lower() != "i" in a "tr" locale.
|
| 23 |
+
|
| 24 |
+
Parameters
|
| 25 |
+
----------
|
| 26 |
+
s : str
|
| 27 |
+
|
| 28 |
+
Returns
|
| 29 |
+
-------
|
| 30 |
+
lowered : str
|
| 31 |
+
|
| 32 |
+
Examples
|
| 33 |
+
--------
|
| 34 |
+
>>> from numpy._core.numerictypes import english_lower
|
| 35 |
+
>>> english_lower('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
|
| 36 |
+
'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789_'
|
| 37 |
+
>>> english_lower('')
|
| 38 |
+
''
|
| 39 |
+
"""
|
| 40 |
+
lowered = s.translate(LOWER_TABLE)
|
| 41 |
+
return lowered
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def english_upper(s):
|
| 45 |
+
""" Apply English case rules to convert ASCII strings to all upper case.
|
| 46 |
+
|
| 47 |
+
This is an internal utility function to replace calls to str.upper() such
|
| 48 |
+
that we can avoid changing behavior with changing locales. In particular,
|
| 49 |
+
Turkish has distinct dotted and dotless variants of the Latin letter "I" in
|
| 50 |
+
both lowercase and uppercase. Thus, "i".upper() != "I" in a "tr" locale.
|
| 51 |
+
|
| 52 |
+
Parameters
|
| 53 |
+
----------
|
| 54 |
+
s : str
|
| 55 |
+
|
| 56 |
+
Returns
|
| 57 |
+
-------
|
| 58 |
+
uppered : str
|
| 59 |
+
|
| 60 |
+
Examples
|
| 61 |
+
--------
|
| 62 |
+
>>> from numpy._core.numerictypes import english_upper
|
| 63 |
+
>>> english_upper('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_')
|
| 64 |
+
'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
|
| 65 |
+
>>> english_upper('')
|
| 66 |
+
''
|
| 67 |
+
"""
|
| 68 |
+
uppered = s.translate(UPPER_TABLE)
|
| 69 |
+
return uppered
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def english_capitalize(s):
|
| 73 |
+
""" Apply English case rules to convert the first character of an ASCII
|
| 74 |
+
string to upper case.
|
| 75 |
+
|
| 76 |
+
This is an internal utility function to replace calls to str.capitalize()
|
| 77 |
+
such that we can avoid changing behavior with changing locales.
|
| 78 |
+
|
| 79 |
+
Parameters
|
| 80 |
+
----------
|
| 81 |
+
s : str
|
| 82 |
+
|
| 83 |
+
Returns
|
| 84 |
+
-------
|
| 85 |
+
capitalized : str
|
| 86 |
+
|
| 87 |
+
Examples
|
| 88 |
+
--------
|
| 89 |
+
>>> from numpy._core.numerictypes import english_capitalize
|
| 90 |
+
>>> english_capitalize('int8')
|
| 91 |
+
'Int8'
|
| 92 |
+
>>> english_capitalize('Int8')
|
| 93 |
+
'Int8'
|
| 94 |
+
>>> english_capitalize('')
|
| 95 |
+
''
|
| 96 |
+
"""
|
| 97 |
+
if s:
|
| 98 |
+
return english_upper(s[0]) + s[1:]
|
| 99 |
+
else:
|
| 100 |
+
return s
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_string_helpers.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Final
|
| 2 |
+
|
| 3 |
+
_all_chars: Final[tuple[str, ...]] = ...
|
| 4 |
+
_ascii_upper: Final[tuple[str, ...]] = ...
|
| 5 |
+
_ascii_lower: Final[tuple[str, ...]] = ...
|
| 6 |
+
|
| 7 |
+
LOWER_TABLE: Final[tuple[str, ...]] = ...
|
| 8 |
+
UPPER_TABLE: Final[tuple[str, ...]] = ...
|
| 9 |
+
|
| 10 |
+
def english_lower(s: str) -> str: ...
|
| 11 |
+
def english_upper(s: str) -> str: ...
|
| 12 |
+
def english_capitalize(s: str) -> str: ...
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_struct_ufunc_tests.cp310-win_amd64.lib
ADDED
|
Binary file (2.23 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_struct_ufunc_tests.cp310-win_amd64.pyd
ADDED
|
Binary file (13.8 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_type_aliases.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Due to compatibility, numpy has a very large number of different naming
|
| 3 |
+
conventions for the scalar types (those subclassing from `numpy.generic`).
|
| 4 |
+
This file produces a convoluted set of dictionaries mapping names to types,
|
| 5 |
+
and sometimes other mappings too.
|
| 6 |
+
|
| 7 |
+
.. data:: allTypes
|
| 8 |
+
A dictionary of names to types that will be exposed as attributes through
|
| 9 |
+
``np._core.numerictypes.*``
|
| 10 |
+
|
| 11 |
+
.. data:: sctypeDict
|
| 12 |
+
Similar to `allTypes`, but maps a broader set of aliases to their types.
|
| 13 |
+
|
| 14 |
+
.. data:: sctypes
|
| 15 |
+
A dictionary keyed by a "type group" string, providing a list of types
|
| 16 |
+
under that group.
|
| 17 |
+
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
import numpy._core.multiarray as ma
|
| 21 |
+
from numpy._core.multiarray import typeinfo, dtype
|
| 22 |
+
|
| 23 |
+
######################################
|
| 24 |
+
# Building `sctypeDict` and `allTypes`
|
| 25 |
+
######################################
|
| 26 |
+
|
| 27 |
+
sctypeDict = {}
|
| 28 |
+
allTypes = {}
|
| 29 |
+
c_names_dict = {}
|
| 30 |
+
|
| 31 |
+
_abstract_type_names = {
|
| 32 |
+
"generic", "integer", "inexact", "floating", "number",
|
| 33 |
+
"flexible", "character", "complexfloating", "unsignedinteger",
|
| 34 |
+
"signedinteger"
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
for _abstract_type_name in _abstract_type_names:
|
| 38 |
+
allTypes[_abstract_type_name] = getattr(ma, _abstract_type_name)
|
| 39 |
+
|
| 40 |
+
for k, v in typeinfo.items():
|
| 41 |
+
if k.startswith("NPY_") and v not in c_names_dict:
|
| 42 |
+
c_names_dict[k[4:]] = v
|
| 43 |
+
else:
|
| 44 |
+
concrete_type = v.type
|
| 45 |
+
allTypes[k] = concrete_type
|
| 46 |
+
sctypeDict[k] = concrete_type
|
| 47 |
+
|
| 48 |
+
_aliases = {
|
| 49 |
+
"double": "float64",
|
| 50 |
+
"cdouble": "complex128",
|
| 51 |
+
"single": "float32",
|
| 52 |
+
"csingle": "complex64",
|
| 53 |
+
"half": "float16",
|
| 54 |
+
"bool_": "bool",
|
| 55 |
+
# Default integer:
|
| 56 |
+
"int_": "intp",
|
| 57 |
+
"uint": "uintp",
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
for k, v in _aliases.items():
|
| 61 |
+
sctypeDict[k] = allTypes[v]
|
| 62 |
+
allTypes[k] = allTypes[v]
|
| 63 |
+
|
| 64 |
+
# extra aliases are added only to `sctypeDict`
|
| 65 |
+
# to support dtype name access, such as`np.dtype("float")`
|
| 66 |
+
_extra_aliases = {
|
| 67 |
+
"float": "float64",
|
| 68 |
+
"complex": "complex128",
|
| 69 |
+
"object": "object_",
|
| 70 |
+
"bytes": "bytes_",
|
| 71 |
+
"a": "bytes_",
|
| 72 |
+
"int": "int_",
|
| 73 |
+
"str": "str_",
|
| 74 |
+
"unicode": "str_",
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
for k, v in _extra_aliases.items():
|
| 78 |
+
sctypeDict[k] = allTypes[v]
|
| 79 |
+
|
| 80 |
+
# include extended precision sized aliases
|
| 81 |
+
for is_complex, full_name in [(False, "longdouble"), (True, "clongdouble")]:
|
| 82 |
+
longdouble_type: type = allTypes[full_name]
|
| 83 |
+
|
| 84 |
+
bits: int = dtype(longdouble_type).itemsize * 8
|
| 85 |
+
base_name: str = "complex" if is_complex else "float"
|
| 86 |
+
extended_prec_name: str = f"{base_name}{bits}"
|
| 87 |
+
if extended_prec_name not in allTypes:
|
| 88 |
+
sctypeDict[extended_prec_name] = longdouble_type
|
| 89 |
+
allTypes[extended_prec_name] = longdouble_type
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
####################
|
| 93 |
+
# Building `sctypes`
|
| 94 |
+
####################
|
| 95 |
+
|
| 96 |
+
sctypes = {"int": set(), "uint": set(), "float": set(),
|
| 97 |
+
"complex": set(), "others": set()}
|
| 98 |
+
|
| 99 |
+
for type_info in typeinfo.values():
|
| 100 |
+
if type_info.kind in ["M", "m"]: # exclude timedelta and datetime
|
| 101 |
+
continue
|
| 102 |
+
|
| 103 |
+
concrete_type = type_info.type
|
| 104 |
+
|
| 105 |
+
# find proper group for each concrete type
|
| 106 |
+
for type_group, abstract_type in [
|
| 107 |
+
("int", ma.signedinteger), ("uint", ma.unsignedinteger),
|
| 108 |
+
("float", ma.floating), ("complex", ma.complexfloating),
|
| 109 |
+
("others", ma.generic)
|
| 110 |
+
]:
|
| 111 |
+
if issubclass(concrete_type, abstract_type):
|
| 112 |
+
sctypes[type_group].add(concrete_type)
|
| 113 |
+
break
|
| 114 |
+
|
| 115 |
+
# sort sctype groups by bitsize
|
| 116 |
+
for sctype_key in sctypes.keys():
|
| 117 |
+
sctype_list = list(sctypes[sctype_key])
|
| 118 |
+
sctype_list.sort(key=lambda x: dtype(x).itemsize)
|
| 119 |
+
sctypes[sctype_key] = sctype_list
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_type_aliases.pyi
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from collections.abc import Collection
|
| 2 |
+
from typing import Any, Final, Literal as L, TypeAlias, TypedDict, type_check_only
|
| 3 |
+
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
__all__ = (
|
| 7 |
+
"_abstract_type_names",
|
| 8 |
+
"_aliases",
|
| 9 |
+
"_extra_aliases",
|
| 10 |
+
"allTypes",
|
| 11 |
+
"c_names_dict",
|
| 12 |
+
"sctypeDict",
|
| 13 |
+
"sctypes",
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
sctypeDict: Final[dict[str, type[np.generic]]]
|
| 17 |
+
allTypes: Final[dict[str, type[np.generic]]]
|
| 18 |
+
|
| 19 |
+
@type_check_only
|
| 20 |
+
class _CNamesDict(TypedDict):
|
| 21 |
+
BOOL: np.dtype[np.bool]
|
| 22 |
+
HALF: np.dtype[np.half]
|
| 23 |
+
FLOAT: np.dtype[np.single]
|
| 24 |
+
DOUBLE: np.dtype[np.double]
|
| 25 |
+
LONGDOUBLE: np.dtype[np.longdouble]
|
| 26 |
+
CFLOAT: np.dtype[np.csingle]
|
| 27 |
+
CDOUBLE: np.dtype[np.cdouble]
|
| 28 |
+
CLONGDOUBLE: np.dtype[np.clongdouble]
|
| 29 |
+
STRING: np.dtype[np.bytes_]
|
| 30 |
+
UNICODE: np.dtype[np.str_]
|
| 31 |
+
VOID: np.dtype[np.void]
|
| 32 |
+
OBJECT: np.dtype[np.object_]
|
| 33 |
+
DATETIME: np.dtype[np.datetime64]
|
| 34 |
+
TIMEDELTA: np.dtype[np.timedelta64]
|
| 35 |
+
BYTE: np.dtype[np.byte]
|
| 36 |
+
UBYTE: np.dtype[np.ubyte]
|
| 37 |
+
SHORT: np.dtype[np.short]
|
| 38 |
+
USHORT: np.dtype[np.ushort]
|
| 39 |
+
INT: np.dtype[np.intc]
|
| 40 |
+
UINT: np.dtype[np.uintc]
|
| 41 |
+
LONG: np.dtype[np.long]
|
| 42 |
+
ULONG: np.dtype[np.ulong]
|
| 43 |
+
LONGLONG: np.dtype[np.longlong]
|
| 44 |
+
ULONGLONG: np.dtype[np.ulonglong]
|
| 45 |
+
|
| 46 |
+
c_names_dict: Final[_CNamesDict]
|
| 47 |
+
|
| 48 |
+
_AbstractTypeName: TypeAlias = L[
|
| 49 |
+
"generic",
|
| 50 |
+
"flexible",
|
| 51 |
+
"character",
|
| 52 |
+
"number",
|
| 53 |
+
"integer",
|
| 54 |
+
"inexact",
|
| 55 |
+
"unsignedinteger",
|
| 56 |
+
"signedinteger",
|
| 57 |
+
"floating",
|
| 58 |
+
"complexfloating",
|
| 59 |
+
]
|
| 60 |
+
_abstract_type_names: Final[set[_AbstractTypeName]]
|
| 61 |
+
|
| 62 |
+
@type_check_only
|
| 63 |
+
class _AliasesType(TypedDict):
|
| 64 |
+
double: L["float64"]
|
| 65 |
+
cdouble: L["complex128"]
|
| 66 |
+
single: L["float32"]
|
| 67 |
+
csingle: L["complex64"]
|
| 68 |
+
half: L["float16"]
|
| 69 |
+
bool_: L["bool"]
|
| 70 |
+
int_: L["intp"]
|
| 71 |
+
uint: L["intp"]
|
| 72 |
+
|
| 73 |
+
_aliases: Final[_AliasesType]
|
| 74 |
+
|
| 75 |
+
@type_check_only
|
| 76 |
+
class _ExtraAliasesType(TypedDict):
|
| 77 |
+
float: L["float64"]
|
| 78 |
+
complex: L["complex128"]
|
| 79 |
+
object: L["object_"]
|
| 80 |
+
bytes: L["bytes_"]
|
| 81 |
+
a: L["bytes_"]
|
| 82 |
+
int: L["int_"]
|
| 83 |
+
str: L["str_"]
|
| 84 |
+
unicode: L["str_"]
|
| 85 |
+
|
| 86 |
+
_extra_aliases: Final[_ExtraAliasesType]
|
| 87 |
+
|
| 88 |
+
@type_check_only
|
| 89 |
+
class _SCTypes(TypedDict):
|
| 90 |
+
int: Collection[type[np.signedinteger[Any]]]
|
| 91 |
+
uint: Collection[type[np.unsignedinteger[Any]]]
|
| 92 |
+
float: Collection[type[np.floating[Any]]]
|
| 93 |
+
complex: Collection[type[np.complexfloating[Any, Any]]]
|
| 94 |
+
others: Collection[type[np.flexible | np.bool | np.object_]]
|
| 95 |
+
|
| 96 |
+
sctypes: Final[_SCTypes]
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_ufunc_config.py
ADDED
|
@@ -0,0 +1,483 @@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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Functions for changing global ufunc configuration
|
| 3 |
+
|
| 4 |
+
This provides helpers which wrap `_get_extobj_dict` and `_make_extobj`, and
|
| 5 |
+
`_extobj_contextvar` from umath.
|
| 6 |
+
"""
|
| 7 |
+
import contextlib
|
| 8 |
+
import contextvars
|
| 9 |
+
import functools
|
| 10 |
+
|
| 11 |
+
from .._utils import set_module
|
| 12 |
+
from .umath import _make_extobj, _get_extobj_dict, _extobj_contextvar
|
| 13 |
+
|
| 14 |
+
__all__ = [
|
| 15 |
+
"seterr", "geterr", "setbufsize", "getbufsize", "seterrcall", "geterrcall",
|
| 16 |
+
"errstate"
|
| 17 |
+
]
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
@set_module('numpy')
|
| 21 |
+
def seterr(all=None, divide=None, over=None, under=None, invalid=None):
|
| 22 |
+
"""
|
| 23 |
+
Set how floating-point errors are handled.
|
| 24 |
+
|
| 25 |
+
Note that operations on integer scalar types (such as `int16`) are
|
| 26 |
+
handled like floating point, and are affected by these settings.
|
| 27 |
+
|
| 28 |
+
Parameters
|
| 29 |
+
----------
|
| 30 |
+
all : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
|
| 31 |
+
Set treatment for all types of floating-point errors at once:
|
| 32 |
+
|
| 33 |
+
- ignore: Take no action when the exception occurs.
|
| 34 |
+
- warn: Print a :exc:`RuntimeWarning` (via the Python `warnings`
|
| 35 |
+
module).
|
| 36 |
+
- raise: Raise a :exc:`FloatingPointError`.
|
| 37 |
+
- call: Call a function specified using the `seterrcall` function.
|
| 38 |
+
- print: Print a warning directly to ``stdout``.
|
| 39 |
+
- log: Record error in a Log object specified by `seterrcall`.
|
| 40 |
+
|
| 41 |
+
The default is not to change the current behavior.
|
| 42 |
+
divide : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
|
| 43 |
+
Treatment for division by zero.
|
| 44 |
+
over : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
|
| 45 |
+
Treatment for floating-point overflow.
|
| 46 |
+
under : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
|
| 47 |
+
Treatment for floating-point underflow.
|
| 48 |
+
invalid : {'ignore', 'warn', 'raise', 'call', 'print', 'log'}, optional
|
| 49 |
+
Treatment for invalid floating-point operation.
|
| 50 |
+
|
| 51 |
+
Returns
|
| 52 |
+
-------
|
| 53 |
+
old_settings : dict
|
| 54 |
+
Dictionary containing the old settings.
|
| 55 |
+
|
| 56 |
+
See also
|
| 57 |
+
--------
|
| 58 |
+
seterrcall : Set a callback function for the 'call' mode.
|
| 59 |
+
geterr, geterrcall, errstate
|
| 60 |
+
|
| 61 |
+
Notes
|
| 62 |
+
-----
|
| 63 |
+
The floating-point exceptions are defined in the IEEE 754 standard [1]_:
|
| 64 |
+
|
| 65 |
+
- Division by zero: infinite result obtained from finite numbers.
|
| 66 |
+
- Overflow: result too large to be expressed.
|
| 67 |
+
- Underflow: result so close to zero that some precision
|
| 68 |
+
was lost.
|
| 69 |
+
- Invalid operation: result is not an expressible number, typically
|
| 70 |
+
indicates that a NaN was produced.
|
| 71 |
+
|
| 72 |
+
.. [1] https://en.wikipedia.org/wiki/IEEE_754
|
| 73 |
+
|
| 74 |
+
Examples
|
| 75 |
+
--------
|
| 76 |
+
>>> import numpy as np
|
| 77 |
+
>>> orig_settings = np.seterr(all='ignore') # seterr to known value
|
| 78 |
+
>>> np.int16(32000) * np.int16(3)
|
| 79 |
+
np.int16(30464)
|
| 80 |
+
>>> np.seterr(over='raise')
|
| 81 |
+
{'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
|
| 82 |
+
>>> old_settings = np.seterr(all='warn', over='raise')
|
| 83 |
+
>>> np.int16(32000) * np.int16(3)
|
| 84 |
+
Traceback (most recent call last):
|
| 85 |
+
File "<stdin>", line 1, in <module>
|
| 86 |
+
FloatingPointError: overflow encountered in scalar multiply
|
| 87 |
+
|
| 88 |
+
>>> old_settings = np.seterr(all='print')
|
| 89 |
+
>>> np.geterr()
|
| 90 |
+
{'divide': 'print', 'over': 'print', 'under': 'print', 'invalid': 'print'}
|
| 91 |
+
>>> np.int16(32000) * np.int16(3)
|
| 92 |
+
np.int16(30464)
|
| 93 |
+
>>> np.seterr(**orig_settings) # restore original
|
| 94 |
+
{'divide': 'print', 'over': 'print', 'under': 'print', 'invalid': 'print'}
|
| 95 |
+
|
| 96 |
+
"""
|
| 97 |
+
|
| 98 |
+
old = _get_extobj_dict()
|
| 99 |
+
# The errstate doesn't include call and bufsize, so pop them:
|
| 100 |
+
old.pop("call", None)
|
| 101 |
+
old.pop("bufsize", None)
|
| 102 |
+
|
| 103 |
+
extobj = _make_extobj(
|
| 104 |
+
all=all, divide=divide, over=over, under=under, invalid=invalid)
|
| 105 |
+
_extobj_contextvar.set(extobj)
|
| 106 |
+
return old
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
@set_module('numpy')
|
| 110 |
+
def geterr():
|
| 111 |
+
"""
|
| 112 |
+
Get the current way of handling floating-point errors.
|
| 113 |
+
|
| 114 |
+
Returns
|
| 115 |
+
-------
|
| 116 |
+
res : dict
|
| 117 |
+
A dictionary with keys "divide", "over", "under", and "invalid",
|
| 118 |
+
whose values are from the strings "ignore", "print", "log", "warn",
|
| 119 |
+
"raise", and "call". The keys represent possible floating-point
|
| 120 |
+
exceptions, and the values define how these exceptions are handled.
|
| 121 |
+
|
| 122 |
+
See Also
|
| 123 |
+
--------
|
| 124 |
+
geterrcall, seterr, seterrcall
|
| 125 |
+
|
| 126 |
+
Notes
|
| 127 |
+
-----
|
| 128 |
+
For complete documentation of the types of floating-point exceptions and
|
| 129 |
+
treatment options, see `seterr`.
|
| 130 |
+
|
| 131 |
+
Examples
|
| 132 |
+
--------
|
| 133 |
+
>>> import numpy as np
|
| 134 |
+
>>> np.geterr()
|
| 135 |
+
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
|
| 136 |
+
>>> np.arange(3.) / np.arange(3.) # doctest: +SKIP
|
| 137 |
+
array([nan, 1., 1.])
|
| 138 |
+
RuntimeWarning: invalid value encountered in divide
|
| 139 |
+
|
| 140 |
+
>>> oldsettings = np.seterr(all='warn', invalid='raise')
|
| 141 |
+
>>> np.geterr()
|
| 142 |
+
{'divide': 'warn', 'over': 'warn', 'under': 'warn', 'invalid': 'raise'}
|
| 143 |
+
>>> np.arange(3.) / np.arange(3.)
|
| 144 |
+
Traceback (most recent call last):
|
| 145 |
+
...
|
| 146 |
+
FloatingPointError: invalid value encountered in divide
|
| 147 |
+
>>> oldsettings = np.seterr(**oldsettings) # restore original
|
| 148 |
+
|
| 149 |
+
"""
|
| 150 |
+
res = _get_extobj_dict()
|
| 151 |
+
# The "geterr" doesn't include call and bufsize,:
|
| 152 |
+
res.pop("call", None)
|
| 153 |
+
res.pop("bufsize", None)
|
| 154 |
+
return res
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
@set_module('numpy')
|
| 158 |
+
def setbufsize(size):
|
| 159 |
+
"""
|
| 160 |
+
Set the size of the buffer used in ufuncs.
|
| 161 |
+
|
| 162 |
+
.. versionchanged:: 2.0
|
| 163 |
+
The scope of setting the buffer is tied to the `numpy.errstate`
|
| 164 |
+
context. Exiting a ``with errstate():`` will also restore the bufsize.
|
| 165 |
+
|
| 166 |
+
Parameters
|
| 167 |
+
----------
|
| 168 |
+
size : int
|
| 169 |
+
Size of buffer.
|
| 170 |
+
|
| 171 |
+
Returns
|
| 172 |
+
-------
|
| 173 |
+
bufsize : int
|
| 174 |
+
Previous size of ufunc buffer in bytes.
|
| 175 |
+
|
| 176 |
+
Examples
|
| 177 |
+
--------
|
| 178 |
+
When exiting a `numpy.errstate` context manager the bufsize is restored:
|
| 179 |
+
|
| 180 |
+
>>> import numpy as np
|
| 181 |
+
>>> with np.errstate():
|
| 182 |
+
... np.setbufsize(4096)
|
| 183 |
+
... print(np.getbufsize())
|
| 184 |
+
...
|
| 185 |
+
8192
|
| 186 |
+
4096
|
| 187 |
+
>>> np.getbufsize()
|
| 188 |
+
8192
|
| 189 |
+
|
| 190 |
+
"""
|
| 191 |
+
old = _get_extobj_dict()["bufsize"]
|
| 192 |
+
extobj = _make_extobj(bufsize=size)
|
| 193 |
+
_extobj_contextvar.set(extobj)
|
| 194 |
+
return old
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
@set_module('numpy')
|
| 198 |
+
def getbufsize():
|
| 199 |
+
"""
|
| 200 |
+
Return the size of the buffer used in ufuncs.
|
| 201 |
+
|
| 202 |
+
Returns
|
| 203 |
+
-------
|
| 204 |
+
getbufsize : int
|
| 205 |
+
Size of ufunc buffer in bytes.
|
| 206 |
+
|
| 207 |
+
Examples
|
| 208 |
+
--------
|
| 209 |
+
>>> import numpy as np
|
| 210 |
+
>>> np.getbufsize()
|
| 211 |
+
8192
|
| 212 |
+
|
| 213 |
+
"""
|
| 214 |
+
return _get_extobj_dict()["bufsize"]
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
@set_module('numpy')
|
| 218 |
+
def seterrcall(func):
|
| 219 |
+
"""
|
| 220 |
+
Set the floating-point error callback function or log object.
|
| 221 |
+
|
| 222 |
+
There are two ways to capture floating-point error messages. The first
|
| 223 |
+
is to set the error-handler to 'call', using `seterr`. Then, set
|
| 224 |
+
the function to call using this function.
|
| 225 |
+
|
| 226 |
+
The second is to set the error-handler to 'log', using `seterr`.
|
| 227 |
+
Floating-point errors then trigger a call to the 'write' method of
|
| 228 |
+
the provided object.
|
| 229 |
+
|
| 230 |
+
Parameters
|
| 231 |
+
----------
|
| 232 |
+
func : callable f(err, flag) or object with write method
|
| 233 |
+
Function to call upon floating-point errors ('call'-mode) or
|
| 234 |
+
object whose 'write' method is used to log such message ('log'-mode).
|
| 235 |
+
|
| 236 |
+
The call function takes two arguments. The first is a string describing
|
| 237 |
+
the type of error (such as "divide by zero", "overflow", "underflow",
|
| 238 |
+
or "invalid value"), and the second is the status flag. The flag is a
|
| 239 |
+
byte, whose four least-significant bits indicate the type of error, one
|
| 240 |
+
of "divide", "over", "under", "invalid"::
|
| 241 |
+
|
| 242 |
+
[0 0 0 0 divide over under invalid]
|
| 243 |
+
|
| 244 |
+
In other words, ``flags = divide + 2*over + 4*under + 8*invalid``.
|
| 245 |
+
|
| 246 |
+
If an object is provided, its write method should take one argument,
|
| 247 |
+
a string.
|
| 248 |
+
|
| 249 |
+
Returns
|
| 250 |
+
-------
|
| 251 |
+
h : callable, log instance or None
|
| 252 |
+
The old error handler.
|
| 253 |
+
|
| 254 |
+
See Also
|
| 255 |
+
--------
|
| 256 |
+
seterr, geterr, geterrcall
|
| 257 |
+
|
| 258 |
+
Examples
|
| 259 |
+
--------
|
| 260 |
+
Callback upon error:
|
| 261 |
+
|
| 262 |
+
>>> def err_handler(type, flag):
|
| 263 |
+
... print("Floating point error (%s), with flag %s" % (type, flag))
|
| 264 |
+
...
|
| 265 |
+
|
| 266 |
+
>>> import numpy as np
|
| 267 |
+
|
| 268 |
+
>>> orig_handler = np.seterrcall(err_handler)
|
| 269 |
+
>>> orig_err = np.seterr(all='call')
|
| 270 |
+
|
| 271 |
+
>>> np.array([1, 2, 3]) / 0.0
|
| 272 |
+
Floating point error (divide by zero), with flag 1
|
| 273 |
+
array([inf, inf, inf])
|
| 274 |
+
|
| 275 |
+
>>> np.seterrcall(orig_handler)
|
| 276 |
+
<function err_handler at 0x...>
|
| 277 |
+
>>> np.seterr(**orig_err)
|
| 278 |
+
{'divide': 'call', 'over': 'call', 'under': 'call', 'invalid': 'call'}
|
| 279 |
+
|
| 280 |
+
Log error message:
|
| 281 |
+
|
| 282 |
+
>>> class Log:
|
| 283 |
+
... def write(self, msg):
|
| 284 |
+
... print("LOG: %s" % msg)
|
| 285 |
+
...
|
| 286 |
+
|
| 287 |
+
>>> log = Log()
|
| 288 |
+
>>> saved_handler = np.seterrcall(log)
|
| 289 |
+
>>> save_err = np.seterr(all='log')
|
| 290 |
+
|
| 291 |
+
>>> np.array([1, 2, 3]) / 0.0
|
| 292 |
+
LOG: Warning: divide by zero encountered in divide
|
| 293 |
+
array([inf, inf, inf])
|
| 294 |
+
|
| 295 |
+
>>> np.seterrcall(orig_handler)
|
| 296 |
+
<numpy.Log object at 0x...>
|
| 297 |
+
>>> np.seterr(**orig_err)
|
| 298 |
+
{'divide': 'log', 'over': 'log', 'under': 'log', 'invalid': 'log'}
|
| 299 |
+
|
| 300 |
+
"""
|
| 301 |
+
old = _get_extobj_dict()["call"]
|
| 302 |
+
extobj = _make_extobj(call=func)
|
| 303 |
+
_extobj_contextvar.set(extobj)
|
| 304 |
+
return old
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
@set_module('numpy')
|
| 308 |
+
def geterrcall():
|
| 309 |
+
"""
|
| 310 |
+
Return the current callback function used on floating-point errors.
|
| 311 |
+
|
| 312 |
+
When the error handling for a floating-point error (one of "divide",
|
| 313 |
+
"over", "under", or "invalid") is set to 'call' or 'log', the function
|
| 314 |
+
that is called or the log instance that is written to is returned by
|
| 315 |
+
`geterrcall`. This function or log instance has been set with
|
| 316 |
+
`seterrcall`.
|
| 317 |
+
|
| 318 |
+
Returns
|
| 319 |
+
-------
|
| 320 |
+
errobj : callable, log instance or None
|
| 321 |
+
The current error handler. If no handler was set through `seterrcall`,
|
| 322 |
+
``None`` is returned.
|
| 323 |
+
|
| 324 |
+
See Also
|
| 325 |
+
--------
|
| 326 |
+
seterrcall, seterr, geterr
|
| 327 |
+
|
| 328 |
+
Notes
|
| 329 |
+
-----
|
| 330 |
+
For complete documentation of the types of floating-point exceptions and
|
| 331 |
+
treatment options, see `seterr`.
|
| 332 |
+
|
| 333 |
+
Examples
|
| 334 |
+
--------
|
| 335 |
+
>>> import numpy as np
|
| 336 |
+
>>> np.geterrcall() # we did not yet set a handler, returns None
|
| 337 |
+
|
| 338 |
+
>>> orig_settings = np.seterr(all='call')
|
| 339 |
+
>>> def err_handler(type, flag):
|
| 340 |
+
... print("Floating point error (%s), with flag %s" % (type, flag))
|
| 341 |
+
>>> old_handler = np.seterrcall(err_handler)
|
| 342 |
+
>>> np.array([1, 2, 3]) / 0.0
|
| 343 |
+
Floating point error (divide by zero), with flag 1
|
| 344 |
+
array([inf, inf, inf])
|
| 345 |
+
|
| 346 |
+
>>> cur_handler = np.geterrcall()
|
| 347 |
+
>>> cur_handler is err_handler
|
| 348 |
+
True
|
| 349 |
+
>>> old_settings = np.seterr(**orig_settings) # restore original
|
| 350 |
+
>>> old_handler = np.seterrcall(None) # restore original
|
| 351 |
+
|
| 352 |
+
"""
|
| 353 |
+
return _get_extobj_dict()["call"]
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
class _unspecified:
|
| 357 |
+
pass
|
| 358 |
+
|
| 359 |
+
|
| 360 |
+
_Unspecified = _unspecified()
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
@set_module('numpy')
|
| 364 |
+
class errstate:
|
| 365 |
+
"""
|
| 366 |
+
errstate(**kwargs)
|
| 367 |
+
|
| 368 |
+
Context manager for floating-point error handling.
|
| 369 |
+
|
| 370 |
+
Using an instance of `errstate` as a context manager allows statements in
|
| 371 |
+
that context to execute with a known error handling behavior. Upon entering
|
| 372 |
+
the context the error handling is set with `seterr` and `seterrcall`, and
|
| 373 |
+
upon exiting it is reset to what it was before.
|
| 374 |
+
|
| 375 |
+
.. versionchanged:: 1.17.0
|
| 376 |
+
`errstate` is also usable as a function decorator, saving
|
| 377 |
+
a level of indentation if an entire function is wrapped.
|
| 378 |
+
|
| 379 |
+
.. versionchanged:: 2.0
|
| 380 |
+
`errstate` is now fully thread and asyncio safe, but may not be
|
| 381 |
+
entered more than once.
|
| 382 |
+
It is not safe to decorate async functions using ``errstate``.
|
| 383 |
+
|
| 384 |
+
Parameters
|
| 385 |
+
----------
|
| 386 |
+
kwargs : {divide, over, under, invalid}
|
| 387 |
+
Keyword arguments. The valid keywords are the possible floating-point
|
| 388 |
+
exceptions. Each keyword should have a string value that defines the
|
| 389 |
+
treatment for the particular error. Possible values are
|
| 390 |
+
{'ignore', 'warn', 'raise', 'call', 'print', 'log'}.
|
| 391 |
+
|
| 392 |
+
See Also
|
| 393 |
+
--------
|
| 394 |
+
seterr, geterr, seterrcall, geterrcall
|
| 395 |
+
|
| 396 |
+
Notes
|
| 397 |
+
-----
|
| 398 |
+
For complete documentation of the types of floating-point exceptions and
|
| 399 |
+
treatment options, see `seterr`.
|
| 400 |
+
|
| 401 |
+
Examples
|
| 402 |
+
--------
|
| 403 |
+
>>> import numpy as np
|
| 404 |
+
>>> olderr = np.seterr(all='ignore') # Set error handling to known state.
|
| 405 |
+
|
| 406 |
+
>>> np.arange(3) / 0.
|
| 407 |
+
array([nan, inf, inf])
|
| 408 |
+
>>> with np.errstate(divide='ignore'):
|
| 409 |
+
... np.arange(3) / 0.
|
| 410 |
+
array([nan, inf, inf])
|
| 411 |
+
|
| 412 |
+
>>> np.sqrt(-1)
|
| 413 |
+
np.float64(nan)
|
| 414 |
+
>>> with np.errstate(invalid='raise'):
|
| 415 |
+
... np.sqrt(-1)
|
| 416 |
+
Traceback (most recent call last):
|
| 417 |
+
File "<stdin>", line 2, in <module>
|
| 418 |
+
FloatingPointError: invalid value encountered in sqrt
|
| 419 |
+
|
| 420 |
+
Outside the context the error handling behavior has not changed:
|
| 421 |
+
|
| 422 |
+
>>> np.geterr()
|
| 423 |
+
{'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
|
| 424 |
+
>>> olderr = np.seterr(**olderr) # restore original state
|
| 425 |
+
|
| 426 |
+
"""
|
| 427 |
+
__slots__ = (
|
| 428 |
+
"_call", "_all", "_divide", "_over", "_under", "_invalid", "_token")
|
| 429 |
+
|
| 430 |
+
def __init__(self, *, call=_Unspecified,
|
| 431 |
+
all=None, divide=None, over=None, under=None, invalid=None):
|
| 432 |
+
self._token = None
|
| 433 |
+
self._call = call
|
| 434 |
+
self._all = all
|
| 435 |
+
self._divide = divide
|
| 436 |
+
self._over = over
|
| 437 |
+
self._under = under
|
| 438 |
+
self._invalid = invalid
|
| 439 |
+
|
| 440 |
+
def __enter__(self):
|
| 441 |
+
# Note that __call__ duplicates much of this logic
|
| 442 |
+
if self._token is not None:
|
| 443 |
+
raise TypeError("Cannot enter `np.errstate` twice.")
|
| 444 |
+
if self._call is _Unspecified:
|
| 445 |
+
extobj = _make_extobj(
|
| 446 |
+
all=self._all, divide=self._divide, over=self._over,
|
| 447 |
+
under=self._under, invalid=self._invalid)
|
| 448 |
+
else:
|
| 449 |
+
extobj = _make_extobj(
|
| 450 |
+
call=self._call,
|
| 451 |
+
all=self._all, divide=self._divide, over=self._over,
|
| 452 |
+
under=self._under, invalid=self._invalid)
|
| 453 |
+
|
| 454 |
+
self._token = _extobj_contextvar.set(extobj)
|
| 455 |
+
|
| 456 |
+
def __exit__(self, *exc_info):
|
| 457 |
+
_extobj_contextvar.reset(self._token)
|
| 458 |
+
|
| 459 |
+
def __call__(self, func):
|
| 460 |
+
# We need to customize `__call__` compared to `ContextDecorator`
|
| 461 |
+
# because we must store the token per-thread so cannot store it on
|
| 462 |
+
# the instance (we could create a new instance for this).
|
| 463 |
+
# This duplicates the code from `__enter__`.
|
| 464 |
+
@functools.wraps(func)
|
| 465 |
+
def inner(*args, **kwargs):
|
| 466 |
+
if self._call is _Unspecified:
|
| 467 |
+
extobj = _make_extobj(
|
| 468 |
+
all=self._all, divide=self._divide, over=self._over,
|
| 469 |
+
under=self._under, invalid=self._invalid)
|
| 470 |
+
else:
|
| 471 |
+
extobj = _make_extobj(
|
| 472 |
+
call=self._call,
|
| 473 |
+
all=self._all, divide=self._divide, over=self._over,
|
| 474 |
+
under=self._under, invalid=self._invalid)
|
| 475 |
+
|
| 476 |
+
_token = _extobj_contextvar.set(extobj)
|
| 477 |
+
try:
|
| 478 |
+
# Call the original, decorated, function:
|
| 479 |
+
return func(*args, **kwargs)
|
| 480 |
+
finally:
|
| 481 |
+
_extobj_contextvar.reset(_token)
|
| 482 |
+
|
| 483 |
+
return inner
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_ufunc_config.pyi
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from _typeshed import SupportsWrite
|
| 2 |
+
from collections.abc import Callable
|
| 3 |
+
from typing import Any, Literal, TypeAlias, TypedDict, type_check_only
|
| 4 |
+
|
| 5 |
+
from numpy import errstate as errstate
|
| 6 |
+
|
| 7 |
+
_ErrKind: TypeAlias = Literal["ignore", "warn", "raise", "call", "print", "log"]
|
| 8 |
+
_ErrFunc: TypeAlias = Callable[[str, int], Any]
|
| 9 |
+
_ErrCall: TypeAlias = _ErrFunc | SupportsWrite[str]
|
| 10 |
+
|
| 11 |
+
@type_check_only
|
| 12 |
+
class _ErrDict(TypedDict):
|
| 13 |
+
divide: _ErrKind
|
| 14 |
+
over: _ErrKind
|
| 15 |
+
under: _ErrKind
|
| 16 |
+
invalid: _ErrKind
|
| 17 |
+
|
| 18 |
+
@type_check_only
|
| 19 |
+
class _ErrDictOptional(TypedDict, total=False):
|
| 20 |
+
all: None | _ErrKind
|
| 21 |
+
divide: None | _ErrKind
|
| 22 |
+
over: None | _ErrKind
|
| 23 |
+
under: None | _ErrKind
|
| 24 |
+
invalid: None | _ErrKind
|
| 25 |
+
|
| 26 |
+
def seterr(
|
| 27 |
+
all: None | _ErrKind = ...,
|
| 28 |
+
divide: None | _ErrKind = ...,
|
| 29 |
+
over: None | _ErrKind = ...,
|
| 30 |
+
under: None | _ErrKind = ...,
|
| 31 |
+
invalid: None | _ErrKind = ...,
|
| 32 |
+
) -> _ErrDict: ...
|
| 33 |
+
def geterr() -> _ErrDict: ...
|
| 34 |
+
def setbufsize(size: int) -> int: ...
|
| 35 |
+
def getbufsize() -> int: ...
|
| 36 |
+
def seterrcall(func: _ErrCall | None) -> _ErrCall | None: ...
|
| 37 |
+
def geterrcall() -> _ErrCall | None: ...
|
| 38 |
+
|
| 39 |
+
# See `numpy/__init__.pyi` for the `errstate` class and `no_nep5_warnings`
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_umath_tests.cp310-win_amd64.lib
ADDED
|
Binary file (2.1 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/_umath_tests.cp310-win_amd64.pyd
ADDED
|
Binary file (33.8 kB). View file
|
|
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__multiarray_api.c
ADDED
|
@@ -0,0 +1,376 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/* These pointers will be stored in the C-object for use in other
|
| 3 |
+
extension modules
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
void *PyArray_API[] = {
|
| 7 |
+
(void *) PyArray_GetNDArrayCVersion,
|
| 8 |
+
NULL,
|
| 9 |
+
(void *) &PyArray_Type,
|
| 10 |
+
(void *) &PyArrayDescr_Type,
|
| 11 |
+
NULL,
|
| 12 |
+
(void *) &PyArrayIter_Type,
|
| 13 |
+
(void *) &PyArrayMultiIter_Type,
|
| 14 |
+
(int *) &NPY_NUMUSERTYPES,
|
| 15 |
+
(void *) &PyBoolArrType_Type,
|
| 16 |
+
(void *) &_PyArrayScalar_BoolValues,
|
| 17 |
+
(void *) &PyGenericArrType_Type,
|
| 18 |
+
(void *) &PyNumberArrType_Type,
|
| 19 |
+
(void *) &PyIntegerArrType_Type,
|
| 20 |
+
(void *) &PySignedIntegerArrType_Type,
|
| 21 |
+
(void *) &PyUnsignedIntegerArrType_Type,
|
| 22 |
+
(void *) &PyInexactArrType_Type,
|
| 23 |
+
(void *) &PyFloatingArrType_Type,
|
| 24 |
+
(void *) &PyComplexFloatingArrType_Type,
|
| 25 |
+
(void *) &PyFlexibleArrType_Type,
|
| 26 |
+
(void *) &PyCharacterArrType_Type,
|
| 27 |
+
(void *) &PyByteArrType_Type,
|
| 28 |
+
(void *) &PyShortArrType_Type,
|
| 29 |
+
(void *) &PyIntArrType_Type,
|
| 30 |
+
(void *) &PyLongArrType_Type,
|
| 31 |
+
(void *) &PyLongLongArrType_Type,
|
| 32 |
+
(void *) &PyUByteArrType_Type,
|
| 33 |
+
(void *) &PyUShortArrType_Type,
|
| 34 |
+
(void *) &PyUIntArrType_Type,
|
| 35 |
+
(void *) &PyULongArrType_Type,
|
| 36 |
+
(void *) &PyULongLongArrType_Type,
|
| 37 |
+
(void *) &PyFloatArrType_Type,
|
| 38 |
+
(void *) &PyDoubleArrType_Type,
|
| 39 |
+
(void *) &PyLongDoubleArrType_Type,
|
| 40 |
+
(void *) &PyCFloatArrType_Type,
|
| 41 |
+
(void *) &PyCDoubleArrType_Type,
|
| 42 |
+
(void *) &PyCLongDoubleArrType_Type,
|
| 43 |
+
(void *) &PyObjectArrType_Type,
|
| 44 |
+
(void *) &PyStringArrType_Type,
|
| 45 |
+
(void *) &PyUnicodeArrType_Type,
|
| 46 |
+
(void *) &PyVoidArrType_Type,
|
| 47 |
+
NULL,
|
| 48 |
+
NULL,
|
| 49 |
+
(void *) PyArray_INCREF,
|
| 50 |
+
(void *) PyArray_XDECREF,
|
| 51 |
+
(void *) PyArray_SetStringFunction,
|
| 52 |
+
(void *) PyArray_DescrFromType,
|
| 53 |
+
(void *) PyArray_TypeObjectFromType,
|
| 54 |
+
(void *) PyArray_Zero,
|
| 55 |
+
(void *) PyArray_One,
|
| 56 |
+
(void *) PyArray_CastToType,
|
| 57 |
+
(void *) PyArray_CopyInto,
|
| 58 |
+
(void *) PyArray_CopyAnyInto,
|
| 59 |
+
(void *) PyArray_CanCastSafely,
|
| 60 |
+
(void *) PyArray_CanCastTo,
|
| 61 |
+
(void *) PyArray_ObjectType,
|
| 62 |
+
(void *) PyArray_DescrFromObject,
|
| 63 |
+
(void *) PyArray_ConvertToCommonType,
|
| 64 |
+
(void *) PyArray_DescrFromScalar,
|
| 65 |
+
(void *) PyArray_DescrFromTypeObject,
|
| 66 |
+
(void *) PyArray_Size,
|
| 67 |
+
(void *) PyArray_Scalar,
|
| 68 |
+
(void *) PyArray_FromScalar,
|
| 69 |
+
(void *) PyArray_ScalarAsCtype,
|
| 70 |
+
(void *) PyArray_CastScalarToCtype,
|
| 71 |
+
(void *) PyArray_CastScalarDirect,
|
| 72 |
+
(void *) PyArray_Pack,
|
| 73 |
+
NULL,
|
| 74 |
+
NULL,
|
| 75 |
+
NULL,
|
| 76 |
+
(void *) PyArray_FromAny,
|
| 77 |
+
(void *) PyArray_EnsureArray,
|
| 78 |
+
(void *) PyArray_EnsureAnyArray,
|
| 79 |
+
(void *) PyArray_FromFile,
|
| 80 |
+
(void *) PyArray_FromString,
|
| 81 |
+
(void *) PyArray_FromBuffer,
|
| 82 |
+
(void *) PyArray_FromIter,
|
| 83 |
+
(void *) PyArray_Return,
|
| 84 |
+
(void *) PyArray_GetField,
|
| 85 |
+
(void *) PyArray_SetField,
|
| 86 |
+
(void *) PyArray_Byteswap,
|
| 87 |
+
(void *) PyArray_Resize,
|
| 88 |
+
NULL,
|
| 89 |
+
NULL,
|
| 90 |
+
NULL,
|
| 91 |
+
(void *) PyArray_CopyObject,
|
| 92 |
+
(void *) PyArray_NewCopy,
|
| 93 |
+
(void *) PyArray_ToList,
|
| 94 |
+
(void *) PyArray_ToString,
|
| 95 |
+
(void *) PyArray_ToFile,
|
| 96 |
+
(void *) PyArray_Dump,
|
| 97 |
+
(void *) PyArray_Dumps,
|
| 98 |
+
(void *) PyArray_ValidType,
|
| 99 |
+
(void *) PyArray_UpdateFlags,
|
| 100 |
+
(void *) PyArray_New,
|
| 101 |
+
(void *) PyArray_NewFromDescr,
|
| 102 |
+
(void *) PyArray_DescrNew,
|
| 103 |
+
(void *) PyArray_DescrNewFromType,
|
| 104 |
+
(void *) PyArray_GetPriority,
|
| 105 |
+
(void *) PyArray_IterNew,
|
| 106 |
+
(void *) PyArray_MultiIterNew,
|
| 107 |
+
(void *) PyArray_PyIntAsInt,
|
| 108 |
+
(void *) PyArray_PyIntAsIntp,
|
| 109 |
+
(void *) PyArray_Broadcast,
|
| 110 |
+
NULL,
|
| 111 |
+
(void *) PyArray_FillWithScalar,
|
| 112 |
+
(void *) PyArray_CheckStrides,
|
| 113 |
+
(void *) PyArray_DescrNewByteorder,
|
| 114 |
+
(void *) PyArray_IterAllButAxis,
|
| 115 |
+
(void *) PyArray_CheckFromAny,
|
| 116 |
+
(void *) PyArray_FromArray,
|
| 117 |
+
(void *) PyArray_FromInterface,
|
| 118 |
+
(void *) PyArray_FromStructInterface,
|
| 119 |
+
(void *) PyArray_FromArrayAttr,
|
| 120 |
+
(void *) PyArray_ScalarKind,
|
| 121 |
+
(void *) PyArray_CanCoerceScalar,
|
| 122 |
+
NULL,
|
| 123 |
+
(void *) PyArray_CanCastScalar,
|
| 124 |
+
NULL,
|
| 125 |
+
(void *) PyArray_RemoveSmallest,
|
| 126 |
+
(void *) PyArray_ElementStrides,
|
| 127 |
+
(void *) PyArray_Item_INCREF,
|
| 128 |
+
(void *) PyArray_Item_XDECREF,
|
| 129 |
+
NULL,
|
| 130 |
+
(void *) PyArray_Transpose,
|
| 131 |
+
(void *) PyArray_TakeFrom,
|
| 132 |
+
(void *) PyArray_PutTo,
|
| 133 |
+
(void *) PyArray_PutMask,
|
| 134 |
+
(void *) PyArray_Repeat,
|
| 135 |
+
(void *) PyArray_Choose,
|
| 136 |
+
(void *) PyArray_Sort,
|
| 137 |
+
(void *) PyArray_ArgSort,
|
| 138 |
+
(void *) PyArray_SearchSorted,
|
| 139 |
+
(void *) PyArray_ArgMax,
|
| 140 |
+
(void *) PyArray_ArgMin,
|
| 141 |
+
(void *) PyArray_Reshape,
|
| 142 |
+
(void *) PyArray_Newshape,
|
| 143 |
+
(void *) PyArray_Squeeze,
|
| 144 |
+
(void *) PyArray_View,
|
| 145 |
+
(void *) PyArray_SwapAxes,
|
| 146 |
+
(void *) PyArray_Max,
|
| 147 |
+
(void *) PyArray_Min,
|
| 148 |
+
(void *) PyArray_Ptp,
|
| 149 |
+
(void *) PyArray_Mean,
|
| 150 |
+
(void *) PyArray_Trace,
|
| 151 |
+
(void *) PyArray_Diagonal,
|
| 152 |
+
(void *) PyArray_Clip,
|
| 153 |
+
(void *) PyArray_Conjugate,
|
| 154 |
+
(void *) PyArray_Nonzero,
|
| 155 |
+
(void *) PyArray_Std,
|
| 156 |
+
(void *) PyArray_Sum,
|
| 157 |
+
(void *) PyArray_CumSum,
|
| 158 |
+
(void *) PyArray_Prod,
|
| 159 |
+
(void *) PyArray_CumProd,
|
| 160 |
+
(void *) PyArray_All,
|
| 161 |
+
(void *) PyArray_Any,
|
| 162 |
+
(void *) PyArray_Compress,
|
| 163 |
+
(void *) PyArray_Flatten,
|
| 164 |
+
(void *) PyArray_Ravel,
|
| 165 |
+
(void *) PyArray_MultiplyList,
|
| 166 |
+
(void *) PyArray_MultiplyIntList,
|
| 167 |
+
(void *) PyArray_GetPtr,
|
| 168 |
+
(void *) PyArray_CompareLists,
|
| 169 |
+
(void *) PyArray_AsCArray,
|
| 170 |
+
NULL,
|
| 171 |
+
NULL,
|
| 172 |
+
(void *) PyArray_Free,
|
| 173 |
+
(void *) PyArray_Converter,
|
| 174 |
+
(void *) PyArray_IntpFromSequence,
|
| 175 |
+
(void *) PyArray_Concatenate,
|
| 176 |
+
(void *) PyArray_InnerProduct,
|
| 177 |
+
(void *) PyArray_MatrixProduct,
|
| 178 |
+
NULL,
|
| 179 |
+
(void *) PyArray_Correlate,
|
| 180 |
+
NULL,
|
| 181 |
+
(void *) PyArray_DescrConverter,
|
| 182 |
+
(void *) PyArray_DescrConverter2,
|
| 183 |
+
(void *) PyArray_IntpConverter,
|
| 184 |
+
(void *) PyArray_BufferConverter,
|
| 185 |
+
(void *) PyArray_AxisConverter,
|
| 186 |
+
(void *) PyArray_BoolConverter,
|
| 187 |
+
(void *) PyArray_ByteorderConverter,
|
| 188 |
+
(void *) PyArray_OrderConverter,
|
| 189 |
+
(void *) PyArray_EquivTypes,
|
| 190 |
+
(void *) PyArray_Zeros,
|
| 191 |
+
(void *) PyArray_Empty,
|
| 192 |
+
(void *) PyArray_Where,
|
| 193 |
+
(void *) PyArray_Arange,
|
| 194 |
+
(void *) PyArray_ArangeObj,
|
| 195 |
+
(void *) PyArray_SortkindConverter,
|
| 196 |
+
(void *) PyArray_LexSort,
|
| 197 |
+
(void *) PyArray_Round,
|
| 198 |
+
(void *) PyArray_EquivTypenums,
|
| 199 |
+
(void *) PyArray_RegisterDataType,
|
| 200 |
+
(void *) PyArray_RegisterCastFunc,
|
| 201 |
+
(void *) PyArray_RegisterCanCast,
|
| 202 |
+
(void *) PyArray_InitArrFuncs,
|
| 203 |
+
(void *) PyArray_IntTupleFromIntp,
|
| 204 |
+
NULL,
|
| 205 |
+
(void *) PyArray_ClipmodeConverter,
|
| 206 |
+
(void *) PyArray_OutputConverter,
|
| 207 |
+
(void *) PyArray_BroadcastToShape,
|
| 208 |
+
NULL,
|
| 209 |
+
NULL,
|
| 210 |
+
(void *) PyArray_DescrAlignConverter,
|
| 211 |
+
(void *) PyArray_DescrAlignConverter2,
|
| 212 |
+
(void *) PyArray_SearchsideConverter,
|
| 213 |
+
(void *) PyArray_CheckAxis,
|
| 214 |
+
(void *) PyArray_OverflowMultiplyList,
|
| 215 |
+
NULL,
|
| 216 |
+
(void *) PyArray_MultiIterFromObjects,
|
| 217 |
+
(void *) PyArray_GetEndianness,
|
| 218 |
+
(void *) PyArray_GetNDArrayCFeatureVersion,
|
| 219 |
+
(void *) PyArray_Correlate2,
|
| 220 |
+
(void *) PyArray_NeighborhoodIterNew,
|
| 221 |
+
(void *) &PyTimeIntegerArrType_Type,
|
| 222 |
+
(void *) &PyDatetimeArrType_Type,
|
| 223 |
+
(void *) &PyTimedeltaArrType_Type,
|
| 224 |
+
(void *) &PyHalfArrType_Type,
|
| 225 |
+
(void *) &NpyIter_Type,
|
| 226 |
+
NULL,
|
| 227 |
+
NULL,
|
| 228 |
+
NULL,
|
| 229 |
+
NULL,
|
| 230 |
+
NULL,
|
| 231 |
+
(void *) NpyIter_New,
|
| 232 |
+
(void *) NpyIter_MultiNew,
|
| 233 |
+
(void *) NpyIter_AdvancedNew,
|
| 234 |
+
(void *) NpyIter_Copy,
|
| 235 |
+
(void *) NpyIter_Deallocate,
|
| 236 |
+
(void *) NpyIter_HasDelayedBufAlloc,
|
| 237 |
+
(void *) NpyIter_HasExternalLoop,
|
| 238 |
+
(void *) NpyIter_EnableExternalLoop,
|
| 239 |
+
(void *) NpyIter_GetInnerStrideArray,
|
| 240 |
+
(void *) NpyIter_GetInnerLoopSizePtr,
|
| 241 |
+
(void *) NpyIter_Reset,
|
| 242 |
+
(void *) NpyIter_ResetBasePointers,
|
| 243 |
+
(void *) NpyIter_ResetToIterIndexRange,
|
| 244 |
+
(void *) NpyIter_GetNDim,
|
| 245 |
+
(void *) NpyIter_GetNOp,
|
| 246 |
+
(void *) NpyIter_GetIterNext,
|
| 247 |
+
(void *) NpyIter_GetIterSize,
|
| 248 |
+
(void *) NpyIter_GetIterIndexRange,
|
| 249 |
+
(void *) NpyIter_GetIterIndex,
|
| 250 |
+
(void *) NpyIter_GotoIterIndex,
|
| 251 |
+
(void *) NpyIter_HasMultiIndex,
|
| 252 |
+
(void *) NpyIter_GetShape,
|
| 253 |
+
(void *) NpyIter_GetGetMultiIndex,
|
| 254 |
+
(void *) NpyIter_GotoMultiIndex,
|
| 255 |
+
(void *) NpyIter_RemoveMultiIndex,
|
| 256 |
+
(void *) NpyIter_HasIndex,
|
| 257 |
+
(void *) NpyIter_IsBuffered,
|
| 258 |
+
(void *) NpyIter_IsGrowInner,
|
| 259 |
+
(void *) NpyIter_GetBufferSize,
|
| 260 |
+
(void *) NpyIter_GetIndexPtr,
|
| 261 |
+
(void *) NpyIter_GotoIndex,
|
| 262 |
+
(void *) NpyIter_GetDataPtrArray,
|
| 263 |
+
(void *) NpyIter_GetDescrArray,
|
| 264 |
+
(void *) NpyIter_GetOperandArray,
|
| 265 |
+
(void *) NpyIter_GetIterView,
|
| 266 |
+
(void *) NpyIter_GetReadFlags,
|
| 267 |
+
(void *) NpyIter_GetWriteFlags,
|
| 268 |
+
(void *) NpyIter_DebugPrint,
|
| 269 |
+
(void *) NpyIter_IterationNeedsAPI,
|
| 270 |
+
(void *) NpyIter_GetInnerFixedStrideArray,
|
| 271 |
+
(void *) NpyIter_RemoveAxis,
|
| 272 |
+
(void *) NpyIter_GetAxisStrideArray,
|
| 273 |
+
(void *) NpyIter_RequiresBuffering,
|
| 274 |
+
(void *) NpyIter_GetInitialDataPtrArray,
|
| 275 |
+
(void *) NpyIter_CreateCompatibleStrides,
|
| 276 |
+
(void *) PyArray_CastingConverter,
|
| 277 |
+
(void *) PyArray_CountNonzero,
|
| 278 |
+
(void *) PyArray_PromoteTypes,
|
| 279 |
+
(void *) PyArray_MinScalarType,
|
| 280 |
+
(void *) PyArray_ResultType,
|
| 281 |
+
(void *) PyArray_CanCastArrayTo,
|
| 282 |
+
(void *) PyArray_CanCastTypeTo,
|
| 283 |
+
(void *) PyArray_EinsteinSum,
|
| 284 |
+
(void *) PyArray_NewLikeArray,
|
| 285 |
+
NULL,
|
| 286 |
+
(void *) PyArray_ConvertClipmodeSequence,
|
| 287 |
+
(void *) PyArray_MatrixProduct2,
|
| 288 |
+
(void *) NpyIter_IsFirstVisit,
|
| 289 |
+
(void *) PyArray_SetBaseObject,
|
| 290 |
+
(void *) PyArray_CreateSortedStridePerm,
|
| 291 |
+
(void *) PyArray_RemoveAxesInPlace,
|
| 292 |
+
(void *) PyArray_DebugPrint,
|
| 293 |
+
(void *) PyArray_FailUnlessWriteable,
|
| 294 |
+
(void *) PyArray_SetUpdateIfCopyBase,
|
| 295 |
+
(void *) PyDataMem_NEW,
|
| 296 |
+
(void *) PyDataMem_FREE,
|
| 297 |
+
(void *) PyDataMem_RENEW,
|
| 298 |
+
NULL,
|
| 299 |
+
(NPY_CASTING *) &NPY_DEFAULT_ASSIGN_CASTING,
|
| 300 |
+
NULL,
|
| 301 |
+
NULL,
|
| 302 |
+
NULL,
|
| 303 |
+
(void *) PyArray_Partition,
|
| 304 |
+
(void *) PyArray_ArgPartition,
|
| 305 |
+
(void *) PyArray_SelectkindConverter,
|
| 306 |
+
(void *) PyDataMem_NEW_ZEROED,
|
| 307 |
+
(void *) PyArray_CheckAnyScalarExact,
|
| 308 |
+
NULL,
|
| 309 |
+
(void *) PyArray_ResolveWritebackIfCopy,
|
| 310 |
+
(void *) PyArray_SetWritebackIfCopyBase,
|
| 311 |
+
(void *) PyDataMem_SetHandler,
|
| 312 |
+
(void *) PyDataMem_GetHandler,
|
| 313 |
+
(PyObject* *) &PyDataMem_DefaultHandler,
|
| 314 |
+
(void *) NpyDatetime_ConvertDatetime64ToDatetimeStruct,
|
| 315 |
+
(void *) NpyDatetime_ConvertDatetimeStructToDatetime64,
|
| 316 |
+
(void *) NpyDatetime_ConvertPyDateTimeToDatetimeStruct,
|
| 317 |
+
(void *) NpyDatetime_GetDatetimeISO8601StrLen,
|
| 318 |
+
(void *) NpyDatetime_MakeISO8601Datetime,
|
| 319 |
+
(void *) NpyDatetime_ParseISO8601Datetime,
|
| 320 |
+
(void *) NpyString_load,
|
| 321 |
+
(void *) NpyString_pack,
|
| 322 |
+
(void *) NpyString_pack_null,
|
| 323 |
+
(void *) NpyString_acquire_allocator,
|
| 324 |
+
(void *) NpyString_acquire_allocators,
|
| 325 |
+
(void *) NpyString_release_allocator,
|
| 326 |
+
(void *) NpyString_release_allocators,
|
| 327 |
+
NULL,
|
| 328 |
+
NULL,
|
| 329 |
+
NULL,
|
| 330 |
+
NULL,
|
| 331 |
+
NULL,
|
| 332 |
+
NULL,
|
| 333 |
+
NULL,
|
| 334 |
+
NULL,
|
| 335 |
+
NULL,
|
| 336 |
+
NULL,
|
| 337 |
+
NULL,
|
| 338 |
+
NULL,
|
| 339 |
+
NULL,
|
| 340 |
+
NULL,
|
| 341 |
+
NULL,
|
| 342 |
+
NULL,
|
| 343 |
+
NULL,
|
| 344 |
+
NULL,
|
| 345 |
+
NULL,
|
| 346 |
+
NULL,
|
| 347 |
+
NULL,
|
| 348 |
+
NULL,
|
| 349 |
+
NULL,
|
| 350 |
+
NULL,
|
| 351 |
+
NULL,
|
| 352 |
+
NULL,
|
| 353 |
+
NULL,
|
| 354 |
+
NULL,
|
| 355 |
+
NULL,
|
| 356 |
+
NULL,
|
| 357 |
+
NULL,
|
| 358 |
+
NULL,
|
| 359 |
+
NULL,
|
| 360 |
+
NULL,
|
| 361 |
+
NULL,
|
| 362 |
+
NULL,
|
| 363 |
+
NULL,
|
| 364 |
+
NULL,
|
| 365 |
+
NULL,
|
| 366 |
+
NULL,
|
| 367 |
+
NULL,
|
| 368 |
+
(void *) PyArray_GetDefaultDescr,
|
| 369 |
+
(void *) PyArrayInitDTypeMeta_FromSpec,
|
| 370 |
+
(void *) PyArray_CommonDType,
|
| 371 |
+
(void *) PyArray_PromoteDTypeSequence,
|
| 372 |
+
(void *) _PyDataType_GetArrFuncs,
|
| 373 |
+
NULL,
|
| 374 |
+
NULL,
|
| 375 |
+
NULL
|
| 376 |
+
};
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__multiarray_api.h
ADDED
|
@@ -0,0 +1,1613 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
#if defined(_MULTIARRAYMODULE) || defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
|
| 3 |
+
|
| 4 |
+
typedef struct {
|
| 5 |
+
PyObject_HEAD
|
| 6 |
+
npy_bool obval;
|
| 7 |
+
} PyBoolScalarObject;
|
| 8 |
+
|
| 9 |
+
extern NPY_NO_EXPORT PyTypeObject PyArrayNeighborhoodIter_Type;
|
| 10 |
+
extern NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2];
|
| 11 |
+
|
| 12 |
+
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCVersion \
|
| 13 |
+
(void);
|
| 14 |
+
extern NPY_NO_EXPORT PyTypeObject PyArray_Type;
|
| 15 |
+
|
| 16 |
+
extern NPY_NO_EXPORT PyArray_DTypeMeta PyArrayDescr_TypeFull;
|
| 17 |
+
#define PyArrayDescr_Type (*(PyTypeObject *)(&PyArrayDescr_TypeFull))
|
| 18 |
+
|
| 19 |
+
extern NPY_NO_EXPORT PyTypeObject PyArrayIter_Type;
|
| 20 |
+
|
| 21 |
+
extern NPY_NO_EXPORT PyTypeObject PyArrayMultiIter_Type;
|
| 22 |
+
|
| 23 |
+
extern NPY_NO_EXPORT int NPY_NUMUSERTYPES;
|
| 24 |
+
|
| 25 |
+
extern NPY_NO_EXPORT PyTypeObject PyBoolArrType_Type;
|
| 26 |
+
|
| 27 |
+
extern NPY_NO_EXPORT PyBoolScalarObject _PyArrayScalar_BoolValues[2];
|
| 28 |
+
|
| 29 |
+
extern NPY_NO_EXPORT PyTypeObject PyGenericArrType_Type;
|
| 30 |
+
|
| 31 |
+
extern NPY_NO_EXPORT PyTypeObject PyNumberArrType_Type;
|
| 32 |
+
|
| 33 |
+
extern NPY_NO_EXPORT PyTypeObject PyIntegerArrType_Type;
|
| 34 |
+
|
| 35 |
+
extern NPY_NO_EXPORT PyTypeObject PySignedIntegerArrType_Type;
|
| 36 |
+
|
| 37 |
+
extern NPY_NO_EXPORT PyTypeObject PyUnsignedIntegerArrType_Type;
|
| 38 |
+
|
| 39 |
+
extern NPY_NO_EXPORT PyTypeObject PyInexactArrType_Type;
|
| 40 |
+
|
| 41 |
+
extern NPY_NO_EXPORT PyTypeObject PyFloatingArrType_Type;
|
| 42 |
+
|
| 43 |
+
extern NPY_NO_EXPORT PyTypeObject PyComplexFloatingArrType_Type;
|
| 44 |
+
|
| 45 |
+
extern NPY_NO_EXPORT PyTypeObject PyFlexibleArrType_Type;
|
| 46 |
+
|
| 47 |
+
extern NPY_NO_EXPORT PyTypeObject PyCharacterArrType_Type;
|
| 48 |
+
|
| 49 |
+
extern NPY_NO_EXPORT PyTypeObject PyByteArrType_Type;
|
| 50 |
+
|
| 51 |
+
extern NPY_NO_EXPORT PyTypeObject PyShortArrType_Type;
|
| 52 |
+
|
| 53 |
+
extern NPY_NO_EXPORT PyTypeObject PyIntArrType_Type;
|
| 54 |
+
|
| 55 |
+
extern NPY_NO_EXPORT PyTypeObject PyLongArrType_Type;
|
| 56 |
+
|
| 57 |
+
extern NPY_NO_EXPORT PyTypeObject PyLongLongArrType_Type;
|
| 58 |
+
|
| 59 |
+
extern NPY_NO_EXPORT PyTypeObject PyUByteArrType_Type;
|
| 60 |
+
|
| 61 |
+
extern NPY_NO_EXPORT PyTypeObject PyUShortArrType_Type;
|
| 62 |
+
|
| 63 |
+
extern NPY_NO_EXPORT PyTypeObject PyUIntArrType_Type;
|
| 64 |
+
|
| 65 |
+
extern NPY_NO_EXPORT PyTypeObject PyULongArrType_Type;
|
| 66 |
+
|
| 67 |
+
extern NPY_NO_EXPORT PyTypeObject PyULongLongArrType_Type;
|
| 68 |
+
|
| 69 |
+
extern NPY_NO_EXPORT PyTypeObject PyFloatArrType_Type;
|
| 70 |
+
|
| 71 |
+
extern NPY_NO_EXPORT PyTypeObject PyDoubleArrType_Type;
|
| 72 |
+
|
| 73 |
+
extern NPY_NO_EXPORT PyTypeObject PyLongDoubleArrType_Type;
|
| 74 |
+
|
| 75 |
+
extern NPY_NO_EXPORT PyTypeObject PyCFloatArrType_Type;
|
| 76 |
+
|
| 77 |
+
extern NPY_NO_EXPORT PyTypeObject PyCDoubleArrType_Type;
|
| 78 |
+
|
| 79 |
+
extern NPY_NO_EXPORT PyTypeObject PyCLongDoubleArrType_Type;
|
| 80 |
+
|
| 81 |
+
extern NPY_NO_EXPORT PyTypeObject PyObjectArrType_Type;
|
| 82 |
+
|
| 83 |
+
extern NPY_NO_EXPORT PyTypeObject PyStringArrType_Type;
|
| 84 |
+
|
| 85 |
+
extern NPY_NO_EXPORT PyTypeObject PyUnicodeArrType_Type;
|
| 86 |
+
|
| 87 |
+
extern NPY_NO_EXPORT PyTypeObject PyVoidArrType_Type;
|
| 88 |
+
|
| 89 |
+
NPY_NO_EXPORT int PyArray_INCREF \
|
| 90 |
+
(PyArrayObject *);
|
| 91 |
+
NPY_NO_EXPORT int PyArray_XDECREF \
|
| 92 |
+
(PyArrayObject *);
|
| 93 |
+
NPY_NO_EXPORT void PyArray_SetStringFunction \
|
| 94 |
+
(PyObject *, int);
|
| 95 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromType \
|
| 96 |
+
(int);
|
| 97 |
+
NPY_NO_EXPORT PyObject * PyArray_TypeObjectFromType \
|
| 98 |
+
(int);
|
| 99 |
+
NPY_NO_EXPORT char * PyArray_Zero \
|
| 100 |
+
(PyArrayObject *);
|
| 101 |
+
NPY_NO_EXPORT char * PyArray_One \
|
| 102 |
+
(PyArrayObject *);
|
| 103 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_CastToType \
|
| 104 |
+
(PyArrayObject *, PyArray_Descr *, int);
|
| 105 |
+
NPY_NO_EXPORT int PyArray_CopyInto \
|
| 106 |
+
(PyArrayObject *, PyArrayObject *);
|
| 107 |
+
NPY_NO_EXPORT int PyArray_CopyAnyInto \
|
| 108 |
+
(PyArrayObject *, PyArrayObject *);
|
| 109 |
+
NPY_NO_EXPORT int PyArray_CanCastSafely \
|
| 110 |
+
(int, int);
|
| 111 |
+
NPY_NO_EXPORT npy_bool PyArray_CanCastTo \
|
| 112 |
+
(PyArray_Descr *, PyArray_Descr *);
|
| 113 |
+
NPY_NO_EXPORT int PyArray_ObjectType \
|
| 114 |
+
(PyObject *, int);
|
| 115 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromObject \
|
| 116 |
+
(PyObject *, PyArray_Descr *);
|
| 117 |
+
NPY_NO_EXPORT PyArrayObject ** PyArray_ConvertToCommonType \
|
| 118 |
+
(PyObject *, int *);
|
| 119 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromScalar \
|
| 120 |
+
(PyObject *);
|
| 121 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrFromTypeObject \
|
| 122 |
+
(PyObject *);
|
| 123 |
+
NPY_NO_EXPORT npy_intp PyArray_Size \
|
| 124 |
+
(PyObject *);
|
| 125 |
+
NPY_NO_EXPORT PyObject * PyArray_Scalar \
|
| 126 |
+
(void *, PyArray_Descr *, PyObject *);
|
| 127 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromScalar \
|
| 128 |
+
(PyObject *, PyArray_Descr *);
|
| 129 |
+
NPY_NO_EXPORT void PyArray_ScalarAsCtype \
|
| 130 |
+
(PyObject *, void *);
|
| 131 |
+
NPY_NO_EXPORT int PyArray_CastScalarToCtype \
|
| 132 |
+
(PyObject *, void *, PyArray_Descr *);
|
| 133 |
+
NPY_NO_EXPORT int PyArray_CastScalarDirect \
|
| 134 |
+
(PyObject *, PyArray_Descr *, void *, int);
|
| 135 |
+
NPY_NO_EXPORT int PyArray_Pack \
|
| 136 |
+
(PyArray_Descr *, void *, PyObject *);
|
| 137 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromAny \
|
| 138 |
+
(PyObject *, PyArray_Descr *, int, int, int, PyObject *);
|
| 139 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureArray \
|
| 140 |
+
(PyObject *);
|
| 141 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_EnsureAnyArray \
|
| 142 |
+
(PyObject *);
|
| 143 |
+
NPY_NO_EXPORT PyObject * PyArray_FromFile \
|
| 144 |
+
(FILE *, PyArray_Descr *, npy_intp, char *);
|
| 145 |
+
NPY_NO_EXPORT PyObject * PyArray_FromString \
|
| 146 |
+
(char *, npy_intp, PyArray_Descr *, npy_intp, char *);
|
| 147 |
+
NPY_NO_EXPORT PyObject * PyArray_FromBuffer \
|
| 148 |
+
(PyObject *, PyArray_Descr *, npy_intp, npy_intp);
|
| 149 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromIter \
|
| 150 |
+
(PyObject *, PyArray_Descr *, npy_intp);
|
| 151 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(1) PyObject * PyArray_Return \
|
| 152 |
+
(PyArrayObject *);
|
| 153 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_GetField \
|
| 154 |
+
(PyArrayObject *, PyArray_Descr *, int);
|
| 155 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetField \
|
| 156 |
+
(PyArrayObject *, PyArray_Descr *, int, PyObject *);
|
| 157 |
+
NPY_NO_EXPORT PyObject * PyArray_Byteswap \
|
| 158 |
+
(PyArrayObject *, npy_bool);
|
| 159 |
+
NPY_NO_EXPORT PyObject * PyArray_Resize \
|
| 160 |
+
(PyArrayObject *, PyArray_Dims *, int, NPY_ORDER NPY_UNUSED(order));
|
| 161 |
+
NPY_NO_EXPORT int PyArray_CopyObject \
|
| 162 |
+
(PyArrayObject *, PyObject *);
|
| 163 |
+
NPY_NO_EXPORT PyObject * PyArray_NewCopy \
|
| 164 |
+
(PyArrayObject *, NPY_ORDER);
|
| 165 |
+
NPY_NO_EXPORT PyObject * PyArray_ToList \
|
| 166 |
+
(PyArrayObject *);
|
| 167 |
+
NPY_NO_EXPORT PyObject * PyArray_ToString \
|
| 168 |
+
(PyArrayObject *, NPY_ORDER);
|
| 169 |
+
NPY_NO_EXPORT int PyArray_ToFile \
|
| 170 |
+
(PyArrayObject *, FILE *, char *, char *);
|
| 171 |
+
NPY_NO_EXPORT int PyArray_Dump \
|
| 172 |
+
(PyObject *, PyObject *, int);
|
| 173 |
+
NPY_NO_EXPORT PyObject * PyArray_Dumps \
|
| 174 |
+
(PyObject *, int);
|
| 175 |
+
NPY_NO_EXPORT int PyArray_ValidType \
|
| 176 |
+
(int);
|
| 177 |
+
NPY_NO_EXPORT void PyArray_UpdateFlags \
|
| 178 |
+
(PyArrayObject *, int);
|
| 179 |
+
NPY_NO_EXPORT PyObject * PyArray_New \
|
| 180 |
+
(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *);
|
| 181 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_NewFromDescr \
|
| 182 |
+
(PyTypeObject *, PyArray_Descr *, int, npy_intp const *, npy_intp const *, void *, int, PyObject *);
|
| 183 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNew \
|
| 184 |
+
(PyArray_Descr *);
|
| 185 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewFromType \
|
| 186 |
+
(int);
|
| 187 |
+
NPY_NO_EXPORT double PyArray_GetPriority \
|
| 188 |
+
(PyObject *, double);
|
| 189 |
+
NPY_NO_EXPORT PyObject * PyArray_IterNew \
|
| 190 |
+
(PyObject *);
|
| 191 |
+
NPY_NO_EXPORT PyObject* PyArray_MultiIterNew \
|
| 192 |
+
(int, ...);
|
| 193 |
+
NPY_NO_EXPORT int PyArray_PyIntAsInt \
|
| 194 |
+
(PyObject *);
|
| 195 |
+
NPY_NO_EXPORT npy_intp PyArray_PyIntAsIntp \
|
| 196 |
+
(PyObject *);
|
| 197 |
+
NPY_NO_EXPORT int PyArray_Broadcast \
|
| 198 |
+
(PyArrayMultiIterObject *);
|
| 199 |
+
NPY_NO_EXPORT int PyArray_FillWithScalar \
|
| 200 |
+
(PyArrayObject *, PyObject *);
|
| 201 |
+
NPY_NO_EXPORT npy_bool PyArray_CheckStrides \
|
| 202 |
+
(int, int, npy_intp, npy_intp, npy_intp const *, npy_intp const *);
|
| 203 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_DescrNewByteorder \
|
| 204 |
+
(PyArray_Descr *, char);
|
| 205 |
+
NPY_NO_EXPORT PyObject * PyArray_IterAllButAxis \
|
| 206 |
+
(PyObject *, int *);
|
| 207 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_CheckFromAny \
|
| 208 |
+
(PyObject *, PyArray_Descr *, int, int, int, PyObject *);
|
| 209 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_FromArray \
|
| 210 |
+
(PyArrayObject *, PyArray_Descr *, int);
|
| 211 |
+
NPY_NO_EXPORT PyObject * PyArray_FromInterface \
|
| 212 |
+
(PyObject *);
|
| 213 |
+
NPY_NO_EXPORT PyObject * PyArray_FromStructInterface \
|
| 214 |
+
(PyObject *);
|
| 215 |
+
NPY_NO_EXPORT PyObject * PyArray_FromArrayAttr \
|
| 216 |
+
(PyObject *, PyArray_Descr *, PyObject *);
|
| 217 |
+
NPY_NO_EXPORT NPY_SCALARKIND PyArray_ScalarKind \
|
| 218 |
+
(int, PyArrayObject **);
|
| 219 |
+
NPY_NO_EXPORT int PyArray_CanCoerceScalar \
|
| 220 |
+
(int, int, NPY_SCALARKIND);
|
| 221 |
+
NPY_NO_EXPORT npy_bool PyArray_CanCastScalar \
|
| 222 |
+
(PyTypeObject *, PyTypeObject *);
|
| 223 |
+
NPY_NO_EXPORT int PyArray_RemoveSmallest \
|
| 224 |
+
(PyArrayMultiIterObject *);
|
| 225 |
+
NPY_NO_EXPORT int PyArray_ElementStrides \
|
| 226 |
+
(PyObject *);
|
| 227 |
+
NPY_NO_EXPORT void PyArray_Item_INCREF \
|
| 228 |
+
(char *, PyArray_Descr *);
|
| 229 |
+
NPY_NO_EXPORT void PyArray_Item_XDECREF \
|
| 230 |
+
(char *, PyArray_Descr *);
|
| 231 |
+
NPY_NO_EXPORT PyObject * PyArray_Transpose \
|
| 232 |
+
(PyArrayObject *, PyArray_Dims *);
|
| 233 |
+
NPY_NO_EXPORT PyObject * PyArray_TakeFrom \
|
| 234 |
+
(PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE);
|
| 235 |
+
NPY_NO_EXPORT PyObject * PyArray_PutTo \
|
| 236 |
+
(PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE);
|
| 237 |
+
NPY_NO_EXPORT PyObject * PyArray_PutMask \
|
| 238 |
+
(PyArrayObject *, PyObject*, PyObject*);
|
| 239 |
+
NPY_NO_EXPORT PyObject * PyArray_Repeat \
|
| 240 |
+
(PyArrayObject *, PyObject *, int);
|
| 241 |
+
NPY_NO_EXPORT PyObject * PyArray_Choose \
|
| 242 |
+
(PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE);
|
| 243 |
+
NPY_NO_EXPORT int PyArray_Sort \
|
| 244 |
+
(PyArrayObject *, int, NPY_SORTKIND);
|
| 245 |
+
NPY_NO_EXPORT PyObject * PyArray_ArgSort \
|
| 246 |
+
(PyArrayObject *, int, NPY_SORTKIND);
|
| 247 |
+
NPY_NO_EXPORT PyObject * PyArray_SearchSorted \
|
| 248 |
+
(PyArrayObject *, PyObject *, NPY_SEARCHSIDE, PyObject *);
|
| 249 |
+
NPY_NO_EXPORT PyObject * PyArray_ArgMax \
|
| 250 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 251 |
+
NPY_NO_EXPORT PyObject * PyArray_ArgMin \
|
| 252 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 253 |
+
NPY_NO_EXPORT PyObject * PyArray_Reshape \
|
| 254 |
+
(PyArrayObject *, PyObject *);
|
| 255 |
+
NPY_NO_EXPORT PyObject * PyArray_Newshape \
|
| 256 |
+
(PyArrayObject *, PyArray_Dims *, NPY_ORDER);
|
| 257 |
+
NPY_NO_EXPORT PyObject * PyArray_Squeeze \
|
| 258 |
+
(PyArrayObject *);
|
| 259 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) PyObject * PyArray_View \
|
| 260 |
+
(PyArrayObject *, PyArray_Descr *, PyTypeObject *);
|
| 261 |
+
NPY_NO_EXPORT PyObject * PyArray_SwapAxes \
|
| 262 |
+
(PyArrayObject *, int, int);
|
| 263 |
+
NPY_NO_EXPORT PyObject * PyArray_Max \
|
| 264 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 265 |
+
NPY_NO_EXPORT PyObject * PyArray_Min \
|
| 266 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 267 |
+
NPY_NO_EXPORT PyObject * PyArray_Ptp \
|
| 268 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 269 |
+
NPY_NO_EXPORT PyObject * PyArray_Mean \
|
| 270 |
+
(PyArrayObject *, int, int, PyArrayObject *);
|
| 271 |
+
NPY_NO_EXPORT PyObject * PyArray_Trace \
|
| 272 |
+
(PyArrayObject *, int, int, int, int, PyArrayObject *);
|
| 273 |
+
NPY_NO_EXPORT PyObject * PyArray_Diagonal \
|
| 274 |
+
(PyArrayObject *, int, int, int);
|
| 275 |
+
NPY_NO_EXPORT PyObject * PyArray_Clip \
|
| 276 |
+
(PyArrayObject *, PyObject *, PyObject *, PyArrayObject *);
|
| 277 |
+
NPY_NO_EXPORT PyObject * PyArray_Conjugate \
|
| 278 |
+
(PyArrayObject *, PyArrayObject *);
|
| 279 |
+
NPY_NO_EXPORT PyObject * PyArray_Nonzero \
|
| 280 |
+
(PyArrayObject *);
|
| 281 |
+
NPY_NO_EXPORT PyObject * PyArray_Std \
|
| 282 |
+
(PyArrayObject *, int, int, PyArrayObject *, int);
|
| 283 |
+
NPY_NO_EXPORT PyObject * PyArray_Sum \
|
| 284 |
+
(PyArrayObject *, int, int, PyArrayObject *);
|
| 285 |
+
NPY_NO_EXPORT PyObject * PyArray_CumSum \
|
| 286 |
+
(PyArrayObject *, int, int, PyArrayObject *);
|
| 287 |
+
NPY_NO_EXPORT PyObject * PyArray_Prod \
|
| 288 |
+
(PyArrayObject *, int, int, PyArrayObject *);
|
| 289 |
+
NPY_NO_EXPORT PyObject * PyArray_CumProd \
|
| 290 |
+
(PyArrayObject *, int, int, PyArrayObject *);
|
| 291 |
+
NPY_NO_EXPORT PyObject * PyArray_All \
|
| 292 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 293 |
+
NPY_NO_EXPORT PyObject * PyArray_Any \
|
| 294 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 295 |
+
NPY_NO_EXPORT PyObject * PyArray_Compress \
|
| 296 |
+
(PyArrayObject *, PyObject *, int, PyArrayObject *);
|
| 297 |
+
NPY_NO_EXPORT PyObject * PyArray_Flatten \
|
| 298 |
+
(PyArrayObject *, NPY_ORDER);
|
| 299 |
+
NPY_NO_EXPORT PyObject * PyArray_Ravel \
|
| 300 |
+
(PyArrayObject *, NPY_ORDER);
|
| 301 |
+
NPY_NO_EXPORT npy_intp PyArray_MultiplyList \
|
| 302 |
+
(npy_intp const *, int);
|
| 303 |
+
NPY_NO_EXPORT int PyArray_MultiplyIntList \
|
| 304 |
+
(int const *, int);
|
| 305 |
+
NPY_NO_EXPORT void * PyArray_GetPtr \
|
| 306 |
+
(PyArrayObject *, npy_intp const*);
|
| 307 |
+
NPY_NO_EXPORT int PyArray_CompareLists \
|
| 308 |
+
(npy_intp const *, npy_intp const *, int);
|
| 309 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(5) int PyArray_AsCArray \
|
| 310 |
+
(PyObject **, void *, npy_intp *, int, PyArray_Descr*);
|
| 311 |
+
NPY_NO_EXPORT int PyArray_Free \
|
| 312 |
+
(PyObject *, void *);
|
| 313 |
+
NPY_NO_EXPORT int PyArray_Converter \
|
| 314 |
+
(PyObject *, PyObject **);
|
| 315 |
+
NPY_NO_EXPORT int PyArray_IntpFromSequence \
|
| 316 |
+
(PyObject *, npy_intp *, int);
|
| 317 |
+
NPY_NO_EXPORT PyObject * PyArray_Concatenate \
|
| 318 |
+
(PyObject *, int);
|
| 319 |
+
NPY_NO_EXPORT PyObject * PyArray_InnerProduct \
|
| 320 |
+
(PyObject *, PyObject *);
|
| 321 |
+
NPY_NO_EXPORT PyObject * PyArray_MatrixProduct \
|
| 322 |
+
(PyObject *, PyObject *);
|
| 323 |
+
NPY_NO_EXPORT PyObject * PyArray_Correlate \
|
| 324 |
+
(PyObject *, PyObject *, int);
|
| 325 |
+
NPY_NO_EXPORT int PyArray_DescrConverter \
|
| 326 |
+
(PyObject *, PyArray_Descr **);
|
| 327 |
+
NPY_NO_EXPORT int PyArray_DescrConverter2 \
|
| 328 |
+
(PyObject *, PyArray_Descr **);
|
| 329 |
+
NPY_NO_EXPORT int PyArray_IntpConverter \
|
| 330 |
+
(PyObject *, PyArray_Dims *);
|
| 331 |
+
NPY_NO_EXPORT int PyArray_BufferConverter \
|
| 332 |
+
(PyObject *, PyArray_Chunk *);
|
| 333 |
+
NPY_NO_EXPORT int PyArray_AxisConverter \
|
| 334 |
+
(PyObject *, int *);
|
| 335 |
+
NPY_NO_EXPORT int PyArray_BoolConverter \
|
| 336 |
+
(PyObject *, npy_bool *);
|
| 337 |
+
NPY_NO_EXPORT int PyArray_ByteorderConverter \
|
| 338 |
+
(PyObject *, char *);
|
| 339 |
+
NPY_NO_EXPORT int PyArray_OrderConverter \
|
| 340 |
+
(PyObject *, NPY_ORDER *);
|
| 341 |
+
NPY_NO_EXPORT unsigned char PyArray_EquivTypes \
|
| 342 |
+
(PyArray_Descr *, PyArray_Descr *);
|
| 343 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Zeros \
|
| 344 |
+
(int, npy_intp const *, PyArray_Descr *, int);
|
| 345 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_Empty \
|
| 346 |
+
(int, npy_intp const *, PyArray_Descr *, int);
|
| 347 |
+
NPY_NO_EXPORT PyObject * PyArray_Where \
|
| 348 |
+
(PyObject *, PyObject *, PyObject *);
|
| 349 |
+
NPY_NO_EXPORT PyObject * PyArray_Arange \
|
| 350 |
+
(double, double, double, int);
|
| 351 |
+
NPY_NO_EXPORT PyObject * PyArray_ArangeObj \
|
| 352 |
+
(PyObject *, PyObject *, PyObject *, PyArray_Descr *);
|
| 353 |
+
NPY_NO_EXPORT int PyArray_SortkindConverter \
|
| 354 |
+
(PyObject *, NPY_SORTKIND *);
|
| 355 |
+
NPY_NO_EXPORT PyObject * PyArray_LexSort \
|
| 356 |
+
(PyObject *, int);
|
| 357 |
+
NPY_NO_EXPORT PyObject * PyArray_Round \
|
| 358 |
+
(PyArrayObject *, int, PyArrayObject *);
|
| 359 |
+
NPY_NO_EXPORT unsigned char PyArray_EquivTypenums \
|
| 360 |
+
(int, int);
|
| 361 |
+
NPY_NO_EXPORT int PyArray_RegisterDataType \
|
| 362 |
+
(PyArray_DescrProto *);
|
| 363 |
+
NPY_NO_EXPORT int PyArray_RegisterCastFunc \
|
| 364 |
+
(PyArray_Descr *, int, PyArray_VectorUnaryFunc *);
|
| 365 |
+
NPY_NO_EXPORT int PyArray_RegisterCanCast \
|
| 366 |
+
(PyArray_Descr *, int, NPY_SCALARKIND);
|
| 367 |
+
NPY_NO_EXPORT void PyArray_InitArrFuncs \
|
| 368 |
+
(PyArray_ArrFuncs *);
|
| 369 |
+
NPY_NO_EXPORT PyObject * PyArray_IntTupleFromIntp \
|
| 370 |
+
(int, npy_intp const *);
|
| 371 |
+
NPY_NO_EXPORT int PyArray_ClipmodeConverter \
|
| 372 |
+
(PyObject *, NPY_CLIPMODE *);
|
| 373 |
+
NPY_NO_EXPORT int PyArray_OutputConverter \
|
| 374 |
+
(PyObject *, PyArrayObject **);
|
| 375 |
+
NPY_NO_EXPORT PyObject * PyArray_BroadcastToShape \
|
| 376 |
+
(PyObject *, npy_intp *, int);
|
| 377 |
+
NPY_NO_EXPORT int PyArray_DescrAlignConverter \
|
| 378 |
+
(PyObject *, PyArray_Descr **);
|
| 379 |
+
NPY_NO_EXPORT int PyArray_DescrAlignConverter2 \
|
| 380 |
+
(PyObject *, PyArray_Descr **);
|
| 381 |
+
NPY_NO_EXPORT int PyArray_SearchsideConverter \
|
| 382 |
+
(PyObject *, void *);
|
| 383 |
+
NPY_NO_EXPORT PyObject * PyArray_CheckAxis \
|
| 384 |
+
(PyArrayObject *, int *, int);
|
| 385 |
+
NPY_NO_EXPORT npy_intp PyArray_OverflowMultiplyList \
|
| 386 |
+
(npy_intp const *, int);
|
| 387 |
+
NPY_NO_EXPORT PyObject* PyArray_MultiIterFromObjects \
|
| 388 |
+
(PyObject **, int, int, ...);
|
| 389 |
+
NPY_NO_EXPORT int PyArray_GetEndianness \
|
| 390 |
+
(void);
|
| 391 |
+
NPY_NO_EXPORT unsigned int PyArray_GetNDArrayCFeatureVersion \
|
| 392 |
+
(void);
|
| 393 |
+
NPY_NO_EXPORT PyObject * PyArray_Correlate2 \
|
| 394 |
+
(PyObject *, PyObject *, int);
|
| 395 |
+
NPY_NO_EXPORT PyObject* PyArray_NeighborhoodIterNew \
|
| 396 |
+
(PyArrayIterObject *, const npy_intp *, int, PyArrayObject*);
|
| 397 |
+
extern NPY_NO_EXPORT PyTypeObject PyTimeIntegerArrType_Type;
|
| 398 |
+
|
| 399 |
+
extern NPY_NO_EXPORT PyTypeObject PyDatetimeArrType_Type;
|
| 400 |
+
|
| 401 |
+
extern NPY_NO_EXPORT PyTypeObject PyTimedeltaArrType_Type;
|
| 402 |
+
|
| 403 |
+
extern NPY_NO_EXPORT PyTypeObject PyHalfArrType_Type;
|
| 404 |
+
|
| 405 |
+
extern NPY_NO_EXPORT PyTypeObject NpyIter_Type;
|
| 406 |
+
|
| 407 |
+
NPY_NO_EXPORT NpyIter * NpyIter_New \
|
| 408 |
+
(PyArrayObject *, npy_uint32, NPY_ORDER, NPY_CASTING, PyArray_Descr*);
|
| 409 |
+
NPY_NO_EXPORT NpyIter * NpyIter_MultiNew \
|
| 410 |
+
(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **);
|
| 411 |
+
NPY_NO_EXPORT NpyIter * NpyIter_AdvancedNew \
|
| 412 |
+
(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **, int, int **, npy_intp *, npy_intp);
|
| 413 |
+
NPY_NO_EXPORT NpyIter * NpyIter_Copy \
|
| 414 |
+
(NpyIter *);
|
| 415 |
+
NPY_NO_EXPORT int NpyIter_Deallocate \
|
| 416 |
+
(NpyIter *);
|
| 417 |
+
NPY_NO_EXPORT npy_bool NpyIter_HasDelayedBufAlloc \
|
| 418 |
+
(NpyIter *);
|
| 419 |
+
NPY_NO_EXPORT npy_bool NpyIter_HasExternalLoop \
|
| 420 |
+
(NpyIter *);
|
| 421 |
+
NPY_NO_EXPORT int NpyIter_EnableExternalLoop \
|
| 422 |
+
(NpyIter *);
|
| 423 |
+
NPY_NO_EXPORT npy_intp * NpyIter_GetInnerStrideArray \
|
| 424 |
+
(NpyIter *);
|
| 425 |
+
NPY_NO_EXPORT npy_intp * NpyIter_GetInnerLoopSizePtr \
|
| 426 |
+
(NpyIter *);
|
| 427 |
+
NPY_NO_EXPORT int NpyIter_Reset \
|
| 428 |
+
(NpyIter *, char **);
|
| 429 |
+
NPY_NO_EXPORT int NpyIter_ResetBasePointers \
|
| 430 |
+
(NpyIter *, char **, char **);
|
| 431 |
+
NPY_NO_EXPORT int NpyIter_ResetToIterIndexRange \
|
| 432 |
+
(NpyIter *, npy_intp, npy_intp, char **);
|
| 433 |
+
NPY_NO_EXPORT int NpyIter_GetNDim \
|
| 434 |
+
(NpyIter *);
|
| 435 |
+
NPY_NO_EXPORT int NpyIter_GetNOp \
|
| 436 |
+
(NpyIter *);
|
| 437 |
+
NPY_NO_EXPORT NpyIter_IterNextFunc * NpyIter_GetIterNext \
|
| 438 |
+
(NpyIter *, char **);
|
| 439 |
+
NPY_NO_EXPORT npy_intp NpyIter_GetIterSize \
|
| 440 |
+
(NpyIter *);
|
| 441 |
+
NPY_NO_EXPORT void NpyIter_GetIterIndexRange \
|
| 442 |
+
(NpyIter *, npy_intp *, npy_intp *);
|
| 443 |
+
NPY_NO_EXPORT npy_intp NpyIter_GetIterIndex \
|
| 444 |
+
(NpyIter *);
|
| 445 |
+
NPY_NO_EXPORT int NpyIter_GotoIterIndex \
|
| 446 |
+
(NpyIter *, npy_intp);
|
| 447 |
+
NPY_NO_EXPORT npy_bool NpyIter_HasMultiIndex \
|
| 448 |
+
(NpyIter *);
|
| 449 |
+
NPY_NO_EXPORT int NpyIter_GetShape \
|
| 450 |
+
(NpyIter *, npy_intp *);
|
| 451 |
+
NPY_NO_EXPORT NpyIter_GetMultiIndexFunc * NpyIter_GetGetMultiIndex \
|
| 452 |
+
(NpyIter *, char **);
|
| 453 |
+
NPY_NO_EXPORT int NpyIter_GotoMultiIndex \
|
| 454 |
+
(NpyIter *, npy_intp const *);
|
| 455 |
+
NPY_NO_EXPORT int NpyIter_RemoveMultiIndex \
|
| 456 |
+
(NpyIter *);
|
| 457 |
+
NPY_NO_EXPORT npy_bool NpyIter_HasIndex \
|
| 458 |
+
(NpyIter *);
|
| 459 |
+
NPY_NO_EXPORT npy_bool NpyIter_IsBuffered \
|
| 460 |
+
(NpyIter *);
|
| 461 |
+
NPY_NO_EXPORT npy_bool NpyIter_IsGrowInner \
|
| 462 |
+
(NpyIter *);
|
| 463 |
+
NPY_NO_EXPORT npy_intp NpyIter_GetBufferSize \
|
| 464 |
+
(NpyIter *);
|
| 465 |
+
NPY_NO_EXPORT npy_intp * NpyIter_GetIndexPtr \
|
| 466 |
+
(NpyIter *);
|
| 467 |
+
NPY_NO_EXPORT int NpyIter_GotoIndex \
|
| 468 |
+
(NpyIter *, npy_intp);
|
| 469 |
+
NPY_NO_EXPORT char ** NpyIter_GetDataPtrArray \
|
| 470 |
+
(NpyIter *);
|
| 471 |
+
NPY_NO_EXPORT PyArray_Descr ** NpyIter_GetDescrArray \
|
| 472 |
+
(NpyIter *);
|
| 473 |
+
NPY_NO_EXPORT PyArrayObject ** NpyIter_GetOperandArray \
|
| 474 |
+
(NpyIter *);
|
| 475 |
+
NPY_NO_EXPORT PyArrayObject * NpyIter_GetIterView \
|
| 476 |
+
(NpyIter *, npy_intp);
|
| 477 |
+
NPY_NO_EXPORT void NpyIter_GetReadFlags \
|
| 478 |
+
(NpyIter *, char *);
|
| 479 |
+
NPY_NO_EXPORT void NpyIter_GetWriteFlags \
|
| 480 |
+
(NpyIter *, char *);
|
| 481 |
+
NPY_NO_EXPORT void NpyIter_DebugPrint \
|
| 482 |
+
(NpyIter *);
|
| 483 |
+
NPY_NO_EXPORT npy_bool NpyIter_IterationNeedsAPI \
|
| 484 |
+
(NpyIter *);
|
| 485 |
+
NPY_NO_EXPORT void NpyIter_GetInnerFixedStrideArray \
|
| 486 |
+
(NpyIter *, npy_intp *);
|
| 487 |
+
NPY_NO_EXPORT int NpyIter_RemoveAxis \
|
| 488 |
+
(NpyIter *, int);
|
| 489 |
+
NPY_NO_EXPORT npy_intp * NpyIter_GetAxisStrideArray \
|
| 490 |
+
(NpyIter *, int);
|
| 491 |
+
NPY_NO_EXPORT npy_bool NpyIter_RequiresBuffering \
|
| 492 |
+
(NpyIter *);
|
| 493 |
+
NPY_NO_EXPORT char ** NpyIter_GetInitialDataPtrArray \
|
| 494 |
+
(NpyIter *);
|
| 495 |
+
NPY_NO_EXPORT int NpyIter_CreateCompatibleStrides \
|
| 496 |
+
(NpyIter *, npy_intp, npy_intp *);
|
| 497 |
+
NPY_NO_EXPORT int PyArray_CastingConverter \
|
| 498 |
+
(PyObject *, NPY_CASTING *);
|
| 499 |
+
NPY_NO_EXPORT npy_intp PyArray_CountNonzero \
|
| 500 |
+
(PyArrayObject *);
|
| 501 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_PromoteTypes \
|
| 502 |
+
(PyArray_Descr *, PyArray_Descr *);
|
| 503 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_MinScalarType \
|
| 504 |
+
(PyArrayObject *);
|
| 505 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_ResultType \
|
| 506 |
+
(npy_intp, PyArrayObject *arrs[], npy_intp, PyArray_Descr *descrs[]);
|
| 507 |
+
NPY_NO_EXPORT npy_bool PyArray_CanCastArrayTo \
|
| 508 |
+
(PyArrayObject *, PyArray_Descr *, NPY_CASTING);
|
| 509 |
+
NPY_NO_EXPORT npy_bool PyArray_CanCastTypeTo \
|
| 510 |
+
(PyArray_Descr *, PyArray_Descr *, NPY_CASTING);
|
| 511 |
+
NPY_NO_EXPORT PyArrayObject * PyArray_EinsteinSum \
|
| 512 |
+
(char *, npy_intp, PyArrayObject **, PyArray_Descr *, NPY_ORDER, NPY_CASTING, PyArrayObject *);
|
| 513 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(3) PyObject * PyArray_NewLikeArray \
|
| 514 |
+
(PyArrayObject *, NPY_ORDER, PyArray_Descr *, int);
|
| 515 |
+
NPY_NO_EXPORT int PyArray_ConvertClipmodeSequence \
|
| 516 |
+
(PyObject *, NPY_CLIPMODE *, int);
|
| 517 |
+
NPY_NO_EXPORT PyObject * PyArray_MatrixProduct2 \
|
| 518 |
+
(PyObject *, PyObject *, PyArrayObject*);
|
| 519 |
+
NPY_NO_EXPORT npy_bool NpyIter_IsFirstVisit \
|
| 520 |
+
(NpyIter *, int);
|
| 521 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetBaseObject \
|
| 522 |
+
(PyArrayObject *, PyObject *);
|
| 523 |
+
NPY_NO_EXPORT void PyArray_CreateSortedStridePerm \
|
| 524 |
+
(int, npy_intp const *, npy_stride_sort_item *);
|
| 525 |
+
NPY_NO_EXPORT void PyArray_RemoveAxesInPlace \
|
| 526 |
+
(PyArrayObject *, const npy_bool *);
|
| 527 |
+
NPY_NO_EXPORT void PyArray_DebugPrint \
|
| 528 |
+
(PyArrayObject *);
|
| 529 |
+
NPY_NO_EXPORT int PyArray_FailUnlessWriteable \
|
| 530 |
+
(PyArrayObject *, const char *);
|
| 531 |
+
NPY_NO_EXPORT NPY_STEALS_REF_TO_ARG(2) int PyArray_SetUpdateIfCopyBase \
|
| 532 |
+
(PyArrayObject *, PyArrayObject *);
|
| 533 |
+
NPY_NO_EXPORT void * PyDataMem_NEW \
|
| 534 |
+
(size_t);
|
| 535 |
+
NPY_NO_EXPORT void PyDataMem_FREE \
|
| 536 |
+
(void *);
|
| 537 |
+
NPY_NO_EXPORT void * PyDataMem_RENEW \
|
| 538 |
+
(void *, size_t);
|
| 539 |
+
extern NPY_NO_EXPORT NPY_CASTING NPY_DEFAULT_ASSIGN_CASTING;
|
| 540 |
+
|
| 541 |
+
NPY_NO_EXPORT int PyArray_Partition \
|
| 542 |
+
(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND);
|
| 543 |
+
NPY_NO_EXPORT PyObject * PyArray_ArgPartition \
|
| 544 |
+
(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND);
|
| 545 |
+
NPY_NO_EXPORT int PyArray_SelectkindConverter \
|
| 546 |
+
(PyObject *, NPY_SELECTKIND *);
|
| 547 |
+
NPY_NO_EXPORT void * PyDataMem_NEW_ZEROED \
|
| 548 |
+
(size_t, size_t);
|
| 549 |
+
NPY_NO_EXPORT int PyArray_CheckAnyScalarExact \
|
| 550 |
+
(PyObject *);
|
| 551 |
+
NPY_NO_EXPORT int PyArray_ResolveWritebackIfCopy \
|
| 552 |
+
(PyArrayObject *);
|
| 553 |
+
NPY_NO_EXPORT int PyArray_SetWritebackIfCopyBase \
|
| 554 |
+
(PyArrayObject *, PyArrayObject *);
|
| 555 |
+
NPY_NO_EXPORT PyObject * PyDataMem_SetHandler \
|
| 556 |
+
(PyObject *);
|
| 557 |
+
NPY_NO_EXPORT PyObject * PyDataMem_GetHandler \
|
| 558 |
+
(void);
|
| 559 |
+
extern NPY_NO_EXPORT PyObject* PyDataMem_DefaultHandler;
|
| 560 |
+
|
| 561 |
+
NPY_NO_EXPORT int NpyDatetime_ConvertDatetime64ToDatetimeStruct \
|
| 562 |
+
(PyArray_DatetimeMetaData *, npy_datetime, npy_datetimestruct *);
|
| 563 |
+
NPY_NO_EXPORT int NpyDatetime_ConvertDatetimeStructToDatetime64 \
|
| 564 |
+
(PyArray_DatetimeMetaData *, const npy_datetimestruct *, npy_datetime *);
|
| 565 |
+
NPY_NO_EXPORT int NpyDatetime_ConvertPyDateTimeToDatetimeStruct \
|
| 566 |
+
(PyObject *, npy_datetimestruct *, NPY_DATETIMEUNIT *, int);
|
| 567 |
+
NPY_NO_EXPORT int NpyDatetime_GetDatetimeISO8601StrLen \
|
| 568 |
+
(int, NPY_DATETIMEUNIT);
|
| 569 |
+
NPY_NO_EXPORT int NpyDatetime_MakeISO8601Datetime \
|
| 570 |
+
(npy_datetimestruct *, char *, npy_intp, int, int, NPY_DATETIMEUNIT, int, NPY_CASTING);
|
| 571 |
+
NPY_NO_EXPORT int NpyDatetime_ParseISO8601Datetime \
|
| 572 |
+
(char const *, Py_ssize_t, NPY_DATETIMEUNIT, NPY_CASTING, npy_datetimestruct *, NPY_DATETIMEUNIT *, npy_bool *);
|
| 573 |
+
NPY_NO_EXPORT int NpyString_load \
|
| 574 |
+
(npy_string_allocator *, const npy_packed_static_string *, npy_static_string *);
|
| 575 |
+
NPY_NO_EXPORT int NpyString_pack \
|
| 576 |
+
(npy_string_allocator *, npy_packed_static_string *, const char *, size_t);
|
| 577 |
+
NPY_NO_EXPORT int NpyString_pack_null \
|
| 578 |
+
(npy_string_allocator *, npy_packed_static_string *);
|
| 579 |
+
NPY_NO_EXPORT npy_string_allocator * NpyString_acquire_allocator \
|
| 580 |
+
(const PyArray_StringDTypeObject *);
|
| 581 |
+
NPY_NO_EXPORT void NpyString_acquire_allocators \
|
| 582 |
+
(size_t, PyArray_Descr *const descrs[], npy_string_allocator *allocators[]);
|
| 583 |
+
NPY_NO_EXPORT void NpyString_release_allocator \
|
| 584 |
+
(npy_string_allocator *);
|
| 585 |
+
NPY_NO_EXPORT void NpyString_release_allocators \
|
| 586 |
+
(size_t, npy_string_allocator *allocators[]);
|
| 587 |
+
NPY_NO_EXPORT PyArray_Descr * PyArray_GetDefaultDescr \
|
| 588 |
+
(PyArray_DTypeMeta *);
|
| 589 |
+
NPY_NO_EXPORT int PyArrayInitDTypeMeta_FromSpec \
|
| 590 |
+
(PyArray_DTypeMeta *, PyArrayDTypeMeta_Spec *);
|
| 591 |
+
NPY_NO_EXPORT PyArray_DTypeMeta * PyArray_CommonDType \
|
| 592 |
+
(PyArray_DTypeMeta *, PyArray_DTypeMeta *);
|
| 593 |
+
NPY_NO_EXPORT PyArray_DTypeMeta * PyArray_PromoteDTypeSequence \
|
| 594 |
+
(npy_intp, PyArray_DTypeMeta **);
|
| 595 |
+
NPY_NO_EXPORT PyArray_ArrFuncs * _PyDataType_GetArrFuncs \
|
| 596 |
+
(const PyArray_Descr *);
|
| 597 |
+
|
| 598 |
+
#else
|
| 599 |
+
|
| 600 |
+
#if defined(PY_ARRAY_UNIQUE_SYMBOL)
|
| 601 |
+
#define PyArray_API PY_ARRAY_UNIQUE_SYMBOL
|
| 602 |
+
#define _NPY_VERSION_CONCAT_HELPER2(x, y) x ## y
|
| 603 |
+
#define _NPY_VERSION_CONCAT_HELPER(arg) \
|
| 604 |
+
_NPY_VERSION_CONCAT_HELPER2(arg, PyArray_RUNTIME_VERSION)
|
| 605 |
+
#define PyArray_RUNTIME_VERSION \
|
| 606 |
+
_NPY_VERSION_CONCAT_HELPER(PY_ARRAY_UNIQUE_SYMBOL)
|
| 607 |
+
#endif
|
| 608 |
+
|
| 609 |
+
/* By default do not export API in an .so (was never the case on windows) */
|
| 610 |
+
#ifndef NPY_API_SYMBOL_ATTRIBUTE
|
| 611 |
+
#define NPY_API_SYMBOL_ATTRIBUTE NPY_VISIBILITY_HIDDEN
|
| 612 |
+
#endif
|
| 613 |
+
|
| 614 |
+
#if defined(NO_IMPORT) || defined(NO_IMPORT_ARRAY)
|
| 615 |
+
extern NPY_API_SYMBOL_ATTRIBUTE void **PyArray_API;
|
| 616 |
+
extern NPY_API_SYMBOL_ATTRIBUTE int PyArray_RUNTIME_VERSION;
|
| 617 |
+
#else
|
| 618 |
+
#if defined(PY_ARRAY_UNIQUE_SYMBOL)
|
| 619 |
+
NPY_API_SYMBOL_ATTRIBUTE void **PyArray_API;
|
| 620 |
+
NPY_API_SYMBOL_ATTRIBUTE int PyArray_RUNTIME_VERSION;
|
| 621 |
+
#else
|
| 622 |
+
static void **PyArray_API = NULL;
|
| 623 |
+
static int PyArray_RUNTIME_VERSION = 0;
|
| 624 |
+
#endif
|
| 625 |
+
#endif
|
| 626 |
+
|
| 627 |
+
#define PyArray_GetNDArrayCVersion \
|
| 628 |
+
(*(unsigned int (*)(void)) \
|
| 629 |
+
PyArray_API[0])
|
| 630 |
+
#define PyArray_Type (*(PyTypeObject *)PyArray_API[2])
|
| 631 |
+
#define PyArrayDescr_Type (*(PyTypeObject *)PyArray_API[3])
|
| 632 |
+
#define PyArrayIter_Type (*(PyTypeObject *)PyArray_API[5])
|
| 633 |
+
#define PyArrayMultiIter_Type (*(PyTypeObject *)PyArray_API[6])
|
| 634 |
+
#define NPY_NUMUSERTYPES (*(int *)PyArray_API[7])
|
| 635 |
+
#define PyBoolArrType_Type (*(PyTypeObject *)PyArray_API[8])
|
| 636 |
+
#define _PyArrayScalar_BoolValues ((PyBoolScalarObject *)PyArray_API[9])
|
| 637 |
+
#define PyGenericArrType_Type (*(PyTypeObject *)PyArray_API[10])
|
| 638 |
+
#define PyNumberArrType_Type (*(PyTypeObject *)PyArray_API[11])
|
| 639 |
+
#define PyIntegerArrType_Type (*(PyTypeObject *)PyArray_API[12])
|
| 640 |
+
#define PySignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[13])
|
| 641 |
+
#define PyUnsignedIntegerArrType_Type (*(PyTypeObject *)PyArray_API[14])
|
| 642 |
+
#define PyInexactArrType_Type (*(PyTypeObject *)PyArray_API[15])
|
| 643 |
+
#define PyFloatingArrType_Type (*(PyTypeObject *)PyArray_API[16])
|
| 644 |
+
#define PyComplexFloatingArrType_Type (*(PyTypeObject *)PyArray_API[17])
|
| 645 |
+
#define PyFlexibleArrType_Type (*(PyTypeObject *)PyArray_API[18])
|
| 646 |
+
#define PyCharacterArrType_Type (*(PyTypeObject *)PyArray_API[19])
|
| 647 |
+
#define PyByteArrType_Type (*(PyTypeObject *)PyArray_API[20])
|
| 648 |
+
#define PyShortArrType_Type (*(PyTypeObject *)PyArray_API[21])
|
| 649 |
+
#define PyIntArrType_Type (*(PyTypeObject *)PyArray_API[22])
|
| 650 |
+
#define PyLongArrType_Type (*(PyTypeObject *)PyArray_API[23])
|
| 651 |
+
#define PyLongLongArrType_Type (*(PyTypeObject *)PyArray_API[24])
|
| 652 |
+
#define PyUByteArrType_Type (*(PyTypeObject *)PyArray_API[25])
|
| 653 |
+
#define PyUShortArrType_Type (*(PyTypeObject *)PyArray_API[26])
|
| 654 |
+
#define PyUIntArrType_Type (*(PyTypeObject *)PyArray_API[27])
|
| 655 |
+
#define PyULongArrType_Type (*(PyTypeObject *)PyArray_API[28])
|
| 656 |
+
#define PyULongLongArrType_Type (*(PyTypeObject *)PyArray_API[29])
|
| 657 |
+
#define PyFloatArrType_Type (*(PyTypeObject *)PyArray_API[30])
|
| 658 |
+
#define PyDoubleArrType_Type (*(PyTypeObject *)PyArray_API[31])
|
| 659 |
+
#define PyLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[32])
|
| 660 |
+
#define PyCFloatArrType_Type (*(PyTypeObject *)PyArray_API[33])
|
| 661 |
+
#define PyCDoubleArrType_Type (*(PyTypeObject *)PyArray_API[34])
|
| 662 |
+
#define PyCLongDoubleArrType_Type (*(PyTypeObject *)PyArray_API[35])
|
| 663 |
+
#define PyObjectArrType_Type (*(PyTypeObject *)PyArray_API[36])
|
| 664 |
+
#define PyStringArrType_Type (*(PyTypeObject *)PyArray_API[37])
|
| 665 |
+
#define PyUnicodeArrType_Type (*(PyTypeObject *)PyArray_API[38])
|
| 666 |
+
#define PyVoidArrType_Type (*(PyTypeObject *)PyArray_API[39])
|
| 667 |
+
#define PyArray_INCREF \
|
| 668 |
+
(*(int (*)(PyArrayObject *)) \
|
| 669 |
+
PyArray_API[42])
|
| 670 |
+
#define PyArray_XDECREF \
|
| 671 |
+
(*(int (*)(PyArrayObject *)) \
|
| 672 |
+
PyArray_API[43])
|
| 673 |
+
#define PyArray_SetStringFunction \
|
| 674 |
+
(*(void (*)(PyObject *, int)) \
|
| 675 |
+
PyArray_API[44])
|
| 676 |
+
#define PyArray_DescrFromType \
|
| 677 |
+
(*(PyArray_Descr * (*)(int)) \
|
| 678 |
+
PyArray_API[45])
|
| 679 |
+
#define PyArray_TypeObjectFromType \
|
| 680 |
+
(*(PyObject * (*)(int)) \
|
| 681 |
+
PyArray_API[46])
|
| 682 |
+
#define PyArray_Zero \
|
| 683 |
+
(*(char * (*)(PyArrayObject *)) \
|
| 684 |
+
PyArray_API[47])
|
| 685 |
+
#define PyArray_One \
|
| 686 |
+
(*(char * (*)(PyArrayObject *)) \
|
| 687 |
+
PyArray_API[48])
|
| 688 |
+
#define PyArray_CastToType \
|
| 689 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
|
| 690 |
+
PyArray_API[49])
|
| 691 |
+
#define PyArray_CopyInto \
|
| 692 |
+
(*(int (*)(PyArrayObject *, PyArrayObject *)) \
|
| 693 |
+
PyArray_API[50])
|
| 694 |
+
#define PyArray_CopyAnyInto \
|
| 695 |
+
(*(int (*)(PyArrayObject *, PyArrayObject *)) \
|
| 696 |
+
PyArray_API[51])
|
| 697 |
+
#define PyArray_CanCastSafely \
|
| 698 |
+
(*(int (*)(int, int)) \
|
| 699 |
+
PyArray_API[52])
|
| 700 |
+
#define PyArray_CanCastTo \
|
| 701 |
+
(*(npy_bool (*)(PyArray_Descr *, PyArray_Descr *)) \
|
| 702 |
+
PyArray_API[53])
|
| 703 |
+
#define PyArray_ObjectType \
|
| 704 |
+
(*(int (*)(PyObject *, int)) \
|
| 705 |
+
PyArray_API[54])
|
| 706 |
+
#define PyArray_DescrFromObject \
|
| 707 |
+
(*(PyArray_Descr * (*)(PyObject *, PyArray_Descr *)) \
|
| 708 |
+
PyArray_API[55])
|
| 709 |
+
#define PyArray_ConvertToCommonType \
|
| 710 |
+
(*(PyArrayObject ** (*)(PyObject *, int *)) \
|
| 711 |
+
PyArray_API[56])
|
| 712 |
+
#define PyArray_DescrFromScalar \
|
| 713 |
+
(*(PyArray_Descr * (*)(PyObject *)) \
|
| 714 |
+
PyArray_API[57])
|
| 715 |
+
#define PyArray_DescrFromTypeObject \
|
| 716 |
+
(*(PyArray_Descr * (*)(PyObject *)) \
|
| 717 |
+
PyArray_API[58])
|
| 718 |
+
#define PyArray_Size \
|
| 719 |
+
(*(npy_intp (*)(PyObject *)) \
|
| 720 |
+
PyArray_API[59])
|
| 721 |
+
#define PyArray_Scalar \
|
| 722 |
+
(*(PyObject * (*)(void *, PyArray_Descr *, PyObject *)) \
|
| 723 |
+
PyArray_API[60])
|
| 724 |
+
#define PyArray_FromScalar \
|
| 725 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *)) \
|
| 726 |
+
PyArray_API[61])
|
| 727 |
+
#define PyArray_ScalarAsCtype \
|
| 728 |
+
(*(void (*)(PyObject *, void *)) \
|
| 729 |
+
PyArray_API[62])
|
| 730 |
+
#define PyArray_CastScalarToCtype \
|
| 731 |
+
(*(int (*)(PyObject *, void *, PyArray_Descr *)) \
|
| 732 |
+
PyArray_API[63])
|
| 733 |
+
#define PyArray_CastScalarDirect \
|
| 734 |
+
(*(int (*)(PyObject *, PyArray_Descr *, void *, int)) \
|
| 735 |
+
PyArray_API[64])
|
| 736 |
+
|
| 737 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 738 |
+
#define PyArray_Pack \
|
| 739 |
+
(*(int (*)(PyArray_Descr *, void *, PyObject *)) \
|
| 740 |
+
PyArray_API[65])
|
| 741 |
+
#endif
|
| 742 |
+
#define PyArray_FromAny \
|
| 743 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \
|
| 744 |
+
PyArray_API[69])
|
| 745 |
+
#define PyArray_EnsureArray \
|
| 746 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 747 |
+
PyArray_API[70])
|
| 748 |
+
#define PyArray_EnsureAnyArray \
|
| 749 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 750 |
+
PyArray_API[71])
|
| 751 |
+
#define PyArray_FromFile \
|
| 752 |
+
(*(PyObject * (*)(FILE *, PyArray_Descr *, npy_intp, char *)) \
|
| 753 |
+
PyArray_API[72])
|
| 754 |
+
#define PyArray_FromString \
|
| 755 |
+
(*(PyObject * (*)(char *, npy_intp, PyArray_Descr *, npy_intp, char *)) \
|
| 756 |
+
PyArray_API[73])
|
| 757 |
+
#define PyArray_FromBuffer \
|
| 758 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp, npy_intp)) \
|
| 759 |
+
PyArray_API[74])
|
| 760 |
+
#define PyArray_FromIter \
|
| 761 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *, npy_intp)) \
|
| 762 |
+
PyArray_API[75])
|
| 763 |
+
#define PyArray_Return \
|
| 764 |
+
(*(PyObject * (*)(PyArrayObject *)) \
|
| 765 |
+
PyArray_API[76])
|
| 766 |
+
#define PyArray_GetField \
|
| 767 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
|
| 768 |
+
PyArray_API[77])
|
| 769 |
+
#define PyArray_SetField \
|
| 770 |
+
(*(int (*)(PyArrayObject *, PyArray_Descr *, int, PyObject *)) \
|
| 771 |
+
PyArray_API[78])
|
| 772 |
+
#define PyArray_Byteswap \
|
| 773 |
+
(*(PyObject * (*)(PyArrayObject *, npy_bool)) \
|
| 774 |
+
PyArray_API[79])
|
| 775 |
+
#define PyArray_Resize \
|
| 776 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, int, NPY_ORDER NPY_UNUSED(order))) \
|
| 777 |
+
PyArray_API[80])
|
| 778 |
+
#define PyArray_CopyObject \
|
| 779 |
+
(*(int (*)(PyArrayObject *, PyObject *)) \
|
| 780 |
+
PyArray_API[84])
|
| 781 |
+
#define PyArray_NewCopy \
|
| 782 |
+
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
|
| 783 |
+
PyArray_API[85])
|
| 784 |
+
#define PyArray_ToList \
|
| 785 |
+
(*(PyObject * (*)(PyArrayObject *)) \
|
| 786 |
+
PyArray_API[86])
|
| 787 |
+
#define PyArray_ToString \
|
| 788 |
+
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
|
| 789 |
+
PyArray_API[87])
|
| 790 |
+
#define PyArray_ToFile \
|
| 791 |
+
(*(int (*)(PyArrayObject *, FILE *, char *, char *)) \
|
| 792 |
+
PyArray_API[88])
|
| 793 |
+
#define PyArray_Dump \
|
| 794 |
+
(*(int (*)(PyObject *, PyObject *, int)) \
|
| 795 |
+
PyArray_API[89])
|
| 796 |
+
#define PyArray_Dumps \
|
| 797 |
+
(*(PyObject * (*)(PyObject *, int)) \
|
| 798 |
+
PyArray_API[90])
|
| 799 |
+
#define PyArray_ValidType \
|
| 800 |
+
(*(int (*)(int)) \
|
| 801 |
+
PyArray_API[91])
|
| 802 |
+
#define PyArray_UpdateFlags \
|
| 803 |
+
(*(void (*)(PyArrayObject *, int)) \
|
| 804 |
+
PyArray_API[92])
|
| 805 |
+
#define PyArray_New \
|
| 806 |
+
(*(PyObject * (*)(PyTypeObject *, int, npy_intp const *, int, npy_intp const *, void *, int, int, PyObject *)) \
|
| 807 |
+
PyArray_API[93])
|
| 808 |
+
#define PyArray_NewFromDescr \
|
| 809 |
+
(*(PyObject * (*)(PyTypeObject *, PyArray_Descr *, int, npy_intp const *, npy_intp const *, void *, int, PyObject *)) \
|
| 810 |
+
PyArray_API[94])
|
| 811 |
+
#define PyArray_DescrNew \
|
| 812 |
+
(*(PyArray_Descr * (*)(PyArray_Descr *)) \
|
| 813 |
+
PyArray_API[95])
|
| 814 |
+
#define PyArray_DescrNewFromType \
|
| 815 |
+
(*(PyArray_Descr * (*)(int)) \
|
| 816 |
+
PyArray_API[96])
|
| 817 |
+
#define PyArray_GetPriority \
|
| 818 |
+
(*(double (*)(PyObject *, double)) \
|
| 819 |
+
PyArray_API[97])
|
| 820 |
+
#define PyArray_IterNew \
|
| 821 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 822 |
+
PyArray_API[98])
|
| 823 |
+
#define PyArray_MultiIterNew \
|
| 824 |
+
(*(PyObject* (*)(int, ...)) \
|
| 825 |
+
PyArray_API[99])
|
| 826 |
+
#define PyArray_PyIntAsInt \
|
| 827 |
+
(*(int (*)(PyObject *)) \
|
| 828 |
+
PyArray_API[100])
|
| 829 |
+
#define PyArray_PyIntAsIntp \
|
| 830 |
+
(*(npy_intp (*)(PyObject *)) \
|
| 831 |
+
PyArray_API[101])
|
| 832 |
+
#define PyArray_Broadcast \
|
| 833 |
+
(*(int (*)(PyArrayMultiIterObject *)) \
|
| 834 |
+
PyArray_API[102])
|
| 835 |
+
#define PyArray_FillWithScalar \
|
| 836 |
+
(*(int (*)(PyArrayObject *, PyObject *)) \
|
| 837 |
+
PyArray_API[104])
|
| 838 |
+
#define PyArray_CheckStrides \
|
| 839 |
+
(*(npy_bool (*)(int, int, npy_intp, npy_intp, npy_intp const *, npy_intp const *)) \
|
| 840 |
+
PyArray_API[105])
|
| 841 |
+
#define PyArray_DescrNewByteorder \
|
| 842 |
+
(*(PyArray_Descr * (*)(PyArray_Descr *, char)) \
|
| 843 |
+
PyArray_API[106])
|
| 844 |
+
#define PyArray_IterAllButAxis \
|
| 845 |
+
(*(PyObject * (*)(PyObject *, int *)) \
|
| 846 |
+
PyArray_API[107])
|
| 847 |
+
#define PyArray_CheckFromAny \
|
| 848 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *, int, int, int, PyObject *)) \
|
| 849 |
+
PyArray_API[108])
|
| 850 |
+
#define PyArray_FromArray \
|
| 851 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, int)) \
|
| 852 |
+
PyArray_API[109])
|
| 853 |
+
#define PyArray_FromInterface \
|
| 854 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 855 |
+
PyArray_API[110])
|
| 856 |
+
#define PyArray_FromStructInterface \
|
| 857 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 858 |
+
PyArray_API[111])
|
| 859 |
+
#define PyArray_FromArrayAttr \
|
| 860 |
+
(*(PyObject * (*)(PyObject *, PyArray_Descr *, PyObject *)) \
|
| 861 |
+
PyArray_API[112])
|
| 862 |
+
#define PyArray_ScalarKind \
|
| 863 |
+
(*(NPY_SCALARKIND (*)(int, PyArrayObject **)) \
|
| 864 |
+
PyArray_API[113])
|
| 865 |
+
#define PyArray_CanCoerceScalar \
|
| 866 |
+
(*(int (*)(int, int, NPY_SCALARKIND)) \
|
| 867 |
+
PyArray_API[114])
|
| 868 |
+
#define PyArray_CanCastScalar \
|
| 869 |
+
(*(npy_bool (*)(PyTypeObject *, PyTypeObject *)) \
|
| 870 |
+
PyArray_API[116])
|
| 871 |
+
#define PyArray_RemoveSmallest \
|
| 872 |
+
(*(int (*)(PyArrayMultiIterObject *)) \
|
| 873 |
+
PyArray_API[118])
|
| 874 |
+
#define PyArray_ElementStrides \
|
| 875 |
+
(*(int (*)(PyObject *)) \
|
| 876 |
+
PyArray_API[119])
|
| 877 |
+
#define PyArray_Item_INCREF \
|
| 878 |
+
(*(void (*)(char *, PyArray_Descr *)) \
|
| 879 |
+
PyArray_API[120])
|
| 880 |
+
#define PyArray_Item_XDECREF \
|
| 881 |
+
(*(void (*)(char *, PyArray_Descr *)) \
|
| 882 |
+
PyArray_API[121])
|
| 883 |
+
#define PyArray_Transpose \
|
| 884 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Dims *)) \
|
| 885 |
+
PyArray_API[123])
|
| 886 |
+
#define PyArray_TakeFrom \
|
| 887 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *, NPY_CLIPMODE)) \
|
| 888 |
+
PyArray_API[124])
|
| 889 |
+
#define PyArray_PutTo \
|
| 890 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject *, NPY_CLIPMODE)) \
|
| 891 |
+
PyArray_API[125])
|
| 892 |
+
#define PyArray_PutMask \
|
| 893 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject*, PyObject*)) \
|
| 894 |
+
PyArray_API[126])
|
| 895 |
+
#define PyArray_Repeat \
|
| 896 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, int)) \
|
| 897 |
+
PyArray_API[127])
|
| 898 |
+
#define PyArray_Choose \
|
| 899 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, PyArrayObject *, NPY_CLIPMODE)) \
|
| 900 |
+
PyArray_API[128])
|
| 901 |
+
#define PyArray_Sort \
|
| 902 |
+
(*(int (*)(PyArrayObject *, int, NPY_SORTKIND)) \
|
| 903 |
+
PyArray_API[129])
|
| 904 |
+
#define PyArray_ArgSort \
|
| 905 |
+
(*(PyObject * (*)(PyArrayObject *, int, NPY_SORTKIND)) \
|
| 906 |
+
PyArray_API[130])
|
| 907 |
+
#define PyArray_SearchSorted \
|
| 908 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, NPY_SEARCHSIDE, PyObject *)) \
|
| 909 |
+
PyArray_API[131])
|
| 910 |
+
#define PyArray_ArgMax \
|
| 911 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 912 |
+
PyArray_API[132])
|
| 913 |
+
#define PyArray_ArgMin \
|
| 914 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 915 |
+
PyArray_API[133])
|
| 916 |
+
#define PyArray_Reshape \
|
| 917 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *)) \
|
| 918 |
+
PyArray_API[134])
|
| 919 |
+
#define PyArray_Newshape \
|
| 920 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Dims *, NPY_ORDER)) \
|
| 921 |
+
PyArray_API[135])
|
| 922 |
+
#define PyArray_Squeeze \
|
| 923 |
+
(*(PyObject * (*)(PyArrayObject *)) \
|
| 924 |
+
PyArray_API[136])
|
| 925 |
+
#define PyArray_View \
|
| 926 |
+
(*(PyObject * (*)(PyArrayObject *, PyArray_Descr *, PyTypeObject *)) \
|
| 927 |
+
PyArray_API[137])
|
| 928 |
+
#define PyArray_SwapAxes \
|
| 929 |
+
(*(PyObject * (*)(PyArrayObject *, int, int)) \
|
| 930 |
+
PyArray_API[138])
|
| 931 |
+
#define PyArray_Max \
|
| 932 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 933 |
+
PyArray_API[139])
|
| 934 |
+
#define PyArray_Min \
|
| 935 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 936 |
+
PyArray_API[140])
|
| 937 |
+
#define PyArray_Ptp \
|
| 938 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 939 |
+
PyArray_API[141])
|
| 940 |
+
#define PyArray_Mean \
|
| 941 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
|
| 942 |
+
PyArray_API[142])
|
| 943 |
+
#define PyArray_Trace \
|
| 944 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, int, int, PyArrayObject *)) \
|
| 945 |
+
PyArray_API[143])
|
| 946 |
+
#define PyArray_Diagonal \
|
| 947 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, int)) \
|
| 948 |
+
PyArray_API[144])
|
| 949 |
+
#define PyArray_Clip \
|
| 950 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, PyObject *, PyArrayObject *)) \
|
| 951 |
+
PyArray_API[145])
|
| 952 |
+
#define PyArray_Conjugate \
|
| 953 |
+
(*(PyObject * (*)(PyArrayObject *, PyArrayObject *)) \
|
| 954 |
+
PyArray_API[146])
|
| 955 |
+
#define PyArray_Nonzero \
|
| 956 |
+
(*(PyObject * (*)(PyArrayObject *)) \
|
| 957 |
+
PyArray_API[147])
|
| 958 |
+
#define PyArray_Std \
|
| 959 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *, int)) \
|
| 960 |
+
PyArray_API[148])
|
| 961 |
+
#define PyArray_Sum \
|
| 962 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
|
| 963 |
+
PyArray_API[149])
|
| 964 |
+
#define PyArray_CumSum \
|
| 965 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
|
| 966 |
+
PyArray_API[150])
|
| 967 |
+
#define PyArray_Prod \
|
| 968 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
|
| 969 |
+
PyArray_API[151])
|
| 970 |
+
#define PyArray_CumProd \
|
| 971 |
+
(*(PyObject * (*)(PyArrayObject *, int, int, PyArrayObject *)) \
|
| 972 |
+
PyArray_API[152])
|
| 973 |
+
#define PyArray_All \
|
| 974 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 975 |
+
PyArray_API[153])
|
| 976 |
+
#define PyArray_Any \
|
| 977 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 978 |
+
PyArray_API[154])
|
| 979 |
+
#define PyArray_Compress \
|
| 980 |
+
(*(PyObject * (*)(PyArrayObject *, PyObject *, int, PyArrayObject *)) \
|
| 981 |
+
PyArray_API[155])
|
| 982 |
+
#define PyArray_Flatten \
|
| 983 |
+
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
|
| 984 |
+
PyArray_API[156])
|
| 985 |
+
#define PyArray_Ravel \
|
| 986 |
+
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER)) \
|
| 987 |
+
PyArray_API[157])
|
| 988 |
+
#define PyArray_MultiplyList \
|
| 989 |
+
(*(npy_intp (*)(npy_intp const *, int)) \
|
| 990 |
+
PyArray_API[158])
|
| 991 |
+
#define PyArray_MultiplyIntList \
|
| 992 |
+
(*(int (*)(int const *, int)) \
|
| 993 |
+
PyArray_API[159])
|
| 994 |
+
#define PyArray_GetPtr \
|
| 995 |
+
(*(void * (*)(PyArrayObject *, npy_intp const*)) \
|
| 996 |
+
PyArray_API[160])
|
| 997 |
+
#define PyArray_CompareLists \
|
| 998 |
+
(*(int (*)(npy_intp const *, npy_intp const *, int)) \
|
| 999 |
+
PyArray_API[161])
|
| 1000 |
+
#define PyArray_AsCArray \
|
| 1001 |
+
(*(int (*)(PyObject **, void *, npy_intp *, int, PyArray_Descr*)) \
|
| 1002 |
+
PyArray_API[162])
|
| 1003 |
+
#define PyArray_Free \
|
| 1004 |
+
(*(int (*)(PyObject *, void *)) \
|
| 1005 |
+
PyArray_API[165])
|
| 1006 |
+
#define PyArray_Converter \
|
| 1007 |
+
(*(int (*)(PyObject *, PyObject **)) \
|
| 1008 |
+
PyArray_API[166])
|
| 1009 |
+
#define PyArray_IntpFromSequence \
|
| 1010 |
+
(*(int (*)(PyObject *, npy_intp *, int)) \
|
| 1011 |
+
PyArray_API[167])
|
| 1012 |
+
#define PyArray_Concatenate \
|
| 1013 |
+
(*(PyObject * (*)(PyObject *, int)) \
|
| 1014 |
+
PyArray_API[168])
|
| 1015 |
+
#define PyArray_InnerProduct \
|
| 1016 |
+
(*(PyObject * (*)(PyObject *, PyObject *)) \
|
| 1017 |
+
PyArray_API[169])
|
| 1018 |
+
#define PyArray_MatrixProduct \
|
| 1019 |
+
(*(PyObject * (*)(PyObject *, PyObject *)) \
|
| 1020 |
+
PyArray_API[170])
|
| 1021 |
+
#define PyArray_Correlate \
|
| 1022 |
+
(*(PyObject * (*)(PyObject *, PyObject *, int)) \
|
| 1023 |
+
PyArray_API[172])
|
| 1024 |
+
#define PyArray_DescrConverter \
|
| 1025 |
+
(*(int (*)(PyObject *, PyArray_Descr **)) \
|
| 1026 |
+
PyArray_API[174])
|
| 1027 |
+
#define PyArray_DescrConverter2 \
|
| 1028 |
+
(*(int (*)(PyObject *, PyArray_Descr **)) \
|
| 1029 |
+
PyArray_API[175])
|
| 1030 |
+
#define PyArray_IntpConverter \
|
| 1031 |
+
(*(int (*)(PyObject *, PyArray_Dims *)) \
|
| 1032 |
+
PyArray_API[176])
|
| 1033 |
+
#define PyArray_BufferConverter \
|
| 1034 |
+
(*(int (*)(PyObject *, PyArray_Chunk *)) \
|
| 1035 |
+
PyArray_API[177])
|
| 1036 |
+
#define PyArray_AxisConverter \
|
| 1037 |
+
(*(int (*)(PyObject *, int *)) \
|
| 1038 |
+
PyArray_API[178])
|
| 1039 |
+
#define PyArray_BoolConverter \
|
| 1040 |
+
(*(int (*)(PyObject *, npy_bool *)) \
|
| 1041 |
+
PyArray_API[179])
|
| 1042 |
+
#define PyArray_ByteorderConverter \
|
| 1043 |
+
(*(int (*)(PyObject *, char *)) \
|
| 1044 |
+
PyArray_API[180])
|
| 1045 |
+
#define PyArray_OrderConverter \
|
| 1046 |
+
(*(int (*)(PyObject *, NPY_ORDER *)) \
|
| 1047 |
+
PyArray_API[181])
|
| 1048 |
+
#define PyArray_EquivTypes \
|
| 1049 |
+
(*(unsigned char (*)(PyArray_Descr *, PyArray_Descr *)) \
|
| 1050 |
+
PyArray_API[182])
|
| 1051 |
+
#define PyArray_Zeros \
|
| 1052 |
+
(*(PyObject * (*)(int, npy_intp const *, PyArray_Descr *, int)) \
|
| 1053 |
+
PyArray_API[183])
|
| 1054 |
+
#define PyArray_Empty \
|
| 1055 |
+
(*(PyObject * (*)(int, npy_intp const *, PyArray_Descr *, int)) \
|
| 1056 |
+
PyArray_API[184])
|
| 1057 |
+
#define PyArray_Where \
|
| 1058 |
+
(*(PyObject * (*)(PyObject *, PyObject *, PyObject *)) \
|
| 1059 |
+
PyArray_API[185])
|
| 1060 |
+
#define PyArray_Arange \
|
| 1061 |
+
(*(PyObject * (*)(double, double, double, int)) \
|
| 1062 |
+
PyArray_API[186])
|
| 1063 |
+
#define PyArray_ArangeObj \
|
| 1064 |
+
(*(PyObject * (*)(PyObject *, PyObject *, PyObject *, PyArray_Descr *)) \
|
| 1065 |
+
PyArray_API[187])
|
| 1066 |
+
#define PyArray_SortkindConverter \
|
| 1067 |
+
(*(int (*)(PyObject *, NPY_SORTKIND *)) \
|
| 1068 |
+
PyArray_API[188])
|
| 1069 |
+
#define PyArray_LexSort \
|
| 1070 |
+
(*(PyObject * (*)(PyObject *, int)) \
|
| 1071 |
+
PyArray_API[189])
|
| 1072 |
+
#define PyArray_Round \
|
| 1073 |
+
(*(PyObject * (*)(PyArrayObject *, int, PyArrayObject *)) \
|
| 1074 |
+
PyArray_API[190])
|
| 1075 |
+
#define PyArray_EquivTypenums \
|
| 1076 |
+
(*(unsigned char (*)(int, int)) \
|
| 1077 |
+
PyArray_API[191])
|
| 1078 |
+
#define PyArray_RegisterDataType \
|
| 1079 |
+
(*(int (*)(PyArray_DescrProto *)) \
|
| 1080 |
+
PyArray_API[192])
|
| 1081 |
+
#define PyArray_RegisterCastFunc \
|
| 1082 |
+
(*(int (*)(PyArray_Descr *, int, PyArray_VectorUnaryFunc *)) \
|
| 1083 |
+
PyArray_API[193])
|
| 1084 |
+
#define PyArray_RegisterCanCast \
|
| 1085 |
+
(*(int (*)(PyArray_Descr *, int, NPY_SCALARKIND)) \
|
| 1086 |
+
PyArray_API[194])
|
| 1087 |
+
#define PyArray_InitArrFuncs \
|
| 1088 |
+
(*(void (*)(PyArray_ArrFuncs *)) \
|
| 1089 |
+
PyArray_API[195])
|
| 1090 |
+
#define PyArray_IntTupleFromIntp \
|
| 1091 |
+
(*(PyObject * (*)(int, npy_intp const *)) \
|
| 1092 |
+
PyArray_API[196])
|
| 1093 |
+
#define PyArray_ClipmodeConverter \
|
| 1094 |
+
(*(int (*)(PyObject *, NPY_CLIPMODE *)) \
|
| 1095 |
+
PyArray_API[198])
|
| 1096 |
+
#define PyArray_OutputConverter \
|
| 1097 |
+
(*(int (*)(PyObject *, PyArrayObject **)) \
|
| 1098 |
+
PyArray_API[199])
|
| 1099 |
+
#define PyArray_BroadcastToShape \
|
| 1100 |
+
(*(PyObject * (*)(PyObject *, npy_intp *, int)) \
|
| 1101 |
+
PyArray_API[200])
|
| 1102 |
+
#define PyArray_DescrAlignConverter \
|
| 1103 |
+
(*(int (*)(PyObject *, PyArray_Descr **)) \
|
| 1104 |
+
PyArray_API[203])
|
| 1105 |
+
#define PyArray_DescrAlignConverter2 \
|
| 1106 |
+
(*(int (*)(PyObject *, PyArray_Descr **)) \
|
| 1107 |
+
PyArray_API[204])
|
| 1108 |
+
#define PyArray_SearchsideConverter \
|
| 1109 |
+
(*(int (*)(PyObject *, void *)) \
|
| 1110 |
+
PyArray_API[205])
|
| 1111 |
+
#define PyArray_CheckAxis \
|
| 1112 |
+
(*(PyObject * (*)(PyArrayObject *, int *, int)) \
|
| 1113 |
+
PyArray_API[206])
|
| 1114 |
+
#define PyArray_OverflowMultiplyList \
|
| 1115 |
+
(*(npy_intp (*)(npy_intp const *, int)) \
|
| 1116 |
+
PyArray_API[207])
|
| 1117 |
+
#define PyArray_MultiIterFromObjects \
|
| 1118 |
+
(*(PyObject* (*)(PyObject **, int, int, ...)) \
|
| 1119 |
+
PyArray_API[209])
|
| 1120 |
+
#define PyArray_GetEndianness \
|
| 1121 |
+
(*(int (*)(void)) \
|
| 1122 |
+
PyArray_API[210])
|
| 1123 |
+
#define PyArray_GetNDArrayCFeatureVersion \
|
| 1124 |
+
(*(unsigned int (*)(void)) \
|
| 1125 |
+
PyArray_API[211])
|
| 1126 |
+
#define PyArray_Correlate2 \
|
| 1127 |
+
(*(PyObject * (*)(PyObject *, PyObject *, int)) \
|
| 1128 |
+
PyArray_API[212])
|
| 1129 |
+
#define PyArray_NeighborhoodIterNew \
|
| 1130 |
+
(*(PyObject* (*)(PyArrayIterObject *, const npy_intp *, int, PyArrayObject*)) \
|
| 1131 |
+
PyArray_API[213])
|
| 1132 |
+
#define PyTimeIntegerArrType_Type (*(PyTypeObject *)PyArray_API[214])
|
| 1133 |
+
#define PyDatetimeArrType_Type (*(PyTypeObject *)PyArray_API[215])
|
| 1134 |
+
#define PyTimedeltaArrType_Type (*(PyTypeObject *)PyArray_API[216])
|
| 1135 |
+
#define PyHalfArrType_Type (*(PyTypeObject *)PyArray_API[217])
|
| 1136 |
+
#define NpyIter_Type (*(PyTypeObject *)PyArray_API[218])
|
| 1137 |
+
#define NpyIter_New \
|
| 1138 |
+
(*(NpyIter * (*)(PyArrayObject *, npy_uint32, NPY_ORDER, NPY_CASTING, PyArray_Descr*)) \
|
| 1139 |
+
PyArray_API[224])
|
| 1140 |
+
#define NpyIter_MultiNew \
|
| 1141 |
+
(*(NpyIter * (*)(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **)) \
|
| 1142 |
+
PyArray_API[225])
|
| 1143 |
+
#define NpyIter_AdvancedNew \
|
| 1144 |
+
(*(NpyIter * (*)(int, PyArrayObject **, npy_uint32, NPY_ORDER, NPY_CASTING, npy_uint32 *, PyArray_Descr **, int, int **, npy_intp *, npy_intp)) \
|
| 1145 |
+
PyArray_API[226])
|
| 1146 |
+
#define NpyIter_Copy \
|
| 1147 |
+
(*(NpyIter * (*)(NpyIter *)) \
|
| 1148 |
+
PyArray_API[227])
|
| 1149 |
+
#define NpyIter_Deallocate \
|
| 1150 |
+
(*(int (*)(NpyIter *)) \
|
| 1151 |
+
PyArray_API[228])
|
| 1152 |
+
#define NpyIter_HasDelayedBufAlloc \
|
| 1153 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1154 |
+
PyArray_API[229])
|
| 1155 |
+
#define NpyIter_HasExternalLoop \
|
| 1156 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1157 |
+
PyArray_API[230])
|
| 1158 |
+
#define NpyIter_EnableExternalLoop \
|
| 1159 |
+
(*(int (*)(NpyIter *)) \
|
| 1160 |
+
PyArray_API[231])
|
| 1161 |
+
#define NpyIter_GetInnerStrideArray \
|
| 1162 |
+
(*(npy_intp * (*)(NpyIter *)) \
|
| 1163 |
+
PyArray_API[232])
|
| 1164 |
+
#define NpyIter_GetInnerLoopSizePtr \
|
| 1165 |
+
(*(npy_intp * (*)(NpyIter *)) \
|
| 1166 |
+
PyArray_API[233])
|
| 1167 |
+
#define NpyIter_Reset \
|
| 1168 |
+
(*(int (*)(NpyIter *, char **)) \
|
| 1169 |
+
PyArray_API[234])
|
| 1170 |
+
#define NpyIter_ResetBasePointers \
|
| 1171 |
+
(*(int (*)(NpyIter *, char **, char **)) \
|
| 1172 |
+
PyArray_API[235])
|
| 1173 |
+
#define NpyIter_ResetToIterIndexRange \
|
| 1174 |
+
(*(int (*)(NpyIter *, npy_intp, npy_intp, char **)) \
|
| 1175 |
+
PyArray_API[236])
|
| 1176 |
+
#define NpyIter_GetNDim \
|
| 1177 |
+
(*(int (*)(NpyIter *)) \
|
| 1178 |
+
PyArray_API[237])
|
| 1179 |
+
#define NpyIter_GetNOp \
|
| 1180 |
+
(*(int (*)(NpyIter *)) \
|
| 1181 |
+
PyArray_API[238])
|
| 1182 |
+
#define NpyIter_GetIterNext \
|
| 1183 |
+
(*(NpyIter_IterNextFunc * (*)(NpyIter *, char **)) \
|
| 1184 |
+
PyArray_API[239])
|
| 1185 |
+
#define NpyIter_GetIterSize \
|
| 1186 |
+
(*(npy_intp (*)(NpyIter *)) \
|
| 1187 |
+
PyArray_API[240])
|
| 1188 |
+
#define NpyIter_GetIterIndexRange \
|
| 1189 |
+
(*(void (*)(NpyIter *, npy_intp *, npy_intp *)) \
|
| 1190 |
+
PyArray_API[241])
|
| 1191 |
+
#define NpyIter_GetIterIndex \
|
| 1192 |
+
(*(npy_intp (*)(NpyIter *)) \
|
| 1193 |
+
PyArray_API[242])
|
| 1194 |
+
#define NpyIter_GotoIterIndex \
|
| 1195 |
+
(*(int (*)(NpyIter *, npy_intp)) \
|
| 1196 |
+
PyArray_API[243])
|
| 1197 |
+
#define NpyIter_HasMultiIndex \
|
| 1198 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1199 |
+
PyArray_API[244])
|
| 1200 |
+
#define NpyIter_GetShape \
|
| 1201 |
+
(*(int (*)(NpyIter *, npy_intp *)) \
|
| 1202 |
+
PyArray_API[245])
|
| 1203 |
+
#define NpyIter_GetGetMultiIndex \
|
| 1204 |
+
(*(NpyIter_GetMultiIndexFunc * (*)(NpyIter *, char **)) \
|
| 1205 |
+
PyArray_API[246])
|
| 1206 |
+
#define NpyIter_GotoMultiIndex \
|
| 1207 |
+
(*(int (*)(NpyIter *, npy_intp const *)) \
|
| 1208 |
+
PyArray_API[247])
|
| 1209 |
+
#define NpyIter_RemoveMultiIndex \
|
| 1210 |
+
(*(int (*)(NpyIter *)) \
|
| 1211 |
+
PyArray_API[248])
|
| 1212 |
+
#define NpyIter_HasIndex \
|
| 1213 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1214 |
+
PyArray_API[249])
|
| 1215 |
+
#define NpyIter_IsBuffered \
|
| 1216 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1217 |
+
PyArray_API[250])
|
| 1218 |
+
#define NpyIter_IsGrowInner \
|
| 1219 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1220 |
+
PyArray_API[251])
|
| 1221 |
+
#define NpyIter_GetBufferSize \
|
| 1222 |
+
(*(npy_intp (*)(NpyIter *)) \
|
| 1223 |
+
PyArray_API[252])
|
| 1224 |
+
#define NpyIter_GetIndexPtr \
|
| 1225 |
+
(*(npy_intp * (*)(NpyIter *)) \
|
| 1226 |
+
PyArray_API[253])
|
| 1227 |
+
#define NpyIter_GotoIndex \
|
| 1228 |
+
(*(int (*)(NpyIter *, npy_intp)) \
|
| 1229 |
+
PyArray_API[254])
|
| 1230 |
+
#define NpyIter_GetDataPtrArray \
|
| 1231 |
+
(*(char ** (*)(NpyIter *)) \
|
| 1232 |
+
PyArray_API[255])
|
| 1233 |
+
#define NpyIter_GetDescrArray \
|
| 1234 |
+
(*(PyArray_Descr ** (*)(NpyIter *)) \
|
| 1235 |
+
PyArray_API[256])
|
| 1236 |
+
#define NpyIter_GetOperandArray \
|
| 1237 |
+
(*(PyArrayObject ** (*)(NpyIter *)) \
|
| 1238 |
+
PyArray_API[257])
|
| 1239 |
+
#define NpyIter_GetIterView \
|
| 1240 |
+
(*(PyArrayObject * (*)(NpyIter *, npy_intp)) \
|
| 1241 |
+
PyArray_API[258])
|
| 1242 |
+
#define NpyIter_GetReadFlags \
|
| 1243 |
+
(*(void (*)(NpyIter *, char *)) \
|
| 1244 |
+
PyArray_API[259])
|
| 1245 |
+
#define NpyIter_GetWriteFlags \
|
| 1246 |
+
(*(void (*)(NpyIter *, char *)) \
|
| 1247 |
+
PyArray_API[260])
|
| 1248 |
+
#define NpyIter_DebugPrint \
|
| 1249 |
+
(*(void (*)(NpyIter *)) \
|
| 1250 |
+
PyArray_API[261])
|
| 1251 |
+
#define NpyIter_IterationNeedsAPI \
|
| 1252 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1253 |
+
PyArray_API[262])
|
| 1254 |
+
#define NpyIter_GetInnerFixedStrideArray \
|
| 1255 |
+
(*(void (*)(NpyIter *, npy_intp *)) \
|
| 1256 |
+
PyArray_API[263])
|
| 1257 |
+
#define NpyIter_RemoveAxis \
|
| 1258 |
+
(*(int (*)(NpyIter *, int)) \
|
| 1259 |
+
PyArray_API[264])
|
| 1260 |
+
#define NpyIter_GetAxisStrideArray \
|
| 1261 |
+
(*(npy_intp * (*)(NpyIter *, int)) \
|
| 1262 |
+
PyArray_API[265])
|
| 1263 |
+
#define NpyIter_RequiresBuffering \
|
| 1264 |
+
(*(npy_bool (*)(NpyIter *)) \
|
| 1265 |
+
PyArray_API[266])
|
| 1266 |
+
#define NpyIter_GetInitialDataPtrArray \
|
| 1267 |
+
(*(char ** (*)(NpyIter *)) \
|
| 1268 |
+
PyArray_API[267])
|
| 1269 |
+
#define NpyIter_CreateCompatibleStrides \
|
| 1270 |
+
(*(int (*)(NpyIter *, npy_intp, npy_intp *)) \
|
| 1271 |
+
PyArray_API[268])
|
| 1272 |
+
#define PyArray_CastingConverter \
|
| 1273 |
+
(*(int (*)(PyObject *, NPY_CASTING *)) \
|
| 1274 |
+
PyArray_API[269])
|
| 1275 |
+
#define PyArray_CountNonzero \
|
| 1276 |
+
(*(npy_intp (*)(PyArrayObject *)) \
|
| 1277 |
+
PyArray_API[270])
|
| 1278 |
+
#define PyArray_PromoteTypes \
|
| 1279 |
+
(*(PyArray_Descr * (*)(PyArray_Descr *, PyArray_Descr *)) \
|
| 1280 |
+
PyArray_API[271])
|
| 1281 |
+
#define PyArray_MinScalarType \
|
| 1282 |
+
(*(PyArray_Descr * (*)(PyArrayObject *)) \
|
| 1283 |
+
PyArray_API[272])
|
| 1284 |
+
#define PyArray_ResultType \
|
| 1285 |
+
(*(PyArray_Descr * (*)(npy_intp, PyArrayObject *arrs[], npy_intp, PyArray_Descr *descrs[])) \
|
| 1286 |
+
PyArray_API[273])
|
| 1287 |
+
#define PyArray_CanCastArrayTo \
|
| 1288 |
+
(*(npy_bool (*)(PyArrayObject *, PyArray_Descr *, NPY_CASTING)) \
|
| 1289 |
+
PyArray_API[274])
|
| 1290 |
+
#define PyArray_CanCastTypeTo \
|
| 1291 |
+
(*(npy_bool (*)(PyArray_Descr *, PyArray_Descr *, NPY_CASTING)) \
|
| 1292 |
+
PyArray_API[275])
|
| 1293 |
+
#define PyArray_EinsteinSum \
|
| 1294 |
+
(*(PyArrayObject * (*)(char *, npy_intp, PyArrayObject **, PyArray_Descr *, NPY_ORDER, NPY_CASTING, PyArrayObject *)) \
|
| 1295 |
+
PyArray_API[276])
|
| 1296 |
+
#define PyArray_NewLikeArray \
|
| 1297 |
+
(*(PyObject * (*)(PyArrayObject *, NPY_ORDER, PyArray_Descr *, int)) \
|
| 1298 |
+
PyArray_API[277])
|
| 1299 |
+
#define PyArray_ConvertClipmodeSequence \
|
| 1300 |
+
(*(int (*)(PyObject *, NPY_CLIPMODE *, int)) \
|
| 1301 |
+
PyArray_API[279])
|
| 1302 |
+
#define PyArray_MatrixProduct2 \
|
| 1303 |
+
(*(PyObject * (*)(PyObject *, PyObject *, PyArrayObject*)) \
|
| 1304 |
+
PyArray_API[280])
|
| 1305 |
+
#define NpyIter_IsFirstVisit \
|
| 1306 |
+
(*(npy_bool (*)(NpyIter *, int)) \
|
| 1307 |
+
PyArray_API[281])
|
| 1308 |
+
#define PyArray_SetBaseObject \
|
| 1309 |
+
(*(int (*)(PyArrayObject *, PyObject *)) \
|
| 1310 |
+
PyArray_API[282])
|
| 1311 |
+
#define PyArray_CreateSortedStridePerm \
|
| 1312 |
+
(*(void (*)(int, npy_intp const *, npy_stride_sort_item *)) \
|
| 1313 |
+
PyArray_API[283])
|
| 1314 |
+
#define PyArray_RemoveAxesInPlace \
|
| 1315 |
+
(*(void (*)(PyArrayObject *, const npy_bool *)) \
|
| 1316 |
+
PyArray_API[284])
|
| 1317 |
+
#define PyArray_DebugPrint \
|
| 1318 |
+
(*(void (*)(PyArrayObject *)) \
|
| 1319 |
+
PyArray_API[285])
|
| 1320 |
+
#define PyArray_FailUnlessWriteable \
|
| 1321 |
+
(*(int (*)(PyArrayObject *, const char *)) \
|
| 1322 |
+
PyArray_API[286])
|
| 1323 |
+
#define PyArray_SetUpdateIfCopyBase \
|
| 1324 |
+
(*(int (*)(PyArrayObject *, PyArrayObject *)) \
|
| 1325 |
+
PyArray_API[287])
|
| 1326 |
+
#define PyDataMem_NEW \
|
| 1327 |
+
(*(void * (*)(size_t)) \
|
| 1328 |
+
PyArray_API[288])
|
| 1329 |
+
#define PyDataMem_FREE \
|
| 1330 |
+
(*(void (*)(void *)) \
|
| 1331 |
+
PyArray_API[289])
|
| 1332 |
+
#define PyDataMem_RENEW \
|
| 1333 |
+
(*(void * (*)(void *, size_t)) \
|
| 1334 |
+
PyArray_API[290])
|
| 1335 |
+
#define NPY_DEFAULT_ASSIGN_CASTING (*(NPY_CASTING *)PyArray_API[292])
|
| 1336 |
+
#define PyArray_Partition \
|
| 1337 |
+
(*(int (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \
|
| 1338 |
+
PyArray_API[296])
|
| 1339 |
+
#define PyArray_ArgPartition \
|
| 1340 |
+
(*(PyObject * (*)(PyArrayObject *, PyArrayObject *, int, NPY_SELECTKIND)) \
|
| 1341 |
+
PyArray_API[297])
|
| 1342 |
+
#define PyArray_SelectkindConverter \
|
| 1343 |
+
(*(int (*)(PyObject *, NPY_SELECTKIND *)) \
|
| 1344 |
+
PyArray_API[298])
|
| 1345 |
+
#define PyDataMem_NEW_ZEROED \
|
| 1346 |
+
(*(void * (*)(size_t, size_t)) \
|
| 1347 |
+
PyArray_API[299])
|
| 1348 |
+
#define PyArray_CheckAnyScalarExact \
|
| 1349 |
+
(*(int (*)(PyObject *)) \
|
| 1350 |
+
PyArray_API[300])
|
| 1351 |
+
#define PyArray_ResolveWritebackIfCopy \
|
| 1352 |
+
(*(int (*)(PyArrayObject *)) \
|
| 1353 |
+
PyArray_API[302])
|
| 1354 |
+
#define PyArray_SetWritebackIfCopyBase \
|
| 1355 |
+
(*(int (*)(PyArrayObject *, PyArrayObject *)) \
|
| 1356 |
+
PyArray_API[303])
|
| 1357 |
+
|
| 1358 |
+
#if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
|
| 1359 |
+
#define PyDataMem_SetHandler \
|
| 1360 |
+
(*(PyObject * (*)(PyObject *)) \
|
| 1361 |
+
PyArray_API[304])
|
| 1362 |
+
#endif
|
| 1363 |
+
|
| 1364 |
+
#if NPY_FEATURE_VERSION >= NPY_1_22_API_VERSION
|
| 1365 |
+
#define PyDataMem_GetHandler \
|
| 1366 |
+
(*(PyObject * (*)(void)) \
|
| 1367 |
+
PyArray_API[305])
|
| 1368 |
+
#endif
|
| 1369 |
+
#define PyDataMem_DefaultHandler (*(PyObject* *)PyArray_API[306])
|
| 1370 |
+
|
| 1371 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1372 |
+
#define NpyDatetime_ConvertDatetime64ToDatetimeStruct \
|
| 1373 |
+
(*(int (*)(PyArray_DatetimeMetaData *, npy_datetime, npy_datetimestruct *)) \
|
| 1374 |
+
PyArray_API[307])
|
| 1375 |
+
#endif
|
| 1376 |
+
|
| 1377 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1378 |
+
#define NpyDatetime_ConvertDatetimeStructToDatetime64 \
|
| 1379 |
+
(*(int (*)(PyArray_DatetimeMetaData *, const npy_datetimestruct *, npy_datetime *)) \
|
| 1380 |
+
PyArray_API[308])
|
| 1381 |
+
#endif
|
| 1382 |
+
|
| 1383 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1384 |
+
#define NpyDatetime_ConvertPyDateTimeToDatetimeStruct \
|
| 1385 |
+
(*(int (*)(PyObject *, npy_datetimestruct *, NPY_DATETIMEUNIT *, int)) \
|
| 1386 |
+
PyArray_API[309])
|
| 1387 |
+
#endif
|
| 1388 |
+
|
| 1389 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1390 |
+
#define NpyDatetime_GetDatetimeISO8601StrLen \
|
| 1391 |
+
(*(int (*)(int, NPY_DATETIMEUNIT)) \
|
| 1392 |
+
PyArray_API[310])
|
| 1393 |
+
#endif
|
| 1394 |
+
|
| 1395 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1396 |
+
#define NpyDatetime_MakeISO8601Datetime \
|
| 1397 |
+
(*(int (*)(npy_datetimestruct *, char *, npy_intp, int, int, NPY_DATETIMEUNIT, int, NPY_CASTING)) \
|
| 1398 |
+
PyArray_API[311])
|
| 1399 |
+
#endif
|
| 1400 |
+
|
| 1401 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1402 |
+
#define NpyDatetime_ParseISO8601Datetime \
|
| 1403 |
+
(*(int (*)(char const *, Py_ssize_t, NPY_DATETIMEUNIT, NPY_CASTING, npy_datetimestruct *, NPY_DATETIMEUNIT *, npy_bool *)) \
|
| 1404 |
+
PyArray_API[312])
|
| 1405 |
+
#endif
|
| 1406 |
+
|
| 1407 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1408 |
+
#define NpyString_load \
|
| 1409 |
+
(*(int (*)(npy_string_allocator *, const npy_packed_static_string *, npy_static_string *)) \
|
| 1410 |
+
PyArray_API[313])
|
| 1411 |
+
#endif
|
| 1412 |
+
|
| 1413 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1414 |
+
#define NpyString_pack \
|
| 1415 |
+
(*(int (*)(npy_string_allocator *, npy_packed_static_string *, const char *, size_t)) \
|
| 1416 |
+
PyArray_API[314])
|
| 1417 |
+
#endif
|
| 1418 |
+
|
| 1419 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1420 |
+
#define NpyString_pack_null \
|
| 1421 |
+
(*(int (*)(npy_string_allocator *, npy_packed_static_string *)) \
|
| 1422 |
+
PyArray_API[315])
|
| 1423 |
+
#endif
|
| 1424 |
+
|
| 1425 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1426 |
+
#define NpyString_acquire_allocator \
|
| 1427 |
+
(*(npy_string_allocator * (*)(const PyArray_StringDTypeObject *)) \
|
| 1428 |
+
PyArray_API[316])
|
| 1429 |
+
#endif
|
| 1430 |
+
|
| 1431 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1432 |
+
#define NpyString_acquire_allocators \
|
| 1433 |
+
(*(void (*)(size_t, PyArray_Descr *const descrs[], npy_string_allocator *allocators[])) \
|
| 1434 |
+
PyArray_API[317])
|
| 1435 |
+
#endif
|
| 1436 |
+
|
| 1437 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1438 |
+
#define NpyString_release_allocator \
|
| 1439 |
+
(*(void (*)(npy_string_allocator *)) \
|
| 1440 |
+
PyArray_API[318])
|
| 1441 |
+
#endif
|
| 1442 |
+
|
| 1443 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1444 |
+
#define NpyString_release_allocators \
|
| 1445 |
+
(*(void (*)(size_t, npy_string_allocator *allocators[])) \
|
| 1446 |
+
PyArray_API[319])
|
| 1447 |
+
#endif
|
| 1448 |
+
|
| 1449 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1450 |
+
#define PyArray_GetDefaultDescr \
|
| 1451 |
+
(*(PyArray_Descr * (*)(PyArray_DTypeMeta *)) \
|
| 1452 |
+
PyArray_API[361])
|
| 1453 |
+
#endif
|
| 1454 |
+
|
| 1455 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1456 |
+
#define PyArrayInitDTypeMeta_FromSpec \
|
| 1457 |
+
(*(int (*)(PyArray_DTypeMeta *, PyArrayDTypeMeta_Spec *)) \
|
| 1458 |
+
PyArray_API[362])
|
| 1459 |
+
#endif
|
| 1460 |
+
|
| 1461 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1462 |
+
#define PyArray_CommonDType \
|
| 1463 |
+
(*(PyArray_DTypeMeta * (*)(PyArray_DTypeMeta *, PyArray_DTypeMeta *)) \
|
| 1464 |
+
PyArray_API[363])
|
| 1465 |
+
#endif
|
| 1466 |
+
|
| 1467 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 1468 |
+
#define PyArray_PromoteDTypeSequence \
|
| 1469 |
+
(*(PyArray_DTypeMeta * (*)(npy_intp, PyArray_DTypeMeta **)) \
|
| 1470 |
+
PyArray_API[364])
|
| 1471 |
+
#endif
|
| 1472 |
+
#define _PyDataType_GetArrFuncs \
|
| 1473 |
+
(*(PyArray_ArrFuncs * (*)(const PyArray_Descr *)) \
|
| 1474 |
+
PyArray_API[365])
|
| 1475 |
+
|
| 1476 |
+
/*
|
| 1477 |
+
* The DType classes are inconvenient for the Python generation so exposed
|
| 1478 |
+
* manually in the header below (may be moved).
|
| 1479 |
+
*/
|
| 1480 |
+
#include "numpy/_public_dtype_api_table.h"
|
| 1481 |
+
|
| 1482 |
+
#if !defined(NO_IMPORT_ARRAY) && !defined(NO_IMPORT)
|
| 1483 |
+
static int
|
| 1484 |
+
_import_array(void)
|
| 1485 |
+
{
|
| 1486 |
+
int st;
|
| 1487 |
+
PyObject *numpy = PyImport_ImportModule("numpy._core._multiarray_umath");
|
| 1488 |
+
if (numpy == NULL && PyErr_ExceptionMatches(PyExc_ModuleNotFoundError)) {
|
| 1489 |
+
PyErr_Clear();
|
| 1490 |
+
numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
|
| 1491 |
+
}
|
| 1492 |
+
|
| 1493 |
+
if (numpy == NULL) {
|
| 1494 |
+
return -1;
|
| 1495 |
+
}
|
| 1496 |
+
|
| 1497 |
+
PyObject *c_api = PyObject_GetAttrString(numpy, "_ARRAY_API");
|
| 1498 |
+
Py_DECREF(numpy);
|
| 1499 |
+
if (c_api == NULL) {
|
| 1500 |
+
return -1;
|
| 1501 |
+
}
|
| 1502 |
+
|
| 1503 |
+
if (!PyCapsule_CheckExact(c_api)) {
|
| 1504 |
+
PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is not PyCapsule object");
|
| 1505 |
+
Py_DECREF(c_api);
|
| 1506 |
+
return -1;
|
| 1507 |
+
}
|
| 1508 |
+
PyArray_API = (void **)PyCapsule_GetPointer(c_api, NULL);
|
| 1509 |
+
Py_DECREF(c_api);
|
| 1510 |
+
if (PyArray_API == NULL) {
|
| 1511 |
+
PyErr_SetString(PyExc_RuntimeError, "_ARRAY_API is NULL pointer");
|
| 1512 |
+
return -1;
|
| 1513 |
+
}
|
| 1514 |
+
|
| 1515 |
+
/*
|
| 1516 |
+
* On exceedingly few platforms these sizes may not match, in which case
|
| 1517 |
+
* We do not support older NumPy versions at all.
|
| 1518 |
+
*/
|
| 1519 |
+
if (sizeof(Py_ssize_t) != sizeof(Py_intptr_t) &&
|
| 1520 |
+
PyArray_RUNTIME_VERSION < NPY_2_0_API_VERSION) {
|
| 1521 |
+
PyErr_Format(PyExc_RuntimeError,
|
| 1522 |
+
"module compiled against NumPy 2.0 but running on NumPy 1.x. "
|
| 1523 |
+
"Unfortunately, this is not supported on niche platforms where "
|
| 1524 |
+
"`sizeof(size_t) != sizeof(inptr_t)`.");
|
| 1525 |
+
}
|
| 1526 |
+
/*
|
| 1527 |
+
* Perform runtime check of C API version. As of now NumPy 2.0 is ABI
|
| 1528 |
+
* backwards compatible (in the exposed feature subset!) for all practical
|
| 1529 |
+
* purposes.
|
| 1530 |
+
*/
|
| 1531 |
+
if (NPY_VERSION < PyArray_GetNDArrayCVersion()) {
|
| 1532 |
+
PyErr_Format(PyExc_RuntimeError, "module compiled against "\
|
| 1533 |
+
"ABI version 0x%x but this version of numpy is 0x%x", \
|
| 1534 |
+
(int) NPY_VERSION, (int) PyArray_GetNDArrayCVersion());
|
| 1535 |
+
return -1;
|
| 1536 |
+
}
|
| 1537 |
+
PyArray_RUNTIME_VERSION = (int)PyArray_GetNDArrayCFeatureVersion();
|
| 1538 |
+
if (NPY_FEATURE_VERSION > PyArray_RUNTIME_VERSION) {
|
| 1539 |
+
PyErr_Format(PyExc_RuntimeError,
|
| 1540 |
+
"module was compiled against NumPy C-API version 0x%x "
|
| 1541 |
+
"(NumPy " NPY_FEATURE_VERSION_STRING ") "
|
| 1542 |
+
"but the running NumPy has C-API version 0x%x. "
|
| 1543 |
+
"Check the section C-API incompatibility at the "
|
| 1544 |
+
"Troubleshooting ImportError section at "
|
| 1545 |
+
"https://numpy.org/devdocs/user/troubleshooting-importerror.html"
|
| 1546 |
+
"#c-api-incompatibility "
|
| 1547 |
+
"for indications on how to solve this problem.",
|
| 1548 |
+
(int)NPY_FEATURE_VERSION, PyArray_RUNTIME_VERSION);
|
| 1549 |
+
return -1;
|
| 1550 |
+
}
|
| 1551 |
+
|
| 1552 |
+
/*
|
| 1553 |
+
* Perform runtime check of endianness and check it matches the one set by
|
| 1554 |
+
* the headers (npy_endian.h) as a safeguard
|
| 1555 |
+
*/
|
| 1556 |
+
st = PyArray_GetEndianness();
|
| 1557 |
+
if (st == NPY_CPU_UNKNOWN_ENDIAN) {
|
| 1558 |
+
PyErr_SetString(PyExc_RuntimeError,
|
| 1559 |
+
"FATAL: module compiled as unknown endian");
|
| 1560 |
+
return -1;
|
| 1561 |
+
}
|
| 1562 |
+
#if NPY_BYTE_ORDER == NPY_BIG_ENDIAN
|
| 1563 |
+
if (st != NPY_CPU_BIG) {
|
| 1564 |
+
PyErr_SetString(PyExc_RuntimeError,
|
| 1565 |
+
"FATAL: module compiled as big endian, but "
|
| 1566 |
+
"detected different endianness at runtime");
|
| 1567 |
+
return -1;
|
| 1568 |
+
}
|
| 1569 |
+
#elif NPY_BYTE_ORDER == NPY_LITTLE_ENDIAN
|
| 1570 |
+
if (st != NPY_CPU_LITTLE) {
|
| 1571 |
+
PyErr_SetString(PyExc_RuntimeError,
|
| 1572 |
+
"FATAL: module compiled as little endian, but "
|
| 1573 |
+
"detected different endianness at runtime");
|
| 1574 |
+
return -1;
|
| 1575 |
+
}
|
| 1576 |
+
#endif
|
| 1577 |
+
|
| 1578 |
+
return 0;
|
| 1579 |
+
}
|
| 1580 |
+
|
| 1581 |
+
#define import_array() { \
|
| 1582 |
+
if (_import_array() < 0) { \
|
| 1583 |
+
PyErr_Print(); \
|
| 1584 |
+
PyErr_SetString( \
|
| 1585 |
+
PyExc_ImportError, \
|
| 1586 |
+
"numpy._core.multiarray failed to import" \
|
| 1587 |
+
); \
|
| 1588 |
+
return NULL; \
|
| 1589 |
+
} \
|
| 1590 |
+
}
|
| 1591 |
+
|
| 1592 |
+
#define import_array1(ret) { \
|
| 1593 |
+
if (_import_array() < 0) { \
|
| 1594 |
+
PyErr_Print(); \
|
| 1595 |
+
PyErr_SetString( \
|
| 1596 |
+
PyExc_ImportError, \
|
| 1597 |
+
"numpy._core.multiarray failed to import" \
|
| 1598 |
+
); \
|
| 1599 |
+
return ret; \
|
| 1600 |
+
} \
|
| 1601 |
+
}
|
| 1602 |
+
|
| 1603 |
+
#define import_array2(msg, ret) { \
|
| 1604 |
+
if (_import_array() < 0) { \
|
| 1605 |
+
PyErr_Print(); \
|
| 1606 |
+
PyErr_SetString(PyExc_ImportError, msg); \
|
| 1607 |
+
return ret; \
|
| 1608 |
+
} \
|
| 1609 |
+
}
|
| 1610 |
+
|
| 1611 |
+
#endif
|
| 1612 |
+
|
| 1613 |
+
#endif
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__ufunc_api.c
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
/* These pointers will be stored in the C-object for use in other
|
| 3 |
+
extension modules
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
void *PyUFunc_API[] = {
|
| 7 |
+
(void *) &PyUFunc_Type,
|
| 8 |
+
(void *) PyUFunc_FromFuncAndData,
|
| 9 |
+
(void *) PyUFunc_RegisterLoopForType,
|
| 10 |
+
NULL,
|
| 11 |
+
(void *) PyUFunc_f_f_As_d_d,
|
| 12 |
+
(void *) PyUFunc_d_d,
|
| 13 |
+
(void *) PyUFunc_f_f,
|
| 14 |
+
(void *) PyUFunc_g_g,
|
| 15 |
+
(void *) PyUFunc_F_F_As_D_D,
|
| 16 |
+
(void *) PyUFunc_F_F,
|
| 17 |
+
(void *) PyUFunc_D_D,
|
| 18 |
+
(void *) PyUFunc_G_G,
|
| 19 |
+
(void *) PyUFunc_O_O,
|
| 20 |
+
(void *) PyUFunc_ff_f_As_dd_d,
|
| 21 |
+
(void *) PyUFunc_ff_f,
|
| 22 |
+
(void *) PyUFunc_dd_d,
|
| 23 |
+
(void *) PyUFunc_gg_g,
|
| 24 |
+
(void *) PyUFunc_FF_F_As_DD_D,
|
| 25 |
+
(void *) PyUFunc_DD_D,
|
| 26 |
+
(void *) PyUFunc_FF_F,
|
| 27 |
+
(void *) PyUFunc_GG_G,
|
| 28 |
+
(void *) PyUFunc_OO_O,
|
| 29 |
+
(void *) PyUFunc_O_O_method,
|
| 30 |
+
(void *) PyUFunc_OO_O_method,
|
| 31 |
+
(void *) PyUFunc_On_Om,
|
| 32 |
+
NULL,
|
| 33 |
+
NULL,
|
| 34 |
+
(void *) PyUFunc_clearfperr,
|
| 35 |
+
(void *) PyUFunc_getfperr,
|
| 36 |
+
NULL,
|
| 37 |
+
(void *) PyUFunc_ReplaceLoopBySignature,
|
| 38 |
+
(void *) PyUFunc_FromFuncAndDataAndSignature,
|
| 39 |
+
NULL,
|
| 40 |
+
(void *) PyUFunc_e_e,
|
| 41 |
+
(void *) PyUFunc_e_e_As_f_f,
|
| 42 |
+
(void *) PyUFunc_e_e_As_d_d,
|
| 43 |
+
(void *) PyUFunc_ee_e,
|
| 44 |
+
(void *) PyUFunc_ee_e_As_ff_f,
|
| 45 |
+
(void *) PyUFunc_ee_e_As_dd_d,
|
| 46 |
+
(void *) PyUFunc_DefaultTypeResolver,
|
| 47 |
+
(void *) PyUFunc_ValidateCasting,
|
| 48 |
+
(void *) PyUFunc_RegisterLoopForDescr,
|
| 49 |
+
(void *) PyUFunc_FromFuncAndDataAndSignatureAndIdentity,
|
| 50 |
+
(void *) PyUFunc_AddLoopFromSpec,
|
| 51 |
+
(void *) PyUFunc_AddPromoter,
|
| 52 |
+
(void *) PyUFunc_AddWrappingLoop,
|
| 53 |
+
(void *) PyUFunc_GiveFloatingpointErrors
|
| 54 |
+
};
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/__ufunc_api.h
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
#ifdef _UMATHMODULE
|
| 3 |
+
|
| 4 |
+
extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
|
| 5 |
+
|
| 6 |
+
extern NPY_NO_EXPORT PyTypeObject PyUFunc_Type;
|
| 7 |
+
|
| 8 |
+
NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndData \
|
| 9 |
+
(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int);
|
| 10 |
+
NPY_NO_EXPORT int PyUFunc_RegisterLoopForType \
|
| 11 |
+
(PyUFuncObject *, int, PyUFuncGenericFunction, const int *, void *);
|
| 12 |
+
NPY_NO_EXPORT void PyUFunc_f_f_As_d_d \
|
| 13 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 14 |
+
NPY_NO_EXPORT void PyUFunc_d_d \
|
| 15 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 16 |
+
NPY_NO_EXPORT void PyUFunc_f_f \
|
| 17 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 18 |
+
NPY_NO_EXPORT void PyUFunc_g_g \
|
| 19 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 20 |
+
NPY_NO_EXPORT void PyUFunc_F_F_As_D_D \
|
| 21 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 22 |
+
NPY_NO_EXPORT void PyUFunc_F_F \
|
| 23 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 24 |
+
NPY_NO_EXPORT void PyUFunc_D_D \
|
| 25 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 26 |
+
NPY_NO_EXPORT void PyUFunc_G_G \
|
| 27 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 28 |
+
NPY_NO_EXPORT void PyUFunc_O_O \
|
| 29 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 30 |
+
NPY_NO_EXPORT void PyUFunc_ff_f_As_dd_d \
|
| 31 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 32 |
+
NPY_NO_EXPORT void PyUFunc_ff_f \
|
| 33 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 34 |
+
NPY_NO_EXPORT void PyUFunc_dd_d \
|
| 35 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 36 |
+
NPY_NO_EXPORT void PyUFunc_gg_g \
|
| 37 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 38 |
+
NPY_NO_EXPORT void PyUFunc_FF_F_As_DD_D \
|
| 39 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 40 |
+
NPY_NO_EXPORT void PyUFunc_DD_D \
|
| 41 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 42 |
+
NPY_NO_EXPORT void PyUFunc_FF_F \
|
| 43 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 44 |
+
NPY_NO_EXPORT void PyUFunc_GG_G \
|
| 45 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 46 |
+
NPY_NO_EXPORT void PyUFunc_OO_O \
|
| 47 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 48 |
+
NPY_NO_EXPORT void PyUFunc_O_O_method \
|
| 49 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 50 |
+
NPY_NO_EXPORT void PyUFunc_OO_O_method \
|
| 51 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 52 |
+
NPY_NO_EXPORT void PyUFunc_On_Om \
|
| 53 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 54 |
+
NPY_NO_EXPORT void PyUFunc_clearfperr \
|
| 55 |
+
(void);
|
| 56 |
+
NPY_NO_EXPORT int PyUFunc_getfperr \
|
| 57 |
+
(void);
|
| 58 |
+
NPY_NO_EXPORT int PyUFunc_ReplaceLoopBySignature \
|
| 59 |
+
(PyUFuncObject *, PyUFuncGenericFunction, const int *, PyUFuncGenericFunction *);
|
| 60 |
+
NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignature \
|
| 61 |
+
(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int, const char *);
|
| 62 |
+
NPY_NO_EXPORT void PyUFunc_e_e \
|
| 63 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 64 |
+
NPY_NO_EXPORT void PyUFunc_e_e_As_f_f \
|
| 65 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 66 |
+
NPY_NO_EXPORT void PyUFunc_e_e_As_d_d \
|
| 67 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 68 |
+
NPY_NO_EXPORT void PyUFunc_ee_e \
|
| 69 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 70 |
+
NPY_NO_EXPORT void PyUFunc_ee_e_As_ff_f \
|
| 71 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 72 |
+
NPY_NO_EXPORT void PyUFunc_ee_e_As_dd_d \
|
| 73 |
+
(char **, npy_intp const *, npy_intp const *, void *);
|
| 74 |
+
NPY_NO_EXPORT int PyUFunc_DefaultTypeResolver \
|
| 75 |
+
(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyObject *, PyArray_Descr **);
|
| 76 |
+
NPY_NO_EXPORT int PyUFunc_ValidateCasting \
|
| 77 |
+
(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr *const *);
|
| 78 |
+
NPY_NO_EXPORT int PyUFunc_RegisterLoopForDescr \
|
| 79 |
+
(PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *);
|
| 80 |
+
NPY_NO_EXPORT PyObject * PyUFunc_FromFuncAndDataAndSignatureAndIdentity \
|
| 81 |
+
(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, const int, const char *, PyObject *);
|
| 82 |
+
NPY_NO_EXPORT int PyUFunc_AddLoopFromSpec \
|
| 83 |
+
(PyObject *, PyArrayMethod_Spec *);
|
| 84 |
+
NPY_NO_EXPORT int PyUFunc_AddPromoter \
|
| 85 |
+
(PyObject *, PyObject *, PyObject *);
|
| 86 |
+
NPY_NO_EXPORT int PyUFunc_AddWrappingLoop \
|
| 87 |
+
(PyObject *, PyArray_DTypeMeta *new_dtypes[], PyArray_DTypeMeta *wrapped_dtypes[], PyArrayMethod_TranslateGivenDescriptors *, PyArrayMethod_TranslateLoopDescriptors *);
|
| 88 |
+
NPY_NO_EXPORT int PyUFunc_GiveFloatingpointErrors \
|
| 89 |
+
(const char *, int);
|
| 90 |
+
|
| 91 |
+
#else
|
| 92 |
+
|
| 93 |
+
#if defined(PY_UFUNC_UNIQUE_SYMBOL)
|
| 94 |
+
#define PyUFunc_API PY_UFUNC_UNIQUE_SYMBOL
|
| 95 |
+
#endif
|
| 96 |
+
|
| 97 |
+
/* By default do not export API in an .so (was never the case on windows) */
|
| 98 |
+
#ifndef NPY_API_SYMBOL_ATTRIBUTE
|
| 99 |
+
#define NPY_API_SYMBOL_ATTRIBUTE NPY_VISIBILITY_HIDDEN
|
| 100 |
+
#endif
|
| 101 |
+
|
| 102 |
+
#if defined(NO_IMPORT) || defined(NO_IMPORT_UFUNC)
|
| 103 |
+
extern NPY_API_SYMBOL_ATTRIBUTE void **PyUFunc_API;
|
| 104 |
+
#else
|
| 105 |
+
#if defined(PY_UFUNC_UNIQUE_SYMBOL)
|
| 106 |
+
NPY_API_SYMBOL_ATTRIBUTE void **PyUFunc_API;
|
| 107 |
+
#else
|
| 108 |
+
static void **PyUFunc_API=NULL;
|
| 109 |
+
#endif
|
| 110 |
+
#endif
|
| 111 |
+
|
| 112 |
+
#define PyUFunc_Type (*(PyTypeObject *)PyUFunc_API[0])
|
| 113 |
+
#define PyUFunc_FromFuncAndData \
|
| 114 |
+
(*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int)) \
|
| 115 |
+
PyUFunc_API[1])
|
| 116 |
+
#define PyUFunc_RegisterLoopForType \
|
| 117 |
+
(*(int (*)(PyUFuncObject *, int, PyUFuncGenericFunction, const int *, void *)) \
|
| 118 |
+
PyUFunc_API[2])
|
| 119 |
+
#define PyUFunc_f_f_As_d_d \
|
| 120 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 121 |
+
PyUFunc_API[4])
|
| 122 |
+
#define PyUFunc_d_d \
|
| 123 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 124 |
+
PyUFunc_API[5])
|
| 125 |
+
#define PyUFunc_f_f \
|
| 126 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 127 |
+
PyUFunc_API[6])
|
| 128 |
+
#define PyUFunc_g_g \
|
| 129 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 130 |
+
PyUFunc_API[7])
|
| 131 |
+
#define PyUFunc_F_F_As_D_D \
|
| 132 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 133 |
+
PyUFunc_API[8])
|
| 134 |
+
#define PyUFunc_F_F \
|
| 135 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 136 |
+
PyUFunc_API[9])
|
| 137 |
+
#define PyUFunc_D_D \
|
| 138 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 139 |
+
PyUFunc_API[10])
|
| 140 |
+
#define PyUFunc_G_G \
|
| 141 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 142 |
+
PyUFunc_API[11])
|
| 143 |
+
#define PyUFunc_O_O \
|
| 144 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 145 |
+
PyUFunc_API[12])
|
| 146 |
+
#define PyUFunc_ff_f_As_dd_d \
|
| 147 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 148 |
+
PyUFunc_API[13])
|
| 149 |
+
#define PyUFunc_ff_f \
|
| 150 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 151 |
+
PyUFunc_API[14])
|
| 152 |
+
#define PyUFunc_dd_d \
|
| 153 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 154 |
+
PyUFunc_API[15])
|
| 155 |
+
#define PyUFunc_gg_g \
|
| 156 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 157 |
+
PyUFunc_API[16])
|
| 158 |
+
#define PyUFunc_FF_F_As_DD_D \
|
| 159 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 160 |
+
PyUFunc_API[17])
|
| 161 |
+
#define PyUFunc_DD_D \
|
| 162 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 163 |
+
PyUFunc_API[18])
|
| 164 |
+
#define PyUFunc_FF_F \
|
| 165 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 166 |
+
PyUFunc_API[19])
|
| 167 |
+
#define PyUFunc_GG_G \
|
| 168 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 169 |
+
PyUFunc_API[20])
|
| 170 |
+
#define PyUFunc_OO_O \
|
| 171 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 172 |
+
PyUFunc_API[21])
|
| 173 |
+
#define PyUFunc_O_O_method \
|
| 174 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 175 |
+
PyUFunc_API[22])
|
| 176 |
+
#define PyUFunc_OO_O_method \
|
| 177 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 178 |
+
PyUFunc_API[23])
|
| 179 |
+
#define PyUFunc_On_Om \
|
| 180 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 181 |
+
PyUFunc_API[24])
|
| 182 |
+
#define PyUFunc_clearfperr \
|
| 183 |
+
(*(void (*)(void)) \
|
| 184 |
+
PyUFunc_API[27])
|
| 185 |
+
#define PyUFunc_getfperr \
|
| 186 |
+
(*(int (*)(void)) \
|
| 187 |
+
PyUFunc_API[28])
|
| 188 |
+
#define PyUFunc_ReplaceLoopBySignature \
|
| 189 |
+
(*(int (*)(PyUFuncObject *, PyUFuncGenericFunction, const int *, PyUFuncGenericFunction *)) \
|
| 190 |
+
PyUFunc_API[30])
|
| 191 |
+
#define PyUFunc_FromFuncAndDataAndSignature \
|
| 192 |
+
(*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, int, const char *)) \
|
| 193 |
+
PyUFunc_API[31])
|
| 194 |
+
#define PyUFunc_e_e \
|
| 195 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 196 |
+
PyUFunc_API[33])
|
| 197 |
+
#define PyUFunc_e_e_As_f_f \
|
| 198 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 199 |
+
PyUFunc_API[34])
|
| 200 |
+
#define PyUFunc_e_e_As_d_d \
|
| 201 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 202 |
+
PyUFunc_API[35])
|
| 203 |
+
#define PyUFunc_ee_e \
|
| 204 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 205 |
+
PyUFunc_API[36])
|
| 206 |
+
#define PyUFunc_ee_e_As_ff_f \
|
| 207 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 208 |
+
PyUFunc_API[37])
|
| 209 |
+
#define PyUFunc_ee_e_As_dd_d \
|
| 210 |
+
(*(void (*)(char **, npy_intp const *, npy_intp const *, void *)) \
|
| 211 |
+
PyUFunc_API[38])
|
| 212 |
+
#define PyUFunc_DefaultTypeResolver \
|
| 213 |
+
(*(int (*)(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyObject *, PyArray_Descr **)) \
|
| 214 |
+
PyUFunc_API[39])
|
| 215 |
+
#define PyUFunc_ValidateCasting \
|
| 216 |
+
(*(int (*)(PyUFuncObject *, NPY_CASTING, PyArrayObject **, PyArray_Descr *const *)) \
|
| 217 |
+
PyUFunc_API[40])
|
| 218 |
+
#define PyUFunc_RegisterLoopForDescr \
|
| 219 |
+
(*(int (*)(PyUFuncObject *, PyArray_Descr *, PyUFuncGenericFunction, PyArray_Descr **, void *)) \
|
| 220 |
+
PyUFunc_API[41])
|
| 221 |
+
|
| 222 |
+
#if NPY_FEATURE_VERSION >= NPY_1_16_API_VERSION
|
| 223 |
+
#define PyUFunc_FromFuncAndDataAndSignatureAndIdentity \
|
| 224 |
+
(*(PyObject * (*)(PyUFuncGenericFunction *, void *const *, const char *, int, int, int, int, const char *, const char *, const int, const char *, PyObject *)) \
|
| 225 |
+
PyUFunc_API[42])
|
| 226 |
+
#endif
|
| 227 |
+
|
| 228 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 229 |
+
#define PyUFunc_AddLoopFromSpec \
|
| 230 |
+
(*(int (*)(PyObject *, PyArrayMethod_Spec *)) \
|
| 231 |
+
PyUFunc_API[43])
|
| 232 |
+
#endif
|
| 233 |
+
|
| 234 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 235 |
+
#define PyUFunc_AddPromoter \
|
| 236 |
+
(*(int (*)(PyObject *, PyObject *, PyObject *)) \
|
| 237 |
+
PyUFunc_API[44])
|
| 238 |
+
#endif
|
| 239 |
+
|
| 240 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 241 |
+
#define PyUFunc_AddWrappingLoop \
|
| 242 |
+
(*(int (*)(PyObject *, PyArray_DTypeMeta *new_dtypes[], PyArray_DTypeMeta *wrapped_dtypes[], PyArrayMethod_TranslateGivenDescriptors *, PyArrayMethod_TranslateLoopDescriptors *)) \
|
| 243 |
+
PyUFunc_API[45])
|
| 244 |
+
#endif
|
| 245 |
+
|
| 246 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 247 |
+
#define PyUFunc_GiveFloatingpointErrors \
|
| 248 |
+
(*(int (*)(const char *, int)) \
|
| 249 |
+
PyUFunc_API[46])
|
| 250 |
+
#endif
|
| 251 |
+
|
| 252 |
+
static inline int
|
| 253 |
+
_import_umath(void)
|
| 254 |
+
{
|
| 255 |
+
PyObject *numpy = PyImport_ImportModule("numpy._core._multiarray_umath");
|
| 256 |
+
if (numpy == NULL && PyErr_ExceptionMatches(PyExc_ModuleNotFoundError)) {
|
| 257 |
+
PyErr_Clear();
|
| 258 |
+
numpy = PyImport_ImportModule("numpy.core._multiarray_umath");
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
if (numpy == NULL) {
|
| 262 |
+
PyErr_SetString(PyExc_ImportError,
|
| 263 |
+
"_multiarray_umath failed to import");
|
| 264 |
+
return -1;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
PyObject *c_api = PyObject_GetAttrString(numpy, "_UFUNC_API");
|
| 268 |
+
Py_DECREF(numpy);
|
| 269 |
+
if (c_api == NULL) {
|
| 270 |
+
PyErr_SetString(PyExc_AttributeError, "_UFUNC_API not found");
|
| 271 |
+
return -1;
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
if (!PyCapsule_CheckExact(c_api)) {
|
| 275 |
+
PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is not PyCapsule object");
|
| 276 |
+
Py_DECREF(c_api);
|
| 277 |
+
return -1;
|
| 278 |
+
}
|
| 279 |
+
PyUFunc_API = (void **)PyCapsule_GetPointer(c_api, NULL);
|
| 280 |
+
Py_DECREF(c_api);
|
| 281 |
+
if (PyUFunc_API == NULL) {
|
| 282 |
+
PyErr_SetString(PyExc_RuntimeError, "_UFUNC_API is NULL pointer");
|
| 283 |
+
return -1;
|
| 284 |
+
}
|
| 285 |
+
return 0;
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
#define import_umath() \
|
| 289 |
+
do {\
|
| 290 |
+
UFUNC_NOFPE\
|
| 291 |
+
if (_import_umath() < 0) {\
|
| 292 |
+
PyErr_Print();\
|
| 293 |
+
PyErr_SetString(PyExc_ImportError,\
|
| 294 |
+
"numpy._core.umath failed to import");\
|
| 295 |
+
return NULL;\
|
| 296 |
+
}\
|
| 297 |
+
} while(0)
|
| 298 |
+
|
| 299 |
+
#define import_umath1(ret) \
|
| 300 |
+
do {\
|
| 301 |
+
UFUNC_NOFPE\
|
| 302 |
+
if (_import_umath() < 0) {\
|
| 303 |
+
PyErr_Print();\
|
| 304 |
+
PyErr_SetString(PyExc_ImportError,\
|
| 305 |
+
"numpy._core.umath failed to import");\
|
| 306 |
+
return ret;\
|
| 307 |
+
}\
|
| 308 |
+
} while(0)
|
| 309 |
+
|
| 310 |
+
#define import_umath2(ret, msg) \
|
| 311 |
+
do {\
|
| 312 |
+
UFUNC_NOFPE\
|
| 313 |
+
if (_import_umath() < 0) {\
|
| 314 |
+
PyErr_Print();\
|
| 315 |
+
PyErr_SetString(PyExc_ImportError, msg);\
|
| 316 |
+
return ret;\
|
| 317 |
+
}\
|
| 318 |
+
} while(0)
|
| 319 |
+
|
| 320 |
+
#define import_ufunc() \
|
| 321 |
+
do {\
|
| 322 |
+
UFUNC_NOFPE\
|
| 323 |
+
if (_import_umath() < 0) {\
|
| 324 |
+
PyErr_Print();\
|
| 325 |
+
PyErr_SetString(PyExc_ImportError,\
|
| 326 |
+
"numpy._core.umath failed to import");\
|
| 327 |
+
}\
|
| 328 |
+
} while(0)
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
static inline int
|
| 332 |
+
PyUFunc_ImportUFuncAPI()
|
| 333 |
+
{
|
| 334 |
+
if (NPY_UNLIKELY(PyUFunc_API == NULL)) {
|
| 335 |
+
import_umath1(-1);
|
| 336 |
+
}
|
| 337 |
+
return 0;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
#endif
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_neighborhood_iterator_imp.h
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef NUMPY_CORE_INCLUDE_NUMPY__NEIGHBORHOOD_IMP_H_
|
| 2 |
+
#error You should not include this header directly
|
| 3 |
+
#endif
|
| 4 |
+
/*
|
| 5 |
+
* Private API (here for inline)
|
| 6 |
+
*/
|
| 7 |
+
static inline int
|
| 8 |
+
_PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter);
|
| 9 |
+
|
| 10 |
+
/*
|
| 11 |
+
* Update to next item of the iterator
|
| 12 |
+
*
|
| 13 |
+
* Note: this simply increment the coordinates vector, last dimension
|
| 14 |
+
* incremented first , i.e, for dimension 3
|
| 15 |
+
* ...
|
| 16 |
+
* -1, -1, -1
|
| 17 |
+
* -1, -1, 0
|
| 18 |
+
* -1, -1, 1
|
| 19 |
+
* ....
|
| 20 |
+
* -1, 0, -1
|
| 21 |
+
* -1, 0, 0
|
| 22 |
+
* ....
|
| 23 |
+
* 0, -1, -1
|
| 24 |
+
* 0, -1, 0
|
| 25 |
+
* ....
|
| 26 |
+
*/
|
| 27 |
+
#define _UPDATE_COORD_ITER(c) \
|
| 28 |
+
wb = iter->coordinates[c] < iter->bounds[c][1]; \
|
| 29 |
+
if (wb) { \
|
| 30 |
+
iter->coordinates[c] += 1; \
|
| 31 |
+
return 0; \
|
| 32 |
+
} \
|
| 33 |
+
else { \
|
| 34 |
+
iter->coordinates[c] = iter->bounds[c][0]; \
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
static inline int
|
| 38 |
+
_PyArrayNeighborhoodIter_IncrCoord(PyArrayNeighborhoodIterObject* iter)
|
| 39 |
+
{
|
| 40 |
+
npy_intp i, wb;
|
| 41 |
+
|
| 42 |
+
for (i = iter->nd - 1; i >= 0; --i) {
|
| 43 |
+
_UPDATE_COORD_ITER(i)
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
return 0;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/*
|
| 50 |
+
* Version optimized for 2d arrays, manual loop unrolling
|
| 51 |
+
*/
|
| 52 |
+
static inline int
|
| 53 |
+
_PyArrayNeighborhoodIter_IncrCoord2D(PyArrayNeighborhoodIterObject* iter)
|
| 54 |
+
{
|
| 55 |
+
npy_intp wb;
|
| 56 |
+
|
| 57 |
+
_UPDATE_COORD_ITER(1)
|
| 58 |
+
_UPDATE_COORD_ITER(0)
|
| 59 |
+
|
| 60 |
+
return 0;
|
| 61 |
+
}
|
| 62 |
+
#undef _UPDATE_COORD_ITER
|
| 63 |
+
|
| 64 |
+
/*
|
| 65 |
+
* Advance to the next neighbour
|
| 66 |
+
*/
|
| 67 |
+
static inline int
|
| 68 |
+
PyArrayNeighborhoodIter_Next(PyArrayNeighborhoodIterObject* iter)
|
| 69 |
+
{
|
| 70 |
+
_PyArrayNeighborhoodIter_IncrCoord (iter);
|
| 71 |
+
iter->dataptr = iter->translate((PyArrayIterObject*)iter, iter->coordinates);
|
| 72 |
+
|
| 73 |
+
return 0;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/*
|
| 77 |
+
* Reset functions
|
| 78 |
+
*/
|
| 79 |
+
static inline int
|
| 80 |
+
PyArrayNeighborhoodIter_Reset(PyArrayNeighborhoodIterObject* iter)
|
| 81 |
+
{
|
| 82 |
+
npy_intp i;
|
| 83 |
+
|
| 84 |
+
for (i = 0; i < iter->nd; ++i) {
|
| 85 |
+
iter->coordinates[i] = iter->bounds[i][0];
|
| 86 |
+
}
|
| 87 |
+
iter->dataptr = iter->translate((PyArrayIterObject*)iter, iter->coordinates);
|
| 88 |
+
|
| 89 |
+
return 0;
|
| 90 |
+
}
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_numpyconfig.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* #undef NPY_HAVE_ENDIAN_H */
|
| 2 |
+
|
| 3 |
+
#define NPY_SIZEOF_SHORT 2
|
| 4 |
+
#define NPY_SIZEOF_INT 4
|
| 5 |
+
#define NPY_SIZEOF_LONG 4
|
| 6 |
+
#define NPY_SIZEOF_FLOAT 4
|
| 7 |
+
#define NPY_SIZEOF_COMPLEX_FLOAT 8
|
| 8 |
+
#define NPY_SIZEOF_DOUBLE 8
|
| 9 |
+
#define NPY_SIZEOF_COMPLEX_DOUBLE 16
|
| 10 |
+
#define NPY_SIZEOF_LONGDOUBLE 8
|
| 11 |
+
#define NPY_SIZEOF_COMPLEX_LONGDOUBLE 16
|
| 12 |
+
#define NPY_SIZEOF_PY_INTPTR_T 8
|
| 13 |
+
#define NPY_SIZEOF_INTP 8
|
| 14 |
+
#define NPY_SIZEOF_UINTP 8
|
| 15 |
+
#define NPY_SIZEOF_WCHAR_T 2
|
| 16 |
+
#define NPY_SIZEOF_OFF_T 4
|
| 17 |
+
#define NPY_SIZEOF_PY_LONG_LONG 8
|
| 18 |
+
#define NPY_SIZEOF_LONGLONG 8
|
| 19 |
+
|
| 20 |
+
/*
|
| 21 |
+
* Defined to 1 or 0. Note that Pyodide hardcodes NPY_NO_SMP (and other defines
|
| 22 |
+
* in this header) for better cross-compilation, so don't rename them without a
|
| 23 |
+
* good reason.
|
| 24 |
+
*/
|
| 25 |
+
#define NPY_NO_SMP 0
|
| 26 |
+
|
| 27 |
+
#define NPY_VISIBILITY_HIDDEN
|
| 28 |
+
#define NPY_ABI_VERSION 0x02000000
|
| 29 |
+
#define NPY_API_VERSION 0x00000013
|
| 30 |
+
|
| 31 |
+
#ifndef __STDC_FORMAT_MACROS
|
| 32 |
+
#define __STDC_FORMAT_MACROS 1
|
| 33 |
+
#endif
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/_public_dtype_api_table.h
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Public exposure of the DType Classes. These are tricky to expose
|
| 3 |
+
* via the Python API, so they are exposed through this header for now.
|
| 4 |
+
*
|
| 5 |
+
* These definitions are only relevant for the public API and we reserve
|
| 6 |
+
* the slots 320-360 in the API table generation for this (currently).
|
| 7 |
+
*
|
| 8 |
+
* TODO: This file should be consolidated with the API table generation
|
| 9 |
+
* (although not sure the current generation is worth preserving).
|
| 10 |
+
*/
|
| 11 |
+
#ifndef NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_
|
| 12 |
+
#define NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_
|
| 13 |
+
|
| 14 |
+
#if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
|
| 15 |
+
|
| 16 |
+
/* All of these require NumPy 2.0 support */
|
| 17 |
+
#if NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION
|
| 18 |
+
|
| 19 |
+
/*
|
| 20 |
+
* The type of the DType metaclass
|
| 21 |
+
*/
|
| 22 |
+
#define PyArrayDTypeMeta_Type (*(PyTypeObject *)(PyArray_API + 320)[0])
|
| 23 |
+
/*
|
| 24 |
+
* NumPy's builtin DTypes:
|
| 25 |
+
*/
|
| 26 |
+
#define PyArray_BoolDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[1])
|
| 27 |
+
/* Integers */
|
| 28 |
+
#define PyArray_ByteDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[2])
|
| 29 |
+
#define PyArray_UByteDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[3])
|
| 30 |
+
#define PyArray_ShortDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[4])
|
| 31 |
+
#define PyArray_UShortDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[5])
|
| 32 |
+
#define PyArray_IntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[6])
|
| 33 |
+
#define PyArray_UIntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[7])
|
| 34 |
+
#define PyArray_LongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[8])
|
| 35 |
+
#define PyArray_ULongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[9])
|
| 36 |
+
#define PyArray_LongLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[10])
|
| 37 |
+
#define PyArray_ULongLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[11])
|
| 38 |
+
/* Integer aliases */
|
| 39 |
+
#define PyArray_Int8DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[12])
|
| 40 |
+
#define PyArray_UInt8DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[13])
|
| 41 |
+
#define PyArray_Int16DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[14])
|
| 42 |
+
#define PyArray_UInt16DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[15])
|
| 43 |
+
#define PyArray_Int32DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[16])
|
| 44 |
+
#define PyArray_UInt32DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[17])
|
| 45 |
+
#define PyArray_Int64DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[18])
|
| 46 |
+
#define PyArray_UInt64DType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[19])
|
| 47 |
+
#define PyArray_IntpDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[20])
|
| 48 |
+
#define PyArray_UIntpDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[21])
|
| 49 |
+
/* Floats */
|
| 50 |
+
#define PyArray_HalfDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[22])
|
| 51 |
+
#define PyArray_FloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[23])
|
| 52 |
+
#define PyArray_DoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[24])
|
| 53 |
+
#define PyArray_LongDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[25])
|
| 54 |
+
/* Complex */
|
| 55 |
+
#define PyArray_CFloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[26])
|
| 56 |
+
#define PyArray_CDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[27])
|
| 57 |
+
#define PyArray_CLongDoubleDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[28])
|
| 58 |
+
/* String/Bytes */
|
| 59 |
+
#define PyArray_BytesDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[29])
|
| 60 |
+
#define PyArray_UnicodeDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[30])
|
| 61 |
+
/* Datetime/Timedelta */
|
| 62 |
+
#define PyArray_DatetimeDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[31])
|
| 63 |
+
#define PyArray_TimedeltaDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[32])
|
| 64 |
+
/* Object/Void */
|
| 65 |
+
#define PyArray_ObjectDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[33])
|
| 66 |
+
#define PyArray_VoidDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[34])
|
| 67 |
+
/* Python types (used as markers for scalars) */
|
| 68 |
+
#define PyArray_PyLongDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[35])
|
| 69 |
+
#define PyArray_PyFloatDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[36])
|
| 70 |
+
#define PyArray_PyComplexDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[37])
|
| 71 |
+
/* Default integer type */
|
| 72 |
+
#define PyArray_DefaultIntDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[38])
|
| 73 |
+
/* New non-legacy DTypes follow in the order they were added */
|
| 74 |
+
#define PyArray_StringDType (*(PyArray_DTypeMeta *)(PyArray_API + 320)[39])
|
| 75 |
+
|
| 76 |
+
/* NOTE: offset 40 is free */
|
| 77 |
+
|
| 78 |
+
/* Need to start with a larger offset again for the abstract classes: */
|
| 79 |
+
#define PyArray_IntAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[366])
|
| 80 |
+
#define PyArray_FloatAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[367])
|
| 81 |
+
#define PyArray_ComplexAbstractDType (*(PyArray_DTypeMeta *)PyArray_API[368])
|
| 82 |
+
|
| 83 |
+
#endif /* NPY_FEATURE_VERSION >= NPY_2_0_API_VERSION */
|
| 84 |
+
|
| 85 |
+
#endif /* NPY_INTERNAL_BUILD */
|
| 86 |
+
#endif /* NUMPY_CORE_INCLUDE_NUMPY__PUBLIC_DTYPE_API_TABLE_H_ */
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/arrayobject.h
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#ifndef NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_
|
| 2 |
+
#define NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_
|
| 3 |
+
|
| 4 |
+
#ifndef _MULTIARRAYMODULE
|
| 5 |
+
typedef struct {
|
| 6 |
+
PyObject_HEAD
|
| 7 |
+
npy_bool obval;
|
| 8 |
+
} PyBoolScalarObject;
|
| 9 |
+
#endif
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
typedef struct {
|
| 13 |
+
PyObject_HEAD
|
| 14 |
+
signed char obval;
|
| 15 |
+
} PyByteScalarObject;
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
typedef struct {
|
| 19 |
+
PyObject_HEAD
|
| 20 |
+
short obval;
|
| 21 |
+
} PyShortScalarObject;
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
typedef struct {
|
| 25 |
+
PyObject_HEAD
|
| 26 |
+
int obval;
|
| 27 |
+
} PyIntScalarObject;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
typedef struct {
|
| 31 |
+
PyObject_HEAD
|
| 32 |
+
long obval;
|
| 33 |
+
} PyLongScalarObject;
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
typedef struct {
|
| 37 |
+
PyObject_HEAD
|
| 38 |
+
npy_longlong obval;
|
| 39 |
+
} PyLongLongScalarObject;
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
typedef struct {
|
| 43 |
+
PyObject_HEAD
|
| 44 |
+
unsigned char obval;
|
| 45 |
+
} PyUByteScalarObject;
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
typedef struct {
|
| 49 |
+
PyObject_HEAD
|
| 50 |
+
unsigned short obval;
|
| 51 |
+
} PyUShortScalarObject;
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
typedef struct {
|
| 55 |
+
PyObject_HEAD
|
| 56 |
+
unsigned int obval;
|
| 57 |
+
} PyUIntScalarObject;
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
typedef struct {
|
| 61 |
+
PyObject_HEAD
|
| 62 |
+
unsigned long obval;
|
| 63 |
+
} PyULongScalarObject;
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
typedef struct {
|
| 67 |
+
PyObject_HEAD
|
| 68 |
+
npy_ulonglong obval;
|
| 69 |
+
} PyULongLongScalarObject;
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
typedef struct {
|
| 73 |
+
PyObject_HEAD
|
| 74 |
+
npy_half obval;
|
| 75 |
+
} PyHalfScalarObject;
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
typedef struct {
|
| 79 |
+
PyObject_HEAD
|
| 80 |
+
float obval;
|
| 81 |
+
} PyFloatScalarObject;
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
typedef struct {
|
| 85 |
+
PyObject_HEAD
|
| 86 |
+
double obval;
|
| 87 |
+
} PyDoubleScalarObject;
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
typedef struct {
|
| 91 |
+
PyObject_HEAD
|
| 92 |
+
npy_longdouble obval;
|
| 93 |
+
} PyLongDoubleScalarObject;
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
typedef struct {
|
| 97 |
+
PyObject_HEAD
|
| 98 |
+
npy_cfloat obval;
|
| 99 |
+
} PyCFloatScalarObject;
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
typedef struct {
|
| 103 |
+
PyObject_HEAD
|
| 104 |
+
npy_cdouble obval;
|
| 105 |
+
} PyCDoubleScalarObject;
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
typedef struct {
|
| 109 |
+
PyObject_HEAD
|
| 110 |
+
npy_clongdouble obval;
|
| 111 |
+
} PyCLongDoubleScalarObject;
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
typedef struct {
|
| 115 |
+
PyObject_HEAD
|
| 116 |
+
PyObject * obval;
|
| 117 |
+
} PyObjectScalarObject;
|
| 118 |
+
|
| 119 |
+
typedef struct {
|
| 120 |
+
PyObject_HEAD
|
| 121 |
+
npy_datetime obval;
|
| 122 |
+
PyArray_DatetimeMetaData obmeta;
|
| 123 |
+
} PyDatetimeScalarObject;
|
| 124 |
+
|
| 125 |
+
typedef struct {
|
| 126 |
+
PyObject_HEAD
|
| 127 |
+
npy_timedelta obval;
|
| 128 |
+
PyArray_DatetimeMetaData obmeta;
|
| 129 |
+
} PyTimedeltaScalarObject;
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
typedef struct {
|
| 133 |
+
PyObject_HEAD
|
| 134 |
+
char obval;
|
| 135 |
+
} PyScalarObject;
|
| 136 |
+
|
| 137 |
+
#define PyStringScalarObject PyBytesObject
|
| 138 |
+
#ifndef Py_LIMITED_API
|
| 139 |
+
typedef struct {
|
| 140 |
+
/* note that the PyObject_HEAD macro lives right here */
|
| 141 |
+
PyUnicodeObject base;
|
| 142 |
+
Py_UCS4 *obval;
|
| 143 |
+
#if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
|
| 144 |
+
char *buffer_fmt;
|
| 145 |
+
#endif
|
| 146 |
+
} PyUnicodeScalarObject;
|
| 147 |
+
#endif
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
typedef struct {
|
| 151 |
+
PyObject_VAR_HEAD
|
| 152 |
+
char *obval;
|
| 153 |
+
#if defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD
|
| 154 |
+
/* Internally use the subclass to allow accessing names/fields */
|
| 155 |
+
_PyArray_LegacyDescr *descr;
|
| 156 |
+
#else
|
| 157 |
+
PyArray_Descr *descr;
|
| 158 |
+
#endif
|
| 159 |
+
int flags;
|
| 160 |
+
PyObject *base;
|
| 161 |
+
#if NPY_FEATURE_VERSION >= NPY_1_20_API_VERSION
|
| 162 |
+
void *_buffer_info; /* private buffer info, tagged to allow warning */
|
| 163 |
+
#endif
|
| 164 |
+
} PyVoidScalarObject;
|
| 165 |
+
|
| 166 |
+
/* Macros
|
| 167 |
+
Py<Cls><bitsize>ScalarObject
|
| 168 |
+
Py<Cls><bitsize>ArrType_Type
|
| 169 |
+
are defined in ndarrayobject.h
|
| 170 |
+
*/
|
| 171 |
+
|
| 172 |
+
#define PyArrayScalar_False ((PyObject *)(&(_PyArrayScalar_BoolValues[0])))
|
| 173 |
+
#define PyArrayScalar_True ((PyObject *)(&(_PyArrayScalar_BoolValues[1])))
|
| 174 |
+
#define PyArrayScalar_FromLong(i) \
|
| 175 |
+
((PyObject *)(&(_PyArrayScalar_BoolValues[((i)!=0)])))
|
| 176 |
+
#define PyArrayScalar_RETURN_BOOL_FROM_LONG(i) \
|
| 177 |
+
return Py_INCREF(PyArrayScalar_FromLong(i)), \
|
| 178 |
+
PyArrayScalar_FromLong(i)
|
| 179 |
+
#define PyArrayScalar_RETURN_FALSE \
|
| 180 |
+
return Py_INCREF(PyArrayScalar_False), \
|
| 181 |
+
PyArrayScalar_False
|
| 182 |
+
#define PyArrayScalar_RETURN_TRUE \
|
| 183 |
+
return Py_INCREF(PyArrayScalar_True), \
|
| 184 |
+
PyArrayScalar_True
|
| 185 |
+
|
| 186 |
+
#define PyArrayScalar_New(cls) \
|
| 187 |
+
Py##cls##ArrType_Type.tp_alloc(&Py##cls##ArrType_Type, 0)
|
| 188 |
+
#ifndef Py_LIMITED_API
|
| 189 |
+
/* For the limited API, use PyArray_ScalarAsCtype instead */
|
| 190 |
+
#define PyArrayScalar_VAL(obj, cls) \
|
| 191 |
+
((Py##cls##ScalarObject *)obj)->obval
|
| 192 |
+
#define PyArrayScalar_ASSIGN(obj, cls, val) \
|
| 193 |
+
PyArrayScalar_VAL(obj, cls) = val
|
| 194 |
+
#endif
|
| 195 |
+
|
| 196 |
+
#endif /* NUMPY_CORE_INCLUDE_NUMPY_ARRAYSCALARS_H_ */
|
pythonProject/.venv/Lib/site-packages/numpy/_core/include/numpy/dtype_api.h
ADDED
|
@@ -0,0 +1,480 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* The public DType API
|
| 3 |
+
*/
|
| 4 |
+
|
| 5 |
+
#ifndef NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_
|
| 6 |
+
#define NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_
|
| 7 |
+
|
| 8 |
+
struct PyArrayMethodObject_tag;
|
| 9 |
+
|
| 10 |
+
/*
|
| 11 |
+
* Largely opaque struct for DType classes (i.e. metaclass instances).
|
| 12 |
+
* The internal definition is currently in `ndarraytypes.h` (export is a bit
|
| 13 |
+
* more complex because `PyArray_Descr` is a DTypeMeta internally but not
|
| 14 |
+
* externally).
|
| 15 |
+
*/
|
| 16 |
+
#if !(defined(NPY_INTERNAL_BUILD) && NPY_INTERNAL_BUILD)
|
| 17 |
+
|
| 18 |
+
#ifndef Py_LIMITED_API
|
| 19 |
+
|
| 20 |
+
typedef struct PyArray_DTypeMeta_tag {
|
| 21 |
+
PyHeapTypeObject super;
|
| 22 |
+
|
| 23 |
+
/*
|
| 24 |
+
* Most DTypes will have a singleton default instance, for the
|
| 25 |
+
* parametric legacy DTypes (bytes, string, void, datetime) this
|
| 26 |
+
* may be a pointer to the *prototype* instance?
|
| 27 |
+
*/
|
| 28 |
+
PyArray_Descr *singleton;
|
| 29 |
+
/* Copy of the legacy DTypes type number, usually invalid. */
|
| 30 |
+
int type_num;
|
| 31 |
+
|
| 32 |
+
/* The type object of the scalar instances (may be NULL?) */
|
| 33 |
+
PyTypeObject *scalar_type;
|
| 34 |
+
/*
|
| 35 |
+
* DType flags to signal legacy, parametric, or
|
| 36 |
+
* abstract. But plenty of space for additional information/flags.
|
| 37 |
+
*/
|
| 38 |
+
npy_uint64 flags;
|
| 39 |
+
|
| 40 |
+
/*
|
| 41 |
+
* Use indirection in order to allow a fixed size for this struct.
|
| 42 |
+
* A stable ABI size makes creating a static DType less painful
|
| 43 |
+
* while also ensuring flexibility for all opaque API (with one
|
| 44 |
+
* indirection due the pointer lookup).
|
| 45 |
+
*/
|
| 46 |
+
void *dt_slots;
|
| 47 |
+
/* Allow growing (at the moment also beyond this) */
|
| 48 |
+
void *reserved[3];
|
| 49 |
+
} PyArray_DTypeMeta;
|
| 50 |
+
|
| 51 |
+
#else
|
| 52 |
+
|
| 53 |
+
typedef PyTypeObject PyArray_DTypeMeta;
|
| 54 |
+
|
| 55 |
+
#endif /* Py_LIMITED_API */
|
| 56 |
+
|
| 57 |
+
#endif /* not internal build */
|
| 58 |
+
|
| 59 |
+
/*
|
| 60 |
+
* ******************************************************
|
| 61 |
+
* ArrayMethod API (Casting and UFuncs)
|
| 62 |
+
* ******************************************************
|
| 63 |
+
*/
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
typedef enum {
|
| 67 |
+
/* Flag for whether the GIL is required */
|
| 68 |
+
NPY_METH_REQUIRES_PYAPI = 1 << 0,
|
| 69 |
+
/*
|
| 70 |
+
* Some functions cannot set floating point error flags, this flag
|
| 71 |
+
* gives us the option (not requirement) to skip floating point error
|
| 72 |
+
* setup/check. No function should set error flags and ignore them
|
| 73 |
+
* since it would interfere with chaining operations (e.g. casting).
|
| 74 |
+
*/
|
| 75 |
+
NPY_METH_NO_FLOATINGPOINT_ERRORS = 1 << 1,
|
| 76 |
+
/* Whether the method supports unaligned access (not runtime) */
|
| 77 |
+
NPY_METH_SUPPORTS_UNALIGNED = 1 << 2,
|
| 78 |
+
/*
|
| 79 |
+
* Used for reductions to allow reordering the operation. At this point
|
| 80 |
+
* assume that if set, it also applies to normal operations though!
|
| 81 |
+
*/
|
| 82 |
+
NPY_METH_IS_REORDERABLE = 1 << 3,
|
| 83 |
+
/*
|
| 84 |
+
* Private flag for now for *logic* functions. The logical functions
|
| 85 |
+
* `logical_or` and `logical_and` can always cast the inputs to booleans
|
| 86 |
+
* "safely" (because that is how the cast to bool is defined).
|
| 87 |
+
* @seberg: I am not sure this is the best way to handle this, so its
|
| 88 |
+
* private for now (also it is very limited anyway).
|
| 89 |
+
* There is one "exception". NA aware dtypes cannot cast to bool
|
| 90 |
+
* (hopefully), so the `??->?` loop should error even with this flag.
|
| 91 |
+
* But a second NA fallback loop will be necessary.
|
| 92 |
+
*/
|
| 93 |
+
_NPY_METH_FORCE_CAST_INPUTS = 1 << 17,
|
| 94 |
+
|
| 95 |
+
/* All flags which can change at runtime */
|
| 96 |
+
NPY_METH_RUNTIME_FLAGS = (
|
| 97 |
+
NPY_METH_REQUIRES_PYAPI |
|
| 98 |
+
NPY_METH_NO_FLOATINGPOINT_ERRORS),
|
| 99 |
+
} NPY_ARRAYMETHOD_FLAGS;
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
typedef struct PyArrayMethod_Context_tag {
|
| 103 |
+
/* The caller, which is typically the original ufunc. May be NULL */
|
| 104 |
+
PyObject *caller;
|
| 105 |
+
/* The method "self". Currently an opaque object. */
|
| 106 |
+
struct PyArrayMethodObject_tag *method;
|
| 107 |
+
|
| 108 |
+
/* Operand descriptors, filled in by resolve_descriptors */
|
| 109 |
+
PyArray_Descr *const *descriptors;
|
| 110 |
+
/* Structure may grow (this is harmless for DType authors) */
|
| 111 |
+
} PyArrayMethod_Context;
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
/*
|
| 115 |
+
* The main object for creating a new ArrayMethod. We use the typical `slots`
|
| 116 |
+
* mechanism used by the Python limited API (see below for the slot defs).
|
| 117 |
+
*/
|
| 118 |
+
typedef struct {
|
| 119 |
+
const char *name;
|
| 120 |
+
int nin, nout;
|
| 121 |
+
NPY_CASTING casting;
|
| 122 |
+
NPY_ARRAYMETHOD_FLAGS flags;
|
| 123 |
+
PyArray_DTypeMeta **dtypes;
|
| 124 |
+
PyType_Slot *slots;
|
| 125 |
+
} PyArrayMethod_Spec;
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
/*
|
| 129 |
+
* ArrayMethod slots
|
| 130 |
+
* -----------------
|
| 131 |
+
*
|
| 132 |
+
* SLOTS IDs For the ArrayMethod creation, once fully public, IDs are fixed
|
| 133 |
+
* but can be deprecated and arbitrarily extended.
|
| 134 |
+
*/
|
| 135 |
+
#define _NPY_METH_resolve_descriptors_with_scalars 1
|
| 136 |
+
#define NPY_METH_resolve_descriptors 2
|
| 137 |
+
#define NPY_METH_get_loop 3
|
| 138 |
+
#define NPY_METH_get_reduction_initial 4
|
| 139 |
+
/* specific loops for constructions/default get_loop: */
|
| 140 |
+
#define NPY_METH_strided_loop 5
|
| 141 |
+
#define NPY_METH_contiguous_loop 6
|
| 142 |
+
#define NPY_METH_unaligned_strided_loop 7
|
| 143 |
+
#define NPY_METH_unaligned_contiguous_loop 8
|
| 144 |
+
#define NPY_METH_contiguous_indexed_loop 9
|
| 145 |
+
#define _NPY_METH_static_data 10
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
/*
|
| 149 |
+
* The resolve descriptors function, must be able to handle NULL values for
|
| 150 |
+
* all output (but not input) `given_descrs` and fill `loop_descrs`.
|
| 151 |
+
* Return -1 on error or 0 if the operation is not possible without an error
|
| 152 |
+
* set. (This may still be in flux.)
|
| 153 |
+
* Otherwise must return the "casting safety", for normal functions, this is
|
| 154 |
+
* almost always "safe" (or even "equivalent"?).
|
| 155 |
+
*
|
| 156 |
+
* `resolve_descriptors` is optional if all output DTypes are non-parametric.
|
| 157 |
+
*/
|
| 158 |
+
typedef NPY_CASTING (PyArrayMethod_ResolveDescriptors)(
|
| 159 |
+
/* "method" is currently opaque (necessary e.g. to wrap Python) */
|
| 160 |
+
struct PyArrayMethodObject_tag *method,
|
| 161 |
+
/* DTypes the method was created for */
|
| 162 |
+
PyArray_DTypeMeta *const *dtypes,
|
| 163 |
+
/* Input descriptors (instances). Outputs may be NULL. */
|
| 164 |
+
PyArray_Descr *const *given_descrs,
|
| 165 |
+
/* Exact loop descriptors to use, must not hold references on error */
|
| 166 |
+
PyArray_Descr **loop_descrs,
|
| 167 |
+
npy_intp *view_offset);
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
/*
|
| 171 |
+
* Rarely needed, slightly more powerful version of `resolve_descriptors`.
|
| 172 |
+
* See also `PyArrayMethod_ResolveDescriptors` for details on shared arguments.
|
| 173 |
+
*
|
| 174 |
+
* NOTE: This function is private now as it is unclear how and what to pass
|
| 175 |
+
* exactly as additional information to allow dealing with the scalars.
|
| 176 |
+
* See also gh-24915.
|
| 177 |
+
*/
|
| 178 |
+
typedef NPY_CASTING (PyArrayMethod_ResolveDescriptorsWithScalar)(
|
| 179 |
+
struct PyArrayMethodObject_tag *method,
|
| 180 |
+
PyArray_DTypeMeta *const *dtypes,
|
| 181 |
+
/* Unlike above, these can have any DType and we may allow NULL. */
|
| 182 |
+
PyArray_Descr *const *given_descrs,
|
| 183 |
+
/*
|
| 184 |
+
* Input scalars or NULL. Only ever passed for python scalars.
|
| 185 |
+
* WARNING: In some cases, a loop may be explicitly selected and the
|
| 186 |
+
* value passed is not available (NULL) or does not have the
|
| 187 |
+
* expected type.
|
| 188 |
+
*/
|
| 189 |
+
PyObject *const *input_scalars,
|
| 190 |
+
PyArray_Descr **loop_descrs,
|
| 191 |
+
npy_intp *view_offset);
|
| 192 |
+
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
typedef int (PyArrayMethod_StridedLoop)(PyArrayMethod_Context *context,
|
| 196 |
+
char *const *data, const npy_intp *dimensions, const npy_intp *strides,
|
| 197 |
+
NpyAuxData *transferdata);
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
typedef int (PyArrayMethod_GetLoop)(
|
| 201 |
+
PyArrayMethod_Context *context,
|
| 202 |
+
int aligned, int move_references,
|
| 203 |
+
const npy_intp *strides,
|
| 204 |
+
PyArrayMethod_StridedLoop **out_loop,
|
| 205 |
+
NpyAuxData **out_transferdata,
|
| 206 |
+
NPY_ARRAYMETHOD_FLAGS *flags);
|
| 207 |
+
|
| 208 |
+
/**
|
| 209 |
+
* Query an ArrayMethod for the initial value for use in reduction.
|
| 210 |
+
*
|
| 211 |
+
* @param context The arraymethod context, mainly to access the descriptors.
|
| 212 |
+
* @param reduction_is_empty Whether the reduction is empty. When it is, the
|
| 213 |
+
* value returned may differ. In this case it is a "default" value that
|
| 214 |
+
* may differ from the "identity" value normally used. For example:
|
| 215 |
+
* - `0.0` is the default for `sum([])`. But `-0.0` is the correct
|
| 216 |
+
* identity otherwise as it preserves the sign for `sum([-0.0])`.
|
| 217 |
+
* - We use no identity for object, but return the default of `0` and `1`
|
| 218 |
+
* for the empty `sum([], dtype=object)` and `prod([], dtype=object)`.
|
| 219 |
+
* This allows `np.sum(np.array(["a", "b"], dtype=object))` to work.
|
| 220 |
+
* - `-inf` or `INT_MIN` for `max` is an identity, but at least `INT_MIN`
|
| 221 |
+
* not a good *default* when there are no items.
|
| 222 |
+
* @param initial Pointer to initial data to be filled (if possible)
|
| 223 |
+
*
|
| 224 |
+
* @returns -1, 0, or 1 indicating error, no initial value, and initial being
|
| 225 |
+
* successfully filled. Errors must not be given where 0 is correct, NumPy
|
| 226 |
+
* may call this even when not strictly necessary.
|
| 227 |
+
*/
|
| 228 |
+
typedef int (PyArrayMethod_GetReductionInitial)(
|
| 229 |
+
PyArrayMethod_Context *context, npy_bool reduction_is_empty,
|
| 230 |
+
void *initial);
|
| 231 |
+
|
| 232 |
+
/*
|
| 233 |
+
* The following functions are only used by the wrapping array method defined
|
| 234 |
+
* in umath/wrapping_array_method.c
|
| 235 |
+
*/
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
/*
|
| 239 |
+
* The function to convert the given descriptors (passed in to
|
| 240 |
+
* `resolve_descriptors`) and translates them for the wrapped loop.
|
| 241 |
+
* The new descriptors MUST be viewable with the old ones, `NULL` must be
|
| 242 |
+
* supported (for outputs) and should normally be forwarded.
|
| 243 |
+
*
|
| 244 |
+
* The function must clean up on error.
|
| 245 |
+
*
|
| 246 |
+
* NOTE: We currently assume that this translation gives "viewable" results.
|
| 247 |
+
* I.e. there is no additional casting related to the wrapping process.
|
| 248 |
+
* In principle that could be supported, but not sure it is useful.
|
| 249 |
+
* This currently also means that e.g. alignment must apply identically
|
| 250 |
+
* to the new dtypes.
|
| 251 |
+
*
|
| 252 |
+
* TODO: Due to the fact that `resolve_descriptors` is also used for `can_cast`
|
| 253 |
+
* there is no way to "pass out" the result of this function. This means
|
| 254 |
+
* it will be called twice for every ufunc call.
|
| 255 |
+
* (I am considering including `auxdata` as an "optional" parameter to
|
| 256 |
+
* `resolve_descriptors`, so that it can be filled there if not NULL.)
|
| 257 |
+
*/
|
| 258 |
+
typedef int (PyArrayMethod_TranslateGivenDescriptors)(int nin, int nout,
|
| 259 |
+
PyArray_DTypeMeta *const wrapped_dtypes[],
|
| 260 |
+
PyArray_Descr *const given_descrs[], PyArray_Descr *new_descrs[]);
|
| 261 |
+
|
| 262 |
+
/**
|
| 263 |
+
* The function to convert the actual loop descriptors (as returned by the
|
| 264 |
+
* original `resolve_descriptors` function) to the ones the output array
|
| 265 |
+
* should use.
|
| 266 |
+
* This function must return "viewable" types, it must not mutate them in any
|
| 267 |
+
* form that would break the inner-loop logic. Does not need to support NULL.
|
| 268 |
+
*
|
| 269 |
+
* The function must clean up on error.
|
| 270 |
+
*
|
| 271 |
+
* @param nin Number of input arguments
|
| 272 |
+
* @param nout Number of output arguments
|
| 273 |
+
* @param new_dtypes The DTypes of the output (usually probably not needed)
|
| 274 |
+
* @param given_descrs Original given_descrs to the resolver, necessary to
|
| 275 |
+
* fetch any information related to the new dtypes from the original.
|
| 276 |
+
* @param original_descrs The `loop_descrs` returned by the wrapped loop.
|
| 277 |
+
* @param loop_descrs The output descriptors, compatible to `original_descrs`.
|
| 278 |
+
*
|
| 279 |
+
* @returns 0 on success, -1 on failure.
|
| 280 |
+
*/
|
| 281 |
+
typedef int (PyArrayMethod_TranslateLoopDescriptors)(int nin, int nout,
|
| 282 |
+
PyArray_DTypeMeta *const new_dtypes[], PyArray_Descr *const given_descrs[],
|
| 283 |
+
PyArray_Descr *original_descrs[], PyArray_Descr *loop_descrs[]);
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
|
| 287 |
+
/*
|
| 288 |
+
* A traverse loop working on a single array. This is similar to the general
|
| 289 |
+
* strided-loop function. This is designed for loops that need to visit every
|
| 290 |
+
* element of a single array.
|
| 291 |
+
*
|
| 292 |
+
* Currently this is used for array clearing, via the NPY_DT_get_clear_loop
|
| 293 |
+
* API hook, and zero-filling, via the NPY_DT_get_fill_zero_loop API hook.
|
| 294 |
+
* These are most useful for handling arrays storing embedded references to
|
| 295 |
+
* python objects or heap-allocated data.
|
| 296 |
+
*
|
| 297 |
+
* The `void *traverse_context` is passed in because we may need to pass in
|
| 298 |
+
* Interpreter state or similar in the future, but we don't want to pass in
|
| 299 |
+
* a full context (with pointers to dtypes, method, caller which all make
|
| 300 |
+
* no sense for a traverse function).
|
| 301 |
+
*
|
| 302 |
+
* We assume for now that this context can be just passed through in the
|
| 303 |
+
* the future (for structured dtypes).
|
| 304 |
+
*
|
| 305 |
+
*/
|
| 306 |
+
typedef int (PyArrayMethod_TraverseLoop)(
|
| 307 |
+
void *traverse_context, const PyArray_Descr *descr, char *data,
|
| 308 |
+
npy_intp size, npy_intp stride, NpyAuxData *auxdata);
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
/*
|
| 312 |
+
* Simplified get_loop function specific to dtype traversal
|
| 313 |
+
*
|
| 314 |
+
* It should set the flags needed for the traversal loop and set out_loop to the
|
| 315 |
+
* loop function, which must be a valid PyArrayMethod_TraverseLoop
|
| 316 |
+
* pointer. Currently this is used for zero-filling and clearing arrays storing
|
| 317 |
+
* embedded references.
|
| 318 |
+
*
|
| 319 |
+
*/
|
| 320 |
+
typedef int (PyArrayMethod_GetTraverseLoop)(
|
| 321 |
+
void *traverse_context, const PyArray_Descr *descr,
|
| 322 |
+
int aligned, npy_intp fixed_stride,
|
| 323 |
+
PyArrayMethod_TraverseLoop **out_loop, NpyAuxData **out_auxdata,
|
| 324 |
+
NPY_ARRAYMETHOD_FLAGS *flags);
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
/*
|
| 328 |
+
* Type of the C promoter function, which must be wrapped into a
|
| 329 |
+
* PyCapsule with name "numpy._ufunc_promoter".
|
| 330 |
+
*
|
| 331 |
+
* Note that currently the output dtypes are always NULL unless they are
|
| 332 |
+
* also part of the signature. This is an implementation detail and could
|
| 333 |
+
* change in the future. However, in general promoters should not have a
|
| 334 |
+
* need for output dtypes.
|
| 335 |
+
* (There are potential use-cases, these are currently unsupported.)
|
| 336 |
+
*/
|
| 337 |
+
typedef int (PyArrayMethod_PromoterFunction)(PyObject *ufunc,
|
| 338 |
+
PyArray_DTypeMeta *const op_dtypes[], PyArray_DTypeMeta *const signature[],
|
| 339 |
+
PyArray_DTypeMeta *new_op_dtypes[]);
|
| 340 |
+
|
| 341 |
+
/*
|
| 342 |
+
* ****************************
|
| 343 |
+
* DTYPE API
|
| 344 |
+
* ****************************
|
| 345 |
+
*/
|
| 346 |
+
|
| 347 |
+
#define NPY_DT_ABSTRACT 1 << 1
|
| 348 |
+
#define NPY_DT_PARAMETRIC 1 << 2
|
| 349 |
+
#define NPY_DT_NUMERIC 1 << 3
|
| 350 |
+
|
| 351 |
+
/*
|
| 352 |
+
* These correspond to slots in the NPY_DType_Slots struct and must
|
| 353 |
+
* be in the same order as the members of that struct. If new slots
|
| 354 |
+
* get added or old slots get removed NPY_NUM_DTYPE_SLOTS must also
|
| 355 |
+
* be updated
|
| 356 |
+
*/
|
| 357 |
+
|
| 358 |
+
#define NPY_DT_discover_descr_from_pyobject 1
|
| 359 |
+
// this slot is considered private because its API hasn't been decided
|
| 360 |
+
#define _NPY_DT_is_known_scalar_type 2
|
| 361 |
+
#define NPY_DT_default_descr 3
|
| 362 |
+
#define NPY_DT_common_dtype 4
|
| 363 |
+
#define NPY_DT_common_instance 5
|
| 364 |
+
#define NPY_DT_ensure_canonical 6
|
| 365 |
+
#define NPY_DT_setitem 7
|
| 366 |
+
#define NPY_DT_getitem 8
|
| 367 |
+
#define NPY_DT_get_clear_loop 9
|
| 368 |
+
#define NPY_DT_get_fill_zero_loop 10
|
| 369 |
+
#define NPY_DT_finalize_descr 11
|
| 370 |
+
|
| 371 |
+
// These PyArray_ArrFunc slots will be deprecated and replaced eventually
|
| 372 |
+
// getitem and setitem can be defined as a performance optimization;
|
| 373 |
+
// by default the user dtypes call `legacy_getitem_using_DType` and
|
| 374 |
+
// `legacy_setitem_using_DType`, respectively. This functionality is
|
| 375 |
+
// only supported for basic NumPy DTypes.
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
// used to separate dtype slots from arrfuncs slots
|
| 379 |
+
// intended only for internal use but defined here for clarity
|
| 380 |
+
#define _NPY_DT_ARRFUNCS_OFFSET (1 << 10)
|
| 381 |
+
|
| 382 |
+
// Cast is disabled
|
| 383 |
+
// #define NPY_DT_PyArray_ArrFuncs_cast 0 + _NPY_DT_ARRFUNCS_OFFSET
|
| 384 |
+
|
| 385 |
+
#define NPY_DT_PyArray_ArrFuncs_getitem 1 + _NPY_DT_ARRFUNCS_OFFSET
|
| 386 |
+
#define NPY_DT_PyArray_ArrFuncs_setitem 2 + _NPY_DT_ARRFUNCS_OFFSET
|
| 387 |
+
|
| 388 |
+
// Copyswap is disabled
|
| 389 |
+
// #define NPY_DT_PyArray_ArrFuncs_copyswapn 3 + _NPY_DT_ARRFUNCS_OFFSET
|
| 390 |
+
// #define NPY_DT_PyArray_ArrFuncs_copyswap 4 + _NPY_DT_ARRFUNCS_OFFSET
|
| 391 |
+
#define NPY_DT_PyArray_ArrFuncs_compare 5 + _NPY_DT_ARRFUNCS_OFFSET
|
| 392 |
+
#define NPY_DT_PyArray_ArrFuncs_argmax 6 + _NPY_DT_ARRFUNCS_OFFSET
|
| 393 |
+
#define NPY_DT_PyArray_ArrFuncs_dotfunc 7 + _NPY_DT_ARRFUNCS_OFFSET
|
| 394 |
+
#define NPY_DT_PyArray_ArrFuncs_scanfunc 8 + _NPY_DT_ARRFUNCS_OFFSET
|
| 395 |
+
#define NPY_DT_PyArray_ArrFuncs_fromstr 9 + _NPY_DT_ARRFUNCS_OFFSET
|
| 396 |
+
#define NPY_DT_PyArray_ArrFuncs_nonzero 10 + _NPY_DT_ARRFUNCS_OFFSET
|
| 397 |
+
#define NPY_DT_PyArray_ArrFuncs_fill 11 + _NPY_DT_ARRFUNCS_OFFSET
|
| 398 |
+
#define NPY_DT_PyArray_ArrFuncs_fillwithscalar 12 + _NPY_DT_ARRFUNCS_OFFSET
|
| 399 |
+
#define NPY_DT_PyArray_ArrFuncs_sort 13 + _NPY_DT_ARRFUNCS_OFFSET
|
| 400 |
+
#define NPY_DT_PyArray_ArrFuncs_argsort 14 + _NPY_DT_ARRFUNCS_OFFSET
|
| 401 |
+
|
| 402 |
+
// Casting related slots are disabled. See
|
| 403 |
+
// https://github.com/numpy/numpy/pull/23173#discussion_r1101098163
|
| 404 |
+
// #define NPY_DT_PyArray_ArrFuncs_castdict 15 + _NPY_DT_ARRFUNCS_OFFSET
|
| 405 |
+
// #define NPY_DT_PyArray_ArrFuncs_scalarkind 16 + _NPY_DT_ARRFUNCS_OFFSET
|
| 406 |
+
// #define NPY_DT_PyArray_ArrFuncs_cancastscalarkindto 17 + _NPY_DT_ARRFUNCS_OFFSET
|
| 407 |
+
// #define NPY_DT_PyArray_ArrFuncs_cancastto 18 + _NPY_DT_ARRFUNCS_OFFSET
|
| 408 |
+
|
| 409 |
+
// These are deprecated in NumPy 1.19, so are disabled here.
|
| 410 |
+
// #define NPY_DT_PyArray_ArrFuncs_fastclip 19 + _NPY_DT_ARRFUNCS_OFFSET
|
| 411 |
+
// #define NPY_DT_PyArray_ArrFuncs_fastputmask 20 + _NPY_DT_ARRFUNCS_OFFSET
|
| 412 |
+
// #define NPY_DT_PyArray_ArrFuncs_fasttake 21 + _NPY_DT_ARRFUNCS_OFFSET
|
| 413 |
+
#define NPY_DT_PyArray_ArrFuncs_argmin 22 + _NPY_DT_ARRFUNCS_OFFSET
|
| 414 |
+
|
| 415 |
+
|
| 416 |
+
// TODO: These slots probably still need some thought, and/or a way to "grow"?
|
| 417 |
+
typedef struct {
|
| 418 |
+
PyTypeObject *typeobj; /* type of python scalar or NULL */
|
| 419 |
+
int flags; /* flags, including parametric and abstract */
|
| 420 |
+
/* NULL terminated cast definitions. Use NULL for the newly created DType */
|
| 421 |
+
PyArrayMethod_Spec **casts;
|
| 422 |
+
PyType_Slot *slots;
|
| 423 |
+
/* Baseclass or NULL (will always subclass `np.dtype`) */
|
| 424 |
+
PyTypeObject *baseclass;
|
| 425 |
+
} PyArrayDTypeMeta_Spec;
|
| 426 |
+
|
| 427 |
+
|
| 428 |
+
typedef PyArray_Descr *(PyArrayDTypeMeta_DiscoverDescrFromPyobject)(
|
| 429 |
+
PyArray_DTypeMeta *cls, PyObject *obj);
|
| 430 |
+
|
| 431 |
+
/*
|
| 432 |
+
* Before making this public, we should decide whether it should pass
|
| 433 |
+
* the type, or allow looking at the object. A possible use-case:
|
| 434 |
+
* `np.array(np.array([0]), dtype=np.ndarray)`
|
| 435 |
+
* Could consider arrays that are not `dtype=ndarray` "scalars".
|
| 436 |
+
*/
|
| 437 |
+
typedef int (PyArrayDTypeMeta_IsKnownScalarType)(
|
| 438 |
+
PyArray_DTypeMeta *cls, PyTypeObject *obj);
|
| 439 |
+
|
| 440 |
+
typedef PyArray_Descr *(PyArrayDTypeMeta_DefaultDescriptor)(PyArray_DTypeMeta *cls);
|
| 441 |
+
typedef PyArray_DTypeMeta *(PyArrayDTypeMeta_CommonDType)(
|
| 442 |
+
PyArray_DTypeMeta *dtype1, PyArray_DTypeMeta *dtype2);
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
/*
|
| 446 |
+
* Convenience utility for getting a reference to the DType metaclass associated
|
| 447 |
+
* with a dtype instance.
|
| 448 |
+
*/
|
| 449 |
+
#define NPY_DTYPE(descr) ((PyArray_DTypeMeta *)Py_TYPE(descr))
|
| 450 |
+
|
| 451 |
+
static inline PyArray_DTypeMeta *
|
| 452 |
+
NPY_DT_NewRef(PyArray_DTypeMeta *o) {
|
| 453 |
+
Py_INCREF((PyObject *)o);
|
| 454 |
+
return o;
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
typedef PyArray_Descr *(PyArrayDTypeMeta_CommonInstance)(
|
| 459 |
+
PyArray_Descr *dtype1, PyArray_Descr *dtype2);
|
| 460 |
+
typedef PyArray_Descr *(PyArrayDTypeMeta_EnsureCanonical)(PyArray_Descr *dtype);
|
| 461 |
+
/*
|
| 462 |
+
* Returns either a new reference to *dtype* or a new descriptor instance
|
| 463 |
+
* initialized with the same parameters as *dtype*. The caller cannot know
|
| 464 |
+
* which choice a dtype will make. This function is called just before the
|
| 465 |
+
* array buffer is created for a newly created array, it is not called for
|
| 466 |
+
* views and the descriptor returned by this function is attached to the array.
|
| 467 |
+
*/
|
| 468 |
+
typedef PyArray_Descr *(PyArrayDTypeMeta_FinalizeDescriptor)(PyArray_Descr *dtype);
|
| 469 |
+
|
| 470 |
+
/*
|
| 471 |
+
* TODO: These two functions are currently only used for experimental DType
|
| 472 |
+
* API support. Their relation should be "reversed": NumPy should
|
| 473 |
+
* always use them internally.
|
| 474 |
+
* There are open points about "casting safety" though, e.g. setting
|
| 475 |
+
* elements is currently always unsafe.
|
| 476 |
+
*/
|
| 477 |
+
typedef int(PyArrayDTypeMeta_SetItem)(PyArray_Descr *, PyObject *, char *);
|
| 478 |
+
typedef PyObject *(PyArrayDTypeMeta_GetItem)(PyArray_Descr *, char *);
|
| 479 |
+
|
| 480 |
+
#endif /* NUMPY_CORE_INCLUDE_NUMPY___DTYPE_API_H_ */
|