ADAPT-Chase commited on
Commit
ae9b958
·
verified ·
1 Parent(s): a8ec851

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +28 -0
  2. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/__config__.cpython-312.pyc +0 -0
  3. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/__init__.cpython-312.pyc +0 -0
  4. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_distributor_init.cpython-312.pyc +0 -0
  5. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_globals.cpython-312.pyc +0 -0
  6. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_pytesttester.cpython-312.pyc +0 -0
  7. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/conftest.cpython-312.pyc +0 -0
  8. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/ctypeslib.cpython-312.pyc +0 -0
  9. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/dtypes.cpython-312.pyc +0 -0
  10. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/exceptions.cpython-312.pyc +0 -0
  11. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/matlib.cpython-312.pyc +0 -0
  12. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/version.cpython-312.pyc +0 -0
  13. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/__init__.py +0 -0
  14. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/hook-numpy.py +37 -0
  15. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/pyinstaller-smoke.py +32 -0
  16. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/test_pyinstaller.py +35 -0
  17. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/__init__.py +221 -0
  18. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_add_docstring.py +152 -0
  19. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_array_like.py +167 -0
  20. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_callable.pyi +338 -0
  21. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_char_codes.py +111 -0
  22. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_dtype_like.py +246 -0
  23. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_extended_precision.py +27 -0
  24. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_nbit.py +16 -0
  25. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_nested_sequence.py +86 -0
  26. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_scalars.py +30 -0
  27. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_shape.py +7 -0
  28. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_ufunc.pyi +445 -0
  29. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/setup.py +10 -0
  30. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__init__.py +29 -0
  31. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/__init__.cpython-312.pyc +0 -0
  32. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_convertions.cpython-312.pyc +0 -0
  33. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_inspect.cpython-312.pyc +0 -0
  34. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_pep440.cpython-312.pyc +0 -0
  35. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_convertions.py +18 -0
  36. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_inspect.py +191 -0
  37. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_pep440.py +487 -0
  38. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/__init__.py +387 -0
  39. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_array_object.py +1129 -0
  40. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_constants.py +6 -0
  41. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_creation_functions.py +351 -0
  42. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_data_type_functions.py +197 -0
  43. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_dtypes.py +180 -0
  44. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_elementwise_functions.py +765 -0
  45. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_indexing_functions.py +20 -0
  46. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_manipulation_functions.py +112 -0
  47. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_searching_functions.py +51 -0
  48. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_set_functions.py +106 -0
  49. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_sorting_functions.py +54 -0
  50. platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_statistical_functions.py +122 -0
.gitattributes CHANGED
@@ -3301,3 +3301,31 @@ platform/dataops/dto/.venv/lib/python3.12/site-packages/pip/_vendor/rich/__pycac
3301
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pip/_vendor/rich/__pycache__/console.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3302
  platform/dataops/dto/.venv/lib/python3.12/site-packages/regex/__pycache__/_regex_core.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3303
  platform/dataops/dto/.venv/lib/python3.12/site-packages/regex/__pycache__/test_regex.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3301
  platform/dataops/dto/.venv/lib/python3.12/site-packages/pip/_vendor/rich/__pycache__/console.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3302
  platform/dataops/dto/.venv/lib/python3.12/site-packages/regex/__pycache__/_regex_core.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3303
  platform/dataops/dto/.venv/lib/python3.12/site-packages/regex/__pycache__/test_regex.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3304
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pygments/lexers/__pycache__/lisp.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3305
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pycparser/__pycache__/yacctab.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3306
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/pycparser/ply/__pycache__/yacc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3307
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_philox.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3308
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/mtrand.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3309
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/bit_generator.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3310
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_common.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3311
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_pcg64.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3312
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_mt19937.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3313
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_generator.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3314
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/_bounded_integers.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3315
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/_multiarray_umath.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3316
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/_simd.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3317
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/_multiarray_tests.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3318
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/linalg/_umath_linalg.cpython-312-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
3319
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/tests/__pycache__/test_generator_mt19937.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3320
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/tests/__pycache__/test_random.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3321
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/random/tests/__pycache__/test_randomstate.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3322
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/__pycache__/_add_newdocs.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3323
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/__pycache__/fromnumeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3324
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_regression.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3325
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_datetime.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3326
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_dtype.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3327
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_ufunc.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3328
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_umath.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3329
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_multiarray.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3330
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_nditer.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
3331
+ platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/core/tests/__pycache__/test_numeric.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/__config__.cpython-312.pyc ADDED
Binary file (4.69 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (15 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_distributor_init.cpython-312.pyc ADDED
Binary file (537 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_globals.cpython-312.pyc ADDED
Binary file (3.9 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/_pytesttester.cpython-312.pyc ADDED
Binary file (7.09 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/conftest.cpython-312.pyc ADDED
Binary file (5.78 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/ctypeslib.cpython-312.pyc ADDED
Binary file (20.3 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/dtypes.cpython-312.pyc ADDED
Binary file (2.53 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/exceptions.cpython-312.pyc ADDED
Binary file (8.2 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/matlib.cpython-312.pyc ADDED
Binary file (11.8 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/__pycache__/version.cpython-312.pyc ADDED
Binary file (459 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/__init__.py ADDED
File without changes
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/hook-numpy.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """This hook should collect all binary files and any hidden modules that numpy
2
+ needs.
3
+
4
+ Our (some-what inadequate) docs for writing PyInstaller hooks are kept here:
5
+ https://pyinstaller.readthedocs.io/en/stable/hooks.html
6
+
7
+ """
8
+ from PyInstaller.compat import is_conda, is_pure_conda
9
+ from PyInstaller.utils.hooks import collect_dynamic_libs, is_module_satisfies
10
+
11
+ # Collect all DLLs inside numpy's installation folder, dump them into built
12
+ # app's root.
13
+ binaries = collect_dynamic_libs("numpy", ".")
14
+
15
+ # If using Conda without any non-conda virtual environment manager:
16
+ if is_pure_conda:
17
+ # Assume running the NumPy from Conda-forge and collect it's DLLs from the
18
+ # communal Conda bin directory. DLLs from NumPy's dependencies must also be
19
+ # collected to capture MKL, OpenBlas, OpenMP, etc.
20
+ from PyInstaller.utils.hooks import conda_support
21
+ datas = conda_support.collect_dynamic_libs("numpy", dependencies=True)
22
+
23
+ # Submodules PyInstaller cannot detect. `_dtype_ctypes` is only imported
24
+ # from C and `_multiarray_tests` is used in tests (which are not packed).
25
+ hiddenimports = ['numpy.core._dtype_ctypes', 'numpy.core._multiarray_tests']
26
+
27
+ # Remove testing and building code and packages that are referenced throughout
28
+ # NumPy but are not really dependencies.
29
+ excludedimports = [
30
+ "scipy",
31
+ "pytest",
32
+ "f2py",
33
+ "setuptools",
34
+ "numpy.f2py",
35
+ "distutils",
36
+ "numpy.distutils",
37
+ ]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/pyinstaller-smoke.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A crude *bit of everything* smoke test to verify PyInstaller compatibility.
2
+
3
+ PyInstaller typically goes wrong by forgetting to package modules, extension
4
+ modules or shared libraries. This script should aim to touch as many of those
5
+ as possible in an attempt to trip a ModuleNotFoundError or a DLL load failure
6
+ due to an uncollected resource. Missing resources are unlikely to lead to
7
+ arithmetic errors so there's generally no need to verify any calculation's
8
+ output - merely that it made it to the end OK. This script should not
9
+ explicitly import any of numpy's submodules as that gives PyInstaller undue
10
+ hints that those submodules exist and should be collected (accessing implicitly
11
+ loaded submodules is OK).
12
+
13
+ """
14
+ import numpy as np
15
+
16
+ a = np.arange(1., 10.).reshape((3, 3)) % 5
17
+ np.linalg.det(a)
18
+ a @ a
19
+ a @ a.T
20
+ np.linalg.inv(a)
21
+ np.sin(np.exp(a))
22
+ np.linalg.svd(a)
23
+ np.linalg.eigh(a)
24
+
25
+ np.unique(np.random.randint(0, 10, 100))
26
+ np.sort(np.random.uniform(0, 10, 100))
27
+
28
+ np.fft.fft(np.exp(2j * np.pi * np.arange(8) / 8))
29
+ np.ma.masked_array(np.arange(10), np.random.rand(10) < .5).sum()
30
+ np.polynomial.Legendre([7, 8, 9]).roots()
31
+
32
+ print("I made it!")
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_pyinstaller/test_pyinstaller.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ from pathlib import Path
3
+
4
+ import pytest
5
+
6
+
7
+ # PyInstaller has been very unproactive about replacing 'imp' with 'importlib'.
8
+ @pytest.mark.filterwarnings('ignore::DeprecationWarning')
9
+ # It also leaks io.BytesIO()s.
10
+ @pytest.mark.filterwarnings('ignore::ResourceWarning')
11
+ @pytest.mark.parametrize("mode", ["--onedir", "--onefile"])
12
+ @pytest.mark.slow
13
+ def test_pyinstaller(mode, tmp_path):
14
+ """Compile and run pyinstaller-smoke.py using PyInstaller."""
15
+
16
+ pyinstaller_cli = pytest.importorskip("PyInstaller.__main__").run
17
+
18
+ source = Path(__file__).with_name("pyinstaller-smoke.py").resolve()
19
+ args = [
20
+ # Place all generated files in ``tmp_path``.
21
+ '--workpath', str(tmp_path / "build"),
22
+ '--distpath', str(tmp_path / "dist"),
23
+ '--specpath', str(tmp_path),
24
+ mode,
25
+ str(source),
26
+ ]
27
+ pyinstaller_cli(args)
28
+
29
+ if mode == "--onefile":
30
+ exe = tmp_path / "dist" / source.stem
31
+ else:
32
+ exe = tmp_path / "dist" / source.stem / source.stem
33
+
34
+ p = subprocess.run([str(exe)], check=True, stdout=subprocess.PIPE)
35
+ assert p.stdout.strip() == b"I made it!"
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/__init__.py ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Private counterpart of ``numpy.typing``."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from .. import ufunc
6
+ from .._utils import set_module
7
+ from typing import TYPE_CHECKING, final
8
+
9
+
10
+ @final # Disallow the creation of arbitrary `NBitBase` subclasses
11
+ @set_module("numpy.typing")
12
+ class NBitBase:
13
+ """
14
+ A type representing `numpy.number` precision during static type checking.
15
+
16
+ Used exclusively for the purpose static type checking, `NBitBase`
17
+ represents the base of a hierarchical set of subclasses.
18
+ Each subsequent subclass is herein used for representing a lower level
19
+ of precision, *e.g.* ``64Bit > 32Bit > 16Bit``.
20
+
21
+ .. versionadded:: 1.20
22
+
23
+ Examples
24
+ --------
25
+ Below is a typical usage example: `NBitBase` is herein used for annotating
26
+ a function that takes a float and integer of arbitrary precision
27
+ as arguments and returns a new float of whichever precision is largest
28
+ (*e.g.* ``np.float16 + np.int64 -> np.float64``).
29
+
30
+ .. code-block:: python
31
+
32
+ >>> from __future__ import annotations
33
+ >>> from typing import TypeVar, TYPE_CHECKING
34
+ >>> import numpy as np
35
+ >>> import numpy.typing as npt
36
+
37
+ >>> T1 = TypeVar("T1", bound=npt.NBitBase)
38
+ >>> T2 = TypeVar("T2", bound=npt.NBitBase)
39
+
40
+ >>> def add(a: np.floating[T1], b: np.integer[T2]) -> np.floating[T1 | T2]:
41
+ ... return a + b
42
+
43
+ >>> a = np.float16()
44
+ >>> b = np.int64()
45
+ >>> out = add(a, b)
46
+
47
+ >>> if TYPE_CHECKING:
48
+ ... reveal_locals()
49
+ ... # note: Revealed local types are:
50
+ ... # note: a: numpy.floating[numpy.typing._16Bit*]
51
+ ... # note: b: numpy.signedinteger[numpy.typing._64Bit*]
52
+ ... # note: out: numpy.floating[numpy.typing._64Bit*]
53
+
54
+ """
55
+
56
+ def __init_subclass__(cls) -> None:
57
+ allowed_names = {
58
+ "NBitBase", "_256Bit", "_128Bit", "_96Bit", "_80Bit",
59
+ "_64Bit", "_32Bit", "_16Bit", "_8Bit",
60
+ }
61
+ if cls.__name__ not in allowed_names:
62
+ raise TypeError('cannot inherit from final class "NBitBase"')
63
+ super().__init_subclass__()
64
+
65
+
66
+ # Silence errors about subclassing a `@final`-decorated class
67
+ class _256Bit(NBitBase): # type: ignore[misc]
68
+ pass
69
+
70
+ class _128Bit(_256Bit): # type: ignore[misc]
71
+ pass
72
+
73
+ class _96Bit(_128Bit): # type: ignore[misc]
74
+ pass
75
+
76
+ class _80Bit(_96Bit): # type: ignore[misc]
77
+ pass
78
+
79
+ class _64Bit(_80Bit): # type: ignore[misc]
80
+ pass
81
+
82
+ class _32Bit(_64Bit): # type: ignore[misc]
83
+ pass
84
+
85
+ class _16Bit(_32Bit): # type: ignore[misc]
86
+ pass
87
+
88
+ class _8Bit(_16Bit): # type: ignore[misc]
89
+ pass
90
+
91
+
92
+ from ._nested_sequence import (
93
+ _NestedSequence as _NestedSequence,
94
+ )
95
+ from ._nbit import (
96
+ _NBitByte as _NBitByte,
97
+ _NBitShort as _NBitShort,
98
+ _NBitIntC as _NBitIntC,
99
+ _NBitIntP as _NBitIntP,
100
+ _NBitInt as _NBitInt,
101
+ _NBitLongLong as _NBitLongLong,
102
+ _NBitHalf as _NBitHalf,
103
+ _NBitSingle as _NBitSingle,
104
+ _NBitDouble as _NBitDouble,
105
+ _NBitLongDouble as _NBitLongDouble,
106
+ )
107
+ from ._char_codes import (
108
+ _BoolCodes as _BoolCodes,
109
+ _UInt8Codes as _UInt8Codes,
110
+ _UInt16Codes as _UInt16Codes,
111
+ _UInt32Codes as _UInt32Codes,
112
+ _UInt64Codes as _UInt64Codes,
113
+ _Int8Codes as _Int8Codes,
114
+ _Int16Codes as _Int16Codes,
115
+ _Int32Codes as _Int32Codes,
116
+ _Int64Codes as _Int64Codes,
117
+ _Float16Codes as _Float16Codes,
118
+ _Float32Codes as _Float32Codes,
119
+ _Float64Codes as _Float64Codes,
120
+ _Complex64Codes as _Complex64Codes,
121
+ _Complex128Codes as _Complex128Codes,
122
+ _ByteCodes as _ByteCodes,
123
+ _ShortCodes as _ShortCodes,
124
+ _IntCCodes as _IntCCodes,
125
+ _IntPCodes as _IntPCodes,
126
+ _IntCodes as _IntCodes,
127
+ _LongLongCodes as _LongLongCodes,
128
+ _UByteCodes as _UByteCodes,
129
+ _UShortCodes as _UShortCodes,
130
+ _UIntCCodes as _UIntCCodes,
131
+ _UIntPCodes as _UIntPCodes,
132
+ _UIntCodes as _UIntCodes,
133
+ _ULongLongCodes as _ULongLongCodes,
134
+ _HalfCodes as _HalfCodes,
135
+ _SingleCodes as _SingleCodes,
136
+ _DoubleCodes as _DoubleCodes,
137
+ _LongDoubleCodes as _LongDoubleCodes,
138
+ _CSingleCodes as _CSingleCodes,
139
+ _CDoubleCodes as _CDoubleCodes,
140
+ _CLongDoubleCodes as _CLongDoubleCodes,
141
+ _DT64Codes as _DT64Codes,
142
+ _TD64Codes as _TD64Codes,
143
+ _StrCodes as _StrCodes,
144
+ _BytesCodes as _BytesCodes,
145
+ _VoidCodes as _VoidCodes,
146
+ _ObjectCodes as _ObjectCodes,
147
+ )
148
+ from ._scalars import (
149
+ _CharLike_co as _CharLike_co,
150
+ _BoolLike_co as _BoolLike_co,
151
+ _UIntLike_co as _UIntLike_co,
152
+ _IntLike_co as _IntLike_co,
153
+ _FloatLike_co as _FloatLike_co,
154
+ _ComplexLike_co as _ComplexLike_co,
155
+ _TD64Like_co as _TD64Like_co,
156
+ _NumberLike_co as _NumberLike_co,
157
+ _ScalarLike_co as _ScalarLike_co,
158
+ _VoidLike_co as _VoidLike_co,
159
+ )
160
+ from ._shape import (
161
+ _Shape as _Shape,
162
+ _ShapeLike as _ShapeLike,
163
+ )
164
+ from ._dtype_like import (
165
+ DTypeLike as DTypeLike,
166
+ _DTypeLike as _DTypeLike,
167
+ _SupportsDType as _SupportsDType,
168
+ _VoidDTypeLike as _VoidDTypeLike,
169
+ _DTypeLikeBool as _DTypeLikeBool,
170
+ _DTypeLikeUInt as _DTypeLikeUInt,
171
+ _DTypeLikeInt as _DTypeLikeInt,
172
+ _DTypeLikeFloat as _DTypeLikeFloat,
173
+ _DTypeLikeComplex as _DTypeLikeComplex,
174
+ _DTypeLikeTD64 as _DTypeLikeTD64,
175
+ _DTypeLikeDT64 as _DTypeLikeDT64,
176
+ _DTypeLikeObject as _DTypeLikeObject,
177
+ _DTypeLikeVoid as _DTypeLikeVoid,
178
+ _DTypeLikeStr as _DTypeLikeStr,
179
+ _DTypeLikeBytes as _DTypeLikeBytes,
180
+ _DTypeLikeComplex_co as _DTypeLikeComplex_co,
181
+ )
182
+ from ._array_like import (
183
+ NDArray as NDArray,
184
+ ArrayLike as ArrayLike,
185
+ _ArrayLike as _ArrayLike,
186
+ _FiniteNestedSequence as _FiniteNestedSequence,
187
+ _SupportsArray as _SupportsArray,
188
+ _SupportsArrayFunc as _SupportsArrayFunc,
189
+ _ArrayLikeInt as _ArrayLikeInt,
190
+ _ArrayLikeBool_co as _ArrayLikeBool_co,
191
+ _ArrayLikeUInt_co as _ArrayLikeUInt_co,
192
+ _ArrayLikeInt_co as _ArrayLikeInt_co,
193
+ _ArrayLikeFloat_co as _ArrayLikeFloat_co,
194
+ _ArrayLikeComplex_co as _ArrayLikeComplex_co,
195
+ _ArrayLikeNumber_co as _ArrayLikeNumber_co,
196
+ _ArrayLikeTD64_co as _ArrayLikeTD64_co,
197
+ _ArrayLikeDT64_co as _ArrayLikeDT64_co,
198
+ _ArrayLikeObject_co as _ArrayLikeObject_co,
199
+ _ArrayLikeVoid_co as _ArrayLikeVoid_co,
200
+ _ArrayLikeStr_co as _ArrayLikeStr_co,
201
+ _ArrayLikeBytes_co as _ArrayLikeBytes_co,
202
+ _ArrayLikeUnknown as _ArrayLikeUnknown,
203
+ _UnknownType as _UnknownType,
204
+ )
205
+
206
+ if TYPE_CHECKING:
207
+ from ._ufunc import (
208
+ _UFunc_Nin1_Nout1 as _UFunc_Nin1_Nout1,
209
+ _UFunc_Nin2_Nout1 as _UFunc_Nin2_Nout1,
210
+ _UFunc_Nin1_Nout2 as _UFunc_Nin1_Nout2,
211
+ _UFunc_Nin2_Nout2 as _UFunc_Nin2_Nout2,
212
+ _GUFunc_Nin2_Nout1 as _GUFunc_Nin2_Nout1,
213
+ )
214
+ else:
215
+ # Declare the (type-check-only) ufunc subclasses as ufunc aliases during
216
+ # runtime; this helps autocompletion tools such as Jedi (numpy/numpy#19834)
217
+ _UFunc_Nin1_Nout1 = ufunc
218
+ _UFunc_Nin2_Nout1 = ufunc
219
+ _UFunc_Nin1_Nout2 = ufunc
220
+ _UFunc_Nin2_Nout2 = ufunc
221
+ _GUFunc_Nin2_Nout1 = ufunc
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_add_docstring.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A module for creating docstrings for sphinx ``data`` domains."""
2
+
3
+ import re
4
+ import textwrap
5
+
6
+ from ._array_like import NDArray
7
+
8
+ _docstrings_list = []
9
+
10
+
11
+ def add_newdoc(name: str, value: str, doc: str) -> None:
12
+ """Append ``_docstrings_list`` with a docstring for `name`.
13
+
14
+ Parameters
15
+ ----------
16
+ name : str
17
+ The name of the object.
18
+ value : str
19
+ A string-representation of the object.
20
+ doc : str
21
+ The docstring of the object.
22
+
23
+ """
24
+ _docstrings_list.append((name, value, doc))
25
+
26
+
27
+ def _parse_docstrings() -> str:
28
+ """Convert all docstrings in ``_docstrings_list`` into a single
29
+ sphinx-legible text block.
30
+
31
+ """
32
+ type_list_ret = []
33
+ for name, value, doc in _docstrings_list:
34
+ s = textwrap.dedent(doc).replace("\n", "\n ")
35
+
36
+ # Replace sections by rubrics
37
+ lines = s.split("\n")
38
+ new_lines = []
39
+ indent = ""
40
+ for line in lines:
41
+ m = re.match(r'^(\s+)[-=]+\s*$', line)
42
+ if m and new_lines:
43
+ prev = textwrap.dedent(new_lines.pop())
44
+ if prev == "Examples":
45
+ indent = ""
46
+ new_lines.append(f'{m.group(1)}.. rubric:: {prev}')
47
+ else:
48
+ indent = 4 * " "
49
+ new_lines.append(f'{m.group(1)}.. admonition:: {prev}')
50
+ new_lines.append("")
51
+ else:
52
+ new_lines.append(f"{indent}{line}")
53
+
54
+ s = "\n".join(new_lines)
55
+ s_block = f""".. data:: {name}\n :value: {value}\n {s}"""
56
+ type_list_ret.append(s_block)
57
+ return "\n".join(type_list_ret)
58
+
59
+
60
+ add_newdoc('ArrayLike', 'typing.Union[...]',
61
+ """
62
+ A `~typing.Union` representing objects that can be coerced
63
+ into an `~numpy.ndarray`.
64
+
65
+ Among others this includes the likes of:
66
+
67
+ * Scalars.
68
+ * (Nested) sequences.
69
+ * Objects implementing the `~class.__array__` protocol.
70
+
71
+ .. versionadded:: 1.20
72
+
73
+ See Also
74
+ --------
75
+ :term:`array_like`:
76
+ Any scalar or sequence that can be interpreted as an ndarray.
77
+
78
+ Examples
79
+ --------
80
+ .. code-block:: python
81
+
82
+ >>> import numpy as np
83
+ >>> import numpy.typing as npt
84
+
85
+ >>> def as_array(a: npt.ArrayLike) -> np.ndarray:
86
+ ... return np.array(a)
87
+
88
+ """)
89
+
90
+ add_newdoc('DTypeLike', 'typing.Union[...]',
91
+ """
92
+ A `~typing.Union` representing objects that can be coerced
93
+ into a `~numpy.dtype`.
94
+
95
+ Among others this includes the likes of:
96
+
97
+ * :class:`type` objects.
98
+ * Character codes or the names of :class:`type` objects.
99
+ * Objects with the ``.dtype`` attribute.
100
+
101
+ .. versionadded:: 1.20
102
+
103
+ See Also
104
+ --------
105
+ :ref:`Specifying and constructing data types <arrays.dtypes.constructing>`
106
+ A comprehensive overview of all objects that can be coerced
107
+ into data types.
108
+
109
+ Examples
110
+ --------
111
+ .. code-block:: python
112
+
113
+ >>> import numpy as np
114
+ >>> import numpy.typing as npt
115
+
116
+ >>> def as_dtype(d: npt.DTypeLike) -> np.dtype:
117
+ ... return np.dtype(d)
118
+
119
+ """)
120
+
121
+ add_newdoc('NDArray', repr(NDArray),
122
+ """
123
+ A :term:`generic <generic type>` version of
124
+ `np.ndarray[Any, np.dtype[+ScalarType]] <numpy.ndarray>`.
125
+
126
+ Can be used during runtime for typing arrays with a given dtype
127
+ and unspecified shape.
128
+
129
+ .. versionadded:: 1.21
130
+
131
+ Examples
132
+ --------
133
+ .. code-block:: python
134
+
135
+ >>> import numpy as np
136
+ >>> import numpy.typing as npt
137
+
138
+ >>> print(npt.NDArray)
139
+ numpy.ndarray[typing.Any, numpy.dtype[+ScalarType]]
140
+
141
+ >>> print(npt.NDArray[np.float64])
142
+ numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]
143
+
144
+ >>> NDArrayInt = npt.NDArray[np.int_]
145
+ >>> a: NDArrayInt = np.arange(10)
146
+
147
+ >>> def func(a: npt.ArrayLike) -> npt.NDArray[Any]:
148
+ ... return np.array(a)
149
+
150
+ """)
151
+
152
+ _docstrings = _parse_docstrings()
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_array_like.py ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import sys
4
+ from collections.abc import Collection, Callable, Sequence
5
+ from typing import Any, Protocol, Union, TypeVar, runtime_checkable
6
+
7
+ from numpy import (
8
+ ndarray,
9
+ dtype,
10
+ generic,
11
+ bool_,
12
+ unsignedinteger,
13
+ integer,
14
+ floating,
15
+ complexfloating,
16
+ number,
17
+ timedelta64,
18
+ datetime64,
19
+ object_,
20
+ void,
21
+ str_,
22
+ bytes_,
23
+ )
24
+ from ._nested_sequence import _NestedSequence
25
+
26
+ _T = TypeVar("_T")
27
+ _ScalarType = TypeVar("_ScalarType", bound=generic)
28
+ _ScalarType_co = TypeVar("_ScalarType_co", bound=generic, covariant=True)
29
+ _DType = TypeVar("_DType", bound=dtype[Any])
30
+ _DType_co = TypeVar("_DType_co", covariant=True, bound=dtype[Any])
31
+
32
+ NDArray = ndarray[Any, dtype[_ScalarType_co]]
33
+
34
+ # The `_SupportsArray` protocol only cares about the default dtype
35
+ # (i.e. `dtype=None` or no `dtype` parameter at all) of the to-be returned
36
+ # array.
37
+ # Concrete implementations of the protocol are responsible for adding
38
+ # any and all remaining overloads
39
+ @runtime_checkable
40
+ class _SupportsArray(Protocol[_DType_co]):
41
+ def __array__(self) -> ndarray[Any, _DType_co]: ...
42
+
43
+
44
+ @runtime_checkable
45
+ class _SupportsArrayFunc(Protocol):
46
+ """A protocol class representing `~class.__array_function__`."""
47
+ def __array_function__(
48
+ self,
49
+ func: Callable[..., Any],
50
+ types: Collection[type[Any]],
51
+ args: tuple[Any, ...],
52
+ kwargs: dict[str, Any],
53
+ ) -> object: ...
54
+
55
+
56
+ # TODO: Wait until mypy supports recursive objects in combination with typevars
57
+ _FiniteNestedSequence = Union[
58
+ _T,
59
+ Sequence[_T],
60
+ Sequence[Sequence[_T]],
61
+ Sequence[Sequence[Sequence[_T]]],
62
+ Sequence[Sequence[Sequence[Sequence[_T]]]],
63
+ ]
64
+
65
+ # A subset of `npt.ArrayLike` that can be parametrized w.r.t. `np.generic`
66
+ _ArrayLike = Union[
67
+ _SupportsArray[dtype[_ScalarType]],
68
+ _NestedSequence[_SupportsArray[dtype[_ScalarType]]],
69
+ ]
70
+
71
+ # A union representing array-like objects; consists of two typevars:
72
+ # One representing types that can be parametrized w.r.t. `np.dtype`
73
+ # and another one for the rest
74
+ _DualArrayLike = Union[
75
+ _SupportsArray[_DType],
76
+ _NestedSequence[_SupportsArray[_DType]],
77
+ _T,
78
+ _NestedSequence[_T],
79
+ ]
80
+
81
+ if sys.version_info >= (3, 12):
82
+ from collections.abc import Buffer
83
+
84
+ ArrayLike = Buffer | _DualArrayLike[
85
+ dtype[Any],
86
+ Union[bool, int, float, complex, str, bytes],
87
+ ]
88
+ else:
89
+ ArrayLike = _DualArrayLike[
90
+ dtype[Any],
91
+ Union[bool, int, float, complex, str, bytes],
92
+ ]
93
+
94
+ # `ArrayLike<X>_co`: array-like objects that can be coerced into `X`
95
+ # given the casting rules `same_kind`
96
+ _ArrayLikeBool_co = _DualArrayLike[
97
+ dtype[bool_],
98
+ bool,
99
+ ]
100
+ _ArrayLikeUInt_co = _DualArrayLike[
101
+ dtype[Union[bool_, unsignedinteger[Any]]],
102
+ bool,
103
+ ]
104
+ _ArrayLikeInt_co = _DualArrayLike[
105
+ dtype[Union[bool_, integer[Any]]],
106
+ Union[bool, int],
107
+ ]
108
+ _ArrayLikeFloat_co = _DualArrayLike[
109
+ dtype[Union[bool_, integer[Any], floating[Any]]],
110
+ Union[bool, int, float],
111
+ ]
112
+ _ArrayLikeComplex_co = _DualArrayLike[
113
+ dtype[Union[
114
+ bool_,
115
+ integer[Any],
116
+ floating[Any],
117
+ complexfloating[Any, Any],
118
+ ]],
119
+ Union[bool, int, float, complex],
120
+ ]
121
+ _ArrayLikeNumber_co = _DualArrayLike[
122
+ dtype[Union[bool_, number[Any]]],
123
+ Union[bool, int, float, complex],
124
+ ]
125
+ _ArrayLikeTD64_co = _DualArrayLike[
126
+ dtype[Union[bool_, integer[Any], timedelta64]],
127
+ Union[bool, int],
128
+ ]
129
+ _ArrayLikeDT64_co = Union[
130
+ _SupportsArray[dtype[datetime64]],
131
+ _NestedSequence[_SupportsArray[dtype[datetime64]]],
132
+ ]
133
+ _ArrayLikeObject_co = Union[
134
+ _SupportsArray[dtype[object_]],
135
+ _NestedSequence[_SupportsArray[dtype[object_]]],
136
+ ]
137
+
138
+ _ArrayLikeVoid_co = Union[
139
+ _SupportsArray[dtype[void]],
140
+ _NestedSequence[_SupportsArray[dtype[void]]],
141
+ ]
142
+ _ArrayLikeStr_co = _DualArrayLike[
143
+ dtype[str_],
144
+ str,
145
+ ]
146
+ _ArrayLikeBytes_co = _DualArrayLike[
147
+ dtype[bytes_],
148
+ bytes,
149
+ ]
150
+
151
+ _ArrayLikeInt = _DualArrayLike[
152
+ dtype[integer[Any]],
153
+ int,
154
+ ]
155
+
156
+ # Extra ArrayLike type so that pyright can deal with NDArray[Any]
157
+ # Used as the first overload, should only match NDArray[Any],
158
+ # not any actual types.
159
+ # https://github.com/numpy/numpy/pull/22193
160
+ class _UnknownType:
161
+ ...
162
+
163
+
164
+ _ArrayLikeUnknown = _DualArrayLike[
165
+ dtype[_UnknownType],
166
+ _UnknownType,
167
+ ]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_callable.pyi ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A module with various ``typing.Protocol`` subclasses that implement
3
+ the ``__call__`` magic method.
4
+
5
+ See the `Mypy documentation`_ on protocols for more details.
6
+
7
+ .. _`Mypy documentation`: https://mypy.readthedocs.io/en/stable/protocols.html#callback-protocols
8
+
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import (
14
+ TypeVar,
15
+ overload,
16
+ Any,
17
+ NoReturn,
18
+ Protocol,
19
+ )
20
+
21
+ from numpy import (
22
+ ndarray,
23
+ dtype,
24
+ generic,
25
+ bool_,
26
+ timedelta64,
27
+ number,
28
+ integer,
29
+ unsignedinteger,
30
+ signedinteger,
31
+ int8,
32
+ int_,
33
+ floating,
34
+ float64,
35
+ complexfloating,
36
+ complex128,
37
+ )
38
+ from ._nbit import _NBitInt, _NBitDouble
39
+ from ._scalars import (
40
+ _BoolLike_co,
41
+ _IntLike_co,
42
+ _FloatLike_co,
43
+ _NumberLike_co,
44
+ )
45
+ from . import NBitBase
46
+ from ._array_like import NDArray
47
+ from ._nested_sequence import _NestedSequence
48
+
49
+ _T1 = TypeVar("_T1")
50
+ _T2 = TypeVar("_T2")
51
+ _T1_contra = TypeVar("_T1_contra", contravariant=True)
52
+ _T2_contra = TypeVar("_T2_contra", contravariant=True)
53
+ _2Tuple = tuple[_T1, _T1]
54
+
55
+ _NBit1 = TypeVar("_NBit1", bound=NBitBase)
56
+ _NBit2 = TypeVar("_NBit2", bound=NBitBase)
57
+
58
+ _IntType = TypeVar("_IntType", bound=integer)
59
+ _FloatType = TypeVar("_FloatType", bound=floating)
60
+ _NumberType = TypeVar("_NumberType", bound=number)
61
+ _NumberType_co = TypeVar("_NumberType_co", covariant=True, bound=number)
62
+ _GenericType_co = TypeVar("_GenericType_co", covariant=True, bound=generic)
63
+
64
+ class _BoolOp(Protocol[_GenericType_co]):
65
+ @overload
66
+ def __call__(self, other: _BoolLike_co, /) -> _GenericType_co: ...
67
+ @overload # platform dependent
68
+ def __call__(self, other: int, /) -> int_: ...
69
+ @overload
70
+ def __call__(self, other: float, /) -> float64: ...
71
+ @overload
72
+ def __call__(self, other: complex, /) -> complex128: ...
73
+ @overload
74
+ def __call__(self, other: _NumberType, /) -> _NumberType: ...
75
+
76
+ class _BoolBitOp(Protocol[_GenericType_co]):
77
+ @overload
78
+ def __call__(self, other: _BoolLike_co, /) -> _GenericType_co: ...
79
+ @overload # platform dependent
80
+ def __call__(self, other: int, /) -> int_: ...
81
+ @overload
82
+ def __call__(self, other: _IntType, /) -> _IntType: ...
83
+
84
+ class _BoolSub(Protocol):
85
+ # Note that `other: bool_` is absent here
86
+ @overload
87
+ def __call__(self, other: bool, /) -> NoReturn: ...
88
+ @overload # platform dependent
89
+ def __call__(self, other: int, /) -> int_: ...
90
+ @overload
91
+ def __call__(self, other: float, /) -> float64: ...
92
+ @overload
93
+ def __call__(self, other: complex, /) -> complex128: ...
94
+ @overload
95
+ def __call__(self, other: _NumberType, /) -> _NumberType: ...
96
+
97
+ class _BoolTrueDiv(Protocol):
98
+ @overload
99
+ def __call__(self, other: float | _IntLike_co, /) -> float64: ...
100
+ @overload
101
+ def __call__(self, other: complex, /) -> complex128: ...
102
+ @overload
103
+ def __call__(self, other: _NumberType, /) -> _NumberType: ...
104
+
105
+ class _BoolMod(Protocol):
106
+ @overload
107
+ def __call__(self, other: _BoolLike_co, /) -> int8: ...
108
+ @overload # platform dependent
109
+ def __call__(self, other: int, /) -> int_: ...
110
+ @overload
111
+ def __call__(self, other: float, /) -> float64: ...
112
+ @overload
113
+ def __call__(self, other: _IntType, /) -> _IntType: ...
114
+ @overload
115
+ def __call__(self, other: _FloatType, /) -> _FloatType: ...
116
+
117
+ class _BoolDivMod(Protocol):
118
+ @overload
119
+ def __call__(self, other: _BoolLike_co, /) -> _2Tuple[int8]: ...
120
+ @overload # platform dependent
121
+ def __call__(self, other: int, /) -> _2Tuple[int_]: ...
122
+ @overload
123
+ def __call__(self, other: float, /) -> _2Tuple[floating[_NBit1 | _NBitDouble]]: ...
124
+ @overload
125
+ def __call__(self, other: _IntType, /) -> _2Tuple[_IntType]: ...
126
+ @overload
127
+ def __call__(self, other: _FloatType, /) -> _2Tuple[_FloatType]: ...
128
+
129
+ class _TD64Div(Protocol[_NumberType_co]):
130
+ @overload
131
+ def __call__(self, other: timedelta64, /) -> _NumberType_co: ...
132
+ @overload
133
+ def __call__(self, other: _BoolLike_co, /) -> NoReturn: ...
134
+ @overload
135
+ def __call__(self, other: _FloatLike_co, /) -> timedelta64: ...
136
+
137
+ class _IntTrueDiv(Protocol[_NBit1]):
138
+ @overload
139
+ def __call__(self, other: bool, /) -> floating[_NBit1]: ...
140
+ @overload
141
+ def __call__(self, other: int, /) -> floating[_NBit1 | _NBitInt]: ...
142
+ @overload
143
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
144
+ @overload
145
+ def __call__(
146
+ self, other: complex, /,
147
+ ) -> complexfloating[_NBit1 | _NBitDouble, _NBit1 | _NBitDouble]: ...
148
+ @overload
149
+ def __call__(self, other: integer[_NBit2], /) -> floating[_NBit1 | _NBit2]: ...
150
+
151
+ class _UnsignedIntOp(Protocol[_NBit1]):
152
+ # NOTE: `uint64 + signedinteger -> float64`
153
+ @overload
154
+ def __call__(self, other: bool, /) -> unsignedinteger[_NBit1]: ...
155
+ @overload
156
+ def __call__(
157
+ self, other: int | signedinteger[Any], /
158
+ ) -> Any: ...
159
+ @overload
160
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
161
+ @overload
162
+ def __call__(
163
+ self, other: complex, /,
164
+ ) -> complexfloating[_NBit1 | _NBitDouble, _NBit1 | _NBitDouble]: ...
165
+ @overload
166
+ def __call__(
167
+ self, other: unsignedinteger[_NBit2], /
168
+ ) -> unsignedinteger[_NBit1 | _NBit2]: ...
169
+
170
+ class _UnsignedIntBitOp(Protocol[_NBit1]):
171
+ @overload
172
+ def __call__(self, other: bool, /) -> unsignedinteger[_NBit1]: ...
173
+ @overload
174
+ def __call__(self, other: int, /) -> signedinteger[Any]: ...
175
+ @overload
176
+ def __call__(self, other: signedinteger[Any], /) -> signedinteger[Any]: ...
177
+ @overload
178
+ def __call__(
179
+ self, other: unsignedinteger[_NBit2], /
180
+ ) -> unsignedinteger[_NBit1 | _NBit2]: ...
181
+
182
+ class _UnsignedIntMod(Protocol[_NBit1]):
183
+ @overload
184
+ def __call__(self, other: bool, /) -> unsignedinteger[_NBit1]: ...
185
+ @overload
186
+ def __call__(
187
+ self, other: int | signedinteger[Any], /
188
+ ) -> Any: ...
189
+ @overload
190
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
191
+ @overload
192
+ def __call__(
193
+ self, other: unsignedinteger[_NBit2], /
194
+ ) -> unsignedinteger[_NBit1 | _NBit2]: ...
195
+
196
+ class _UnsignedIntDivMod(Protocol[_NBit1]):
197
+ @overload
198
+ def __call__(self, other: bool, /) -> _2Tuple[signedinteger[_NBit1]]: ...
199
+ @overload
200
+ def __call__(
201
+ self, other: int | signedinteger[Any], /
202
+ ) -> _2Tuple[Any]: ...
203
+ @overload
204
+ def __call__(self, other: float, /) -> _2Tuple[floating[_NBit1 | _NBitDouble]]: ...
205
+ @overload
206
+ def __call__(
207
+ self, other: unsignedinteger[_NBit2], /
208
+ ) -> _2Tuple[unsignedinteger[_NBit1 | _NBit2]]: ...
209
+
210
+ class _SignedIntOp(Protocol[_NBit1]):
211
+ @overload
212
+ def __call__(self, other: bool, /) -> signedinteger[_NBit1]: ...
213
+ @overload
214
+ def __call__(self, other: int, /) -> signedinteger[_NBit1 | _NBitInt]: ...
215
+ @overload
216
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
217
+ @overload
218
+ def __call__(
219
+ self, other: complex, /,
220
+ ) -> complexfloating[_NBit1 | _NBitDouble, _NBit1 | _NBitDouble]: ...
221
+ @overload
222
+ def __call__(
223
+ self, other: signedinteger[_NBit2], /,
224
+ ) -> signedinteger[_NBit1 | _NBit2]: ...
225
+
226
+ class _SignedIntBitOp(Protocol[_NBit1]):
227
+ @overload
228
+ def __call__(self, other: bool, /) -> signedinteger[_NBit1]: ...
229
+ @overload
230
+ def __call__(self, other: int, /) -> signedinteger[_NBit1 | _NBitInt]: ...
231
+ @overload
232
+ def __call__(
233
+ self, other: signedinteger[_NBit2], /,
234
+ ) -> signedinteger[_NBit1 | _NBit2]: ...
235
+
236
+ class _SignedIntMod(Protocol[_NBit1]):
237
+ @overload
238
+ def __call__(self, other: bool, /) -> signedinteger[_NBit1]: ...
239
+ @overload
240
+ def __call__(self, other: int, /) -> signedinteger[_NBit1 | _NBitInt]: ...
241
+ @overload
242
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
243
+ @overload
244
+ def __call__(
245
+ self, other: signedinteger[_NBit2], /,
246
+ ) -> signedinteger[_NBit1 | _NBit2]: ...
247
+
248
+ class _SignedIntDivMod(Protocol[_NBit1]):
249
+ @overload
250
+ def __call__(self, other: bool, /) -> _2Tuple[signedinteger[_NBit1]]: ...
251
+ @overload
252
+ def __call__(self, other: int, /) -> _2Tuple[signedinteger[_NBit1 | _NBitInt]]: ...
253
+ @overload
254
+ def __call__(self, other: float, /) -> _2Tuple[floating[_NBit1 | _NBitDouble]]: ...
255
+ @overload
256
+ def __call__(
257
+ self, other: signedinteger[_NBit2], /,
258
+ ) -> _2Tuple[signedinteger[_NBit1 | _NBit2]]: ...
259
+
260
+ class _FloatOp(Protocol[_NBit1]):
261
+ @overload
262
+ def __call__(self, other: bool, /) -> floating[_NBit1]: ...
263
+ @overload
264
+ def __call__(self, other: int, /) -> floating[_NBit1 | _NBitInt]: ...
265
+ @overload
266
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
267
+ @overload
268
+ def __call__(
269
+ self, other: complex, /,
270
+ ) -> complexfloating[_NBit1 | _NBitDouble, _NBit1 | _NBitDouble]: ...
271
+ @overload
272
+ def __call__(
273
+ self, other: integer[_NBit2] | floating[_NBit2], /
274
+ ) -> floating[_NBit1 | _NBit2]: ...
275
+
276
+ class _FloatMod(Protocol[_NBit1]):
277
+ @overload
278
+ def __call__(self, other: bool, /) -> floating[_NBit1]: ...
279
+ @overload
280
+ def __call__(self, other: int, /) -> floating[_NBit1 | _NBitInt]: ...
281
+ @overload
282
+ def __call__(self, other: float, /) -> floating[_NBit1 | _NBitDouble]: ...
283
+ @overload
284
+ def __call__(
285
+ self, other: integer[_NBit2] | floating[_NBit2], /
286
+ ) -> floating[_NBit1 | _NBit2]: ...
287
+
288
+ class _FloatDivMod(Protocol[_NBit1]):
289
+ @overload
290
+ def __call__(self, other: bool, /) -> _2Tuple[floating[_NBit1]]: ...
291
+ @overload
292
+ def __call__(self, other: int, /) -> _2Tuple[floating[_NBit1 | _NBitInt]]: ...
293
+ @overload
294
+ def __call__(self, other: float, /) -> _2Tuple[floating[_NBit1 | _NBitDouble]]: ...
295
+ @overload
296
+ def __call__(
297
+ self, other: integer[_NBit2] | floating[_NBit2], /
298
+ ) -> _2Tuple[floating[_NBit1 | _NBit2]]: ...
299
+
300
+ class _ComplexOp(Protocol[_NBit1]):
301
+ @overload
302
+ def __call__(self, other: bool, /) -> complexfloating[_NBit1, _NBit1]: ...
303
+ @overload
304
+ def __call__(self, other: int, /) -> complexfloating[_NBit1 | _NBitInt, _NBit1 | _NBitInt]: ...
305
+ @overload
306
+ def __call__(
307
+ self, other: complex, /,
308
+ ) -> complexfloating[_NBit1 | _NBitDouble, _NBit1 | _NBitDouble]: ...
309
+ @overload
310
+ def __call__(
311
+ self,
312
+ other: (
313
+ integer[_NBit2]
314
+ | floating[_NBit2]
315
+ | complexfloating[_NBit2, _NBit2]
316
+ ), /,
317
+ ) -> complexfloating[_NBit1 | _NBit2, _NBit1 | _NBit2]: ...
318
+
319
+ class _NumberOp(Protocol):
320
+ def __call__(self, other: _NumberLike_co, /) -> Any: ...
321
+
322
+ class _SupportsLT(Protocol):
323
+ def __lt__(self, other: Any, /) -> object: ...
324
+
325
+ class _SupportsGT(Protocol):
326
+ def __gt__(self, other: Any, /) -> object: ...
327
+
328
+ class _ComparisonOp(Protocol[_T1_contra, _T2_contra]):
329
+ @overload
330
+ def __call__(self, other: _T1_contra, /) -> bool_: ...
331
+ @overload
332
+ def __call__(self, other: _T2_contra, /) -> NDArray[bool_]: ...
333
+ @overload
334
+ def __call__(
335
+ self,
336
+ other: _SupportsLT | _SupportsGT | _NestedSequence[_SupportsLT | _SupportsGT],
337
+ /,
338
+ ) -> Any: ...
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_char_codes.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ _BoolCodes = Literal["?", "=?", "<?", ">?", "bool", "bool_", "bool8"]
4
+
5
+ _UInt8Codes = Literal["uint8", "u1", "=u1", "<u1", ">u1"]
6
+ _UInt16Codes = Literal["uint16", "u2", "=u2", "<u2", ">u2"]
7
+ _UInt32Codes = Literal["uint32", "u4", "=u4", "<u4", ">u4"]
8
+ _UInt64Codes = Literal["uint64", "u8", "=u8", "<u8", ">u8"]
9
+
10
+ _Int8Codes = Literal["int8", "i1", "=i1", "<i1", ">i1"]
11
+ _Int16Codes = Literal["int16", "i2", "=i2", "<i2", ">i2"]
12
+ _Int32Codes = Literal["int32", "i4", "=i4", "<i4", ">i4"]
13
+ _Int64Codes = Literal["int64", "i8", "=i8", "<i8", ">i8"]
14
+
15
+ _Float16Codes = Literal["float16", "f2", "=f2", "<f2", ">f2"]
16
+ _Float32Codes = Literal["float32", "f4", "=f4", "<f4", ">f4"]
17
+ _Float64Codes = Literal["float64", "f8", "=f8", "<f8", ">f8"]
18
+
19
+ _Complex64Codes = Literal["complex64", "c8", "=c8", "<c8", ">c8"]
20
+ _Complex128Codes = Literal["complex128", "c16", "=c16", "<c16", ">c16"]
21
+
22
+ _ByteCodes = Literal["byte", "b", "=b", "<b", ">b"]
23
+ _ShortCodes = Literal["short", "h", "=h", "<h", ">h"]
24
+ _IntCCodes = Literal["intc", "i", "=i", "<i", ">i"]
25
+ _IntPCodes = Literal["intp", "int0", "p", "=p", "<p", ">p"]
26
+ _IntCodes = Literal["long", "int", "int_", "l", "=l", "<l", ">l"]
27
+ _LongLongCodes = Literal["longlong", "q", "=q", "<q", ">q"]
28
+
29
+ _UByteCodes = Literal["ubyte", "B", "=B", "<B", ">B"]
30
+ _UShortCodes = Literal["ushort", "H", "=H", "<H", ">H"]
31
+ _UIntCCodes = Literal["uintc", "I", "=I", "<I", ">I"]
32
+ _UIntPCodes = Literal["uintp", "uint0", "P", "=P", "<P", ">P"]
33
+ _UIntCodes = Literal["ulong", "uint", "L", "=L", "<L", ">L"]
34
+ _ULongLongCodes = Literal["ulonglong", "Q", "=Q", "<Q", ">Q"]
35
+
36
+ _HalfCodes = Literal["half", "e", "=e", "<e", ">e"]
37
+ _SingleCodes = Literal["single", "f", "=f", "<f", ">f"]
38
+ _DoubleCodes = Literal["double", "float", "float_", "d", "=d", "<d", ">d"]
39
+ _LongDoubleCodes = Literal["longdouble", "longfloat", "g", "=g", "<g", ">g"]
40
+
41
+ _CSingleCodes = Literal["csingle", "singlecomplex", "F", "=F", "<F", ">F"]
42
+ _CDoubleCodes = Literal["cdouble", "complex", "complex_", "cfloat", "D", "=D", "<D", ">D"]
43
+ _CLongDoubleCodes = Literal["clongdouble", "clongfloat", "longcomplex", "G", "=G", "<G", ">G"]
44
+
45
+ _StrCodes = Literal["str", "str_", "str0", "unicode", "unicode_", "U", "=U", "<U", ">U"]
46
+ _BytesCodes = Literal["bytes", "bytes_", "bytes0", "S", "=S", "<S", ">S"]
47
+ _VoidCodes = Literal["void", "void0", "V", "=V", "<V", ">V"]
48
+ _ObjectCodes = Literal["object", "object_", "O", "=O", "<O", ">O"]
49
+
50
+ _DT64Codes = Literal[
51
+ "datetime64", "=datetime64", "<datetime64", ">datetime64",
52
+ "datetime64[Y]", "=datetime64[Y]", "<datetime64[Y]", ">datetime64[Y]",
53
+ "datetime64[M]", "=datetime64[M]", "<datetime64[M]", ">datetime64[M]",
54
+ "datetime64[W]", "=datetime64[W]", "<datetime64[W]", ">datetime64[W]",
55
+ "datetime64[D]", "=datetime64[D]", "<datetime64[D]", ">datetime64[D]",
56
+ "datetime64[h]", "=datetime64[h]", "<datetime64[h]", ">datetime64[h]",
57
+ "datetime64[m]", "=datetime64[m]", "<datetime64[m]", ">datetime64[m]",
58
+ "datetime64[s]", "=datetime64[s]", "<datetime64[s]", ">datetime64[s]",
59
+ "datetime64[ms]", "=datetime64[ms]", "<datetime64[ms]", ">datetime64[ms]",
60
+ "datetime64[us]", "=datetime64[us]", "<datetime64[us]", ">datetime64[us]",
61
+ "datetime64[ns]", "=datetime64[ns]", "<datetime64[ns]", ">datetime64[ns]",
62
+ "datetime64[ps]", "=datetime64[ps]", "<datetime64[ps]", ">datetime64[ps]",
63
+ "datetime64[fs]", "=datetime64[fs]", "<datetime64[fs]", ">datetime64[fs]",
64
+ "datetime64[as]", "=datetime64[as]", "<datetime64[as]", ">datetime64[as]",
65
+ "M", "=M", "<M", ">M",
66
+ "M8", "=M8", "<M8", ">M8",
67
+ "M8[Y]", "=M8[Y]", "<M8[Y]", ">M8[Y]",
68
+ "M8[M]", "=M8[M]", "<M8[M]", ">M8[M]",
69
+ "M8[W]", "=M8[W]", "<M8[W]", ">M8[W]",
70
+ "M8[D]", "=M8[D]", "<M8[D]", ">M8[D]",
71
+ "M8[h]", "=M8[h]", "<M8[h]", ">M8[h]",
72
+ "M8[m]", "=M8[m]", "<M8[m]", ">M8[m]",
73
+ "M8[s]", "=M8[s]", "<M8[s]", ">M8[s]",
74
+ "M8[ms]", "=M8[ms]", "<M8[ms]", ">M8[ms]",
75
+ "M8[us]", "=M8[us]", "<M8[us]", ">M8[us]",
76
+ "M8[ns]", "=M8[ns]", "<M8[ns]", ">M8[ns]",
77
+ "M8[ps]", "=M8[ps]", "<M8[ps]", ">M8[ps]",
78
+ "M8[fs]", "=M8[fs]", "<M8[fs]", ">M8[fs]",
79
+ "M8[as]", "=M8[as]", "<M8[as]", ">M8[as]",
80
+ ]
81
+ _TD64Codes = Literal[
82
+ "timedelta64", "=timedelta64", "<timedelta64", ">timedelta64",
83
+ "timedelta64[Y]", "=timedelta64[Y]", "<timedelta64[Y]", ">timedelta64[Y]",
84
+ "timedelta64[M]", "=timedelta64[M]", "<timedelta64[M]", ">timedelta64[M]",
85
+ "timedelta64[W]", "=timedelta64[W]", "<timedelta64[W]", ">timedelta64[W]",
86
+ "timedelta64[D]", "=timedelta64[D]", "<timedelta64[D]", ">timedelta64[D]",
87
+ "timedelta64[h]", "=timedelta64[h]", "<timedelta64[h]", ">timedelta64[h]",
88
+ "timedelta64[m]", "=timedelta64[m]", "<timedelta64[m]", ">timedelta64[m]",
89
+ "timedelta64[s]", "=timedelta64[s]", "<timedelta64[s]", ">timedelta64[s]",
90
+ "timedelta64[ms]", "=timedelta64[ms]", "<timedelta64[ms]", ">timedelta64[ms]",
91
+ "timedelta64[us]", "=timedelta64[us]", "<timedelta64[us]", ">timedelta64[us]",
92
+ "timedelta64[ns]", "=timedelta64[ns]", "<timedelta64[ns]", ">timedelta64[ns]",
93
+ "timedelta64[ps]", "=timedelta64[ps]", "<timedelta64[ps]", ">timedelta64[ps]",
94
+ "timedelta64[fs]", "=timedelta64[fs]", "<timedelta64[fs]", ">timedelta64[fs]",
95
+ "timedelta64[as]", "=timedelta64[as]", "<timedelta64[as]", ">timedelta64[as]",
96
+ "m", "=m", "<m", ">m",
97
+ "m8", "=m8", "<m8", ">m8",
98
+ "m8[Y]", "=m8[Y]", "<m8[Y]", ">m8[Y]",
99
+ "m8[M]", "=m8[M]", "<m8[M]", ">m8[M]",
100
+ "m8[W]", "=m8[W]", "<m8[W]", ">m8[W]",
101
+ "m8[D]", "=m8[D]", "<m8[D]", ">m8[D]",
102
+ "m8[h]", "=m8[h]", "<m8[h]", ">m8[h]",
103
+ "m8[m]", "=m8[m]", "<m8[m]", ">m8[m]",
104
+ "m8[s]", "=m8[s]", "<m8[s]", ">m8[s]",
105
+ "m8[ms]", "=m8[ms]", "<m8[ms]", ">m8[ms]",
106
+ "m8[us]", "=m8[us]", "<m8[us]", ">m8[us]",
107
+ "m8[ns]", "=m8[ns]", "<m8[ns]", ">m8[ns]",
108
+ "m8[ps]", "=m8[ps]", "<m8[ps]", ">m8[ps]",
109
+ "m8[fs]", "=m8[fs]", "<m8[fs]", ">m8[fs]",
110
+ "m8[as]", "=m8[as]", "<m8[as]", ">m8[as]",
111
+ ]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_dtype_like.py ADDED
@@ -0,0 +1,246 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from collections.abc import Sequence
2
+ from typing import (
3
+ Any,
4
+ Sequence,
5
+ Union,
6
+ TypeVar,
7
+ Protocol,
8
+ TypedDict,
9
+ runtime_checkable,
10
+ )
11
+
12
+ import numpy as np
13
+
14
+ from ._shape import _ShapeLike
15
+
16
+ from ._char_codes import (
17
+ _BoolCodes,
18
+ _UInt8Codes,
19
+ _UInt16Codes,
20
+ _UInt32Codes,
21
+ _UInt64Codes,
22
+ _Int8Codes,
23
+ _Int16Codes,
24
+ _Int32Codes,
25
+ _Int64Codes,
26
+ _Float16Codes,
27
+ _Float32Codes,
28
+ _Float64Codes,
29
+ _Complex64Codes,
30
+ _Complex128Codes,
31
+ _ByteCodes,
32
+ _ShortCodes,
33
+ _IntCCodes,
34
+ _IntPCodes,
35
+ _IntCodes,
36
+ _LongLongCodes,
37
+ _UByteCodes,
38
+ _UShortCodes,
39
+ _UIntCCodes,
40
+ _UIntPCodes,
41
+ _UIntCodes,
42
+ _ULongLongCodes,
43
+ _HalfCodes,
44
+ _SingleCodes,
45
+ _DoubleCodes,
46
+ _LongDoubleCodes,
47
+ _CSingleCodes,
48
+ _CDoubleCodes,
49
+ _CLongDoubleCodes,
50
+ _DT64Codes,
51
+ _TD64Codes,
52
+ _StrCodes,
53
+ _BytesCodes,
54
+ _VoidCodes,
55
+ _ObjectCodes,
56
+ )
57
+
58
+ _SCT = TypeVar("_SCT", bound=np.generic)
59
+ _DType_co = TypeVar("_DType_co", covariant=True, bound=np.dtype[Any])
60
+
61
+ _DTypeLikeNested = Any # TODO: wait for support for recursive types
62
+
63
+
64
+ # Mandatory keys
65
+ class _DTypeDictBase(TypedDict):
66
+ names: Sequence[str]
67
+ formats: Sequence[_DTypeLikeNested]
68
+
69
+
70
+ # Mandatory + optional keys
71
+ class _DTypeDict(_DTypeDictBase, total=False):
72
+ # Only `str` elements are usable as indexing aliases,
73
+ # but `titles` can in principle accept any object
74
+ offsets: Sequence[int]
75
+ titles: Sequence[Any]
76
+ itemsize: int
77
+ aligned: bool
78
+
79
+
80
+ # A protocol for anything with the dtype attribute
81
+ @runtime_checkable
82
+ class _SupportsDType(Protocol[_DType_co]):
83
+ @property
84
+ def dtype(self) -> _DType_co: ...
85
+
86
+
87
+ # A subset of `npt.DTypeLike` that can be parametrized w.r.t. `np.generic`
88
+ _DTypeLike = Union[
89
+ np.dtype[_SCT],
90
+ type[_SCT],
91
+ _SupportsDType[np.dtype[_SCT]],
92
+ ]
93
+
94
+
95
+ # Would create a dtype[np.void]
96
+ _VoidDTypeLike = Union[
97
+ # (flexible_dtype, itemsize)
98
+ tuple[_DTypeLikeNested, int],
99
+ # (fixed_dtype, shape)
100
+ tuple[_DTypeLikeNested, _ShapeLike],
101
+ # [(field_name, field_dtype, field_shape), ...]
102
+ #
103
+ # The type here is quite broad because NumPy accepts quite a wide
104
+ # range of inputs inside the list; see the tests for some
105
+ # examples.
106
+ list[Any],
107
+ # {'names': ..., 'formats': ..., 'offsets': ..., 'titles': ...,
108
+ # 'itemsize': ...}
109
+ _DTypeDict,
110
+ # (base_dtype, new_dtype)
111
+ tuple[_DTypeLikeNested, _DTypeLikeNested],
112
+ ]
113
+
114
+ # Anything that can be coerced into numpy.dtype.
115
+ # Reference: https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html
116
+ DTypeLike = Union[
117
+ np.dtype[Any],
118
+ # default data type (float64)
119
+ None,
120
+ # array-scalar types and generic types
121
+ type[Any], # NOTE: We're stuck with `type[Any]` due to object dtypes
122
+ # anything with a dtype attribute
123
+ _SupportsDType[np.dtype[Any]],
124
+ # character codes, type strings or comma-separated fields, e.g., 'float64'
125
+ str,
126
+ _VoidDTypeLike,
127
+ ]
128
+
129
+ # NOTE: while it is possible to provide the dtype as a dict of
130
+ # dtype-like objects (e.g. `{'field1': ..., 'field2': ..., ...}`),
131
+ # this syntax is officially discourged and
132
+ # therefore not included in the Union defining `DTypeLike`.
133
+ #
134
+ # See https://github.com/numpy/numpy/issues/16891 for more details.
135
+
136
+ # Aliases for commonly used dtype-like objects.
137
+ # Note that the precision of `np.number` subclasses is ignored herein.
138
+ _DTypeLikeBool = Union[
139
+ type[bool],
140
+ type[np.bool_],
141
+ np.dtype[np.bool_],
142
+ _SupportsDType[np.dtype[np.bool_]],
143
+ _BoolCodes,
144
+ ]
145
+ _DTypeLikeUInt = Union[
146
+ type[np.unsignedinteger],
147
+ np.dtype[np.unsignedinteger],
148
+ _SupportsDType[np.dtype[np.unsignedinteger]],
149
+ _UInt8Codes,
150
+ _UInt16Codes,
151
+ _UInt32Codes,
152
+ _UInt64Codes,
153
+ _UByteCodes,
154
+ _UShortCodes,
155
+ _UIntCCodes,
156
+ _UIntPCodes,
157
+ _UIntCodes,
158
+ _ULongLongCodes,
159
+ ]
160
+ _DTypeLikeInt = Union[
161
+ type[int],
162
+ type[np.signedinteger],
163
+ np.dtype[np.signedinteger],
164
+ _SupportsDType[np.dtype[np.signedinteger]],
165
+ _Int8Codes,
166
+ _Int16Codes,
167
+ _Int32Codes,
168
+ _Int64Codes,
169
+ _ByteCodes,
170
+ _ShortCodes,
171
+ _IntCCodes,
172
+ _IntPCodes,
173
+ _IntCodes,
174
+ _LongLongCodes,
175
+ ]
176
+ _DTypeLikeFloat = Union[
177
+ type[float],
178
+ type[np.floating],
179
+ np.dtype[np.floating],
180
+ _SupportsDType[np.dtype[np.floating]],
181
+ _Float16Codes,
182
+ _Float32Codes,
183
+ _Float64Codes,
184
+ _HalfCodes,
185
+ _SingleCodes,
186
+ _DoubleCodes,
187
+ _LongDoubleCodes,
188
+ ]
189
+ _DTypeLikeComplex = Union[
190
+ type[complex],
191
+ type[np.complexfloating],
192
+ np.dtype[np.complexfloating],
193
+ _SupportsDType[np.dtype[np.complexfloating]],
194
+ _Complex64Codes,
195
+ _Complex128Codes,
196
+ _CSingleCodes,
197
+ _CDoubleCodes,
198
+ _CLongDoubleCodes,
199
+ ]
200
+ _DTypeLikeDT64 = Union[
201
+ type[np.timedelta64],
202
+ np.dtype[np.timedelta64],
203
+ _SupportsDType[np.dtype[np.timedelta64]],
204
+ _TD64Codes,
205
+ ]
206
+ _DTypeLikeTD64 = Union[
207
+ type[np.datetime64],
208
+ np.dtype[np.datetime64],
209
+ _SupportsDType[np.dtype[np.datetime64]],
210
+ _DT64Codes,
211
+ ]
212
+ _DTypeLikeStr = Union[
213
+ type[str],
214
+ type[np.str_],
215
+ np.dtype[np.str_],
216
+ _SupportsDType[np.dtype[np.str_]],
217
+ _StrCodes,
218
+ ]
219
+ _DTypeLikeBytes = Union[
220
+ type[bytes],
221
+ type[np.bytes_],
222
+ np.dtype[np.bytes_],
223
+ _SupportsDType[np.dtype[np.bytes_]],
224
+ _BytesCodes,
225
+ ]
226
+ _DTypeLikeVoid = Union[
227
+ type[np.void],
228
+ np.dtype[np.void],
229
+ _SupportsDType[np.dtype[np.void]],
230
+ _VoidCodes,
231
+ _VoidDTypeLike,
232
+ ]
233
+ _DTypeLikeObject = Union[
234
+ type,
235
+ np.dtype[np.object_],
236
+ _SupportsDType[np.dtype[np.object_]],
237
+ _ObjectCodes,
238
+ ]
239
+
240
+ _DTypeLikeComplex_co = Union[
241
+ _DTypeLikeBool,
242
+ _DTypeLikeUInt,
243
+ _DTypeLikeInt,
244
+ _DTypeLikeFloat,
245
+ _DTypeLikeComplex,
246
+ ]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_extended_precision.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A module with platform-specific extended precision
2
+ `numpy.number` subclasses.
3
+
4
+ The subclasses are defined here (instead of ``__init__.pyi``) such
5
+ that they can be imported conditionally via the numpy's mypy plugin.
6
+ """
7
+
8
+ import numpy as np
9
+ from . import (
10
+ _80Bit,
11
+ _96Bit,
12
+ _128Bit,
13
+ _256Bit,
14
+ )
15
+
16
+ uint128 = np.unsignedinteger[_128Bit]
17
+ uint256 = np.unsignedinteger[_256Bit]
18
+ int128 = np.signedinteger[_128Bit]
19
+ int256 = np.signedinteger[_256Bit]
20
+ float80 = np.floating[_80Bit]
21
+ float96 = np.floating[_96Bit]
22
+ float128 = np.floating[_128Bit]
23
+ float256 = np.floating[_256Bit]
24
+ complex160 = np.complexfloating[_80Bit, _80Bit]
25
+ complex192 = np.complexfloating[_96Bit, _96Bit]
26
+ complex256 = np.complexfloating[_128Bit, _128Bit]
27
+ complex512 = np.complexfloating[_256Bit, _256Bit]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_nbit.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A module with the precisions of platform-specific `~numpy.number`s."""
2
+
3
+ from typing import Any
4
+
5
+ # To-be replaced with a `npt.NBitBase` subclass by numpy's mypy plugin
6
+ _NBitByte = Any
7
+ _NBitShort = Any
8
+ _NBitIntC = Any
9
+ _NBitIntP = Any
10
+ _NBitInt = Any
11
+ _NBitLongLong = Any
12
+
13
+ _NBitHalf = Any
14
+ _NBitSingle = Any
15
+ _NBitDouble = Any
16
+ _NBitLongDouble = Any
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_nested_sequence.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A module containing the `_NestedSequence` protocol."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Iterator
6
+ from typing import (
7
+ Any,
8
+ TypeVar,
9
+ Protocol,
10
+ runtime_checkable,
11
+ )
12
+
13
+ __all__ = ["_NestedSequence"]
14
+
15
+ _T_co = TypeVar("_T_co", covariant=True)
16
+
17
+
18
+ @runtime_checkable
19
+ class _NestedSequence(Protocol[_T_co]):
20
+ """A protocol for representing nested sequences.
21
+
22
+ Warning
23
+ -------
24
+ `_NestedSequence` currently does not work in combination with typevars,
25
+ *e.g.* ``def func(a: _NestedSequnce[T]) -> T: ...``.
26
+
27
+ See Also
28
+ --------
29
+ collections.abc.Sequence
30
+ ABCs for read-only and mutable :term:`sequences`.
31
+
32
+ Examples
33
+ --------
34
+ .. code-block:: python
35
+
36
+ >>> from __future__ import annotations
37
+
38
+ >>> from typing import TYPE_CHECKING
39
+ >>> import numpy as np
40
+ >>> from numpy._typing import _NestedSequence
41
+
42
+ >>> def get_dtype(seq: _NestedSequence[float]) -> np.dtype[np.float64]:
43
+ ... return np.asarray(seq).dtype
44
+
45
+ >>> a = get_dtype([1.0])
46
+ >>> b = get_dtype([[1.0]])
47
+ >>> c = get_dtype([[[1.0]]])
48
+ >>> d = get_dtype([[[[1.0]]]])
49
+
50
+ >>> if TYPE_CHECKING:
51
+ ... reveal_locals()
52
+ ... # note: Revealed local types are:
53
+ ... # note: a: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
54
+ ... # note: b: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
55
+ ... # note: c: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
56
+ ... # note: d: numpy.dtype[numpy.floating[numpy._typing._64Bit]]
57
+
58
+ """
59
+
60
+ def __len__(self, /) -> int:
61
+ """Implement ``len(self)``."""
62
+ raise NotImplementedError
63
+
64
+ def __getitem__(self, index: int, /) -> _T_co | _NestedSequence[_T_co]:
65
+ """Implement ``self[x]``."""
66
+ raise NotImplementedError
67
+
68
+ def __contains__(self, x: object, /) -> bool:
69
+ """Implement ``x in self``."""
70
+ raise NotImplementedError
71
+
72
+ def __iter__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
73
+ """Implement ``iter(self)``."""
74
+ raise NotImplementedError
75
+
76
+ def __reversed__(self, /) -> Iterator[_T_co | _NestedSequence[_T_co]]:
77
+ """Implement ``reversed(self)``."""
78
+ raise NotImplementedError
79
+
80
+ def count(self, value: Any, /) -> int:
81
+ """Return the number of occurrences of `value`."""
82
+ raise NotImplementedError
83
+
84
+ def index(self, value: Any, /) -> int:
85
+ """Return the first index of `value`."""
86
+ raise NotImplementedError
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_scalars.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Union, Any
2
+
3
+ import numpy as np
4
+
5
+ # NOTE: `_StrLike_co` and `_BytesLike_co` are pointless, as `np.str_` and
6
+ # `np.bytes_` are already subclasses of their builtin counterpart
7
+
8
+ _CharLike_co = Union[str, bytes]
9
+
10
+ # The 6 `<X>Like_co` type-aliases below represent all scalars that can be
11
+ # coerced into `<X>` (with the casting rule `same_kind`)
12
+ _BoolLike_co = Union[bool, np.bool_]
13
+ _UIntLike_co = Union[_BoolLike_co, np.unsignedinteger[Any]]
14
+ _IntLike_co = Union[_BoolLike_co, int, np.integer[Any]]
15
+ _FloatLike_co = Union[_IntLike_co, float, np.floating[Any]]
16
+ _ComplexLike_co = Union[_FloatLike_co, complex, np.complexfloating[Any, Any]]
17
+ _TD64Like_co = Union[_IntLike_co, np.timedelta64]
18
+
19
+ _NumberLike_co = Union[int, float, complex, np.number[Any], np.bool_]
20
+ _ScalarLike_co = Union[
21
+ int,
22
+ float,
23
+ complex,
24
+ str,
25
+ bytes,
26
+ np.generic,
27
+ ]
28
+
29
+ # `_VoidLike_co` is technically not a scalar, but it's close enough
30
+ _VoidLike_co = Union[tuple[Any, ...], np.void]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_shape.py ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ from collections.abc import Sequence
2
+ from typing import Union, SupportsIndex
3
+
4
+ _Shape = tuple[int, ...]
5
+
6
+ # Anything that can be coerced to a shape tuple
7
+ _ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/_ufunc.pyi ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A module with private type-check-only `numpy.ufunc` subclasses.
2
+
3
+ The signatures of the ufuncs are too varied to reasonably type
4
+ with a single class. So instead, `ufunc` has been expanded into
5
+ four private subclasses, one for each combination of
6
+ `~ufunc.nin` and `~ufunc.nout`.
7
+
8
+ """
9
+
10
+ from typing import (
11
+ Any,
12
+ Generic,
13
+ overload,
14
+ TypeVar,
15
+ Literal,
16
+ SupportsIndex,
17
+ Protocol,
18
+ )
19
+
20
+ from numpy import ufunc, _CastingKind, _OrderKACF
21
+ from numpy.typing import NDArray
22
+
23
+ from ._shape import _ShapeLike
24
+ from ._scalars import _ScalarLike_co
25
+ from ._array_like import ArrayLike, _ArrayLikeBool_co, _ArrayLikeInt_co
26
+ from ._dtype_like import DTypeLike
27
+
28
+ _T = TypeVar("_T")
29
+ _2Tuple = tuple[_T, _T]
30
+ _3Tuple = tuple[_T, _T, _T]
31
+ _4Tuple = tuple[_T, _T, _T, _T]
32
+
33
+ _NTypes = TypeVar("_NTypes", bound=int)
34
+ _IDType = TypeVar("_IDType", bound=Any)
35
+ _NameType = TypeVar("_NameType", bound=str)
36
+
37
+
38
+ class _SupportsArrayUFunc(Protocol):
39
+ def __array_ufunc__(
40
+ self,
41
+ ufunc: ufunc,
42
+ method: Literal["__call__", "reduce", "reduceat", "accumulate", "outer", "inner"],
43
+ *inputs: Any,
44
+ **kwargs: Any,
45
+ ) -> Any: ...
46
+
47
+
48
+ # NOTE: In reality `extobj` should be a length of list 3 containing an
49
+ # int, an int, and a callable, but there's no way to properly express
50
+ # non-homogenous lists.
51
+ # Use `Any` over `Union` to avoid issues related to lists invariance.
52
+
53
+ # NOTE: `reduce`, `accumulate`, `reduceat` and `outer` raise a ValueError for
54
+ # ufuncs that don't accept two input arguments and return one output argument.
55
+ # In such cases the respective methods are simply typed as `None`.
56
+
57
+ # NOTE: Similarly, `at` won't be defined for ufuncs that return
58
+ # multiple outputs; in such cases `at` is typed as `None`
59
+
60
+ # NOTE: If 2 output types are returned then `out` must be a
61
+ # 2-tuple of arrays. Otherwise `None` or a plain array are also acceptable
62
+
63
+ class _UFunc_Nin1_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
64
+ @property
65
+ def __name__(self) -> _NameType: ...
66
+ @property
67
+ def ntypes(self) -> _NTypes: ...
68
+ @property
69
+ def identity(self) -> _IDType: ...
70
+ @property
71
+ def nin(self) -> Literal[1]: ...
72
+ @property
73
+ def nout(self) -> Literal[1]: ...
74
+ @property
75
+ def nargs(self) -> Literal[2]: ...
76
+ @property
77
+ def signature(self) -> None: ...
78
+ @property
79
+ def reduce(self) -> None: ...
80
+ @property
81
+ def accumulate(self) -> None: ...
82
+ @property
83
+ def reduceat(self) -> None: ...
84
+ @property
85
+ def outer(self) -> None: ...
86
+
87
+ @overload
88
+ def __call__(
89
+ self,
90
+ __x1: _ScalarLike_co,
91
+ out: None = ...,
92
+ *,
93
+ where: None | _ArrayLikeBool_co = ...,
94
+ casting: _CastingKind = ...,
95
+ order: _OrderKACF = ...,
96
+ dtype: DTypeLike = ...,
97
+ subok: bool = ...,
98
+ signature: str | _2Tuple[None | str] = ...,
99
+ extobj: list[Any] = ...,
100
+ ) -> Any: ...
101
+ @overload
102
+ def __call__(
103
+ self,
104
+ __x1: ArrayLike,
105
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
106
+ *,
107
+ where: None | _ArrayLikeBool_co = ...,
108
+ casting: _CastingKind = ...,
109
+ order: _OrderKACF = ...,
110
+ dtype: DTypeLike = ...,
111
+ subok: bool = ...,
112
+ signature: str | _2Tuple[None | str] = ...,
113
+ extobj: list[Any] = ...,
114
+ ) -> NDArray[Any]: ...
115
+ @overload
116
+ def __call__(
117
+ self,
118
+ __x1: _SupportsArrayUFunc,
119
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
120
+ *,
121
+ where: None | _ArrayLikeBool_co = ...,
122
+ casting: _CastingKind = ...,
123
+ order: _OrderKACF = ...,
124
+ dtype: DTypeLike = ...,
125
+ subok: bool = ...,
126
+ signature: str | _2Tuple[None | str] = ...,
127
+ extobj: list[Any] = ...,
128
+ ) -> Any: ...
129
+
130
+ def at(
131
+ self,
132
+ a: _SupportsArrayUFunc,
133
+ indices: _ArrayLikeInt_co,
134
+ /,
135
+ ) -> None: ...
136
+
137
+ class _UFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
138
+ @property
139
+ def __name__(self) -> _NameType: ...
140
+ @property
141
+ def ntypes(self) -> _NTypes: ...
142
+ @property
143
+ def identity(self) -> _IDType: ...
144
+ @property
145
+ def nin(self) -> Literal[2]: ...
146
+ @property
147
+ def nout(self) -> Literal[1]: ...
148
+ @property
149
+ def nargs(self) -> Literal[3]: ...
150
+ @property
151
+ def signature(self) -> None: ...
152
+
153
+ @overload
154
+ def __call__(
155
+ self,
156
+ __x1: _ScalarLike_co,
157
+ __x2: _ScalarLike_co,
158
+ out: None = ...,
159
+ *,
160
+ where: None | _ArrayLikeBool_co = ...,
161
+ casting: _CastingKind = ...,
162
+ order: _OrderKACF = ...,
163
+ dtype: DTypeLike = ...,
164
+ subok: bool = ...,
165
+ signature: str | _3Tuple[None | str] = ...,
166
+ extobj: list[Any] = ...,
167
+ ) -> Any: ...
168
+ @overload
169
+ def __call__(
170
+ self,
171
+ __x1: ArrayLike,
172
+ __x2: ArrayLike,
173
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
174
+ *,
175
+ where: None | _ArrayLikeBool_co = ...,
176
+ casting: _CastingKind = ...,
177
+ order: _OrderKACF = ...,
178
+ dtype: DTypeLike = ...,
179
+ subok: bool = ...,
180
+ signature: str | _3Tuple[None | str] = ...,
181
+ extobj: list[Any] = ...,
182
+ ) -> NDArray[Any]: ...
183
+
184
+ def at(
185
+ self,
186
+ a: NDArray[Any],
187
+ indices: _ArrayLikeInt_co,
188
+ b: ArrayLike,
189
+ /,
190
+ ) -> None: ...
191
+
192
+ def reduce(
193
+ self,
194
+ array: ArrayLike,
195
+ axis: None | _ShapeLike = ...,
196
+ dtype: DTypeLike = ...,
197
+ out: None | NDArray[Any] = ...,
198
+ keepdims: bool = ...,
199
+ initial: Any = ...,
200
+ where: _ArrayLikeBool_co = ...,
201
+ ) -> Any: ...
202
+
203
+ def accumulate(
204
+ self,
205
+ array: ArrayLike,
206
+ axis: SupportsIndex = ...,
207
+ dtype: DTypeLike = ...,
208
+ out: None | NDArray[Any] = ...,
209
+ ) -> NDArray[Any]: ...
210
+
211
+ def reduceat(
212
+ self,
213
+ array: ArrayLike,
214
+ indices: _ArrayLikeInt_co,
215
+ axis: SupportsIndex = ...,
216
+ dtype: DTypeLike = ...,
217
+ out: None | NDArray[Any] = ...,
218
+ ) -> NDArray[Any]: ...
219
+
220
+ # Expand `**kwargs` into explicit keyword-only arguments
221
+ @overload
222
+ def outer(
223
+ self,
224
+ A: _ScalarLike_co,
225
+ B: _ScalarLike_co,
226
+ /, *,
227
+ out: None = ...,
228
+ where: None | _ArrayLikeBool_co = ...,
229
+ casting: _CastingKind = ...,
230
+ order: _OrderKACF = ...,
231
+ dtype: DTypeLike = ...,
232
+ subok: bool = ...,
233
+ signature: str | _3Tuple[None | str] = ...,
234
+ extobj: list[Any] = ...,
235
+ ) -> Any: ...
236
+ @overload
237
+ def outer( # type: ignore[misc]
238
+ self,
239
+ A: ArrayLike,
240
+ B: ArrayLike,
241
+ /, *,
242
+ out: None | NDArray[Any] | tuple[NDArray[Any]] = ...,
243
+ where: None | _ArrayLikeBool_co = ...,
244
+ casting: _CastingKind = ...,
245
+ order: _OrderKACF = ...,
246
+ dtype: DTypeLike = ...,
247
+ subok: bool = ...,
248
+ signature: str | _3Tuple[None | str] = ...,
249
+ extobj: list[Any] = ...,
250
+ ) -> NDArray[Any]: ...
251
+
252
+ class _UFunc_Nin1_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
253
+ @property
254
+ def __name__(self) -> _NameType: ...
255
+ @property
256
+ def ntypes(self) -> _NTypes: ...
257
+ @property
258
+ def identity(self) -> _IDType: ...
259
+ @property
260
+ def nin(self) -> Literal[1]: ...
261
+ @property
262
+ def nout(self) -> Literal[2]: ...
263
+ @property
264
+ def nargs(self) -> Literal[3]: ...
265
+ @property
266
+ def signature(self) -> None: ...
267
+ @property
268
+ def at(self) -> None: ...
269
+ @property
270
+ def reduce(self) -> None: ...
271
+ @property
272
+ def accumulate(self) -> None: ...
273
+ @property
274
+ def reduceat(self) -> None: ...
275
+ @property
276
+ def outer(self) -> None: ...
277
+
278
+ @overload
279
+ def __call__(
280
+ self,
281
+ __x1: _ScalarLike_co,
282
+ __out1: None = ...,
283
+ __out2: None = ...,
284
+ *,
285
+ where: None | _ArrayLikeBool_co = ...,
286
+ casting: _CastingKind = ...,
287
+ order: _OrderKACF = ...,
288
+ dtype: DTypeLike = ...,
289
+ subok: bool = ...,
290
+ signature: str | _3Tuple[None | str] = ...,
291
+ extobj: list[Any] = ...,
292
+ ) -> _2Tuple[Any]: ...
293
+ @overload
294
+ def __call__(
295
+ self,
296
+ __x1: ArrayLike,
297
+ __out1: None | NDArray[Any] = ...,
298
+ __out2: None | NDArray[Any] = ...,
299
+ *,
300
+ out: _2Tuple[NDArray[Any]] = ...,
301
+ where: None | _ArrayLikeBool_co = ...,
302
+ casting: _CastingKind = ...,
303
+ order: _OrderKACF = ...,
304
+ dtype: DTypeLike = ...,
305
+ subok: bool = ...,
306
+ signature: str | _3Tuple[None | str] = ...,
307
+ extobj: list[Any] = ...,
308
+ ) -> _2Tuple[NDArray[Any]]: ...
309
+ @overload
310
+ def __call__(
311
+ self,
312
+ __x1: _SupportsArrayUFunc,
313
+ __out1: None | NDArray[Any] = ...,
314
+ __out2: None | NDArray[Any] = ...,
315
+ *,
316
+ out: _2Tuple[NDArray[Any]] = ...,
317
+ where: None | _ArrayLikeBool_co = ...,
318
+ casting: _CastingKind = ...,
319
+ order: _OrderKACF = ...,
320
+ dtype: DTypeLike = ...,
321
+ subok: bool = ...,
322
+ signature: str | _3Tuple[None | str] = ...,
323
+ extobj: list[Any] = ...,
324
+ ) -> _2Tuple[Any]: ...
325
+
326
+ class _UFunc_Nin2_Nout2(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
327
+ @property
328
+ def __name__(self) -> _NameType: ...
329
+ @property
330
+ def ntypes(self) -> _NTypes: ...
331
+ @property
332
+ def identity(self) -> _IDType: ...
333
+ @property
334
+ def nin(self) -> Literal[2]: ...
335
+ @property
336
+ def nout(self) -> Literal[2]: ...
337
+ @property
338
+ def nargs(self) -> Literal[4]: ...
339
+ @property
340
+ def signature(self) -> None: ...
341
+ @property
342
+ def at(self) -> None: ...
343
+ @property
344
+ def reduce(self) -> None: ...
345
+ @property
346
+ def accumulate(self) -> None: ...
347
+ @property
348
+ def reduceat(self) -> None: ...
349
+ @property
350
+ def outer(self) -> None: ...
351
+
352
+ @overload
353
+ def __call__(
354
+ self,
355
+ __x1: _ScalarLike_co,
356
+ __x2: _ScalarLike_co,
357
+ __out1: None = ...,
358
+ __out2: None = ...,
359
+ *,
360
+ where: None | _ArrayLikeBool_co = ...,
361
+ casting: _CastingKind = ...,
362
+ order: _OrderKACF = ...,
363
+ dtype: DTypeLike = ...,
364
+ subok: bool = ...,
365
+ signature: str | _4Tuple[None | str] = ...,
366
+ extobj: list[Any] = ...,
367
+ ) -> _2Tuple[Any]: ...
368
+ @overload
369
+ def __call__(
370
+ self,
371
+ __x1: ArrayLike,
372
+ __x2: ArrayLike,
373
+ __out1: None | NDArray[Any] = ...,
374
+ __out2: None | NDArray[Any] = ...,
375
+ *,
376
+ out: _2Tuple[NDArray[Any]] = ...,
377
+ where: None | _ArrayLikeBool_co = ...,
378
+ casting: _CastingKind = ...,
379
+ order: _OrderKACF = ...,
380
+ dtype: DTypeLike = ...,
381
+ subok: bool = ...,
382
+ signature: str | _4Tuple[None | str] = ...,
383
+ extobj: list[Any] = ...,
384
+ ) -> _2Tuple[NDArray[Any]]: ...
385
+
386
+ class _GUFunc_Nin2_Nout1(ufunc, Generic[_NameType, _NTypes, _IDType]): # type: ignore[misc]
387
+ @property
388
+ def __name__(self) -> _NameType: ...
389
+ @property
390
+ def ntypes(self) -> _NTypes: ...
391
+ @property
392
+ def identity(self) -> _IDType: ...
393
+ @property
394
+ def nin(self) -> Literal[2]: ...
395
+ @property
396
+ def nout(self) -> Literal[1]: ...
397
+ @property
398
+ def nargs(self) -> Literal[3]: ...
399
+
400
+ # NOTE: In practice the only gufunc in the main namespace is `matmul`,
401
+ # so we can use its signature here
402
+ @property
403
+ def signature(self) -> Literal["(n?,k),(k,m?)->(n?,m?)"]: ...
404
+ @property
405
+ def reduce(self) -> None: ...
406
+ @property
407
+ def accumulate(self) -> None: ...
408
+ @property
409
+ def reduceat(self) -> None: ...
410
+ @property
411
+ def outer(self) -> None: ...
412
+ @property
413
+ def at(self) -> None: ...
414
+
415
+ # Scalar for 1D array-likes; ndarray otherwise
416
+ @overload
417
+ def __call__(
418
+ self,
419
+ __x1: ArrayLike,
420
+ __x2: ArrayLike,
421
+ out: None = ...,
422
+ *,
423
+ casting: _CastingKind = ...,
424
+ order: _OrderKACF = ...,
425
+ dtype: DTypeLike = ...,
426
+ subok: bool = ...,
427
+ signature: str | _3Tuple[None | str] = ...,
428
+ extobj: list[Any] = ...,
429
+ axes: list[_2Tuple[SupportsIndex]] = ...,
430
+ ) -> Any: ...
431
+ @overload
432
+ def __call__(
433
+ self,
434
+ __x1: ArrayLike,
435
+ __x2: ArrayLike,
436
+ out: NDArray[Any] | tuple[NDArray[Any]],
437
+ *,
438
+ casting: _CastingKind = ...,
439
+ order: _OrderKACF = ...,
440
+ dtype: DTypeLike = ...,
441
+ subok: bool = ...,
442
+ signature: str | _3Tuple[None | str] = ...,
443
+ extobj: list[Any] = ...,
444
+ axes: list[_2Tuple[SupportsIndex]] = ...,
445
+ ) -> NDArray[Any]: ...
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_typing/setup.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ def configuration(parent_package='', top_path=None):
2
+ from numpy.distutils.misc_util import Configuration
3
+ config = Configuration('_typing', parent_package, top_path)
4
+ config.add_data_files('*.pyi')
5
+ return config
6
+
7
+
8
+ if __name__ == '__main__':
9
+ from numpy.distutils.core import setup
10
+ setup(configuration=configuration)
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__init__.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ This is a module for defining private helpers which do not depend on the
3
+ rest of NumPy.
4
+
5
+ Everything in here must be self-contained so that it can be
6
+ imported anywhere else without creating circular imports.
7
+ If a utility requires the import of NumPy, it probably belongs
8
+ in ``numpy.core``.
9
+ """
10
+
11
+ from ._convertions import asunicode, asbytes
12
+
13
+
14
+ def set_module(module):
15
+ """Private decorator for overriding __module__ on a function or class.
16
+
17
+ Example usage::
18
+
19
+ @set_module('numpy')
20
+ def example():
21
+ pass
22
+
23
+ assert example.__module__ == 'numpy'
24
+ """
25
+ def decorator(func):
26
+ if module is not None:
27
+ func.__module__ = module
28
+ return func
29
+ return decorator
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/__init__.cpython-312.pyc ADDED
Binary file (1.1 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_convertions.cpython-312.pyc ADDED
Binary file (838 Bytes). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_inspect.cpython-312.pyc ADDED
Binary file (9.45 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/__pycache__/_pep440.cpython-312.pyc ADDED
Binary file (19 kB). View file
 
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_convertions.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A set of methods retained from np.compat module that
3
+ are still used across codebase.
4
+ """
5
+
6
+ __all__ = ["asunicode", "asbytes"]
7
+
8
+
9
+ def asunicode(s):
10
+ if isinstance(s, bytes):
11
+ return s.decode('latin1')
12
+ return str(s)
13
+
14
+
15
+ def asbytes(s):
16
+ if isinstance(s, bytes):
17
+ return s
18
+ return str(s).encode('latin1')
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_inspect.py ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Subset of inspect module from upstream python
2
+
3
+ We use this instead of upstream because upstream inspect is slow to import, and
4
+ significantly contributes to numpy import times. Importing this copy has almost
5
+ no overhead.
6
+
7
+ """
8
+ import types
9
+
10
+ __all__ = ['getargspec', 'formatargspec']
11
+
12
+ # ----------------------------------------------------------- type-checking
13
+ def ismethod(object):
14
+ """Return true if the object is an instance method.
15
+
16
+ Instance method objects provide these attributes:
17
+ __doc__ documentation string
18
+ __name__ name with which this method was defined
19
+ im_class class object in which this method belongs
20
+ im_func function object containing implementation of method
21
+ im_self instance to which this method is bound, or None
22
+
23
+ """
24
+ return isinstance(object, types.MethodType)
25
+
26
+ def isfunction(object):
27
+ """Return true if the object is a user-defined function.
28
+
29
+ Function objects provide these attributes:
30
+ __doc__ documentation string
31
+ __name__ name with which this function was defined
32
+ func_code code object containing compiled function bytecode
33
+ func_defaults tuple of any default values for arguments
34
+ func_doc (same as __doc__)
35
+ func_globals global namespace in which this function was defined
36
+ func_name (same as __name__)
37
+
38
+ """
39
+ return isinstance(object, types.FunctionType)
40
+
41
+ def iscode(object):
42
+ """Return true if the object is a code object.
43
+
44
+ Code objects provide these attributes:
45
+ co_argcount number of arguments (not including * or ** args)
46
+ co_code string of raw compiled bytecode
47
+ co_consts tuple of constants used in the bytecode
48
+ co_filename name of file in which this code object was created
49
+ co_firstlineno number of first line in Python source code
50
+ co_flags bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg
51
+ co_lnotab encoded mapping of line numbers to bytecode indices
52
+ co_name name with which this code object was defined
53
+ co_names tuple of names of local variables
54
+ co_nlocals number of local variables
55
+ co_stacksize virtual machine stack space required
56
+ co_varnames tuple of names of arguments and local variables
57
+
58
+ """
59
+ return isinstance(object, types.CodeType)
60
+
61
+ # ------------------------------------------------ argument list extraction
62
+ # These constants are from Python's compile.h.
63
+ CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 1, 2, 4, 8
64
+
65
+ def getargs(co):
66
+ """Get information about the arguments accepted by a code object.
67
+
68
+ Three things are returned: (args, varargs, varkw), where 'args' is
69
+ a list of argument names (possibly containing nested lists), and
70
+ 'varargs' and 'varkw' are the names of the * and ** arguments or None.
71
+
72
+ """
73
+
74
+ if not iscode(co):
75
+ raise TypeError('arg is not a code object')
76
+
77
+ nargs = co.co_argcount
78
+ names = co.co_varnames
79
+ args = list(names[:nargs])
80
+
81
+ # The following acrobatics are for anonymous (tuple) arguments.
82
+ # Which we do not need to support, so remove to avoid importing
83
+ # the dis module.
84
+ for i in range(nargs):
85
+ if args[i][:1] in ['', '.']:
86
+ raise TypeError("tuple function arguments are not supported")
87
+ varargs = None
88
+ if co.co_flags & CO_VARARGS:
89
+ varargs = co.co_varnames[nargs]
90
+ nargs = nargs + 1
91
+ varkw = None
92
+ if co.co_flags & CO_VARKEYWORDS:
93
+ varkw = co.co_varnames[nargs]
94
+ return args, varargs, varkw
95
+
96
+ def getargspec(func):
97
+ """Get the names and default values of a function's arguments.
98
+
99
+ A tuple of four things is returned: (args, varargs, varkw, defaults).
100
+ 'args' is a list of the argument names (it may contain nested lists).
101
+ 'varargs' and 'varkw' are the names of the * and ** arguments or None.
102
+ 'defaults' is an n-tuple of the default values of the last n arguments.
103
+
104
+ """
105
+
106
+ if ismethod(func):
107
+ func = func.__func__
108
+ if not isfunction(func):
109
+ raise TypeError('arg is not a Python function')
110
+ args, varargs, varkw = getargs(func.__code__)
111
+ return args, varargs, varkw, func.__defaults__
112
+
113
+ def getargvalues(frame):
114
+ """Get information about arguments passed into a particular frame.
115
+
116
+ A tuple of four things is returned: (args, varargs, varkw, locals).
117
+ 'args' is a list of the argument names (it may contain nested lists).
118
+ 'varargs' and 'varkw' are the names of the * and ** arguments or None.
119
+ 'locals' is the locals dictionary of the given frame.
120
+
121
+ """
122
+ args, varargs, varkw = getargs(frame.f_code)
123
+ return args, varargs, varkw, frame.f_locals
124
+
125
+ def joinseq(seq):
126
+ if len(seq) == 1:
127
+ return '(' + seq[0] + ',)'
128
+ else:
129
+ return '(' + ', '.join(seq) + ')'
130
+
131
+ def strseq(object, convert, join=joinseq):
132
+ """Recursively walk a sequence, stringifying each element.
133
+
134
+ """
135
+ if type(object) in [list, tuple]:
136
+ return join([strseq(_o, convert, join) for _o in object])
137
+ else:
138
+ return convert(object)
139
+
140
+ def formatargspec(args, varargs=None, varkw=None, defaults=None,
141
+ formatarg=str,
142
+ formatvarargs=lambda name: '*' + name,
143
+ formatvarkw=lambda name: '**' + name,
144
+ formatvalue=lambda value: '=' + repr(value),
145
+ join=joinseq):
146
+ """Format an argument spec from the 4 values returned by getargspec.
147
+
148
+ The first four arguments are (args, varargs, varkw, defaults). The
149
+ other four arguments are the corresponding optional formatting functions
150
+ that are called to turn names and values into strings. The ninth
151
+ argument is an optional function to format the sequence of arguments.
152
+
153
+ """
154
+ specs = []
155
+ if defaults:
156
+ firstdefault = len(args) - len(defaults)
157
+ for i in range(len(args)):
158
+ spec = strseq(args[i], formatarg, join)
159
+ if defaults and i >= firstdefault:
160
+ spec = spec + formatvalue(defaults[i - firstdefault])
161
+ specs.append(spec)
162
+ if varargs is not None:
163
+ specs.append(formatvarargs(varargs))
164
+ if varkw is not None:
165
+ specs.append(formatvarkw(varkw))
166
+ return '(' + ', '.join(specs) + ')'
167
+
168
+ def formatargvalues(args, varargs, varkw, locals,
169
+ formatarg=str,
170
+ formatvarargs=lambda name: '*' + name,
171
+ formatvarkw=lambda name: '**' + name,
172
+ formatvalue=lambda value: '=' + repr(value),
173
+ join=joinseq):
174
+ """Format an argument spec from the 4 values returned by getargvalues.
175
+
176
+ The first four arguments are (args, varargs, varkw, locals). The
177
+ next four arguments are the corresponding optional formatting functions
178
+ that are called to turn names and values into strings. The ninth
179
+ argument is an optional function to format the sequence of arguments.
180
+
181
+ """
182
+ def convert(name, locals=locals,
183
+ formatarg=formatarg, formatvalue=formatvalue):
184
+ return formatarg(name) + formatvalue(locals[name])
185
+ specs = [strseq(arg, convert, join) for arg in args]
186
+
187
+ if varargs:
188
+ specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
189
+ if varkw:
190
+ specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
191
+ return '(' + ', '.join(specs) + ')'
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/_utils/_pep440.py ADDED
@@ -0,0 +1,487 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utility to compare pep440 compatible version strings.
2
+
3
+ The LooseVersion and StrictVersion classes that distutils provides don't
4
+ work; they don't recognize anything like alpha/beta/rc/dev versions.
5
+ """
6
+
7
+ # Copyright (c) Donald Stufft and individual contributors.
8
+ # All rights reserved.
9
+
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+
13
+ # 1. Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+
16
+ # 2. Redistributions in binary form must reproduce the above copyright
17
+ # notice, this list of conditions and the following disclaimer in the
18
+ # documentation and/or other materials provided with the distribution.
19
+
20
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+ # POSSIBILITY OF SUCH DAMAGE.
31
+
32
+ import collections
33
+ import itertools
34
+ import re
35
+
36
+
37
+ __all__ = [
38
+ "parse", "Version", "LegacyVersion", "InvalidVersion", "VERSION_PATTERN",
39
+ ]
40
+
41
+
42
+ # BEGIN packaging/_structures.py
43
+
44
+
45
+ class Infinity:
46
+ def __repr__(self):
47
+ return "Infinity"
48
+
49
+ def __hash__(self):
50
+ return hash(repr(self))
51
+
52
+ def __lt__(self, other):
53
+ return False
54
+
55
+ def __le__(self, other):
56
+ return False
57
+
58
+ def __eq__(self, other):
59
+ return isinstance(other, self.__class__)
60
+
61
+ def __ne__(self, other):
62
+ return not isinstance(other, self.__class__)
63
+
64
+ def __gt__(self, other):
65
+ return True
66
+
67
+ def __ge__(self, other):
68
+ return True
69
+
70
+ def __neg__(self):
71
+ return NegativeInfinity
72
+
73
+
74
+ Infinity = Infinity()
75
+
76
+
77
+ class NegativeInfinity:
78
+ def __repr__(self):
79
+ return "-Infinity"
80
+
81
+ def __hash__(self):
82
+ return hash(repr(self))
83
+
84
+ def __lt__(self, other):
85
+ return True
86
+
87
+ def __le__(self, other):
88
+ return True
89
+
90
+ def __eq__(self, other):
91
+ return isinstance(other, self.__class__)
92
+
93
+ def __ne__(self, other):
94
+ return not isinstance(other, self.__class__)
95
+
96
+ def __gt__(self, other):
97
+ return False
98
+
99
+ def __ge__(self, other):
100
+ return False
101
+
102
+ def __neg__(self):
103
+ return Infinity
104
+
105
+
106
+ # BEGIN packaging/version.py
107
+
108
+
109
+ NegativeInfinity = NegativeInfinity()
110
+
111
+ _Version = collections.namedtuple(
112
+ "_Version",
113
+ ["epoch", "release", "dev", "pre", "post", "local"],
114
+ )
115
+
116
+
117
+ def parse(version):
118
+ """
119
+ Parse the given version string and return either a :class:`Version` object
120
+ or a :class:`LegacyVersion` object depending on if the given version is
121
+ a valid PEP 440 version or a legacy version.
122
+ """
123
+ try:
124
+ return Version(version)
125
+ except InvalidVersion:
126
+ return LegacyVersion(version)
127
+
128
+
129
+ class InvalidVersion(ValueError):
130
+ """
131
+ An invalid version was found, users should refer to PEP 440.
132
+ """
133
+
134
+
135
+ class _BaseVersion:
136
+
137
+ def __hash__(self):
138
+ return hash(self._key)
139
+
140
+ def __lt__(self, other):
141
+ return self._compare(other, lambda s, o: s < o)
142
+
143
+ def __le__(self, other):
144
+ return self._compare(other, lambda s, o: s <= o)
145
+
146
+ def __eq__(self, other):
147
+ return self._compare(other, lambda s, o: s == o)
148
+
149
+ def __ge__(self, other):
150
+ return self._compare(other, lambda s, o: s >= o)
151
+
152
+ def __gt__(self, other):
153
+ return self._compare(other, lambda s, o: s > o)
154
+
155
+ def __ne__(self, other):
156
+ return self._compare(other, lambda s, o: s != o)
157
+
158
+ def _compare(self, other, method):
159
+ if not isinstance(other, _BaseVersion):
160
+ return NotImplemented
161
+
162
+ return method(self._key, other._key)
163
+
164
+
165
+ class LegacyVersion(_BaseVersion):
166
+
167
+ def __init__(self, version):
168
+ self._version = str(version)
169
+ self._key = _legacy_cmpkey(self._version)
170
+
171
+ def __str__(self):
172
+ return self._version
173
+
174
+ def __repr__(self):
175
+ return "<LegacyVersion({0})>".format(repr(str(self)))
176
+
177
+ @property
178
+ def public(self):
179
+ return self._version
180
+
181
+ @property
182
+ def base_version(self):
183
+ return self._version
184
+
185
+ @property
186
+ def local(self):
187
+ return None
188
+
189
+ @property
190
+ def is_prerelease(self):
191
+ return False
192
+
193
+ @property
194
+ def is_postrelease(self):
195
+ return False
196
+
197
+
198
+ _legacy_version_component_re = re.compile(
199
+ r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE,
200
+ )
201
+
202
+ _legacy_version_replacement_map = {
203
+ "pre": "c", "preview": "c", "-": "final-", "rc": "c", "dev": "@",
204
+ }
205
+
206
+
207
+ def _parse_version_parts(s):
208
+ for part in _legacy_version_component_re.split(s):
209
+ part = _legacy_version_replacement_map.get(part, part)
210
+
211
+ if not part or part == ".":
212
+ continue
213
+
214
+ if part[:1] in "0123456789":
215
+ # pad for numeric comparison
216
+ yield part.zfill(8)
217
+ else:
218
+ yield "*" + part
219
+
220
+ # ensure that alpha/beta/candidate are before final
221
+ yield "*final"
222
+
223
+
224
+ def _legacy_cmpkey(version):
225
+ # We hardcode an epoch of -1 here. A PEP 440 version can only have an epoch
226
+ # greater than or equal to 0. This will effectively put the LegacyVersion,
227
+ # which uses the defacto standard originally implemented by setuptools,
228
+ # as before all PEP 440 versions.
229
+ epoch = -1
230
+
231
+ # This scheme is taken from pkg_resources.parse_version setuptools prior to
232
+ # its adoption of the packaging library.
233
+ parts = []
234
+ for part in _parse_version_parts(version.lower()):
235
+ if part.startswith("*"):
236
+ # remove "-" before a prerelease tag
237
+ if part < "*final":
238
+ while parts and parts[-1] == "*final-":
239
+ parts.pop()
240
+
241
+ # remove trailing zeros from each series of numeric parts
242
+ while parts and parts[-1] == "00000000":
243
+ parts.pop()
244
+
245
+ parts.append(part)
246
+ parts = tuple(parts)
247
+
248
+ return epoch, parts
249
+
250
+
251
+ # Deliberately not anchored to the start and end of the string, to make it
252
+ # easier for 3rd party code to reuse
253
+ VERSION_PATTERN = r"""
254
+ v?
255
+ (?:
256
+ (?:(?P<epoch>[0-9]+)!)? # epoch
257
+ (?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
258
+ (?P<pre> # pre-release
259
+ [-_\.]?
260
+ (?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
261
+ [-_\.]?
262
+ (?P<pre_n>[0-9]+)?
263
+ )?
264
+ (?P<post> # post release
265
+ (?:-(?P<post_n1>[0-9]+))
266
+ |
267
+ (?:
268
+ [-_\.]?
269
+ (?P<post_l>post|rev|r)
270
+ [-_\.]?
271
+ (?P<post_n2>[0-9]+)?
272
+ )
273
+ )?
274
+ (?P<dev> # dev release
275
+ [-_\.]?
276
+ (?P<dev_l>dev)
277
+ [-_\.]?
278
+ (?P<dev_n>[0-9]+)?
279
+ )?
280
+ )
281
+ (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
282
+ """
283
+
284
+
285
+ class Version(_BaseVersion):
286
+
287
+ _regex = re.compile(
288
+ r"^\s*" + VERSION_PATTERN + r"\s*$",
289
+ re.VERBOSE | re.IGNORECASE,
290
+ )
291
+
292
+ def __init__(self, version):
293
+ # Validate the version and parse it into pieces
294
+ match = self._regex.search(version)
295
+ if not match:
296
+ raise InvalidVersion("Invalid version: '{0}'".format(version))
297
+
298
+ # Store the parsed out pieces of the version
299
+ self._version = _Version(
300
+ epoch=int(match.group("epoch")) if match.group("epoch") else 0,
301
+ release=tuple(int(i) for i in match.group("release").split(".")),
302
+ pre=_parse_letter_version(
303
+ match.group("pre_l"),
304
+ match.group("pre_n"),
305
+ ),
306
+ post=_parse_letter_version(
307
+ match.group("post_l"),
308
+ match.group("post_n1") or match.group("post_n2"),
309
+ ),
310
+ dev=_parse_letter_version(
311
+ match.group("dev_l"),
312
+ match.group("dev_n"),
313
+ ),
314
+ local=_parse_local_version(match.group("local")),
315
+ )
316
+
317
+ # Generate a key which will be used for sorting
318
+ self._key = _cmpkey(
319
+ self._version.epoch,
320
+ self._version.release,
321
+ self._version.pre,
322
+ self._version.post,
323
+ self._version.dev,
324
+ self._version.local,
325
+ )
326
+
327
+ def __repr__(self):
328
+ return "<Version({0})>".format(repr(str(self)))
329
+
330
+ def __str__(self):
331
+ parts = []
332
+
333
+ # Epoch
334
+ if self._version.epoch != 0:
335
+ parts.append("{0}!".format(self._version.epoch))
336
+
337
+ # Release segment
338
+ parts.append(".".join(str(x) for x in self._version.release))
339
+
340
+ # Pre-release
341
+ if self._version.pre is not None:
342
+ parts.append("".join(str(x) for x in self._version.pre))
343
+
344
+ # Post-release
345
+ if self._version.post is not None:
346
+ parts.append(".post{0}".format(self._version.post[1]))
347
+
348
+ # Development release
349
+ if self._version.dev is not None:
350
+ parts.append(".dev{0}".format(self._version.dev[1]))
351
+
352
+ # Local version segment
353
+ if self._version.local is not None:
354
+ parts.append(
355
+ "+{0}".format(".".join(str(x) for x in self._version.local))
356
+ )
357
+
358
+ return "".join(parts)
359
+
360
+ @property
361
+ def public(self):
362
+ return str(self).split("+", 1)[0]
363
+
364
+ @property
365
+ def base_version(self):
366
+ parts = []
367
+
368
+ # Epoch
369
+ if self._version.epoch != 0:
370
+ parts.append("{0}!".format(self._version.epoch))
371
+
372
+ # Release segment
373
+ parts.append(".".join(str(x) for x in self._version.release))
374
+
375
+ return "".join(parts)
376
+
377
+ @property
378
+ def local(self):
379
+ version_string = str(self)
380
+ if "+" in version_string:
381
+ return version_string.split("+", 1)[1]
382
+
383
+ @property
384
+ def is_prerelease(self):
385
+ return bool(self._version.dev or self._version.pre)
386
+
387
+ @property
388
+ def is_postrelease(self):
389
+ return bool(self._version.post)
390
+
391
+
392
+ def _parse_letter_version(letter, number):
393
+ if letter:
394
+ # We assume there is an implicit 0 in a pre-release if there is
395
+ # no numeral associated with it.
396
+ if number is None:
397
+ number = 0
398
+
399
+ # We normalize any letters to their lower-case form
400
+ letter = letter.lower()
401
+
402
+ # We consider some words to be alternate spellings of other words and
403
+ # in those cases we want to normalize the spellings to our preferred
404
+ # spelling.
405
+ if letter == "alpha":
406
+ letter = "a"
407
+ elif letter == "beta":
408
+ letter = "b"
409
+ elif letter in ["c", "pre", "preview"]:
410
+ letter = "rc"
411
+ elif letter in ["rev", "r"]:
412
+ letter = "post"
413
+
414
+ return letter, int(number)
415
+ if not letter and number:
416
+ # We assume that if we are given a number but not given a letter,
417
+ # then this is using the implicit post release syntax (e.g., 1.0-1)
418
+ letter = "post"
419
+
420
+ return letter, int(number)
421
+
422
+
423
+ _local_version_seperators = re.compile(r"[\._-]")
424
+
425
+
426
+ def _parse_local_version(local):
427
+ """
428
+ Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
429
+ """
430
+ if local is not None:
431
+ return tuple(
432
+ part.lower() if not part.isdigit() else int(part)
433
+ for part in _local_version_seperators.split(local)
434
+ )
435
+
436
+
437
+ def _cmpkey(epoch, release, pre, post, dev, local):
438
+ # When we compare a release version, we want to compare it with all of the
439
+ # trailing zeros removed. So we'll use a reverse the list, drop all the now
440
+ # leading zeros until we come to something non-zero, then take the rest,
441
+ # re-reverse it back into the correct order, and make it a tuple and use
442
+ # that for our sorting key.
443
+ release = tuple(
444
+ reversed(list(
445
+ itertools.dropwhile(
446
+ lambda x: x == 0,
447
+ reversed(release),
448
+ )
449
+ ))
450
+ )
451
+
452
+ # We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
453
+ # We'll do this by abusing the pre-segment, but we _only_ want to do this
454
+ # if there is no pre- or a post-segment. If we have one of those, then
455
+ # the normal sorting rules will handle this case correctly.
456
+ if pre is None and post is None and dev is not None:
457
+ pre = -Infinity
458
+ # Versions without a pre-release (except as noted above) should sort after
459
+ # those with one.
460
+ elif pre is None:
461
+ pre = Infinity
462
+
463
+ # Versions without a post-segment should sort before those with one.
464
+ if post is None:
465
+ post = -Infinity
466
+
467
+ # Versions without a development segment should sort after those with one.
468
+ if dev is None:
469
+ dev = Infinity
470
+
471
+ if local is None:
472
+ # Versions without a local segment should sort before those with one.
473
+ local = -Infinity
474
+ else:
475
+ # Versions with a local segment need that segment parsed to implement
476
+ # the sorting rules in PEP440.
477
+ # - Alphanumeric segments sort before numeric segments
478
+ # - Alphanumeric segments sort lexicographically
479
+ # - Numeric segments sort numerically
480
+ # - Shorter versions sort before longer versions when the prefixes
481
+ # match exactly
482
+ local = tuple(
483
+ (i, "") if isinstance(i, int) else (-Infinity, i)
484
+ for i in local
485
+ )
486
+
487
+ return epoch, release, pre, post, dev, local
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/__init__.py ADDED
@@ -0,0 +1,387 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ A NumPy sub-namespace that conforms to the Python array API standard.
3
+
4
+ This submodule accompanies NEP 47, which proposes its inclusion in NumPy. It
5
+ is still considered experimental, and will issue a warning when imported.
6
+
7
+ This is a proof-of-concept namespace that wraps the corresponding NumPy
8
+ functions to give a conforming implementation of the Python array API standard
9
+ (https://data-apis.github.io/array-api/latest/). The standard is currently in
10
+ an RFC phase and comments on it are both welcome and encouraged. Comments
11
+ should be made either at https://github.com/data-apis/array-api or at
12
+ https://github.com/data-apis/consortium-feedback/discussions.
13
+
14
+ NumPy already follows the proposed spec for the most part, so this module
15
+ serves mostly as a thin wrapper around it. However, NumPy also implements a
16
+ lot of behavior that is not included in the spec, so this serves as a
17
+ restricted subset of the API. Only those functions that are part of the spec
18
+ are included in this namespace, and all functions are given with the exact
19
+ signature given in the spec, including the use of position-only arguments, and
20
+ omitting any extra keyword arguments implemented by NumPy but not part of the
21
+ spec. The behavior of some functions is also modified from the NumPy behavior
22
+ to conform to the standard. Note that the underlying array object itself is
23
+ wrapped in a wrapper Array() class, but is otherwise unchanged. This submodule
24
+ is implemented in pure Python with no C extensions.
25
+
26
+ The array API spec is designed as a "minimal API subset" and explicitly allows
27
+ libraries to include behaviors not specified by it. But users of this module
28
+ that intend to write portable code should be aware that only those behaviors
29
+ that are listed in the spec are guaranteed to be implemented across libraries.
30
+ Consequently, the NumPy implementation was chosen to be both conforming and
31
+ minimal, so that users can use this implementation of the array API namespace
32
+ and be sure that behaviors that it defines will be available in conforming
33
+ namespaces from other libraries.
34
+
35
+ A few notes about the current state of this submodule:
36
+
37
+ - There is a test suite that tests modules against the array API standard at
38
+ https://github.com/data-apis/array-api-tests. The test suite is still a work
39
+ in progress, but the existing tests pass on this module, with a few
40
+ exceptions:
41
+
42
+ - DLPack support (see https://github.com/data-apis/array-api/pull/106) is
43
+ not included here, as it requires a full implementation in NumPy proper
44
+ first.
45
+
46
+ The test suite is not yet complete, and even the tests that exist are not
47
+ guaranteed to give a comprehensive coverage of the spec. Therefore, when
48
+ reviewing and using this submodule, you should refer to the standard
49
+ documents themselves. There are some tests in numpy.array_api.tests, but
50
+ they primarily focus on things that are not tested by the official array API
51
+ test suite.
52
+
53
+ - There is a custom array object, numpy.array_api.Array, which is returned by
54
+ all functions in this module. All functions in the array API namespace
55
+ implicitly assume that they will only receive this object as input. The only
56
+ way to create instances of this object is to use one of the array creation
57
+ functions. It does not have a public constructor on the object itself. The
58
+ object is a small wrapper class around numpy.ndarray. The main purpose of it
59
+ is to restrict the namespace of the array object to only those dtypes and
60
+ only those methods that are required by the spec, as well as to limit/change
61
+ certain behavior that differs in the spec. In particular:
62
+
63
+ - The array API namespace does not have scalar objects, only 0-D arrays.
64
+ Operations on Array that would create a scalar in NumPy create a 0-D
65
+ array.
66
+
67
+ - Indexing: Only a subset of indices supported by NumPy are required by the
68
+ spec. The Array object restricts indexing to only allow those types of
69
+ indices that are required by the spec. See the docstring of the
70
+ numpy.array_api.Array._validate_indices helper function for more
71
+ information.
72
+
73
+ - Type promotion: Some type promotion rules are different in the spec. In
74
+ particular, the spec does not have any value-based casting. The spec also
75
+ does not require cross-kind casting, like integer -> floating-point. Only
76
+ those promotions that are explicitly required by the array API
77
+ specification are allowed in this module. See NEP 47 for more info.
78
+
79
+ - Functions do not automatically call asarray() on their input, and will not
80
+ work if the input type is not Array. The exception is array creation
81
+ functions, and Python operators on the Array object, which accept Python
82
+ scalars of the same type as the array dtype.
83
+
84
+ - All functions include type annotations, corresponding to those given in the
85
+ spec (see _typing.py for definitions of some custom types). These do not
86
+ currently fully pass mypy due to some limitations in mypy.
87
+
88
+ - Dtype objects are just the NumPy dtype objects, e.g., float64 =
89
+ np.dtype('float64'). The spec does not require any behavior on these dtype
90
+ objects other than that they be accessible by name and be comparable by
91
+ equality, but it was considered too much extra complexity to create custom
92
+ objects to represent dtypes.
93
+
94
+ - All places where the implementations in this submodule are known to deviate
95
+ from their corresponding functions in NumPy are marked with "# Note:"
96
+ comments.
97
+
98
+ Still TODO in this module are:
99
+
100
+ - DLPack support for numpy.ndarray is still in progress. See
101
+ https://github.com/numpy/numpy/pull/19083.
102
+
103
+ - The copy=False keyword argument to asarray() is not yet implemented. This
104
+ requires support in numpy.asarray() first.
105
+
106
+ - Some functions are not yet fully tested in the array API test suite, and may
107
+ require updates that are not yet known until the tests are written.
108
+
109
+ - The spec is still in an RFC phase and may still have minor updates, which
110
+ will need to be reflected here.
111
+
112
+ - Complex number support in array API spec is planned but not yet finalized,
113
+ as are the fft extension and certain linear algebra functions such as eig
114
+ that require complex dtypes.
115
+
116
+ """
117
+
118
+ import warnings
119
+
120
+ warnings.warn(
121
+ "The numpy.array_api submodule is still experimental. See NEP 47.", stacklevel=2
122
+ )
123
+
124
+ __array_api_version__ = "2022.12"
125
+
126
+ __all__ = ["__array_api_version__"]
127
+
128
+ from ._constants import e, inf, nan, pi
129
+
130
+ __all__ += ["e", "inf", "nan", "pi"]
131
+
132
+ from ._creation_functions import (
133
+ asarray,
134
+ arange,
135
+ empty,
136
+ empty_like,
137
+ eye,
138
+ from_dlpack,
139
+ full,
140
+ full_like,
141
+ linspace,
142
+ meshgrid,
143
+ ones,
144
+ ones_like,
145
+ tril,
146
+ triu,
147
+ zeros,
148
+ zeros_like,
149
+ )
150
+
151
+ __all__ += [
152
+ "asarray",
153
+ "arange",
154
+ "empty",
155
+ "empty_like",
156
+ "eye",
157
+ "from_dlpack",
158
+ "full",
159
+ "full_like",
160
+ "linspace",
161
+ "meshgrid",
162
+ "ones",
163
+ "ones_like",
164
+ "tril",
165
+ "triu",
166
+ "zeros",
167
+ "zeros_like",
168
+ ]
169
+
170
+ from ._data_type_functions import (
171
+ astype,
172
+ broadcast_arrays,
173
+ broadcast_to,
174
+ can_cast,
175
+ finfo,
176
+ isdtype,
177
+ iinfo,
178
+ result_type,
179
+ )
180
+
181
+ __all__ += [
182
+ "astype",
183
+ "broadcast_arrays",
184
+ "broadcast_to",
185
+ "can_cast",
186
+ "finfo",
187
+ "iinfo",
188
+ "result_type",
189
+ ]
190
+
191
+ from ._dtypes import (
192
+ int8,
193
+ int16,
194
+ int32,
195
+ int64,
196
+ uint8,
197
+ uint16,
198
+ uint32,
199
+ uint64,
200
+ float32,
201
+ float64,
202
+ complex64,
203
+ complex128,
204
+ bool,
205
+ )
206
+
207
+ __all__ += [
208
+ "int8",
209
+ "int16",
210
+ "int32",
211
+ "int64",
212
+ "uint8",
213
+ "uint16",
214
+ "uint32",
215
+ "uint64",
216
+ "float32",
217
+ "float64",
218
+ "bool",
219
+ ]
220
+
221
+ from ._elementwise_functions import (
222
+ abs,
223
+ acos,
224
+ acosh,
225
+ add,
226
+ asin,
227
+ asinh,
228
+ atan,
229
+ atan2,
230
+ atanh,
231
+ bitwise_and,
232
+ bitwise_left_shift,
233
+ bitwise_invert,
234
+ bitwise_or,
235
+ bitwise_right_shift,
236
+ bitwise_xor,
237
+ ceil,
238
+ conj,
239
+ cos,
240
+ cosh,
241
+ divide,
242
+ equal,
243
+ exp,
244
+ expm1,
245
+ floor,
246
+ floor_divide,
247
+ greater,
248
+ greater_equal,
249
+ imag,
250
+ isfinite,
251
+ isinf,
252
+ isnan,
253
+ less,
254
+ less_equal,
255
+ log,
256
+ log1p,
257
+ log2,
258
+ log10,
259
+ logaddexp,
260
+ logical_and,
261
+ logical_not,
262
+ logical_or,
263
+ logical_xor,
264
+ multiply,
265
+ negative,
266
+ not_equal,
267
+ positive,
268
+ pow,
269
+ real,
270
+ remainder,
271
+ round,
272
+ sign,
273
+ sin,
274
+ sinh,
275
+ square,
276
+ sqrt,
277
+ subtract,
278
+ tan,
279
+ tanh,
280
+ trunc,
281
+ )
282
+
283
+ __all__ += [
284
+ "abs",
285
+ "acos",
286
+ "acosh",
287
+ "add",
288
+ "asin",
289
+ "asinh",
290
+ "atan",
291
+ "atan2",
292
+ "atanh",
293
+ "bitwise_and",
294
+ "bitwise_left_shift",
295
+ "bitwise_invert",
296
+ "bitwise_or",
297
+ "bitwise_right_shift",
298
+ "bitwise_xor",
299
+ "ceil",
300
+ "cos",
301
+ "cosh",
302
+ "divide",
303
+ "equal",
304
+ "exp",
305
+ "expm1",
306
+ "floor",
307
+ "floor_divide",
308
+ "greater",
309
+ "greater_equal",
310
+ "isfinite",
311
+ "isinf",
312
+ "isnan",
313
+ "less",
314
+ "less_equal",
315
+ "log",
316
+ "log1p",
317
+ "log2",
318
+ "log10",
319
+ "logaddexp",
320
+ "logical_and",
321
+ "logical_not",
322
+ "logical_or",
323
+ "logical_xor",
324
+ "multiply",
325
+ "negative",
326
+ "not_equal",
327
+ "positive",
328
+ "pow",
329
+ "remainder",
330
+ "round",
331
+ "sign",
332
+ "sin",
333
+ "sinh",
334
+ "square",
335
+ "sqrt",
336
+ "subtract",
337
+ "tan",
338
+ "tanh",
339
+ "trunc",
340
+ ]
341
+
342
+ from ._indexing_functions import take
343
+
344
+ __all__ += ["take"]
345
+
346
+ # linalg is an extension in the array API spec, which is a sub-namespace. Only
347
+ # a subset of functions in it are imported into the top-level namespace.
348
+ from . import linalg
349
+
350
+ __all__ += ["linalg"]
351
+
352
+ from .linalg import matmul, tensordot, matrix_transpose, vecdot
353
+
354
+ __all__ += ["matmul", "tensordot", "matrix_transpose", "vecdot"]
355
+
356
+ from ._manipulation_functions import (
357
+ concat,
358
+ expand_dims,
359
+ flip,
360
+ permute_dims,
361
+ reshape,
362
+ roll,
363
+ squeeze,
364
+ stack,
365
+ )
366
+
367
+ __all__ += ["concat", "expand_dims", "flip", "permute_dims", "reshape", "roll", "squeeze", "stack"]
368
+
369
+ from ._searching_functions import argmax, argmin, nonzero, where
370
+
371
+ __all__ += ["argmax", "argmin", "nonzero", "where"]
372
+
373
+ from ._set_functions import unique_all, unique_counts, unique_inverse, unique_values
374
+
375
+ __all__ += ["unique_all", "unique_counts", "unique_inverse", "unique_values"]
376
+
377
+ from ._sorting_functions import argsort, sort
378
+
379
+ __all__ += ["argsort", "sort"]
380
+
381
+ from ._statistical_functions import max, mean, min, prod, std, sum, var
382
+
383
+ __all__ += ["max", "mean", "min", "prod", "std", "sum", "var"]
384
+
385
+ from ._utility_functions import all, any
386
+
387
+ __all__ += ["all", "any"]
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_array_object.py ADDED
@@ -0,0 +1,1129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Wrapper class around the ndarray object for the array API standard.
3
+
4
+ The array API standard defines some behaviors differently than ndarray, in
5
+ particular, type promotion rules are different (the standard has no
6
+ value-based casting). The standard also specifies a more limited subset of
7
+ array methods and functionalities than are implemented on ndarray. Since the
8
+ goal of the array_api namespace is to be a minimal implementation of the array
9
+ API standard, we need to define a separate wrapper class for the array_api
10
+ namespace.
11
+
12
+ The standard compliant class is only a wrapper class. It is *not* a subclass
13
+ of ndarray.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ import operator
19
+ from enum import IntEnum
20
+ from ._creation_functions import asarray
21
+ from ._dtypes import (
22
+ _all_dtypes,
23
+ _boolean_dtypes,
24
+ _integer_dtypes,
25
+ _integer_or_boolean_dtypes,
26
+ _floating_dtypes,
27
+ _complex_floating_dtypes,
28
+ _numeric_dtypes,
29
+ _result_type,
30
+ _dtype_categories,
31
+ )
32
+
33
+ from typing import TYPE_CHECKING, Optional, Tuple, Union, Any, SupportsIndex
34
+ import types
35
+
36
+ if TYPE_CHECKING:
37
+ from ._typing import Any, PyCapsule, Device, Dtype
38
+ import numpy.typing as npt
39
+
40
+ import numpy as np
41
+
42
+ from numpy import array_api
43
+
44
+
45
+ class Array:
46
+ """
47
+ n-d array object for the array API namespace.
48
+
49
+ See the docstring of :py:obj:`np.ndarray <numpy.ndarray>` for more
50
+ information.
51
+
52
+ This is a wrapper around numpy.ndarray that restricts the usage to only
53
+ those things that are required by the array API namespace. Note,
54
+ attributes on this object that start with a single underscore are not part
55
+ of the API specification and should only be used internally. This object
56
+ should not be constructed directly. Rather, use one of the creation
57
+ functions, such as asarray().
58
+
59
+ """
60
+ _array: np.ndarray[Any, Any]
61
+
62
+ # Use a custom constructor instead of __init__, as manually initializing
63
+ # this class is not supported API.
64
+ @classmethod
65
+ def _new(cls, x, /):
66
+ """
67
+ This is a private method for initializing the array API Array
68
+ object.
69
+
70
+ Functions outside of the array_api submodule should not use this
71
+ method. Use one of the creation functions instead, such as
72
+ ``asarray``.
73
+
74
+ """
75
+ obj = super().__new__(cls)
76
+ # Note: The spec does not have array scalars, only 0-D arrays.
77
+ if isinstance(x, np.generic):
78
+ # Convert the array scalar to a 0-D array
79
+ x = np.asarray(x)
80
+ if x.dtype not in _all_dtypes:
81
+ raise TypeError(
82
+ f"The array_api namespace does not support the dtype '{x.dtype}'"
83
+ )
84
+ obj._array = x
85
+ return obj
86
+
87
+ # Prevent Array() from working
88
+ def __new__(cls, *args, **kwargs):
89
+ raise TypeError(
90
+ "The array_api Array object should not be instantiated directly. Use an array creation function, such as asarray(), instead."
91
+ )
92
+
93
+ # These functions are not required by the spec, but are implemented for
94
+ # the sake of usability.
95
+
96
+ def __str__(self: Array, /) -> str:
97
+ """
98
+ Performs the operation __str__.
99
+ """
100
+ return self._array.__str__().replace("array", "Array")
101
+
102
+ def __repr__(self: Array, /) -> str:
103
+ """
104
+ Performs the operation __repr__.
105
+ """
106
+ suffix = f", dtype={self.dtype.name})"
107
+ if 0 in self.shape:
108
+ prefix = "empty("
109
+ mid = str(self.shape)
110
+ else:
111
+ prefix = "Array("
112
+ mid = np.array2string(self._array, separator=', ', prefix=prefix, suffix=suffix)
113
+ return prefix + mid + suffix
114
+
115
+ # This function is not required by the spec, but we implement it here for
116
+ # convenience so that np.asarray(np.array_api.Array) will work.
117
+ def __array__(self, dtype: None | np.dtype[Any] = None) -> npt.NDArray[Any]:
118
+ """
119
+ Warning: this method is NOT part of the array API spec. Implementers
120
+ of other libraries need not include it, and users should not assume it
121
+ will be present in other implementations.
122
+
123
+ """
124
+ return np.asarray(self._array, dtype=dtype)
125
+
126
+ # These are various helper functions to make the array behavior match the
127
+ # spec in places where it either deviates from or is more strict than
128
+ # NumPy behavior
129
+
130
+ def _check_allowed_dtypes(self, other: bool | int | float | Array, dtype_category: str, op: str) -> Array:
131
+ """
132
+ Helper function for operators to only allow specific input dtypes
133
+
134
+ Use like
135
+
136
+ other = self._check_allowed_dtypes(other, 'numeric', '__add__')
137
+ if other is NotImplemented:
138
+ return other
139
+ """
140
+
141
+ if self.dtype not in _dtype_categories[dtype_category]:
142
+ raise TypeError(f"Only {dtype_category} dtypes are allowed in {op}")
143
+ if isinstance(other, (int, complex, float, bool)):
144
+ other = self._promote_scalar(other)
145
+ elif isinstance(other, Array):
146
+ if other.dtype not in _dtype_categories[dtype_category]:
147
+ raise TypeError(f"Only {dtype_category} dtypes are allowed in {op}")
148
+ else:
149
+ return NotImplemented
150
+
151
+ # This will raise TypeError for type combinations that are not allowed
152
+ # to promote in the spec (even if the NumPy array operator would
153
+ # promote them).
154
+ res_dtype = _result_type(self.dtype, other.dtype)
155
+ if op.startswith("__i"):
156
+ # Note: NumPy will allow in-place operators in some cases where
157
+ # the type promoted operator does not match the left-hand side
158
+ # operand. For example,
159
+
160
+ # >>> a = np.array(1, dtype=np.int8)
161
+ # >>> a += np.array(1, dtype=np.int16)
162
+
163
+ # The spec explicitly disallows this.
164
+ if res_dtype != self.dtype:
165
+ raise TypeError(
166
+ f"Cannot perform {op} with dtypes {self.dtype} and {other.dtype}"
167
+ )
168
+
169
+ return other
170
+
171
+ # Helper function to match the type promotion rules in the spec
172
+ def _promote_scalar(self, scalar):
173
+ """
174
+ Returns a promoted version of a Python scalar appropriate for use with
175
+ operations on self.
176
+
177
+ This may raise an OverflowError in cases where the scalar is an
178
+ integer that is too large to fit in a NumPy integer dtype, or
179
+ TypeError when the scalar type is incompatible with the dtype of self.
180
+ """
181
+ # Note: Only Python scalar types that match the array dtype are
182
+ # allowed.
183
+ if isinstance(scalar, bool):
184
+ if self.dtype not in _boolean_dtypes:
185
+ raise TypeError(
186
+ "Python bool scalars can only be promoted with bool arrays"
187
+ )
188
+ elif isinstance(scalar, int):
189
+ if self.dtype in _boolean_dtypes:
190
+ raise TypeError(
191
+ "Python int scalars cannot be promoted with bool arrays"
192
+ )
193
+ if self.dtype in _integer_dtypes:
194
+ info = np.iinfo(self.dtype)
195
+ if not (info.min <= scalar <= info.max):
196
+ raise OverflowError(
197
+ "Python int scalars must be within the bounds of the dtype for integer arrays"
198
+ )
199
+ # int + array(floating) is allowed
200
+ elif isinstance(scalar, float):
201
+ if self.dtype not in _floating_dtypes:
202
+ raise TypeError(
203
+ "Python float scalars can only be promoted with floating-point arrays."
204
+ )
205
+ elif isinstance(scalar, complex):
206
+ if self.dtype not in _complex_floating_dtypes:
207
+ raise TypeError(
208
+ "Python complex scalars can only be promoted with complex floating-point arrays."
209
+ )
210
+ else:
211
+ raise TypeError("'scalar' must be a Python scalar")
212
+
213
+ # Note: scalars are unconditionally cast to the same dtype as the
214
+ # array.
215
+
216
+ # Note: the spec only specifies integer-dtype/int promotion
217
+ # behavior for integers within the bounds of the integer dtype.
218
+ # Outside of those bounds we use the default NumPy behavior (either
219
+ # cast or raise OverflowError).
220
+ return Array._new(np.array(scalar, self.dtype))
221
+
222
+ @staticmethod
223
+ def _normalize_two_args(x1, x2) -> Tuple[Array, Array]:
224
+ """
225
+ Normalize inputs to two arg functions to fix type promotion rules
226
+
227
+ NumPy deviates from the spec type promotion rules in cases where one
228
+ argument is 0-dimensional and the other is not. For example:
229
+
230
+ >>> import numpy as np
231
+ >>> a = np.array([1.0], dtype=np.float32)
232
+ >>> b = np.array(1.0, dtype=np.float64)
233
+ >>> np.add(a, b) # The spec says this should be float64
234
+ array([2.], dtype=float32)
235
+
236
+ To fix this, we add a dimension to the 0-dimension array before passing it
237
+ through. This works because a dimension would be added anyway from
238
+ broadcasting, so the resulting shape is the same, but this prevents NumPy
239
+ from not promoting the dtype.
240
+ """
241
+ # Another option would be to use signature=(x1.dtype, x2.dtype, None),
242
+ # but that only works for ufuncs, so we would have to call the ufuncs
243
+ # directly in the operator methods. One should also note that this
244
+ # sort of trick wouldn't work for functions like searchsorted, which
245
+ # don't do normal broadcasting, but there aren't any functions like
246
+ # that in the array API namespace.
247
+ if x1.ndim == 0 and x2.ndim != 0:
248
+ # The _array[None] workaround was chosen because it is relatively
249
+ # performant. broadcast_to(x1._array, x2.shape) is much slower. We
250
+ # could also manually type promote x2, but that is more complicated
251
+ # and about the same performance as this.
252
+ x1 = Array._new(x1._array[None])
253
+ elif x2.ndim == 0 and x1.ndim != 0:
254
+ x2 = Array._new(x2._array[None])
255
+ return (x1, x2)
256
+
257
+ # Note: A large fraction of allowed indices are disallowed here (see the
258
+ # docstring below)
259
+ def _validate_index(self, key):
260
+ """
261
+ Validate an index according to the array API.
262
+
263
+ The array API specification only requires a subset of indices that are
264
+ supported by NumPy. This function will reject any index that is
265
+ allowed by NumPy but not required by the array API specification. We
266
+ always raise ``IndexError`` on such indices (the spec does not require
267
+ any specific behavior on them, but this makes the NumPy array API
268
+ namespace a minimal implementation of the spec). See
269
+ https://data-apis.org/array-api/latest/API_specification/indexing.html
270
+ for the full list of required indexing behavior
271
+
272
+ This function raises IndexError if the index ``key`` is invalid. It
273
+ only raises ``IndexError`` on indices that are not already rejected by
274
+ NumPy, as NumPy will already raise the appropriate error on such
275
+ indices. ``shape`` may be None, in which case, only cases that are
276
+ independent of the array shape are checked.
277
+
278
+ The following cases are allowed by NumPy, but not specified by the array
279
+ API specification:
280
+
281
+ - Indices to not include an implicit ellipsis at the end. That is,
282
+ every axis of an array must be explicitly indexed or an ellipsis
283
+ included. This behaviour is sometimes referred to as flat indexing.
284
+
285
+ - The start and stop of a slice may not be out of bounds. In
286
+ particular, for a slice ``i:j:k`` on an axis of size ``n``, only the
287
+ following are allowed:
288
+
289
+ - ``i`` or ``j`` omitted (``None``).
290
+ - ``-n <= i <= max(0, n - 1)``.
291
+ - For ``k > 0`` or ``k`` omitted (``None``), ``-n <= j <= n``.
292
+ - For ``k < 0``, ``-n - 1 <= j <= max(0, n - 1)``.
293
+
294
+ - Boolean array indices are not allowed as part of a larger tuple
295
+ index.
296
+
297
+ - Integer array indices are not allowed (with the exception of 0-D
298
+ arrays, which are treated the same as scalars).
299
+
300
+ Additionally, it should be noted that indices that would return a
301
+ scalar in NumPy will return a 0-D array. Array scalars are not allowed
302
+ in the specification, only 0-D arrays. This is done in the
303
+ ``Array._new`` constructor, not this function.
304
+
305
+ """
306
+ _key = key if isinstance(key, tuple) else (key,)
307
+ for i in _key:
308
+ if isinstance(i, bool) or not (
309
+ isinstance(i, SupportsIndex) # i.e. ints
310
+ or isinstance(i, slice)
311
+ or i == Ellipsis
312
+ or i is None
313
+ or isinstance(i, Array)
314
+ or isinstance(i, np.ndarray)
315
+ ):
316
+ raise IndexError(
317
+ f"Single-axes index {i} has {type(i)=}, but only "
318
+ "integers, slices (:), ellipsis (...), newaxis (None), "
319
+ "zero-dimensional integer arrays and boolean arrays "
320
+ "are specified in the Array API."
321
+ )
322
+
323
+ nonexpanding_key = []
324
+ single_axes = []
325
+ n_ellipsis = 0
326
+ key_has_mask = False
327
+ for i in _key:
328
+ if i is not None:
329
+ nonexpanding_key.append(i)
330
+ if isinstance(i, Array) or isinstance(i, np.ndarray):
331
+ if i.dtype in _boolean_dtypes:
332
+ key_has_mask = True
333
+ single_axes.append(i)
334
+ else:
335
+ # i must not be an array here, to avoid elementwise equals
336
+ if i == Ellipsis:
337
+ n_ellipsis += 1
338
+ else:
339
+ single_axes.append(i)
340
+
341
+ n_single_axes = len(single_axes)
342
+ if n_ellipsis > 1:
343
+ return # handled by ndarray
344
+ elif n_ellipsis == 0:
345
+ # Note boolean masks must be the sole index, which we check for
346
+ # later on.
347
+ if not key_has_mask and n_single_axes < self.ndim:
348
+ raise IndexError(
349
+ f"{self.ndim=}, but the multi-axes index only specifies "
350
+ f"{n_single_axes} dimensions. If this was intentional, "
351
+ "add a trailing ellipsis (...) which expands into as many "
352
+ "slices (:) as necessary - this is what np.ndarray arrays "
353
+ "implicitly do, but such flat indexing behaviour is not "
354
+ "specified in the Array API."
355
+ )
356
+
357
+ if n_ellipsis == 0:
358
+ indexed_shape = self.shape
359
+ else:
360
+ ellipsis_start = None
361
+ for pos, i in enumerate(nonexpanding_key):
362
+ if not (isinstance(i, Array) or isinstance(i, np.ndarray)):
363
+ if i == Ellipsis:
364
+ ellipsis_start = pos
365
+ break
366
+ assert ellipsis_start is not None # sanity check
367
+ ellipsis_end = self.ndim - (n_single_axes - ellipsis_start)
368
+ indexed_shape = (
369
+ self.shape[:ellipsis_start] + self.shape[ellipsis_end:]
370
+ )
371
+ for i, side in zip(single_axes, indexed_shape):
372
+ if isinstance(i, slice):
373
+ if side == 0:
374
+ f_range = "0 (or None)"
375
+ else:
376
+ f_range = f"between -{side} and {side - 1} (or None)"
377
+ if i.start is not None:
378
+ try:
379
+ start = operator.index(i.start)
380
+ except TypeError:
381
+ pass # handled by ndarray
382
+ else:
383
+ if not (-side <= start <= side):
384
+ raise IndexError(
385
+ f"Slice {i} contains {start=}, but should be "
386
+ f"{f_range} for an axis of size {side} "
387
+ "(out-of-bounds starts are not specified in "
388
+ "the Array API)"
389
+ )
390
+ if i.stop is not None:
391
+ try:
392
+ stop = operator.index(i.stop)
393
+ except TypeError:
394
+ pass # handled by ndarray
395
+ else:
396
+ if not (-side <= stop <= side):
397
+ raise IndexError(
398
+ f"Slice {i} contains {stop=}, but should be "
399
+ f"{f_range} for an axis of size {side} "
400
+ "(out-of-bounds stops are not specified in "
401
+ "the Array API)"
402
+ )
403
+ elif isinstance(i, Array):
404
+ if i.dtype in _boolean_dtypes and len(_key) != 1:
405
+ assert isinstance(key, tuple) # sanity check
406
+ raise IndexError(
407
+ f"Single-axes index {i} is a boolean array and "
408
+ f"{len(key)=}, but masking is only specified in the "
409
+ "Array API when the array is the sole index."
410
+ )
411
+ elif i.dtype in _integer_dtypes and i.ndim != 0:
412
+ raise IndexError(
413
+ f"Single-axes index {i} is a non-zero-dimensional "
414
+ "integer array, but advanced integer indexing is not "
415
+ "specified in the Array API."
416
+ )
417
+ elif isinstance(i, tuple):
418
+ raise IndexError(
419
+ f"Single-axes index {i} is a tuple, but nested tuple "
420
+ "indices are not specified in the Array API."
421
+ )
422
+
423
+ # Everything below this line is required by the spec.
424
+
425
+ def __abs__(self: Array, /) -> Array:
426
+ """
427
+ Performs the operation __abs__.
428
+ """
429
+ if self.dtype not in _numeric_dtypes:
430
+ raise TypeError("Only numeric dtypes are allowed in __abs__")
431
+ res = self._array.__abs__()
432
+ return self.__class__._new(res)
433
+
434
+ def __add__(self: Array, other: Union[int, float, Array], /) -> Array:
435
+ """
436
+ Performs the operation __add__.
437
+ """
438
+ other = self._check_allowed_dtypes(other, "numeric", "__add__")
439
+ if other is NotImplemented:
440
+ return other
441
+ self, other = self._normalize_two_args(self, other)
442
+ res = self._array.__add__(other._array)
443
+ return self.__class__._new(res)
444
+
445
+ def __and__(self: Array, other: Union[int, bool, Array], /) -> Array:
446
+ """
447
+ Performs the operation __and__.
448
+ """
449
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__and__")
450
+ if other is NotImplemented:
451
+ return other
452
+ self, other = self._normalize_two_args(self, other)
453
+ res = self._array.__and__(other._array)
454
+ return self.__class__._new(res)
455
+
456
+ def __array_namespace__(
457
+ self: Array, /, *, api_version: Optional[str] = None
458
+ ) -> types.ModuleType:
459
+ if api_version is not None and not api_version.startswith("2021."):
460
+ raise ValueError(f"Unrecognized array API version: {api_version!r}")
461
+ return array_api
462
+
463
+ def __bool__(self: Array, /) -> bool:
464
+ """
465
+ Performs the operation __bool__.
466
+ """
467
+ # Note: This is an error here.
468
+ if self._array.ndim != 0:
469
+ raise TypeError("bool is only allowed on arrays with 0 dimensions")
470
+ res = self._array.__bool__()
471
+ return res
472
+
473
+ def __complex__(self: Array, /) -> complex:
474
+ """
475
+ Performs the operation __complex__.
476
+ """
477
+ # Note: This is an error here.
478
+ if self._array.ndim != 0:
479
+ raise TypeError("complex is only allowed on arrays with 0 dimensions")
480
+ res = self._array.__complex__()
481
+ return res
482
+
483
+ def __dlpack__(self: Array, /, *, stream: None = None) -> PyCapsule:
484
+ """
485
+ Performs the operation __dlpack__.
486
+ """
487
+ return self._array.__dlpack__(stream=stream)
488
+
489
+ def __dlpack_device__(self: Array, /) -> Tuple[IntEnum, int]:
490
+ """
491
+ Performs the operation __dlpack_device__.
492
+ """
493
+ # Note: device support is required for this
494
+ return self._array.__dlpack_device__()
495
+
496
+ def __eq__(self: Array, other: Union[int, float, bool, Array], /) -> Array:
497
+ """
498
+ Performs the operation __eq__.
499
+ """
500
+ # Even though "all" dtypes are allowed, we still require them to be
501
+ # promotable with each other.
502
+ other = self._check_allowed_dtypes(other, "all", "__eq__")
503
+ if other is NotImplemented:
504
+ return other
505
+ self, other = self._normalize_two_args(self, other)
506
+ res = self._array.__eq__(other._array)
507
+ return self.__class__._new(res)
508
+
509
+ def __float__(self: Array, /) -> float:
510
+ """
511
+ Performs the operation __float__.
512
+ """
513
+ # Note: This is an error here.
514
+ if self._array.ndim != 0:
515
+ raise TypeError("float is only allowed on arrays with 0 dimensions")
516
+ if self.dtype in _complex_floating_dtypes:
517
+ raise TypeError("float is not allowed on complex floating-point arrays")
518
+ res = self._array.__float__()
519
+ return res
520
+
521
+ def __floordiv__(self: Array, other: Union[int, float, Array], /) -> Array:
522
+ """
523
+ Performs the operation __floordiv__.
524
+ """
525
+ other = self._check_allowed_dtypes(other, "real numeric", "__floordiv__")
526
+ if other is NotImplemented:
527
+ return other
528
+ self, other = self._normalize_two_args(self, other)
529
+ res = self._array.__floordiv__(other._array)
530
+ return self.__class__._new(res)
531
+
532
+ def __ge__(self: Array, other: Union[int, float, Array], /) -> Array:
533
+ """
534
+ Performs the operation __ge__.
535
+ """
536
+ other = self._check_allowed_dtypes(other, "real numeric", "__ge__")
537
+ if other is NotImplemented:
538
+ return other
539
+ self, other = self._normalize_two_args(self, other)
540
+ res = self._array.__ge__(other._array)
541
+ return self.__class__._new(res)
542
+
543
+ def __getitem__(
544
+ self: Array,
545
+ key: Union[
546
+ int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array
547
+ ],
548
+ /,
549
+ ) -> Array:
550
+ """
551
+ Performs the operation __getitem__.
552
+ """
553
+ # Note: Only indices required by the spec are allowed. See the
554
+ # docstring of _validate_index
555
+ self._validate_index(key)
556
+ if isinstance(key, Array):
557
+ # Indexing self._array with array_api arrays can be erroneous
558
+ key = key._array
559
+ res = self._array.__getitem__(key)
560
+ return self._new(res)
561
+
562
+ def __gt__(self: Array, other: Union[int, float, Array], /) -> Array:
563
+ """
564
+ Performs the operation __gt__.
565
+ """
566
+ other = self._check_allowed_dtypes(other, "real numeric", "__gt__")
567
+ if other is NotImplemented:
568
+ return other
569
+ self, other = self._normalize_two_args(self, other)
570
+ res = self._array.__gt__(other._array)
571
+ return self.__class__._new(res)
572
+
573
+ def __int__(self: Array, /) -> int:
574
+ """
575
+ Performs the operation __int__.
576
+ """
577
+ # Note: This is an error here.
578
+ if self._array.ndim != 0:
579
+ raise TypeError("int is only allowed on arrays with 0 dimensions")
580
+ if self.dtype in _complex_floating_dtypes:
581
+ raise TypeError("int is not allowed on complex floating-point arrays")
582
+ res = self._array.__int__()
583
+ return res
584
+
585
+ def __index__(self: Array, /) -> int:
586
+ """
587
+ Performs the operation __index__.
588
+ """
589
+ res = self._array.__index__()
590
+ return res
591
+
592
+ def __invert__(self: Array, /) -> Array:
593
+ """
594
+ Performs the operation __invert__.
595
+ """
596
+ if self.dtype not in _integer_or_boolean_dtypes:
597
+ raise TypeError("Only integer or boolean dtypes are allowed in __invert__")
598
+ res = self._array.__invert__()
599
+ return self.__class__._new(res)
600
+
601
+ def __le__(self: Array, other: Union[int, float, Array], /) -> Array:
602
+ """
603
+ Performs the operation __le__.
604
+ """
605
+ other = self._check_allowed_dtypes(other, "real numeric", "__le__")
606
+ if other is NotImplemented:
607
+ return other
608
+ self, other = self._normalize_two_args(self, other)
609
+ res = self._array.__le__(other._array)
610
+ return self.__class__._new(res)
611
+
612
+ def __lshift__(self: Array, other: Union[int, Array], /) -> Array:
613
+ """
614
+ Performs the operation __lshift__.
615
+ """
616
+ other = self._check_allowed_dtypes(other, "integer", "__lshift__")
617
+ if other is NotImplemented:
618
+ return other
619
+ self, other = self._normalize_two_args(self, other)
620
+ res = self._array.__lshift__(other._array)
621
+ return self.__class__._new(res)
622
+
623
+ def __lt__(self: Array, other: Union[int, float, Array], /) -> Array:
624
+ """
625
+ Performs the operation __lt__.
626
+ """
627
+ other = self._check_allowed_dtypes(other, "real numeric", "__lt__")
628
+ if other is NotImplemented:
629
+ return other
630
+ self, other = self._normalize_two_args(self, other)
631
+ res = self._array.__lt__(other._array)
632
+ return self.__class__._new(res)
633
+
634
+ def __matmul__(self: Array, other: Array, /) -> Array:
635
+ """
636
+ Performs the operation __matmul__.
637
+ """
638
+ # matmul is not defined for scalars, but without this, we may get
639
+ # the wrong error message from asarray.
640
+ other = self._check_allowed_dtypes(other, "numeric", "__matmul__")
641
+ if other is NotImplemented:
642
+ return other
643
+ res = self._array.__matmul__(other._array)
644
+ return self.__class__._new(res)
645
+
646
+ def __mod__(self: Array, other: Union[int, float, Array], /) -> Array:
647
+ """
648
+ Performs the operation __mod__.
649
+ """
650
+ other = self._check_allowed_dtypes(other, "real numeric", "__mod__")
651
+ if other is NotImplemented:
652
+ return other
653
+ self, other = self._normalize_two_args(self, other)
654
+ res = self._array.__mod__(other._array)
655
+ return self.__class__._new(res)
656
+
657
+ def __mul__(self: Array, other: Union[int, float, Array], /) -> Array:
658
+ """
659
+ Performs the operation __mul__.
660
+ """
661
+ other = self._check_allowed_dtypes(other, "numeric", "__mul__")
662
+ if other is NotImplemented:
663
+ return other
664
+ self, other = self._normalize_two_args(self, other)
665
+ res = self._array.__mul__(other._array)
666
+ return self.__class__._new(res)
667
+
668
+ def __ne__(self: Array, other: Union[int, float, bool, Array], /) -> Array:
669
+ """
670
+ Performs the operation __ne__.
671
+ """
672
+ other = self._check_allowed_dtypes(other, "all", "__ne__")
673
+ if other is NotImplemented:
674
+ return other
675
+ self, other = self._normalize_two_args(self, other)
676
+ res = self._array.__ne__(other._array)
677
+ return self.__class__._new(res)
678
+
679
+ def __neg__(self: Array, /) -> Array:
680
+ """
681
+ Performs the operation __neg__.
682
+ """
683
+ if self.dtype not in _numeric_dtypes:
684
+ raise TypeError("Only numeric dtypes are allowed in __neg__")
685
+ res = self._array.__neg__()
686
+ return self.__class__._new(res)
687
+
688
+ def __or__(self: Array, other: Union[int, bool, Array], /) -> Array:
689
+ """
690
+ Performs the operation __or__.
691
+ """
692
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__or__")
693
+ if other is NotImplemented:
694
+ return other
695
+ self, other = self._normalize_two_args(self, other)
696
+ res = self._array.__or__(other._array)
697
+ return self.__class__._new(res)
698
+
699
+ def __pos__(self: Array, /) -> Array:
700
+ """
701
+ Performs the operation __pos__.
702
+ """
703
+ if self.dtype not in _numeric_dtypes:
704
+ raise TypeError("Only numeric dtypes are allowed in __pos__")
705
+ res = self._array.__pos__()
706
+ return self.__class__._new(res)
707
+
708
+ def __pow__(self: Array, other: Union[int, float, Array], /) -> Array:
709
+ """
710
+ Performs the operation __pow__.
711
+ """
712
+ from ._elementwise_functions import pow
713
+
714
+ other = self._check_allowed_dtypes(other, "numeric", "__pow__")
715
+ if other is NotImplemented:
716
+ return other
717
+ # Note: NumPy's __pow__ does not follow type promotion rules for 0-d
718
+ # arrays, so we use pow() here instead.
719
+ return pow(self, other)
720
+
721
+ def __rshift__(self: Array, other: Union[int, Array], /) -> Array:
722
+ """
723
+ Performs the operation __rshift__.
724
+ """
725
+ other = self._check_allowed_dtypes(other, "integer", "__rshift__")
726
+ if other is NotImplemented:
727
+ return other
728
+ self, other = self._normalize_two_args(self, other)
729
+ res = self._array.__rshift__(other._array)
730
+ return self.__class__._new(res)
731
+
732
+ def __setitem__(
733
+ self,
734
+ key: Union[
735
+ int, slice, ellipsis, Tuple[Union[int, slice, ellipsis], ...], Array
736
+ ],
737
+ value: Union[int, float, bool, Array],
738
+ /,
739
+ ) -> None:
740
+ """
741
+ Performs the operation __setitem__.
742
+ """
743
+ # Note: Only indices required by the spec are allowed. See the
744
+ # docstring of _validate_index
745
+ self._validate_index(key)
746
+ if isinstance(key, Array):
747
+ # Indexing self._array with array_api arrays can be erroneous
748
+ key = key._array
749
+ self._array.__setitem__(key, asarray(value)._array)
750
+
751
+ def __sub__(self: Array, other: Union[int, float, Array], /) -> Array:
752
+ """
753
+ Performs the operation __sub__.
754
+ """
755
+ other = self._check_allowed_dtypes(other, "numeric", "__sub__")
756
+ if other is NotImplemented:
757
+ return other
758
+ self, other = self._normalize_two_args(self, other)
759
+ res = self._array.__sub__(other._array)
760
+ return self.__class__._new(res)
761
+
762
+ # PEP 484 requires int to be a subtype of float, but __truediv__ should
763
+ # not accept int.
764
+ def __truediv__(self: Array, other: Union[float, Array], /) -> Array:
765
+ """
766
+ Performs the operation __truediv__.
767
+ """
768
+ other = self._check_allowed_dtypes(other, "floating-point", "__truediv__")
769
+ if other is NotImplemented:
770
+ return other
771
+ self, other = self._normalize_two_args(self, other)
772
+ res = self._array.__truediv__(other._array)
773
+ return self.__class__._new(res)
774
+
775
+ def __xor__(self: Array, other: Union[int, bool, Array], /) -> Array:
776
+ """
777
+ Performs the operation __xor__.
778
+ """
779
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__xor__")
780
+ if other is NotImplemented:
781
+ return other
782
+ self, other = self._normalize_two_args(self, other)
783
+ res = self._array.__xor__(other._array)
784
+ return self.__class__._new(res)
785
+
786
+ def __iadd__(self: Array, other: Union[int, float, Array], /) -> Array:
787
+ """
788
+ Performs the operation __iadd__.
789
+ """
790
+ other = self._check_allowed_dtypes(other, "numeric", "__iadd__")
791
+ if other is NotImplemented:
792
+ return other
793
+ self._array.__iadd__(other._array)
794
+ return self
795
+
796
+ def __radd__(self: Array, other: Union[int, float, Array], /) -> Array:
797
+ """
798
+ Performs the operation __radd__.
799
+ """
800
+ other = self._check_allowed_dtypes(other, "numeric", "__radd__")
801
+ if other is NotImplemented:
802
+ return other
803
+ self, other = self._normalize_two_args(self, other)
804
+ res = self._array.__radd__(other._array)
805
+ return self.__class__._new(res)
806
+
807
+ def __iand__(self: Array, other: Union[int, bool, Array], /) -> Array:
808
+ """
809
+ Performs the operation __iand__.
810
+ """
811
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__iand__")
812
+ if other is NotImplemented:
813
+ return other
814
+ self._array.__iand__(other._array)
815
+ return self
816
+
817
+ def __rand__(self: Array, other: Union[int, bool, Array], /) -> Array:
818
+ """
819
+ Performs the operation __rand__.
820
+ """
821
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__rand__")
822
+ if other is NotImplemented:
823
+ return other
824
+ self, other = self._normalize_two_args(self, other)
825
+ res = self._array.__rand__(other._array)
826
+ return self.__class__._new(res)
827
+
828
+ def __ifloordiv__(self: Array, other: Union[int, float, Array], /) -> Array:
829
+ """
830
+ Performs the operation __ifloordiv__.
831
+ """
832
+ other = self._check_allowed_dtypes(other, "real numeric", "__ifloordiv__")
833
+ if other is NotImplemented:
834
+ return other
835
+ self._array.__ifloordiv__(other._array)
836
+ return self
837
+
838
+ def __rfloordiv__(self: Array, other: Union[int, float, Array], /) -> Array:
839
+ """
840
+ Performs the operation __rfloordiv__.
841
+ """
842
+ other = self._check_allowed_dtypes(other, "real numeric", "__rfloordiv__")
843
+ if other is NotImplemented:
844
+ return other
845
+ self, other = self._normalize_two_args(self, other)
846
+ res = self._array.__rfloordiv__(other._array)
847
+ return self.__class__._new(res)
848
+
849
+ def __ilshift__(self: Array, other: Union[int, Array], /) -> Array:
850
+ """
851
+ Performs the operation __ilshift__.
852
+ """
853
+ other = self._check_allowed_dtypes(other, "integer", "__ilshift__")
854
+ if other is NotImplemented:
855
+ return other
856
+ self._array.__ilshift__(other._array)
857
+ return self
858
+
859
+ def __rlshift__(self: Array, other: Union[int, Array], /) -> Array:
860
+ """
861
+ Performs the operation __rlshift__.
862
+ """
863
+ other = self._check_allowed_dtypes(other, "integer", "__rlshift__")
864
+ if other is NotImplemented:
865
+ return other
866
+ self, other = self._normalize_two_args(self, other)
867
+ res = self._array.__rlshift__(other._array)
868
+ return self.__class__._new(res)
869
+
870
+ def __imatmul__(self: Array, other: Array, /) -> Array:
871
+ """
872
+ Performs the operation __imatmul__.
873
+ """
874
+ # matmul is not defined for scalars, but without this, we may get
875
+ # the wrong error message from asarray.
876
+ other = self._check_allowed_dtypes(other, "numeric", "__imatmul__")
877
+ if other is NotImplemented:
878
+ return other
879
+ res = self._array.__imatmul__(other._array)
880
+ return self.__class__._new(res)
881
+
882
+ def __rmatmul__(self: Array, other: Array, /) -> Array:
883
+ """
884
+ Performs the operation __rmatmul__.
885
+ """
886
+ # matmul is not defined for scalars, but without this, we may get
887
+ # the wrong error message from asarray.
888
+ other = self._check_allowed_dtypes(other, "numeric", "__rmatmul__")
889
+ if other is NotImplemented:
890
+ return other
891
+ res = self._array.__rmatmul__(other._array)
892
+ return self.__class__._new(res)
893
+
894
+ def __imod__(self: Array, other: Union[int, float, Array], /) -> Array:
895
+ """
896
+ Performs the operation __imod__.
897
+ """
898
+ other = self._check_allowed_dtypes(other, "real numeric", "__imod__")
899
+ if other is NotImplemented:
900
+ return other
901
+ self._array.__imod__(other._array)
902
+ return self
903
+
904
+ def __rmod__(self: Array, other: Union[int, float, Array], /) -> Array:
905
+ """
906
+ Performs the operation __rmod__.
907
+ """
908
+ other = self._check_allowed_dtypes(other, "real numeric", "__rmod__")
909
+ if other is NotImplemented:
910
+ return other
911
+ self, other = self._normalize_two_args(self, other)
912
+ res = self._array.__rmod__(other._array)
913
+ return self.__class__._new(res)
914
+
915
+ def __imul__(self: Array, other: Union[int, float, Array], /) -> Array:
916
+ """
917
+ Performs the operation __imul__.
918
+ """
919
+ other = self._check_allowed_dtypes(other, "numeric", "__imul__")
920
+ if other is NotImplemented:
921
+ return other
922
+ self._array.__imul__(other._array)
923
+ return self
924
+
925
+ def __rmul__(self: Array, other: Union[int, float, Array], /) -> Array:
926
+ """
927
+ Performs the operation __rmul__.
928
+ """
929
+ other = self._check_allowed_dtypes(other, "numeric", "__rmul__")
930
+ if other is NotImplemented:
931
+ return other
932
+ self, other = self._normalize_two_args(self, other)
933
+ res = self._array.__rmul__(other._array)
934
+ return self.__class__._new(res)
935
+
936
+ def __ior__(self: Array, other: Union[int, bool, Array], /) -> Array:
937
+ """
938
+ Performs the operation __ior__.
939
+ """
940
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__ior__")
941
+ if other is NotImplemented:
942
+ return other
943
+ self._array.__ior__(other._array)
944
+ return self
945
+
946
+ def __ror__(self: Array, other: Union[int, bool, Array], /) -> Array:
947
+ """
948
+ Performs the operation __ror__.
949
+ """
950
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__ror__")
951
+ if other is NotImplemented:
952
+ return other
953
+ self, other = self._normalize_two_args(self, other)
954
+ res = self._array.__ror__(other._array)
955
+ return self.__class__._new(res)
956
+
957
+ def __ipow__(self: Array, other: Union[int, float, Array], /) -> Array:
958
+ """
959
+ Performs the operation __ipow__.
960
+ """
961
+ other = self._check_allowed_dtypes(other, "numeric", "__ipow__")
962
+ if other is NotImplemented:
963
+ return other
964
+ self._array.__ipow__(other._array)
965
+ return self
966
+
967
+ def __rpow__(self: Array, other: Union[int, float, Array], /) -> Array:
968
+ """
969
+ Performs the operation __rpow__.
970
+ """
971
+ from ._elementwise_functions import pow
972
+
973
+ other = self._check_allowed_dtypes(other, "numeric", "__rpow__")
974
+ if other is NotImplemented:
975
+ return other
976
+ # Note: NumPy's __pow__ does not follow the spec type promotion rules
977
+ # for 0-d arrays, so we use pow() here instead.
978
+ return pow(other, self)
979
+
980
+ def __irshift__(self: Array, other: Union[int, Array], /) -> Array:
981
+ """
982
+ Performs the operation __irshift__.
983
+ """
984
+ other = self._check_allowed_dtypes(other, "integer", "__irshift__")
985
+ if other is NotImplemented:
986
+ return other
987
+ self._array.__irshift__(other._array)
988
+ return self
989
+
990
+ def __rrshift__(self: Array, other: Union[int, Array], /) -> Array:
991
+ """
992
+ Performs the operation __rrshift__.
993
+ """
994
+ other = self._check_allowed_dtypes(other, "integer", "__rrshift__")
995
+ if other is NotImplemented:
996
+ return other
997
+ self, other = self._normalize_two_args(self, other)
998
+ res = self._array.__rrshift__(other._array)
999
+ return self.__class__._new(res)
1000
+
1001
+ def __isub__(self: Array, other: Union[int, float, Array], /) -> Array:
1002
+ """
1003
+ Performs the operation __isub__.
1004
+ """
1005
+ other = self._check_allowed_dtypes(other, "numeric", "__isub__")
1006
+ if other is NotImplemented:
1007
+ return other
1008
+ self._array.__isub__(other._array)
1009
+ return self
1010
+
1011
+ def __rsub__(self: Array, other: Union[int, float, Array], /) -> Array:
1012
+ """
1013
+ Performs the operation __rsub__.
1014
+ """
1015
+ other = self._check_allowed_dtypes(other, "numeric", "__rsub__")
1016
+ if other is NotImplemented:
1017
+ return other
1018
+ self, other = self._normalize_two_args(self, other)
1019
+ res = self._array.__rsub__(other._array)
1020
+ return self.__class__._new(res)
1021
+
1022
+ def __itruediv__(self: Array, other: Union[float, Array], /) -> Array:
1023
+ """
1024
+ Performs the operation __itruediv__.
1025
+ """
1026
+ other = self._check_allowed_dtypes(other, "floating-point", "__itruediv__")
1027
+ if other is NotImplemented:
1028
+ return other
1029
+ self._array.__itruediv__(other._array)
1030
+ return self
1031
+
1032
+ def __rtruediv__(self: Array, other: Union[float, Array], /) -> Array:
1033
+ """
1034
+ Performs the operation __rtruediv__.
1035
+ """
1036
+ other = self._check_allowed_dtypes(other, "floating-point", "__rtruediv__")
1037
+ if other is NotImplemented:
1038
+ return other
1039
+ self, other = self._normalize_two_args(self, other)
1040
+ res = self._array.__rtruediv__(other._array)
1041
+ return self.__class__._new(res)
1042
+
1043
+ def __ixor__(self: Array, other: Union[int, bool, Array], /) -> Array:
1044
+ """
1045
+ Performs the operation __ixor__.
1046
+ """
1047
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__ixor__")
1048
+ if other is NotImplemented:
1049
+ return other
1050
+ self._array.__ixor__(other._array)
1051
+ return self
1052
+
1053
+ def __rxor__(self: Array, other: Union[int, bool, Array], /) -> Array:
1054
+ """
1055
+ Performs the operation __rxor__.
1056
+ """
1057
+ other = self._check_allowed_dtypes(other, "integer or boolean", "__rxor__")
1058
+ if other is NotImplemented:
1059
+ return other
1060
+ self, other = self._normalize_two_args(self, other)
1061
+ res = self._array.__rxor__(other._array)
1062
+ return self.__class__._new(res)
1063
+
1064
+ def to_device(self: Array, device: Device, /, stream: None = None) -> Array:
1065
+ if stream is not None:
1066
+ raise ValueError("The stream argument to to_device() is not supported")
1067
+ if device == 'cpu':
1068
+ return self
1069
+ raise ValueError(f"Unsupported device {device!r}")
1070
+
1071
+ @property
1072
+ def dtype(self) -> Dtype:
1073
+ """
1074
+ Array API compatible wrapper for :py:meth:`np.ndarray.dtype <numpy.ndarray.dtype>`.
1075
+
1076
+ See its docstring for more information.
1077
+ """
1078
+ return self._array.dtype
1079
+
1080
+ @property
1081
+ def device(self) -> Device:
1082
+ return "cpu"
1083
+
1084
+ # Note: mT is new in array API spec (see matrix_transpose)
1085
+ @property
1086
+ def mT(self) -> Array:
1087
+ from .linalg import matrix_transpose
1088
+ return matrix_transpose(self)
1089
+
1090
+ @property
1091
+ def ndim(self) -> int:
1092
+ """
1093
+ Array API compatible wrapper for :py:meth:`np.ndarray.ndim <numpy.ndarray.ndim>`.
1094
+
1095
+ See its docstring for more information.
1096
+ """
1097
+ return self._array.ndim
1098
+
1099
+ @property
1100
+ def shape(self) -> Tuple[int, ...]:
1101
+ """
1102
+ Array API compatible wrapper for :py:meth:`np.ndarray.shape <numpy.ndarray.shape>`.
1103
+
1104
+ See its docstring for more information.
1105
+ """
1106
+ return self._array.shape
1107
+
1108
+ @property
1109
+ def size(self) -> int:
1110
+ """
1111
+ Array API compatible wrapper for :py:meth:`np.ndarray.size <numpy.ndarray.size>`.
1112
+
1113
+ See its docstring for more information.
1114
+ """
1115
+ return self._array.size
1116
+
1117
+ @property
1118
+ def T(self) -> Array:
1119
+ """
1120
+ Array API compatible wrapper for :py:meth:`np.ndarray.T <numpy.ndarray.T>`.
1121
+
1122
+ See its docstring for more information.
1123
+ """
1124
+ # Note: T only works on 2-dimensional arrays. See the corresponding
1125
+ # note in the specification:
1126
+ # https://data-apis.org/array-api/latest/API_specification/array_object.html#t
1127
+ if self.ndim != 2:
1128
+ raise ValueError("x.T requires x to have 2 dimensions. Use x.mT to transpose stacks of matrices and permute_dims() to permute dimensions.")
1129
+ return self.__class__._new(self._array.T)
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_constants.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ e = np.e
4
+ inf = np.inf
5
+ nan = np.nan
6
+ pi = np.pi
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_creation_functions.py ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+
4
+ from typing import TYPE_CHECKING, List, Optional, Tuple, Union
5
+
6
+ if TYPE_CHECKING:
7
+ from ._typing import (
8
+ Array,
9
+ Device,
10
+ Dtype,
11
+ NestedSequence,
12
+ SupportsBufferProtocol,
13
+ )
14
+ from collections.abc import Sequence
15
+ from ._dtypes import _all_dtypes
16
+
17
+ import numpy as np
18
+
19
+
20
+ def _check_valid_dtype(dtype):
21
+ # Note: Only spelling dtypes as the dtype objects is supported.
22
+
23
+ # We use this instead of "dtype in _all_dtypes" because the dtype objects
24
+ # define equality with the sorts of things we want to disallow.
25
+ for d in (None,) + _all_dtypes:
26
+ if dtype is d:
27
+ return
28
+ raise ValueError("dtype must be one of the supported dtypes")
29
+
30
+
31
+ def asarray(
32
+ obj: Union[
33
+ Array,
34
+ bool,
35
+ int,
36
+ float,
37
+ NestedSequence[bool | int | float],
38
+ SupportsBufferProtocol,
39
+ ],
40
+ /,
41
+ *,
42
+ dtype: Optional[Dtype] = None,
43
+ device: Optional[Device] = None,
44
+ copy: Optional[Union[bool, np._CopyMode]] = None,
45
+ ) -> Array:
46
+ """
47
+ Array API compatible wrapper for :py:func:`np.asarray <numpy.asarray>`.
48
+
49
+ See its docstring for more information.
50
+ """
51
+ # _array_object imports in this file are inside the functions to avoid
52
+ # circular imports
53
+ from ._array_object import Array
54
+
55
+ _check_valid_dtype(dtype)
56
+ if device not in ["cpu", None]:
57
+ raise ValueError(f"Unsupported device {device!r}")
58
+ if copy in (False, np._CopyMode.IF_NEEDED):
59
+ # Note: copy=False is not yet implemented in np.asarray
60
+ raise NotImplementedError("copy=False is not yet implemented")
61
+ if isinstance(obj, Array):
62
+ if dtype is not None and obj.dtype != dtype:
63
+ copy = True
64
+ if copy in (True, np._CopyMode.ALWAYS):
65
+ return Array._new(np.array(obj._array, copy=True, dtype=dtype))
66
+ return obj
67
+ if dtype is None and isinstance(obj, int) and (obj > 2 ** 64 or obj < -(2 ** 63)):
68
+ # Give a better error message in this case. NumPy would convert this
69
+ # to an object array. TODO: This won't handle large integers in lists.
70
+ raise OverflowError("Integer out of bounds for array dtypes")
71
+ res = np.asarray(obj, dtype=dtype)
72
+ return Array._new(res)
73
+
74
+
75
+ def arange(
76
+ start: Union[int, float],
77
+ /,
78
+ stop: Optional[Union[int, float]] = None,
79
+ step: Union[int, float] = 1,
80
+ *,
81
+ dtype: Optional[Dtype] = None,
82
+ device: Optional[Device] = None,
83
+ ) -> Array:
84
+ """
85
+ Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.
86
+
87
+ See its docstring for more information.
88
+ """
89
+ from ._array_object import Array
90
+
91
+ _check_valid_dtype(dtype)
92
+ if device not in ["cpu", None]:
93
+ raise ValueError(f"Unsupported device {device!r}")
94
+ return Array._new(np.arange(start, stop=stop, step=step, dtype=dtype))
95
+
96
+
97
+ def empty(
98
+ shape: Union[int, Tuple[int, ...]],
99
+ *,
100
+ dtype: Optional[Dtype] = None,
101
+ device: Optional[Device] = None,
102
+ ) -> Array:
103
+ """
104
+ Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.
105
+
106
+ See its docstring for more information.
107
+ """
108
+ from ._array_object import Array
109
+
110
+ _check_valid_dtype(dtype)
111
+ if device not in ["cpu", None]:
112
+ raise ValueError(f"Unsupported device {device!r}")
113
+ return Array._new(np.empty(shape, dtype=dtype))
114
+
115
+
116
+ def empty_like(
117
+ x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
118
+ ) -> Array:
119
+ """
120
+ Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.
121
+
122
+ See its docstring for more information.
123
+ """
124
+ from ._array_object import Array
125
+
126
+ _check_valid_dtype(dtype)
127
+ if device not in ["cpu", None]:
128
+ raise ValueError(f"Unsupported device {device!r}")
129
+ return Array._new(np.empty_like(x._array, dtype=dtype))
130
+
131
+
132
+ def eye(
133
+ n_rows: int,
134
+ n_cols: Optional[int] = None,
135
+ /,
136
+ *,
137
+ k: int = 0,
138
+ dtype: Optional[Dtype] = None,
139
+ device: Optional[Device] = None,
140
+ ) -> Array:
141
+ """
142
+ Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.
143
+
144
+ See its docstring for more information.
145
+ """
146
+ from ._array_object import Array
147
+
148
+ _check_valid_dtype(dtype)
149
+ if device not in ["cpu", None]:
150
+ raise ValueError(f"Unsupported device {device!r}")
151
+ return Array._new(np.eye(n_rows, M=n_cols, k=k, dtype=dtype))
152
+
153
+
154
+ def from_dlpack(x: object, /) -> Array:
155
+ from ._array_object import Array
156
+
157
+ return Array._new(np.from_dlpack(x))
158
+
159
+
160
+ def full(
161
+ shape: Union[int, Tuple[int, ...]],
162
+ fill_value: Union[int, float],
163
+ *,
164
+ dtype: Optional[Dtype] = None,
165
+ device: Optional[Device] = None,
166
+ ) -> Array:
167
+ """
168
+ Array API compatible wrapper for :py:func:`np.full <numpy.full>`.
169
+
170
+ See its docstring for more information.
171
+ """
172
+ from ._array_object import Array
173
+
174
+ _check_valid_dtype(dtype)
175
+ if device not in ["cpu", None]:
176
+ raise ValueError(f"Unsupported device {device!r}")
177
+ if isinstance(fill_value, Array) and fill_value.ndim == 0:
178
+ fill_value = fill_value._array
179
+ res = np.full(shape, fill_value, dtype=dtype)
180
+ if res.dtype not in _all_dtypes:
181
+ # This will happen if the fill value is not something that NumPy
182
+ # coerces to one of the acceptable dtypes.
183
+ raise TypeError("Invalid input to full")
184
+ return Array._new(res)
185
+
186
+
187
+ def full_like(
188
+ x: Array,
189
+ /,
190
+ fill_value: Union[int, float],
191
+ *,
192
+ dtype: Optional[Dtype] = None,
193
+ device: Optional[Device] = None,
194
+ ) -> Array:
195
+ """
196
+ Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.
197
+
198
+ See its docstring for more information.
199
+ """
200
+ from ._array_object import Array
201
+
202
+ _check_valid_dtype(dtype)
203
+ if device not in ["cpu", None]:
204
+ raise ValueError(f"Unsupported device {device!r}")
205
+ res = np.full_like(x._array, fill_value, dtype=dtype)
206
+ if res.dtype not in _all_dtypes:
207
+ # This will happen if the fill value is not something that NumPy
208
+ # coerces to one of the acceptable dtypes.
209
+ raise TypeError("Invalid input to full_like")
210
+ return Array._new(res)
211
+
212
+
213
+ def linspace(
214
+ start: Union[int, float],
215
+ stop: Union[int, float],
216
+ /,
217
+ num: int,
218
+ *,
219
+ dtype: Optional[Dtype] = None,
220
+ device: Optional[Device] = None,
221
+ endpoint: bool = True,
222
+ ) -> Array:
223
+ """
224
+ Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.
225
+
226
+ See its docstring for more information.
227
+ """
228
+ from ._array_object import Array
229
+
230
+ _check_valid_dtype(dtype)
231
+ if device not in ["cpu", None]:
232
+ raise ValueError(f"Unsupported device {device!r}")
233
+ return Array._new(np.linspace(start, stop, num, dtype=dtype, endpoint=endpoint))
234
+
235
+
236
+ def meshgrid(*arrays: Array, indexing: str = "xy") -> List[Array]:
237
+ """
238
+ Array API compatible wrapper for :py:func:`np.meshgrid <numpy.meshgrid>`.
239
+
240
+ See its docstring for more information.
241
+ """
242
+ from ._array_object import Array
243
+
244
+ # Note: unlike np.meshgrid, only inputs with all the same dtype are
245
+ # allowed
246
+
247
+ if len({a.dtype for a in arrays}) > 1:
248
+ raise ValueError("meshgrid inputs must all have the same dtype")
249
+
250
+ return [
251
+ Array._new(array)
252
+ for array in np.meshgrid(*[a._array for a in arrays], indexing=indexing)
253
+ ]
254
+
255
+
256
+ def ones(
257
+ shape: Union[int, Tuple[int, ...]],
258
+ *,
259
+ dtype: Optional[Dtype] = None,
260
+ device: Optional[Device] = None,
261
+ ) -> Array:
262
+ """
263
+ Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.
264
+
265
+ See its docstring for more information.
266
+ """
267
+ from ._array_object import Array
268
+
269
+ _check_valid_dtype(dtype)
270
+ if device not in ["cpu", None]:
271
+ raise ValueError(f"Unsupported device {device!r}")
272
+ return Array._new(np.ones(shape, dtype=dtype))
273
+
274
+
275
+ def ones_like(
276
+ x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
277
+ ) -> Array:
278
+ """
279
+ Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.
280
+
281
+ See its docstring for more information.
282
+ """
283
+ from ._array_object import Array
284
+
285
+ _check_valid_dtype(dtype)
286
+ if device not in ["cpu", None]:
287
+ raise ValueError(f"Unsupported device {device!r}")
288
+ return Array._new(np.ones_like(x._array, dtype=dtype))
289
+
290
+
291
+ def tril(x: Array, /, *, k: int = 0) -> Array:
292
+ """
293
+ Array API compatible wrapper for :py:func:`np.tril <numpy.tril>`.
294
+
295
+ See its docstring for more information.
296
+ """
297
+ from ._array_object import Array
298
+
299
+ if x.ndim < 2:
300
+ # Note: Unlike np.tril, x must be at least 2-D
301
+ raise ValueError("x must be at least 2-dimensional for tril")
302
+ return Array._new(np.tril(x._array, k=k))
303
+
304
+
305
+ def triu(x: Array, /, *, k: int = 0) -> Array:
306
+ """
307
+ Array API compatible wrapper for :py:func:`np.triu <numpy.triu>`.
308
+
309
+ See its docstring for more information.
310
+ """
311
+ from ._array_object import Array
312
+
313
+ if x.ndim < 2:
314
+ # Note: Unlike np.triu, x must be at least 2-D
315
+ raise ValueError("x must be at least 2-dimensional for triu")
316
+ return Array._new(np.triu(x._array, k=k))
317
+
318
+
319
+ def zeros(
320
+ shape: Union[int, Tuple[int, ...]],
321
+ *,
322
+ dtype: Optional[Dtype] = None,
323
+ device: Optional[Device] = None,
324
+ ) -> Array:
325
+ """
326
+ Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.
327
+
328
+ See its docstring for more information.
329
+ """
330
+ from ._array_object import Array
331
+
332
+ _check_valid_dtype(dtype)
333
+ if device not in ["cpu", None]:
334
+ raise ValueError(f"Unsupported device {device!r}")
335
+ return Array._new(np.zeros(shape, dtype=dtype))
336
+
337
+
338
+ def zeros_like(
339
+ x: Array, /, *, dtype: Optional[Dtype] = None, device: Optional[Device] = None
340
+ ) -> Array:
341
+ """
342
+ Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.
343
+
344
+ See its docstring for more information.
345
+ """
346
+ from ._array_object import Array
347
+
348
+ _check_valid_dtype(dtype)
349
+ if device not in ["cpu", None]:
350
+ raise ValueError(f"Unsupported device {device!r}")
351
+ return Array._new(np.zeros_like(x._array, dtype=dtype))
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_data_type_functions.py ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+ from ._dtypes import (
5
+ _all_dtypes,
6
+ _boolean_dtypes,
7
+ _signed_integer_dtypes,
8
+ _unsigned_integer_dtypes,
9
+ _integer_dtypes,
10
+ _real_floating_dtypes,
11
+ _complex_floating_dtypes,
12
+ _numeric_dtypes,
13
+ _result_type,
14
+ )
15
+
16
+ from dataclasses import dataclass
17
+ from typing import TYPE_CHECKING, List, Tuple, Union
18
+
19
+ if TYPE_CHECKING:
20
+ from ._typing import Dtype
21
+ from collections.abc import Sequence
22
+
23
+ import numpy as np
24
+
25
+
26
+ # Note: astype is a function, not an array method as in NumPy.
27
+ def astype(x: Array, dtype: Dtype, /, *, copy: bool = True) -> Array:
28
+ if not copy and dtype == x.dtype:
29
+ return x
30
+ return Array._new(x._array.astype(dtype=dtype, copy=copy))
31
+
32
+
33
+ def broadcast_arrays(*arrays: Array) -> List[Array]:
34
+ """
35
+ Array API compatible wrapper for :py:func:`np.broadcast_arrays <numpy.broadcast_arrays>`.
36
+
37
+ See its docstring for more information.
38
+ """
39
+ from ._array_object import Array
40
+
41
+ return [
42
+ Array._new(array) for array in np.broadcast_arrays(*[a._array for a in arrays])
43
+ ]
44
+
45
+
46
+ def broadcast_to(x: Array, /, shape: Tuple[int, ...]) -> Array:
47
+ """
48
+ Array API compatible wrapper for :py:func:`np.broadcast_to <numpy.broadcast_to>`.
49
+
50
+ See its docstring for more information.
51
+ """
52
+ from ._array_object import Array
53
+
54
+ return Array._new(np.broadcast_to(x._array, shape))
55
+
56
+
57
+ def can_cast(from_: Union[Dtype, Array], to: Dtype, /) -> bool:
58
+ """
59
+ Array API compatible wrapper for :py:func:`np.can_cast <numpy.can_cast>`.
60
+
61
+ See its docstring for more information.
62
+ """
63
+ if isinstance(from_, Array):
64
+ from_ = from_.dtype
65
+ elif from_ not in _all_dtypes:
66
+ raise TypeError(f"{from_=}, but should be an array_api array or dtype")
67
+ if to not in _all_dtypes:
68
+ raise TypeError(f"{to=}, but should be a dtype")
69
+ # Note: We avoid np.can_cast() as it has discrepancies with the array API,
70
+ # since NumPy allows cross-kind casting (e.g., NumPy allows bool -> int8).
71
+ # See https://github.com/numpy/numpy/issues/20870
72
+ try:
73
+ # We promote `from_` and `to` together. We then check if the promoted
74
+ # dtype is `to`, which indicates if `from_` can (up)cast to `to`.
75
+ dtype = _result_type(from_, to)
76
+ return to == dtype
77
+ except TypeError:
78
+ # _result_type() raises if the dtypes don't promote together
79
+ return False
80
+
81
+
82
+ # These are internal objects for the return types of finfo and iinfo, since
83
+ # the NumPy versions contain extra data that isn't part of the spec.
84
+ @dataclass
85
+ class finfo_object:
86
+ bits: int
87
+ # Note: The types of the float data here are float, whereas in NumPy they
88
+ # are scalars of the corresponding float dtype.
89
+ eps: float
90
+ max: float
91
+ min: float
92
+ smallest_normal: float
93
+ dtype: Dtype
94
+
95
+
96
+ @dataclass
97
+ class iinfo_object:
98
+ bits: int
99
+ max: int
100
+ min: int
101
+ dtype: Dtype
102
+
103
+
104
+ def finfo(type: Union[Dtype, Array], /) -> finfo_object:
105
+ """
106
+ Array API compatible wrapper for :py:func:`np.finfo <numpy.finfo>`.
107
+
108
+ See its docstring for more information.
109
+ """
110
+ fi = np.finfo(type)
111
+ # Note: The types of the float data here are float, whereas in NumPy they
112
+ # are scalars of the corresponding float dtype.
113
+ return finfo_object(
114
+ fi.bits,
115
+ float(fi.eps),
116
+ float(fi.max),
117
+ float(fi.min),
118
+ float(fi.smallest_normal),
119
+ fi.dtype,
120
+ )
121
+
122
+
123
+ def iinfo(type: Union[Dtype, Array], /) -> iinfo_object:
124
+ """
125
+ Array API compatible wrapper for :py:func:`np.iinfo <numpy.iinfo>`.
126
+
127
+ See its docstring for more information.
128
+ """
129
+ ii = np.iinfo(type)
130
+ return iinfo_object(ii.bits, ii.max, ii.min, ii.dtype)
131
+
132
+
133
+ # Note: isdtype is a new function from the 2022.12 array API specification.
134
+ def isdtype(
135
+ dtype: Dtype, kind: Union[Dtype, str, Tuple[Union[Dtype, str], ...]]
136
+ ) -> bool:
137
+ """
138
+ Returns a boolean indicating whether a provided dtype is of a specified data type ``kind``.
139
+
140
+ See
141
+ https://data-apis.org/array-api/latest/API_specification/generated/array_api.isdtype.html
142
+ for more details
143
+ """
144
+ if isinstance(kind, tuple):
145
+ # Disallow nested tuples
146
+ if any(isinstance(k, tuple) for k in kind):
147
+ raise TypeError("'kind' must be a dtype, str, or tuple of dtypes and strs")
148
+ return any(isdtype(dtype, k) for k in kind)
149
+ elif isinstance(kind, str):
150
+ if kind == 'bool':
151
+ return dtype in _boolean_dtypes
152
+ elif kind == 'signed integer':
153
+ return dtype in _signed_integer_dtypes
154
+ elif kind == 'unsigned integer':
155
+ return dtype in _unsigned_integer_dtypes
156
+ elif kind == 'integral':
157
+ return dtype in _integer_dtypes
158
+ elif kind == 'real floating':
159
+ return dtype in _real_floating_dtypes
160
+ elif kind == 'complex floating':
161
+ return dtype in _complex_floating_dtypes
162
+ elif kind == 'numeric':
163
+ return dtype in _numeric_dtypes
164
+ else:
165
+ raise ValueError(f"Unrecognized data type kind: {kind!r}")
166
+ elif kind in _all_dtypes:
167
+ return dtype == kind
168
+ else:
169
+ raise TypeError(f"'kind' must be a dtype, str, or tuple of dtypes and strs, not {type(kind).__name__}")
170
+
171
+ def result_type(*arrays_and_dtypes: Union[Array, Dtype]) -> Dtype:
172
+ """
173
+ Array API compatible wrapper for :py:func:`np.result_type <numpy.result_type>`.
174
+
175
+ See its docstring for more information.
176
+ """
177
+ # Note: we use a custom implementation that gives only the type promotions
178
+ # required by the spec rather than using np.result_type. NumPy implements
179
+ # too many extra type promotions like int64 + uint64 -> float64, and does
180
+ # value-based casting on scalar arrays.
181
+ A = []
182
+ for a in arrays_and_dtypes:
183
+ if isinstance(a, Array):
184
+ a = a.dtype
185
+ elif isinstance(a, np.ndarray) or a not in _all_dtypes:
186
+ raise TypeError("result_type() inputs must be array_api arrays or dtypes")
187
+ A.append(a)
188
+
189
+ if len(A) == 0:
190
+ raise ValueError("at least one array or dtype is required")
191
+ elif len(A) == 1:
192
+ return A[0]
193
+ else:
194
+ t = A[0]
195
+ for t2 in A[1:]:
196
+ t = _result_type(t, t2)
197
+ return t
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_dtypes.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+
3
+ # Note: we use dtype objects instead of dtype classes. The spec does not
4
+ # require any behavior on dtypes other than equality.
5
+ int8 = np.dtype("int8")
6
+ int16 = np.dtype("int16")
7
+ int32 = np.dtype("int32")
8
+ int64 = np.dtype("int64")
9
+ uint8 = np.dtype("uint8")
10
+ uint16 = np.dtype("uint16")
11
+ uint32 = np.dtype("uint32")
12
+ uint64 = np.dtype("uint64")
13
+ float32 = np.dtype("float32")
14
+ float64 = np.dtype("float64")
15
+ complex64 = np.dtype("complex64")
16
+ complex128 = np.dtype("complex128")
17
+ # Note: This name is changed
18
+ bool = np.dtype("bool")
19
+
20
+ _all_dtypes = (
21
+ int8,
22
+ int16,
23
+ int32,
24
+ int64,
25
+ uint8,
26
+ uint16,
27
+ uint32,
28
+ uint64,
29
+ float32,
30
+ float64,
31
+ complex64,
32
+ complex128,
33
+ bool,
34
+ )
35
+ _boolean_dtypes = (bool,)
36
+ _real_floating_dtypes = (float32, float64)
37
+ _floating_dtypes = (float32, float64, complex64, complex128)
38
+ _complex_floating_dtypes = (complex64, complex128)
39
+ _integer_dtypes = (int8, int16, int32, int64, uint8, uint16, uint32, uint64)
40
+ _signed_integer_dtypes = (int8, int16, int32, int64)
41
+ _unsigned_integer_dtypes = (uint8, uint16, uint32, uint64)
42
+ _integer_or_boolean_dtypes = (
43
+ bool,
44
+ int8,
45
+ int16,
46
+ int32,
47
+ int64,
48
+ uint8,
49
+ uint16,
50
+ uint32,
51
+ uint64,
52
+ )
53
+ _real_numeric_dtypes = (
54
+ float32,
55
+ float64,
56
+ int8,
57
+ int16,
58
+ int32,
59
+ int64,
60
+ uint8,
61
+ uint16,
62
+ uint32,
63
+ uint64,
64
+ )
65
+ _numeric_dtypes = (
66
+ float32,
67
+ float64,
68
+ complex64,
69
+ complex128,
70
+ int8,
71
+ int16,
72
+ int32,
73
+ int64,
74
+ uint8,
75
+ uint16,
76
+ uint32,
77
+ uint64,
78
+ )
79
+
80
+ _dtype_categories = {
81
+ "all": _all_dtypes,
82
+ "real numeric": _real_numeric_dtypes,
83
+ "numeric": _numeric_dtypes,
84
+ "integer": _integer_dtypes,
85
+ "integer or boolean": _integer_or_boolean_dtypes,
86
+ "boolean": _boolean_dtypes,
87
+ "real floating-point": _floating_dtypes,
88
+ "complex floating-point": _complex_floating_dtypes,
89
+ "floating-point": _floating_dtypes,
90
+ }
91
+
92
+
93
+ # Note: the spec defines a restricted type promotion table compared to NumPy.
94
+ # In particular, cross-kind promotions like integer + float or boolean +
95
+ # integer are not allowed, even for functions that accept both kinds.
96
+ # Additionally, NumPy promotes signed integer + uint64 to float64, but this
97
+ # promotion is not allowed here. To be clear, Python scalar int objects are
98
+ # allowed to promote to floating-point dtypes, but only in array operators
99
+ # (see Array._promote_scalar) method in _array_object.py.
100
+ _promotion_table = {
101
+ (int8, int8): int8,
102
+ (int8, int16): int16,
103
+ (int8, int32): int32,
104
+ (int8, int64): int64,
105
+ (int16, int8): int16,
106
+ (int16, int16): int16,
107
+ (int16, int32): int32,
108
+ (int16, int64): int64,
109
+ (int32, int8): int32,
110
+ (int32, int16): int32,
111
+ (int32, int32): int32,
112
+ (int32, int64): int64,
113
+ (int64, int8): int64,
114
+ (int64, int16): int64,
115
+ (int64, int32): int64,
116
+ (int64, int64): int64,
117
+ (uint8, uint8): uint8,
118
+ (uint8, uint16): uint16,
119
+ (uint8, uint32): uint32,
120
+ (uint8, uint64): uint64,
121
+ (uint16, uint8): uint16,
122
+ (uint16, uint16): uint16,
123
+ (uint16, uint32): uint32,
124
+ (uint16, uint64): uint64,
125
+ (uint32, uint8): uint32,
126
+ (uint32, uint16): uint32,
127
+ (uint32, uint32): uint32,
128
+ (uint32, uint64): uint64,
129
+ (uint64, uint8): uint64,
130
+ (uint64, uint16): uint64,
131
+ (uint64, uint32): uint64,
132
+ (uint64, uint64): uint64,
133
+ (int8, uint8): int16,
134
+ (int8, uint16): int32,
135
+ (int8, uint32): int64,
136
+ (int16, uint8): int16,
137
+ (int16, uint16): int32,
138
+ (int16, uint32): int64,
139
+ (int32, uint8): int32,
140
+ (int32, uint16): int32,
141
+ (int32, uint32): int64,
142
+ (int64, uint8): int64,
143
+ (int64, uint16): int64,
144
+ (int64, uint32): int64,
145
+ (uint8, int8): int16,
146
+ (uint16, int8): int32,
147
+ (uint32, int8): int64,
148
+ (uint8, int16): int16,
149
+ (uint16, int16): int32,
150
+ (uint32, int16): int64,
151
+ (uint8, int32): int32,
152
+ (uint16, int32): int32,
153
+ (uint32, int32): int64,
154
+ (uint8, int64): int64,
155
+ (uint16, int64): int64,
156
+ (uint32, int64): int64,
157
+ (float32, float32): float32,
158
+ (float32, float64): float64,
159
+ (float64, float32): float64,
160
+ (float64, float64): float64,
161
+ (complex64, complex64): complex64,
162
+ (complex64, complex128): complex128,
163
+ (complex128, complex64): complex128,
164
+ (complex128, complex128): complex128,
165
+ (float32, complex64): complex64,
166
+ (float32, complex128): complex128,
167
+ (float64, complex64): complex128,
168
+ (float64, complex128): complex128,
169
+ (complex64, float32): complex64,
170
+ (complex64, float64): complex128,
171
+ (complex128, float32): complex128,
172
+ (complex128, float64): complex128,
173
+ (bool, bool): bool,
174
+ }
175
+
176
+
177
+ def _result_type(type1, type2):
178
+ if (type1, type2) in _promotion_table:
179
+ return _promotion_table[type1, type2]
180
+ raise TypeError(f"{type1} and {type2} cannot be type promoted together")
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_elementwise_functions.py ADDED
@@ -0,0 +1,765 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._dtypes import (
4
+ _boolean_dtypes,
5
+ _floating_dtypes,
6
+ _real_floating_dtypes,
7
+ _complex_floating_dtypes,
8
+ _integer_dtypes,
9
+ _integer_or_boolean_dtypes,
10
+ _real_numeric_dtypes,
11
+ _numeric_dtypes,
12
+ _result_type,
13
+ )
14
+ from ._array_object import Array
15
+
16
+ import numpy as np
17
+
18
+
19
+ def abs(x: Array, /) -> Array:
20
+ """
21
+ Array API compatible wrapper for :py:func:`np.abs <numpy.abs>`.
22
+
23
+ See its docstring for more information.
24
+ """
25
+ if x.dtype not in _numeric_dtypes:
26
+ raise TypeError("Only numeric dtypes are allowed in abs")
27
+ return Array._new(np.abs(x._array))
28
+
29
+
30
+ # Note: the function name is different here
31
+ def acos(x: Array, /) -> Array:
32
+ """
33
+ Array API compatible wrapper for :py:func:`np.arccos <numpy.arccos>`.
34
+
35
+ See its docstring for more information.
36
+ """
37
+ if x.dtype not in _floating_dtypes:
38
+ raise TypeError("Only floating-point dtypes are allowed in acos")
39
+ return Array._new(np.arccos(x._array))
40
+
41
+
42
+ # Note: the function name is different here
43
+ def acosh(x: Array, /) -> Array:
44
+ """
45
+ Array API compatible wrapper for :py:func:`np.arccosh <numpy.arccosh>`.
46
+
47
+ See its docstring for more information.
48
+ """
49
+ if x.dtype not in _floating_dtypes:
50
+ raise TypeError("Only floating-point dtypes are allowed in acosh")
51
+ return Array._new(np.arccosh(x._array))
52
+
53
+
54
+ def add(x1: Array, x2: Array, /) -> Array:
55
+ """
56
+ Array API compatible wrapper for :py:func:`np.add <numpy.add>`.
57
+
58
+ See its docstring for more information.
59
+ """
60
+ if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
61
+ raise TypeError("Only numeric dtypes are allowed in add")
62
+ # Call result type here just to raise on disallowed type combinations
63
+ _result_type(x1.dtype, x2.dtype)
64
+ x1, x2 = Array._normalize_two_args(x1, x2)
65
+ return Array._new(np.add(x1._array, x2._array))
66
+
67
+
68
+ # Note: the function name is different here
69
+ def asin(x: Array, /) -> Array:
70
+ """
71
+ Array API compatible wrapper for :py:func:`np.arcsin <numpy.arcsin>`.
72
+
73
+ See its docstring for more information.
74
+ """
75
+ if x.dtype not in _floating_dtypes:
76
+ raise TypeError("Only floating-point dtypes are allowed in asin")
77
+ return Array._new(np.arcsin(x._array))
78
+
79
+
80
+ # Note: the function name is different here
81
+ def asinh(x: Array, /) -> Array:
82
+ """
83
+ Array API compatible wrapper for :py:func:`np.arcsinh <numpy.arcsinh>`.
84
+
85
+ See its docstring for more information.
86
+ """
87
+ if x.dtype not in _floating_dtypes:
88
+ raise TypeError("Only floating-point dtypes are allowed in asinh")
89
+ return Array._new(np.arcsinh(x._array))
90
+
91
+
92
+ # Note: the function name is different here
93
+ def atan(x: Array, /) -> Array:
94
+ """
95
+ Array API compatible wrapper for :py:func:`np.arctan <numpy.arctan>`.
96
+
97
+ See its docstring for more information.
98
+ """
99
+ if x.dtype not in _floating_dtypes:
100
+ raise TypeError("Only floating-point dtypes are allowed in atan")
101
+ return Array._new(np.arctan(x._array))
102
+
103
+
104
+ # Note: the function name is different here
105
+ def atan2(x1: Array, x2: Array, /) -> Array:
106
+ """
107
+ Array API compatible wrapper for :py:func:`np.arctan2 <numpy.arctan2>`.
108
+
109
+ See its docstring for more information.
110
+ """
111
+ if x1.dtype not in _real_floating_dtypes or x2.dtype not in _real_floating_dtypes:
112
+ raise TypeError("Only real floating-point dtypes are allowed in atan2")
113
+ # Call result type here just to raise on disallowed type combinations
114
+ _result_type(x1.dtype, x2.dtype)
115
+ x1, x2 = Array._normalize_two_args(x1, x2)
116
+ return Array._new(np.arctan2(x1._array, x2._array))
117
+
118
+
119
+ # Note: the function name is different here
120
+ def atanh(x: Array, /) -> Array:
121
+ """
122
+ Array API compatible wrapper for :py:func:`np.arctanh <numpy.arctanh>`.
123
+
124
+ See its docstring for more information.
125
+ """
126
+ if x.dtype not in _floating_dtypes:
127
+ raise TypeError("Only floating-point dtypes are allowed in atanh")
128
+ return Array._new(np.arctanh(x._array))
129
+
130
+
131
+ def bitwise_and(x1: Array, x2: Array, /) -> Array:
132
+ """
133
+ Array API compatible wrapper for :py:func:`np.bitwise_and <numpy.bitwise_and>`.
134
+
135
+ See its docstring for more information.
136
+ """
137
+ if (
138
+ x1.dtype not in _integer_or_boolean_dtypes
139
+ or x2.dtype not in _integer_or_boolean_dtypes
140
+ ):
141
+ raise TypeError("Only integer or boolean dtypes are allowed in bitwise_and")
142
+ # Call result type here just to raise on disallowed type combinations
143
+ _result_type(x1.dtype, x2.dtype)
144
+ x1, x2 = Array._normalize_two_args(x1, x2)
145
+ return Array._new(np.bitwise_and(x1._array, x2._array))
146
+
147
+
148
+ # Note: the function name is different here
149
+ def bitwise_left_shift(x1: Array, x2: Array, /) -> Array:
150
+ """
151
+ Array API compatible wrapper for :py:func:`np.left_shift <numpy.left_shift>`.
152
+
153
+ See its docstring for more information.
154
+ """
155
+ if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes:
156
+ raise TypeError("Only integer dtypes are allowed in bitwise_left_shift")
157
+ # Call result type here just to raise on disallowed type combinations
158
+ _result_type(x1.dtype, x2.dtype)
159
+ x1, x2 = Array._normalize_two_args(x1, x2)
160
+ # Note: bitwise_left_shift is only defined for x2 nonnegative.
161
+ if np.any(x2._array < 0):
162
+ raise ValueError("bitwise_left_shift(x1, x2) is only defined for x2 >= 0")
163
+ return Array._new(np.left_shift(x1._array, x2._array))
164
+
165
+
166
+ # Note: the function name is different here
167
+ def bitwise_invert(x: Array, /) -> Array:
168
+ """
169
+ Array API compatible wrapper for :py:func:`np.invert <numpy.invert>`.
170
+
171
+ See its docstring for more information.
172
+ """
173
+ if x.dtype not in _integer_or_boolean_dtypes:
174
+ raise TypeError("Only integer or boolean dtypes are allowed in bitwise_invert")
175
+ return Array._new(np.invert(x._array))
176
+
177
+
178
+ def bitwise_or(x1: Array, x2: Array, /) -> Array:
179
+ """
180
+ Array API compatible wrapper for :py:func:`np.bitwise_or <numpy.bitwise_or>`.
181
+
182
+ See its docstring for more information.
183
+ """
184
+ if (
185
+ x1.dtype not in _integer_or_boolean_dtypes
186
+ or x2.dtype not in _integer_or_boolean_dtypes
187
+ ):
188
+ raise TypeError("Only integer or boolean dtypes are allowed in bitwise_or")
189
+ # Call result type here just to raise on disallowed type combinations
190
+ _result_type(x1.dtype, x2.dtype)
191
+ x1, x2 = Array._normalize_two_args(x1, x2)
192
+ return Array._new(np.bitwise_or(x1._array, x2._array))
193
+
194
+
195
+ # Note: the function name is different here
196
+ def bitwise_right_shift(x1: Array, x2: Array, /) -> Array:
197
+ """
198
+ Array API compatible wrapper for :py:func:`np.right_shift <numpy.right_shift>`.
199
+
200
+ See its docstring for more information.
201
+ """
202
+ if x1.dtype not in _integer_dtypes or x2.dtype not in _integer_dtypes:
203
+ raise TypeError("Only integer dtypes are allowed in bitwise_right_shift")
204
+ # Call result type here just to raise on disallowed type combinations
205
+ _result_type(x1.dtype, x2.dtype)
206
+ x1, x2 = Array._normalize_two_args(x1, x2)
207
+ # Note: bitwise_right_shift is only defined for x2 nonnegative.
208
+ if np.any(x2._array < 0):
209
+ raise ValueError("bitwise_right_shift(x1, x2) is only defined for x2 >= 0")
210
+ return Array._new(np.right_shift(x1._array, x2._array))
211
+
212
+
213
+ def bitwise_xor(x1: Array, x2: Array, /) -> Array:
214
+ """
215
+ Array API compatible wrapper for :py:func:`np.bitwise_xor <numpy.bitwise_xor>`.
216
+
217
+ See its docstring for more information.
218
+ """
219
+ if (
220
+ x1.dtype not in _integer_or_boolean_dtypes
221
+ or x2.dtype not in _integer_or_boolean_dtypes
222
+ ):
223
+ raise TypeError("Only integer or boolean dtypes are allowed in bitwise_xor")
224
+ # Call result type here just to raise on disallowed type combinations
225
+ _result_type(x1.dtype, x2.dtype)
226
+ x1, x2 = Array._normalize_two_args(x1, x2)
227
+ return Array._new(np.bitwise_xor(x1._array, x2._array))
228
+
229
+
230
+ def ceil(x: Array, /) -> Array:
231
+ """
232
+ Array API compatible wrapper for :py:func:`np.ceil <numpy.ceil>`.
233
+
234
+ See its docstring for more information.
235
+ """
236
+ if x.dtype not in _real_numeric_dtypes:
237
+ raise TypeError("Only real numeric dtypes are allowed in ceil")
238
+ if x.dtype in _integer_dtypes:
239
+ # Note: The return dtype of ceil is the same as the input
240
+ return x
241
+ return Array._new(np.ceil(x._array))
242
+
243
+
244
+ def conj(x: Array, /) -> Array:
245
+ """
246
+ Array API compatible wrapper for :py:func:`np.conj <numpy.conj>`.
247
+
248
+ See its docstring for more information.
249
+ """
250
+ if x.dtype not in _complex_floating_dtypes:
251
+ raise TypeError("Only complex floating-point dtypes are allowed in conj")
252
+ return Array._new(np.conj(x))
253
+
254
+
255
+ def cos(x: Array, /) -> Array:
256
+ """
257
+ Array API compatible wrapper for :py:func:`np.cos <numpy.cos>`.
258
+
259
+ See its docstring for more information.
260
+ """
261
+ if x.dtype not in _floating_dtypes:
262
+ raise TypeError("Only floating-point dtypes are allowed in cos")
263
+ return Array._new(np.cos(x._array))
264
+
265
+
266
+ def cosh(x: Array, /) -> Array:
267
+ """
268
+ Array API compatible wrapper for :py:func:`np.cosh <numpy.cosh>`.
269
+
270
+ See its docstring for more information.
271
+ """
272
+ if x.dtype not in _floating_dtypes:
273
+ raise TypeError("Only floating-point dtypes are allowed in cosh")
274
+ return Array._new(np.cosh(x._array))
275
+
276
+
277
+ def divide(x1: Array, x2: Array, /) -> Array:
278
+ """
279
+ Array API compatible wrapper for :py:func:`np.divide <numpy.divide>`.
280
+
281
+ See its docstring for more information.
282
+ """
283
+ if x1.dtype not in _floating_dtypes or x2.dtype not in _floating_dtypes:
284
+ raise TypeError("Only floating-point dtypes are allowed in divide")
285
+ # Call result type here just to raise on disallowed type combinations
286
+ _result_type(x1.dtype, x2.dtype)
287
+ x1, x2 = Array._normalize_two_args(x1, x2)
288
+ return Array._new(np.divide(x1._array, x2._array))
289
+
290
+
291
+ def equal(x1: Array, x2: Array, /) -> Array:
292
+ """
293
+ Array API compatible wrapper for :py:func:`np.equal <numpy.equal>`.
294
+
295
+ See its docstring for more information.
296
+ """
297
+ # Call result type here just to raise on disallowed type combinations
298
+ _result_type(x1.dtype, x2.dtype)
299
+ x1, x2 = Array._normalize_two_args(x1, x2)
300
+ return Array._new(np.equal(x1._array, x2._array))
301
+
302
+
303
+ def exp(x: Array, /) -> Array:
304
+ """
305
+ Array API compatible wrapper for :py:func:`np.exp <numpy.exp>`.
306
+
307
+ See its docstring for more information.
308
+ """
309
+ if x.dtype not in _floating_dtypes:
310
+ raise TypeError("Only floating-point dtypes are allowed in exp")
311
+ return Array._new(np.exp(x._array))
312
+
313
+
314
+ def expm1(x: Array, /) -> Array:
315
+ """
316
+ Array API compatible wrapper for :py:func:`np.expm1 <numpy.expm1>`.
317
+
318
+ See its docstring for more information.
319
+ """
320
+ if x.dtype not in _floating_dtypes:
321
+ raise TypeError("Only floating-point dtypes are allowed in expm1")
322
+ return Array._new(np.expm1(x._array))
323
+
324
+
325
+ def floor(x: Array, /) -> Array:
326
+ """
327
+ Array API compatible wrapper for :py:func:`np.floor <numpy.floor>`.
328
+
329
+ See its docstring for more information.
330
+ """
331
+ if x.dtype not in _real_numeric_dtypes:
332
+ raise TypeError("Only real numeric dtypes are allowed in floor")
333
+ if x.dtype in _integer_dtypes:
334
+ # Note: The return dtype of floor is the same as the input
335
+ return x
336
+ return Array._new(np.floor(x._array))
337
+
338
+
339
+ def floor_divide(x1: Array, x2: Array, /) -> Array:
340
+ """
341
+ Array API compatible wrapper for :py:func:`np.floor_divide <numpy.floor_divide>`.
342
+
343
+ See its docstring for more information.
344
+ """
345
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
346
+ raise TypeError("Only real numeric dtypes are allowed in floor_divide")
347
+ # Call result type here just to raise on disallowed type combinations
348
+ _result_type(x1.dtype, x2.dtype)
349
+ x1, x2 = Array._normalize_two_args(x1, x2)
350
+ return Array._new(np.floor_divide(x1._array, x2._array))
351
+
352
+
353
+ def greater(x1: Array, x2: Array, /) -> Array:
354
+ """
355
+ Array API compatible wrapper for :py:func:`np.greater <numpy.greater>`.
356
+
357
+ See its docstring for more information.
358
+ """
359
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
360
+ raise TypeError("Only real numeric dtypes are allowed in greater")
361
+ # Call result type here just to raise on disallowed type combinations
362
+ _result_type(x1.dtype, x2.dtype)
363
+ x1, x2 = Array._normalize_two_args(x1, x2)
364
+ return Array._new(np.greater(x1._array, x2._array))
365
+
366
+
367
+ def greater_equal(x1: Array, x2: Array, /) -> Array:
368
+ """
369
+ Array API compatible wrapper for :py:func:`np.greater_equal <numpy.greater_equal>`.
370
+
371
+ See its docstring for more information.
372
+ """
373
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
374
+ raise TypeError("Only real numeric dtypes are allowed in greater_equal")
375
+ # Call result type here just to raise on disallowed type combinations
376
+ _result_type(x1.dtype, x2.dtype)
377
+ x1, x2 = Array._normalize_two_args(x1, x2)
378
+ return Array._new(np.greater_equal(x1._array, x2._array))
379
+
380
+
381
+ def imag(x: Array, /) -> Array:
382
+ """
383
+ Array API compatible wrapper for :py:func:`np.imag <numpy.imag>`.
384
+
385
+ See its docstring for more information.
386
+ """
387
+ if x.dtype not in _complex_floating_dtypes:
388
+ raise TypeError("Only complex floating-point dtypes are allowed in imag")
389
+ return Array._new(np.imag(x))
390
+
391
+
392
+ def isfinite(x: Array, /) -> Array:
393
+ """
394
+ Array API compatible wrapper for :py:func:`np.isfinite <numpy.isfinite>`.
395
+
396
+ See its docstring for more information.
397
+ """
398
+ if x.dtype not in _numeric_dtypes:
399
+ raise TypeError("Only numeric dtypes are allowed in isfinite")
400
+ return Array._new(np.isfinite(x._array))
401
+
402
+
403
+ def isinf(x: Array, /) -> Array:
404
+ """
405
+ Array API compatible wrapper for :py:func:`np.isinf <numpy.isinf>`.
406
+
407
+ See its docstring for more information.
408
+ """
409
+ if x.dtype not in _numeric_dtypes:
410
+ raise TypeError("Only numeric dtypes are allowed in isinf")
411
+ return Array._new(np.isinf(x._array))
412
+
413
+
414
+ def isnan(x: Array, /) -> Array:
415
+ """
416
+ Array API compatible wrapper for :py:func:`np.isnan <numpy.isnan>`.
417
+
418
+ See its docstring for more information.
419
+ """
420
+ if x.dtype not in _numeric_dtypes:
421
+ raise TypeError("Only numeric dtypes are allowed in isnan")
422
+ return Array._new(np.isnan(x._array))
423
+
424
+
425
+ def less(x1: Array, x2: Array, /) -> Array:
426
+ """
427
+ Array API compatible wrapper for :py:func:`np.less <numpy.less>`.
428
+
429
+ See its docstring for more information.
430
+ """
431
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
432
+ raise TypeError("Only real numeric dtypes are allowed in less")
433
+ # Call result type here just to raise on disallowed type combinations
434
+ _result_type(x1.dtype, x2.dtype)
435
+ x1, x2 = Array._normalize_two_args(x1, x2)
436
+ return Array._new(np.less(x1._array, x2._array))
437
+
438
+
439
+ def less_equal(x1: Array, x2: Array, /) -> Array:
440
+ """
441
+ Array API compatible wrapper for :py:func:`np.less_equal <numpy.less_equal>`.
442
+
443
+ See its docstring for more information.
444
+ """
445
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
446
+ raise TypeError("Only real numeric dtypes are allowed in less_equal")
447
+ # Call result type here just to raise on disallowed type combinations
448
+ _result_type(x1.dtype, x2.dtype)
449
+ x1, x2 = Array._normalize_two_args(x1, x2)
450
+ return Array._new(np.less_equal(x1._array, x2._array))
451
+
452
+
453
+ def log(x: Array, /) -> Array:
454
+ """
455
+ Array API compatible wrapper for :py:func:`np.log <numpy.log>`.
456
+
457
+ See its docstring for more information.
458
+ """
459
+ if x.dtype not in _floating_dtypes:
460
+ raise TypeError("Only floating-point dtypes are allowed in log")
461
+ return Array._new(np.log(x._array))
462
+
463
+
464
+ def log1p(x: Array, /) -> Array:
465
+ """
466
+ Array API compatible wrapper for :py:func:`np.log1p <numpy.log1p>`.
467
+
468
+ See its docstring for more information.
469
+ """
470
+ if x.dtype not in _floating_dtypes:
471
+ raise TypeError("Only floating-point dtypes are allowed in log1p")
472
+ return Array._new(np.log1p(x._array))
473
+
474
+
475
+ def log2(x: Array, /) -> Array:
476
+ """
477
+ Array API compatible wrapper for :py:func:`np.log2 <numpy.log2>`.
478
+
479
+ See its docstring for more information.
480
+ """
481
+ if x.dtype not in _floating_dtypes:
482
+ raise TypeError("Only floating-point dtypes are allowed in log2")
483
+ return Array._new(np.log2(x._array))
484
+
485
+
486
+ def log10(x: Array, /) -> Array:
487
+ """
488
+ Array API compatible wrapper for :py:func:`np.log10 <numpy.log10>`.
489
+
490
+ See its docstring for more information.
491
+ """
492
+ if x.dtype not in _floating_dtypes:
493
+ raise TypeError("Only floating-point dtypes are allowed in log10")
494
+ return Array._new(np.log10(x._array))
495
+
496
+
497
+ def logaddexp(x1: Array, x2: Array) -> Array:
498
+ """
499
+ Array API compatible wrapper for :py:func:`np.logaddexp <numpy.logaddexp>`.
500
+
501
+ See its docstring for more information.
502
+ """
503
+ if x1.dtype not in _real_floating_dtypes or x2.dtype not in _real_floating_dtypes:
504
+ raise TypeError("Only real floating-point dtypes are allowed in logaddexp")
505
+ # Call result type here just to raise on disallowed type combinations
506
+ _result_type(x1.dtype, x2.dtype)
507
+ x1, x2 = Array._normalize_two_args(x1, x2)
508
+ return Array._new(np.logaddexp(x1._array, x2._array))
509
+
510
+
511
+ def logical_and(x1: Array, x2: Array, /) -> Array:
512
+ """
513
+ Array API compatible wrapper for :py:func:`np.logical_and <numpy.logical_and>`.
514
+
515
+ See its docstring for more information.
516
+ """
517
+ if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes:
518
+ raise TypeError("Only boolean dtypes are allowed in logical_and")
519
+ # Call result type here just to raise on disallowed type combinations
520
+ _result_type(x1.dtype, x2.dtype)
521
+ x1, x2 = Array._normalize_two_args(x1, x2)
522
+ return Array._new(np.logical_and(x1._array, x2._array))
523
+
524
+
525
+ def logical_not(x: Array, /) -> Array:
526
+ """
527
+ Array API compatible wrapper for :py:func:`np.logical_not <numpy.logical_not>`.
528
+
529
+ See its docstring for more information.
530
+ """
531
+ if x.dtype not in _boolean_dtypes:
532
+ raise TypeError("Only boolean dtypes are allowed in logical_not")
533
+ return Array._new(np.logical_not(x._array))
534
+
535
+
536
+ def logical_or(x1: Array, x2: Array, /) -> Array:
537
+ """
538
+ Array API compatible wrapper for :py:func:`np.logical_or <numpy.logical_or>`.
539
+
540
+ See its docstring for more information.
541
+ """
542
+ if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes:
543
+ raise TypeError("Only boolean dtypes are allowed in logical_or")
544
+ # Call result type here just to raise on disallowed type combinations
545
+ _result_type(x1.dtype, x2.dtype)
546
+ x1, x2 = Array._normalize_two_args(x1, x2)
547
+ return Array._new(np.logical_or(x1._array, x2._array))
548
+
549
+
550
+ def logical_xor(x1: Array, x2: Array, /) -> Array:
551
+ """
552
+ Array API compatible wrapper for :py:func:`np.logical_xor <numpy.logical_xor>`.
553
+
554
+ See its docstring for more information.
555
+ """
556
+ if x1.dtype not in _boolean_dtypes or x2.dtype not in _boolean_dtypes:
557
+ raise TypeError("Only boolean dtypes are allowed in logical_xor")
558
+ # Call result type here just to raise on disallowed type combinations
559
+ _result_type(x1.dtype, x2.dtype)
560
+ x1, x2 = Array._normalize_two_args(x1, x2)
561
+ return Array._new(np.logical_xor(x1._array, x2._array))
562
+
563
+
564
+ def multiply(x1: Array, x2: Array, /) -> Array:
565
+ """
566
+ Array API compatible wrapper for :py:func:`np.multiply <numpy.multiply>`.
567
+
568
+ See its docstring for more information.
569
+ """
570
+ if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
571
+ raise TypeError("Only numeric dtypes are allowed in multiply")
572
+ # Call result type here just to raise on disallowed type combinations
573
+ _result_type(x1.dtype, x2.dtype)
574
+ x1, x2 = Array._normalize_two_args(x1, x2)
575
+ return Array._new(np.multiply(x1._array, x2._array))
576
+
577
+
578
+ def negative(x: Array, /) -> Array:
579
+ """
580
+ Array API compatible wrapper for :py:func:`np.negative <numpy.negative>`.
581
+
582
+ See its docstring for more information.
583
+ """
584
+ if x.dtype not in _numeric_dtypes:
585
+ raise TypeError("Only numeric dtypes are allowed in negative")
586
+ return Array._new(np.negative(x._array))
587
+
588
+
589
+ def not_equal(x1: Array, x2: Array, /) -> Array:
590
+ """
591
+ Array API compatible wrapper for :py:func:`np.not_equal <numpy.not_equal>`.
592
+
593
+ See its docstring for more information.
594
+ """
595
+ # Call result type here just to raise on disallowed type combinations
596
+ _result_type(x1.dtype, x2.dtype)
597
+ x1, x2 = Array._normalize_two_args(x1, x2)
598
+ return Array._new(np.not_equal(x1._array, x2._array))
599
+
600
+
601
+ def positive(x: Array, /) -> Array:
602
+ """
603
+ Array API compatible wrapper for :py:func:`np.positive <numpy.positive>`.
604
+
605
+ See its docstring for more information.
606
+ """
607
+ if x.dtype not in _numeric_dtypes:
608
+ raise TypeError("Only numeric dtypes are allowed in positive")
609
+ return Array._new(np.positive(x._array))
610
+
611
+
612
+ # Note: the function name is different here
613
+ def pow(x1: Array, x2: Array, /) -> Array:
614
+ """
615
+ Array API compatible wrapper for :py:func:`np.power <numpy.power>`.
616
+
617
+ See its docstring for more information.
618
+ """
619
+ if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
620
+ raise TypeError("Only numeric dtypes are allowed in pow")
621
+ # Call result type here just to raise on disallowed type combinations
622
+ _result_type(x1.dtype, x2.dtype)
623
+ x1, x2 = Array._normalize_two_args(x1, x2)
624
+ return Array._new(np.power(x1._array, x2._array))
625
+
626
+
627
+ def real(x: Array, /) -> Array:
628
+ """
629
+ Array API compatible wrapper for :py:func:`np.real <numpy.real>`.
630
+
631
+ See its docstring for more information.
632
+ """
633
+ if x.dtype not in _complex_floating_dtypes:
634
+ raise TypeError("Only complex floating-point dtypes are allowed in real")
635
+ return Array._new(np.real(x))
636
+
637
+
638
+ def remainder(x1: Array, x2: Array, /) -> Array:
639
+ """
640
+ Array API compatible wrapper for :py:func:`np.remainder <numpy.remainder>`.
641
+
642
+ See its docstring for more information.
643
+ """
644
+ if x1.dtype not in _real_numeric_dtypes or x2.dtype not in _real_numeric_dtypes:
645
+ raise TypeError("Only real numeric dtypes are allowed in remainder")
646
+ # Call result type here just to raise on disallowed type combinations
647
+ _result_type(x1.dtype, x2.dtype)
648
+ x1, x2 = Array._normalize_two_args(x1, x2)
649
+ return Array._new(np.remainder(x1._array, x2._array))
650
+
651
+
652
+ def round(x: Array, /) -> Array:
653
+ """
654
+ Array API compatible wrapper for :py:func:`np.round <numpy.round>`.
655
+
656
+ See its docstring for more information.
657
+ """
658
+ if x.dtype not in _numeric_dtypes:
659
+ raise TypeError("Only numeric dtypes are allowed in round")
660
+ return Array._new(np.round(x._array))
661
+
662
+
663
+ def sign(x: Array, /) -> Array:
664
+ """
665
+ Array API compatible wrapper for :py:func:`np.sign <numpy.sign>`.
666
+
667
+ See its docstring for more information.
668
+ """
669
+ if x.dtype not in _numeric_dtypes:
670
+ raise TypeError("Only numeric dtypes are allowed in sign")
671
+ return Array._new(np.sign(x._array))
672
+
673
+
674
+ def sin(x: Array, /) -> Array:
675
+ """
676
+ Array API compatible wrapper for :py:func:`np.sin <numpy.sin>`.
677
+
678
+ See its docstring for more information.
679
+ """
680
+ if x.dtype not in _floating_dtypes:
681
+ raise TypeError("Only floating-point dtypes are allowed in sin")
682
+ return Array._new(np.sin(x._array))
683
+
684
+
685
+ def sinh(x: Array, /) -> Array:
686
+ """
687
+ Array API compatible wrapper for :py:func:`np.sinh <numpy.sinh>`.
688
+
689
+ See its docstring for more information.
690
+ """
691
+ if x.dtype not in _floating_dtypes:
692
+ raise TypeError("Only floating-point dtypes are allowed in sinh")
693
+ return Array._new(np.sinh(x._array))
694
+
695
+
696
+ def square(x: Array, /) -> Array:
697
+ """
698
+ Array API compatible wrapper for :py:func:`np.square <numpy.square>`.
699
+
700
+ See its docstring for more information.
701
+ """
702
+ if x.dtype not in _numeric_dtypes:
703
+ raise TypeError("Only numeric dtypes are allowed in square")
704
+ return Array._new(np.square(x._array))
705
+
706
+
707
+ def sqrt(x: Array, /) -> Array:
708
+ """
709
+ Array API compatible wrapper for :py:func:`np.sqrt <numpy.sqrt>`.
710
+
711
+ See its docstring for more information.
712
+ """
713
+ if x.dtype not in _floating_dtypes:
714
+ raise TypeError("Only floating-point dtypes are allowed in sqrt")
715
+ return Array._new(np.sqrt(x._array))
716
+
717
+
718
+ def subtract(x1: Array, x2: Array, /) -> Array:
719
+ """
720
+ Array API compatible wrapper for :py:func:`np.subtract <numpy.subtract>`.
721
+
722
+ See its docstring for more information.
723
+ """
724
+ if x1.dtype not in _numeric_dtypes or x2.dtype not in _numeric_dtypes:
725
+ raise TypeError("Only numeric dtypes are allowed in subtract")
726
+ # Call result type here just to raise on disallowed type combinations
727
+ _result_type(x1.dtype, x2.dtype)
728
+ x1, x2 = Array._normalize_two_args(x1, x2)
729
+ return Array._new(np.subtract(x1._array, x2._array))
730
+
731
+
732
+ def tan(x: Array, /) -> Array:
733
+ """
734
+ Array API compatible wrapper for :py:func:`np.tan <numpy.tan>`.
735
+
736
+ See its docstring for more information.
737
+ """
738
+ if x.dtype not in _floating_dtypes:
739
+ raise TypeError("Only floating-point dtypes are allowed in tan")
740
+ return Array._new(np.tan(x._array))
741
+
742
+
743
+ def tanh(x: Array, /) -> Array:
744
+ """
745
+ Array API compatible wrapper for :py:func:`np.tanh <numpy.tanh>`.
746
+
747
+ See its docstring for more information.
748
+ """
749
+ if x.dtype not in _floating_dtypes:
750
+ raise TypeError("Only floating-point dtypes are allowed in tanh")
751
+ return Array._new(np.tanh(x._array))
752
+
753
+
754
+ def trunc(x: Array, /) -> Array:
755
+ """
756
+ Array API compatible wrapper for :py:func:`np.trunc <numpy.trunc>`.
757
+
758
+ See its docstring for more information.
759
+ """
760
+ if x.dtype not in _real_numeric_dtypes:
761
+ raise TypeError("Only real numeric dtypes are allowed in trunc")
762
+ if x.dtype in _integer_dtypes:
763
+ # Note: The return dtype of trunc is the same as the input
764
+ return x
765
+ return Array._new(np.trunc(x._array))
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_indexing_functions.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+ from ._dtypes import _integer_dtypes
5
+
6
+ import numpy as np
7
+
8
+ def take(x: Array, indices: Array, /, *, axis: Optional[int] = None) -> Array:
9
+ """
10
+ Array API compatible wrapper for :py:func:`np.take <numpy.take>`.
11
+
12
+ See its docstring for more information.
13
+ """
14
+ if axis is None and x.ndim != 1:
15
+ raise ValueError("axis must be specified when ndim > 1")
16
+ if indices.dtype not in _integer_dtypes:
17
+ raise TypeError("Only integer dtypes are allowed in indexing")
18
+ if indices.ndim != 1:
19
+ raise ValueError("Only 1-dim indices array is supported")
20
+ return Array._new(np.take(x._array, indices._array, axis=axis))
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_manipulation_functions.py ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+ from ._data_type_functions import result_type
5
+
6
+ from typing import List, Optional, Tuple, Union
7
+
8
+ import numpy as np
9
+
10
+ # Note: the function name is different here
11
+ def concat(
12
+ arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: Optional[int] = 0
13
+ ) -> Array:
14
+ """
15
+ Array API compatible wrapper for :py:func:`np.concatenate <numpy.concatenate>`.
16
+
17
+ See its docstring for more information.
18
+ """
19
+ # Note: Casting rules here are different from the np.concatenate default
20
+ # (no for scalars with axis=None, no cross-kind casting)
21
+ dtype = result_type(*arrays)
22
+ arrays = tuple(a._array for a in arrays)
23
+ return Array._new(np.concatenate(arrays, axis=axis, dtype=dtype))
24
+
25
+
26
+ def expand_dims(x: Array, /, *, axis: int) -> Array:
27
+ """
28
+ Array API compatible wrapper for :py:func:`np.expand_dims <numpy.expand_dims>`.
29
+
30
+ See its docstring for more information.
31
+ """
32
+ return Array._new(np.expand_dims(x._array, axis))
33
+
34
+
35
+ def flip(x: Array, /, *, axis: Optional[Union[int, Tuple[int, ...]]] = None) -> Array:
36
+ """
37
+ Array API compatible wrapper for :py:func:`np.flip <numpy.flip>`.
38
+
39
+ See its docstring for more information.
40
+ """
41
+ return Array._new(np.flip(x._array, axis=axis))
42
+
43
+
44
+ # Note: The function name is different here (see also matrix_transpose).
45
+ # Unlike transpose(), the axes argument is required.
46
+ def permute_dims(x: Array, /, axes: Tuple[int, ...]) -> Array:
47
+ """
48
+ Array API compatible wrapper for :py:func:`np.transpose <numpy.transpose>`.
49
+
50
+ See its docstring for more information.
51
+ """
52
+ return Array._new(np.transpose(x._array, axes))
53
+
54
+
55
+ # Note: the optional argument is called 'shape', not 'newshape'
56
+ def reshape(x: Array,
57
+ /,
58
+ shape: Tuple[int, ...],
59
+ *,
60
+ copy: Optional[Bool] = None) -> Array:
61
+ """
62
+ Array API compatible wrapper for :py:func:`np.reshape <numpy.reshape>`.
63
+
64
+ See its docstring for more information.
65
+ """
66
+
67
+ data = x._array
68
+ if copy:
69
+ data = np.copy(data)
70
+
71
+ reshaped = np.reshape(data, shape)
72
+
73
+ if copy is False and not np.shares_memory(data, reshaped):
74
+ raise AttributeError("Incompatible shape for in-place modification.")
75
+
76
+ return Array._new(reshaped)
77
+
78
+
79
+ def roll(
80
+ x: Array,
81
+ /,
82
+ shift: Union[int, Tuple[int, ...]],
83
+ *,
84
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
85
+ ) -> Array:
86
+ """
87
+ Array API compatible wrapper for :py:func:`np.roll <numpy.roll>`.
88
+
89
+ See its docstring for more information.
90
+ """
91
+ return Array._new(np.roll(x._array, shift, axis=axis))
92
+
93
+
94
+ def squeeze(x: Array, /, axis: Union[int, Tuple[int, ...]]) -> Array:
95
+ """
96
+ Array API compatible wrapper for :py:func:`np.squeeze <numpy.squeeze>`.
97
+
98
+ See its docstring for more information.
99
+ """
100
+ return Array._new(np.squeeze(x._array, axis=axis))
101
+
102
+
103
+ def stack(arrays: Union[Tuple[Array, ...], List[Array]], /, *, axis: int = 0) -> Array:
104
+ """
105
+ Array API compatible wrapper for :py:func:`np.stack <numpy.stack>`.
106
+
107
+ See its docstring for more information.
108
+ """
109
+ # Call result type here just to raise on disallowed type combinations
110
+ result_type(*arrays)
111
+ arrays = tuple(a._array for a in arrays)
112
+ return Array._new(np.stack(arrays, axis=axis))
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_searching_functions.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+ from ._dtypes import _result_type, _real_numeric_dtypes
5
+
6
+ from typing import Optional, Tuple
7
+
8
+ import numpy as np
9
+
10
+
11
+ def argmax(x: Array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> Array:
12
+ """
13
+ Array API compatible wrapper for :py:func:`np.argmax <numpy.argmax>`.
14
+
15
+ See its docstring for more information.
16
+ """
17
+ if x.dtype not in _real_numeric_dtypes:
18
+ raise TypeError("Only real numeric dtypes are allowed in argmax")
19
+ return Array._new(np.asarray(np.argmax(x._array, axis=axis, keepdims=keepdims)))
20
+
21
+
22
+ def argmin(x: Array, /, *, axis: Optional[int] = None, keepdims: bool = False) -> Array:
23
+ """
24
+ Array API compatible wrapper for :py:func:`np.argmin <numpy.argmin>`.
25
+
26
+ See its docstring for more information.
27
+ """
28
+ if x.dtype not in _real_numeric_dtypes:
29
+ raise TypeError("Only real numeric dtypes are allowed in argmin")
30
+ return Array._new(np.asarray(np.argmin(x._array, axis=axis, keepdims=keepdims)))
31
+
32
+
33
+ def nonzero(x: Array, /) -> Tuple[Array, ...]:
34
+ """
35
+ Array API compatible wrapper for :py:func:`np.nonzero <numpy.nonzero>`.
36
+
37
+ See its docstring for more information.
38
+ """
39
+ return tuple(Array._new(i) for i in np.nonzero(x._array))
40
+
41
+
42
+ def where(condition: Array, x1: Array, x2: Array, /) -> Array:
43
+ """
44
+ Array API compatible wrapper for :py:func:`np.where <numpy.where>`.
45
+
46
+ See its docstring for more information.
47
+ """
48
+ # Call result type here just to raise on disallowed type combinations
49
+ _result_type(x1.dtype, x2.dtype)
50
+ x1, x2 = Array._normalize_two_args(x1, x2)
51
+ return Array._new(np.where(condition._array, x1._array, x2._array))
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_set_functions.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+
5
+ from typing import NamedTuple
6
+
7
+ import numpy as np
8
+
9
+ # Note: np.unique() is split into four functions in the array API:
10
+ # unique_all, unique_counts, unique_inverse, and unique_values (this is done
11
+ # to remove polymorphic return types).
12
+
13
+ # Note: The various unique() functions are supposed to return multiple NaNs.
14
+ # This does not match the NumPy behavior, however, this is currently left as a
15
+ # TODO in this implementation as this behavior may be reverted in np.unique().
16
+ # See https://github.com/numpy/numpy/issues/20326.
17
+
18
+ # Note: The functions here return a namedtuple (np.unique() returns a normal
19
+ # tuple).
20
+
21
+ class UniqueAllResult(NamedTuple):
22
+ values: Array
23
+ indices: Array
24
+ inverse_indices: Array
25
+ counts: Array
26
+
27
+
28
+ class UniqueCountsResult(NamedTuple):
29
+ values: Array
30
+ counts: Array
31
+
32
+
33
+ class UniqueInverseResult(NamedTuple):
34
+ values: Array
35
+ inverse_indices: Array
36
+
37
+
38
+ def unique_all(x: Array, /) -> UniqueAllResult:
39
+ """
40
+ Array API compatible wrapper for :py:func:`np.unique <numpy.unique>`.
41
+
42
+ See its docstring for more information.
43
+ """
44
+ values, indices, inverse_indices, counts = np.unique(
45
+ x._array,
46
+ return_counts=True,
47
+ return_index=True,
48
+ return_inverse=True,
49
+ equal_nan=False,
50
+ )
51
+ # np.unique() flattens inverse indices, but they need to share x's shape
52
+ # See https://github.com/numpy/numpy/issues/20638
53
+ inverse_indices = inverse_indices.reshape(x.shape)
54
+ return UniqueAllResult(
55
+ Array._new(values),
56
+ Array._new(indices),
57
+ Array._new(inverse_indices),
58
+ Array._new(counts),
59
+ )
60
+
61
+
62
+ def unique_counts(x: Array, /) -> UniqueCountsResult:
63
+ res = np.unique(
64
+ x._array,
65
+ return_counts=True,
66
+ return_index=False,
67
+ return_inverse=False,
68
+ equal_nan=False,
69
+ )
70
+
71
+ return UniqueCountsResult(*[Array._new(i) for i in res])
72
+
73
+
74
+ def unique_inverse(x: Array, /) -> UniqueInverseResult:
75
+ """
76
+ Array API compatible wrapper for :py:func:`np.unique <numpy.unique>`.
77
+
78
+ See its docstring for more information.
79
+ """
80
+ values, inverse_indices = np.unique(
81
+ x._array,
82
+ return_counts=False,
83
+ return_index=False,
84
+ return_inverse=True,
85
+ equal_nan=False,
86
+ )
87
+ # np.unique() flattens inverse indices, but they need to share x's shape
88
+ # See https://github.com/numpy/numpy/issues/20638
89
+ inverse_indices = inverse_indices.reshape(x.shape)
90
+ return UniqueInverseResult(Array._new(values), Array._new(inverse_indices))
91
+
92
+
93
+ def unique_values(x: Array, /) -> Array:
94
+ """
95
+ Array API compatible wrapper for :py:func:`np.unique <numpy.unique>`.
96
+
97
+ See its docstring for more information.
98
+ """
99
+ res = np.unique(
100
+ x._array,
101
+ return_counts=False,
102
+ return_index=False,
103
+ return_inverse=False,
104
+ equal_nan=False,
105
+ )
106
+ return Array._new(res)
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_sorting_functions.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._array_object import Array
4
+ from ._dtypes import _real_numeric_dtypes
5
+
6
+ import numpy as np
7
+
8
+
9
+ # Note: the descending keyword argument is new in this function
10
+ def argsort(
11
+ x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True
12
+ ) -> Array:
13
+ """
14
+ Array API compatible wrapper for :py:func:`np.argsort <numpy.argsort>`.
15
+
16
+ See its docstring for more information.
17
+ """
18
+ if x.dtype not in _real_numeric_dtypes:
19
+ raise TypeError("Only real numeric dtypes are allowed in argsort")
20
+ # Note: this keyword argument is different, and the default is different.
21
+ kind = "stable" if stable else "quicksort"
22
+ if not descending:
23
+ res = np.argsort(x._array, axis=axis, kind=kind)
24
+ else:
25
+ # As NumPy has no native descending sort, we imitate it here. Note that
26
+ # simply flipping the results of np.argsort(x._array, ...) would not
27
+ # respect the relative order like it would in native descending sorts.
28
+ res = np.flip(
29
+ np.argsort(np.flip(x._array, axis=axis), axis=axis, kind=kind),
30
+ axis=axis,
31
+ )
32
+ # Rely on flip()/argsort() to validate axis
33
+ normalised_axis = axis if axis >= 0 else x.ndim + axis
34
+ max_i = x.shape[normalised_axis] - 1
35
+ res = max_i - res
36
+ return Array._new(res)
37
+
38
+ # Note: the descending keyword argument is new in this function
39
+ def sort(
40
+ x: Array, /, *, axis: int = -1, descending: bool = False, stable: bool = True
41
+ ) -> Array:
42
+ """
43
+ Array API compatible wrapper for :py:func:`np.sort <numpy.sort>`.
44
+
45
+ See its docstring for more information.
46
+ """
47
+ if x.dtype not in _real_numeric_dtypes:
48
+ raise TypeError("Only real numeric dtypes are allowed in sort")
49
+ # Note: this keyword argument is different, and the default is different.
50
+ kind = "stable" if stable else "quicksort"
51
+ res = np.sort(x._array, axis=axis, kind=kind)
52
+ if descending:
53
+ res = np.flip(res, axis=axis)
54
+ return Array._new(res)
platform/dataops/dto/.venv/lib/python3.12/site-packages/numpy/array_api/_statistical_functions.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from ._dtypes import (
4
+ _real_floating_dtypes,
5
+ _real_numeric_dtypes,
6
+ _numeric_dtypes,
7
+ )
8
+ from ._array_object import Array
9
+ from ._dtypes import float32, float64, complex64, complex128
10
+
11
+ from typing import TYPE_CHECKING, Optional, Tuple, Union
12
+
13
+ if TYPE_CHECKING:
14
+ from ._typing import Dtype
15
+
16
+ import numpy as np
17
+
18
+
19
+ def max(
20
+ x: Array,
21
+ /,
22
+ *,
23
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
24
+ keepdims: bool = False,
25
+ ) -> Array:
26
+ if x.dtype not in _real_numeric_dtypes:
27
+ raise TypeError("Only real numeric dtypes are allowed in max")
28
+ return Array._new(np.max(x._array, axis=axis, keepdims=keepdims))
29
+
30
+
31
+ def mean(
32
+ x: Array,
33
+ /,
34
+ *,
35
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
36
+ keepdims: bool = False,
37
+ ) -> Array:
38
+ if x.dtype not in _real_floating_dtypes:
39
+ raise TypeError("Only real floating-point dtypes are allowed in mean")
40
+ return Array._new(np.mean(x._array, axis=axis, keepdims=keepdims))
41
+
42
+
43
+ def min(
44
+ x: Array,
45
+ /,
46
+ *,
47
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
48
+ keepdims: bool = False,
49
+ ) -> Array:
50
+ if x.dtype not in _real_numeric_dtypes:
51
+ raise TypeError("Only real numeric dtypes are allowed in min")
52
+ return Array._new(np.min(x._array, axis=axis, keepdims=keepdims))
53
+
54
+
55
+ def prod(
56
+ x: Array,
57
+ /,
58
+ *,
59
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
60
+ dtype: Optional[Dtype] = None,
61
+ keepdims: bool = False,
62
+ ) -> Array:
63
+ if x.dtype not in _numeric_dtypes:
64
+ raise TypeError("Only numeric dtypes are allowed in prod")
65
+ # Note: sum() and prod() always upcast for dtype=None. `np.prod` does that
66
+ # for integers, but not for float32 or complex64, so we need to
67
+ # special-case it here
68
+ if dtype is None:
69
+ if x.dtype == float32:
70
+ dtype = float64
71
+ elif x.dtype == complex64:
72
+ dtype = complex128
73
+ return Array._new(np.prod(x._array, dtype=dtype, axis=axis, keepdims=keepdims))
74
+
75
+
76
+ def std(
77
+ x: Array,
78
+ /,
79
+ *,
80
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
81
+ correction: Union[int, float] = 0.0,
82
+ keepdims: bool = False,
83
+ ) -> Array:
84
+ # Note: the keyword argument correction is different here
85
+ if x.dtype not in _real_floating_dtypes:
86
+ raise TypeError("Only real floating-point dtypes are allowed in std")
87
+ return Array._new(np.std(x._array, axis=axis, ddof=correction, keepdims=keepdims))
88
+
89
+
90
+ def sum(
91
+ x: Array,
92
+ /,
93
+ *,
94
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
95
+ dtype: Optional[Dtype] = None,
96
+ keepdims: bool = False,
97
+ ) -> Array:
98
+ if x.dtype not in _numeric_dtypes:
99
+ raise TypeError("Only numeric dtypes are allowed in sum")
100
+ # Note: sum() and prod() always upcast for dtype=None. `np.sum` does that
101
+ # for integers, but not for float32 or complex64, so we need to
102
+ # special-case it here
103
+ if dtype is None:
104
+ if x.dtype == float32:
105
+ dtype = float64
106
+ elif x.dtype == complex64:
107
+ dtype = complex128
108
+ return Array._new(np.sum(x._array, axis=axis, dtype=dtype, keepdims=keepdims))
109
+
110
+
111
+ def var(
112
+ x: Array,
113
+ /,
114
+ *,
115
+ axis: Optional[Union[int, Tuple[int, ...]]] = None,
116
+ correction: Union[int, float] = 0.0,
117
+ keepdims: bool = False,
118
+ ) -> Array:
119
+ # Note: the keyword argument correction is different here
120
+ if x.dtype not in _real_floating_dtypes:
121
+ raise TypeError("Only real floating-point dtypes are allowed in var")
122
+ return Array._new(np.var(x._array, axis=axis, ddof=correction, keepdims=keepdims))