Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/__init__.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_distributor_init.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_globals.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_pytesttester.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/ctypeslib.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/dtypes.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/exceptions.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/matlib.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/version.cpython-310.pyc +0 -0
- env-llmeval/lib/python3.10/site-packages/numpy/compat/__init__.py +19 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/arithmetic.pyi +121 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/arrayterator.pyi +14 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/comparisons.pyi +27 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/dtype.pyi +20 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/histograms.pyi +12 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/lib_function_base.pyi +53 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/lib_polynomial.pyi +29 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/linalg.pyi +48 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/multiarray.pyi +55 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/npyio.pyi +27 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/random.pyi +61 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/scalars.pyi +92 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/stride_tricks.pyi +9 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arithmetic.pyi +516 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/array_constructors.pyi +221 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arraypad.pyi +28 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arrayprint.pyi +30 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arraysetops.pyi +68 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arrayterator.pyi +33 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/bitwise_ops.pyi +135 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/char.pyi +154 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/chararray.pyi +140 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/comparisons.pyi +270 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/constants.pyi +61 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/ctypeslib.pyi +95 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/datasource.pyi +29 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/dtype.pyi +85 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/einsumfunc.pyi +45 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/emath.pyi +60 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/false_positives.pyi +18 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/fft.pyi +43 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/flatiter.pyi +31 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/fromnumeric.pyi +305 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/getlimits.pyi +56 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/histograms.pyi +27 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/index_tricks.pyi +74 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_function_base.pyi +185 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_polynomial.pyi +150 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_utils.pyi +41 -0
- env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_version.pyi +25 -0
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (11.6 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_distributor_init.cpython-310.pyc
ADDED
Binary file (615 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_globals.cpython-310.pyc
ADDED
Binary file (3.49 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/_pytesttester.cpython-310.pyc
ADDED
Binary file (5.87 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/ctypeslib.cpython-310.pyc
ADDED
Binary file (14.5 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/dtypes.cpython-310.pyc
ADDED
Binary file (2.29 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/exceptions.cpython-310.pyc
ADDED
Binary file (7.68 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/matlib.cpython-310.pyc
ADDED
Binary file (10.5 kB). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/__pycache__/version.cpython-310.pyc
ADDED
Binary file (366 Bytes). View file
|
|
env-llmeval/lib/python3.10/site-packages/numpy/compat/__init__.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Compatibility module.
|
3 |
+
|
4 |
+
This module contains duplicated code from Python itself or 3rd party
|
5 |
+
extensions, which may be included for the following reasons:
|
6 |
+
|
7 |
+
* compatibility
|
8 |
+
* we may only need a small subset of the copied library/module
|
9 |
+
|
10 |
+
"""
|
11 |
+
|
12 |
+
from .._utils import _inspect
|
13 |
+
from .._utils._inspect import getargspec, formatargspec
|
14 |
+
from . import py3k
|
15 |
+
from .py3k import *
|
16 |
+
|
17 |
+
__all__ = []
|
18 |
+
__all__.extend(_inspect.__all__)
|
19 |
+
__all__.extend(py3k.__all__)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/arithmetic.pyi
ADDED
@@ -0,0 +1,121 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
b_ = np.bool_()
|
5 |
+
dt = np.datetime64(0, "D")
|
6 |
+
td = np.timedelta64(0, "D")
|
7 |
+
|
8 |
+
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
|
9 |
+
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
|
10 |
+
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
11 |
+
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
12 |
+
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
13 |
+
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
14 |
+
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
15 |
+
|
16 |
+
ANY: Any
|
17 |
+
|
18 |
+
AR_LIKE_b: list[bool]
|
19 |
+
AR_LIKE_u: list[np.uint32]
|
20 |
+
AR_LIKE_i: list[int]
|
21 |
+
AR_LIKE_f: list[float]
|
22 |
+
AR_LIKE_c: list[complex]
|
23 |
+
AR_LIKE_m: list[np.timedelta64]
|
24 |
+
AR_LIKE_M: list[np.datetime64]
|
25 |
+
|
26 |
+
# Array subtraction
|
27 |
+
|
28 |
+
# NOTE: mypys `NoReturn` errors are, unfortunately, not that great
|
29 |
+
_1 = AR_b - AR_LIKE_b # E: Need type annotation
|
30 |
+
_2 = AR_LIKE_b - AR_b # E: Need type annotation
|
31 |
+
AR_i - bytes() # E: No overload variant
|
32 |
+
|
33 |
+
AR_f - AR_LIKE_m # E: Unsupported operand types
|
34 |
+
AR_f - AR_LIKE_M # E: Unsupported operand types
|
35 |
+
AR_c - AR_LIKE_m # E: Unsupported operand types
|
36 |
+
AR_c - AR_LIKE_M # E: Unsupported operand types
|
37 |
+
|
38 |
+
AR_m - AR_LIKE_f # E: Unsupported operand types
|
39 |
+
AR_M - AR_LIKE_f # E: Unsupported operand types
|
40 |
+
AR_m - AR_LIKE_c # E: Unsupported operand types
|
41 |
+
AR_M - AR_LIKE_c # E: Unsupported operand types
|
42 |
+
|
43 |
+
AR_m - AR_LIKE_M # E: Unsupported operand types
|
44 |
+
AR_LIKE_m - AR_M # E: Unsupported operand types
|
45 |
+
|
46 |
+
# array floor division
|
47 |
+
|
48 |
+
AR_M // AR_LIKE_b # E: Unsupported operand types
|
49 |
+
AR_M // AR_LIKE_u # E: Unsupported operand types
|
50 |
+
AR_M // AR_LIKE_i # E: Unsupported operand types
|
51 |
+
AR_M // AR_LIKE_f # E: Unsupported operand types
|
52 |
+
AR_M // AR_LIKE_c # E: Unsupported operand types
|
53 |
+
AR_M // AR_LIKE_m # E: Unsupported operand types
|
54 |
+
AR_M // AR_LIKE_M # E: Unsupported operand types
|
55 |
+
|
56 |
+
AR_b // AR_LIKE_M # E: Unsupported operand types
|
57 |
+
AR_u // AR_LIKE_M # E: Unsupported operand types
|
58 |
+
AR_i // AR_LIKE_M # E: Unsupported operand types
|
59 |
+
AR_f // AR_LIKE_M # E: Unsupported operand types
|
60 |
+
AR_c // AR_LIKE_M # E: Unsupported operand types
|
61 |
+
AR_m // AR_LIKE_M # E: Unsupported operand types
|
62 |
+
AR_M // AR_LIKE_M # E: Unsupported operand types
|
63 |
+
|
64 |
+
_3 = AR_m // AR_LIKE_b # E: Need type annotation
|
65 |
+
AR_m // AR_LIKE_c # E: Unsupported operand types
|
66 |
+
|
67 |
+
AR_b // AR_LIKE_m # E: Unsupported operand types
|
68 |
+
AR_u // AR_LIKE_m # E: Unsupported operand types
|
69 |
+
AR_i // AR_LIKE_m # E: Unsupported operand types
|
70 |
+
AR_f // AR_LIKE_m # E: Unsupported operand types
|
71 |
+
AR_c // AR_LIKE_m # E: Unsupported operand types
|
72 |
+
|
73 |
+
# Array multiplication
|
74 |
+
|
75 |
+
AR_b *= AR_LIKE_u # E: incompatible type
|
76 |
+
AR_b *= AR_LIKE_i # E: incompatible type
|
77 |
+
AR_b *= AR_LIKE_f # E: incompatible type
|
78 |
+
AR_b *= AR_LIKE_c # E: incompatible type
|
79 |
+
AR_b *= AR_LIKE_m # E: incompatible type
|
80 |
+
|
81 |
+
AR_u *= AR_LIKE_i # E: incompatible type
|
82 |
+
AR_u *= AR_LIKE_f # E: incompatible type
|
83 |
+
AR_u *= AR_LIKE_c # E: incompatible type
|
84 |
+
AR_u *= AR_LIKE_m # E: incompatible type
|
85 |
+
|
86 |
+
AR_i *= AR_LIKE_f # E: incompatible type
|
87 |
+
AR_i *= AR_LIKE_c # E: incompatible type
|
88 |
+
AR_i *= AR_LIKE_m # E: incompatible type
|
89 |
+
|
90 |
+
AR_f *= AR_LIKE_c # E: incompatible type
|
91 |
+
AR_f *= AR_LIKE_m # E: incompatible type
|
92 |
+
|
93 |
+
# Array power
|
94 |
+
|
95 |
+
AR_b **= AR_LIKE_b # E: Invalid self argument
|
96 |
+
AR_b **= AR_LIKE_u # E: Invalid self argument
|
97 |
+
AR_b **= AR_LIKE_i # E: Invalid self argument
|
98 |
+
AR_b **= AR_LIKE_f # E: Invalid self argument
|
99 |
+
AR_b **= AR_LIKE_c # E: Invalid self argument
|
100 |
+
|
101 |
+
AR_u **= AR_LIKE_i # E: incompatible type
|
102 |
+
AR_u **= AR_LIKE_f # E: incompatible type
|
103 |
+
AR_u **= AR_LIKE_c # E: incompatible type
|
104 |
+
|
105 |
+
AR_i **= AR_LIKE_f # E: incompatible type
|
106 |
+
AR_i **= AR_LIKE_c # E: incompatible type
|
107 |
+
|
108 |
+
AR_f **= AR_LIKE_c # E: incompatible type
|
109 |
+
|
110 |
+
# Scalars
|
111 |
+
|
112 |
+
b_ - b_ # E: No overload variant
|
113 |
+
|
114 |
+
dt + dt # E: Unsupported operand types
|
115 |
+
td - dt # E: Unsupported operand types
|
116 |
+
td % 1 # E: Unsupported operand types
|
117 |
+
td / dt # E: No overload
|
118 |
+
td % dt # E: Unsupported operand types
|
119 |
+
|
120 |
+
-b_ # E: Unsupported operand type
|
121 |
+
+b_ # E: Unsupported operand type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/arrayterator.pyi
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
|
5 |
+
ar_iter = np.lib.Arrayterator(AR_i8)
|
6 |
+
|
7 |
+
np.lib.Arrayterator(np.int64()) # E: incompatible type
|
8 |
+
ar_iter.shape = (10, 5) # E: is read-only
|
9 |
+
ar_iter[None] # E: Invalid index type
|
10 |
+
ar_iter[None, 1] # E: Invalid index type
|
11 |
+
ar_iter[np.intp()] # E: Invalid index type
|
12 |
+
ar_iter[np.intp(), ...] # E: Invalid index type
|
13 |
+
ar_iter[AR_i8] # E: Invalid index type
|
14 |
+
ar_iter[AR_i8, :] # E: Invalid index type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/comparisons.pyi
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
5 |
+
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
6 |
+
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
7 |
+
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
8 |
+
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
9 |
+
|
10 |
+
AR_f > AR_m # E: Unsupported operand types
|
11 |
+
AR_c > AR_m # E: Unsupported operand types
|
12 |
+
|
13 |
+
AR_m > AR_f # E: Unsupported operand types
|
14 |
+
AR_m > AR_c # E: Unsupported operand types
|
15 |
+
|
16 |
+
AR_i > AR_M # E: Unsupported operand types
|
17 |
+
AR_f > AR_M # E: Unsupported operand types
|
18 |
+
AR_m > AR_M # E: Unsupported operand types
|
19 |
+
|
20 |
+
AR_M > AR_i # E: Unsupported operand types
|
21 |
+
AR_M > AR_f # E: Unsupported operand types
|
22 |
+
AR_M > AR_m # E: Unsupported operand types
|
23 |
+
|
24 |
+
AR_i > str() # E: No overload variant
|
25 |
+
AR_i > bytes() # E: No overload variant
|
26 |
+
str() > AR_M # E: Unsupported operand types
|
27 |
+
bytes() > AR_M # E: Unsupported operand types
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/dtype.pyi
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
|
3 |
+
|
4 |
+
class Test1:
|
5 |
+
not_dtype = np.dtype(float)
|
6 |
+
|
7 |
+
|
8 |
+
class Test2:
|
9 |
+
dtype = float
|
10 |
+
|
11 |
+
|
12 |
+
np.dtype(Test1()) # E: No overload variant of "dtype" matches
|
13 |
+
np.dtype(Test2()) # E: incompatible type
|
14 |
+
|
15 |
+
np.dtype( # E: No overload variant of "dtype" matches
|
16 |
+
{
|
17 |
+
"field1": (float, 1),
|
18 |
+
"field2": (int, 3),
|
19 |
+
}
|
20 |
+
)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/histograms.pyi
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import numpy.typing as npt
|
3 |
+
|
4 |
+
AR_i8: npt.NDArray[np.int64]
|
5 |
+
AR_f8: npt.NDArray[np.float64]
|
6 |
+
|
7 |
+
np.histogram_bin_edges(AR_i8, range=(0, 1, 2)) # E: incompatible type
|
8 |
+
|
9 |
+
np.histogram(AR_i8, range=(0, 1, 2)) # E: incompatible type
|
10 |
+
|
11 |
+
np.histogramdd(AR_i8, range=(0, 1)) # E: incompatible type
|
12 |
+
np.histogramdd(AR_i8, range=[(0, 1, 2)]) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/lib_function_base.pyi
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Any
|
2 |
+
|
3 |
+
import numpy as np
|
4 |
+
import numpy.typing as npt
|
5 |
+
|
6 |
+
AR_f8: npt.NDArray[np.float64]
|
7 |
+
AR_c16: npt.NDArray[np.complex128]
|
8 |
+
AR_m: npt.NDArray[np.timedelta64]
|
9 |
+
AR_M: npt.NDArray[np.datetime64]
|
10 |
+
AR_O: npt.NDArray[np.object_]
|
11 |
+
|
12 |
+
def func(a: int) -> None: ...
|
13 |
+
|
14 |
+
np.average(AR_m) # E: incompatible type
|
15 |
+
np.select(1, [AR_f8]) # E: incompatible type
|
16 |
+
np.angle(AR_m) # E: incompatible type
|
17 |
+
np.unwrap(AR_m) # E: incompatible type
|
18 |
+
np.unwrap(AR_c16) # E: incompatible type
|
19 |
+
np.trim_zeros(1) # E: incompatible type
|
20 |
+
np.place(1, [True], 1.5) # E: incompatible type
|
21 |
+
np.vectorize(1) # E: incompatible type
|
22 |
+
np.add_newdoc("__main__", 1.5, "docstring") # E: incompatible type
|
23 |
+
np.place(AR_f8, slice(None), 5) # E: incompatible type
|
24 |
+
|
25 |
+
np.interp(AR_f8, AR_c16, AR_f8) # E: incompatible type
|
26 |
+
np.interp(AR_c16, AR_f8, AR_f8) # E: incompatible type
|
27 |
+
np.interp(AR_f8, AR_f8, AR_f8, period=AR_c16) # E: No overload variant
|
28 |
+
np.interp(AR_f8, AR_f8, AR_O) # E: incompatible type
|
29 |
+
|
30 |
+
np.cov(AR_m) # E: incompatible type
|
31 |
+
np.cov(AR_O) # E: incompatible type
|
32 |
+
np.corrcoef(AR_m) # E: incompatible type
|
33 |
+
np.corrcoef(AR_O) # E: incompatible type
|
34 |
+
np.corrcoef(AR_f8, bias=True) # E: No overload variant
|
35 |
+
np.corrcoef(AR_f8, ddof=2) # E: No overload variant
|
36 |
+
np.blackman(1j) # E: incompatible type
|
37 |
+
np.bartlett(1j) # E: incompatible type
|
38 |
+
np.hanning(1j) # E: incompatible type
|
39 |
+
np.hamming(1j) # E: incompatible type
|
40 |
+
np.hamming(AR_c16) # E: incompatible type
|
41 |
+
np.kaiser(1j, 1) # E: incompatible type
|
42 |
+
np.sinc(AR_O) # E: incompatible type
|
43 |
+
np.median(AR_M) # E: incompatible type
|
44 |
+
|
45 |
+
np.add_newdoc_ufunc(func, "docstring") # E: incompatible type
|
46 |
+
np.percentile(AR_f8, 50j) # E: No overload variant
|
47 |
+
np.percentile(AR_f8, 50, interpolation="bob") # E: No overload variant
|
48 |
+
np.quantile(AR_f8, 0.5j) # E: No overload variant
|
49 |
+
np.quantile(AR_f8, 0.5, interpolation="bob") # E: No overload variant
|
50 |
+
np.meshgrid(AR_f8, AR_f8, indexing="bob") # E: incompatible type
|
51 |
+
np.delete(AR_f8, AR_f8) # E: incompatible type
|
52 |
+
np.insert(AR_f8, AR_f8, 1.5) # E: incompatible type
|
53 |
+
np.digitize(AR_f8, 1j) # E: No overload variant
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/lib_polynomial.pyi
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import numpy.typing as npt
|
3 |
+
|
4 |
+
AR_f8: npt.NDArray[np.float64]
|
5 |
+
AR_c16: npt.NDArray[np.complex128]
|
6 |
+
AR_O: npt.NDArray[np.object_]
|
7 |
+
AR_U: npt.NDArray[np.str_]
|
8 |
+
|
9 |
+
poly_obj: np.poly1d
|
10 |
+
|
11 |
+
np.polymul(AR_f8, AR_U) # E: incompatible type
|
12 |
+
np.polydiv(AR_f8, AR_U) # E: incompatible type
|
13 |
+
|
14 |
+
5**poly_obj # E: No overload variant
|
15 |
+
|
16 |
+
np.polyint(AR_U) # E: incompatible type
|
17 |
+
np.polyint(AR_f8, m=1j) # E: No overload variant
|
18 |
+
|
19 |
+
np.polyder(AR_U) # E: incompatible type
|
20 |
+
np.polyder(AR_f8, m=1j) # E: No overload variant
|
21 |
+
|
22 |
+
np.polyfit(AR_O, AR_f8, 1) # E: incompatible type
|
23 |
+
np.polyfit(AR_f8, AR_f8, 1, rcond=1j) # E: No overload variant
|
24 |
+
np.polyfit(AR_f8, AR_f8, 1, w=AR_c16) # E: incompatible type
|
25 |
+
np.polyfit(AR_f8, AR_f8, 1, cov="bob") # E: No overload variant
|
26 |
+
|
27 |
+
np.polyval(AR_f8, AR_U) # E: incompatible type
|
28 |
+
np.polyadd(AR_f8, AR_U) # E: incompatible type
|
29 |
+
np.polysub(AR_f8, AR_U) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/linalg.pyi
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import numpy.typing as npt
|
3 |
+
|
4 |
+
AR_f8: npt.NDArray[np.float64]
|
5 |
+
AR_O: npt.NDArray[np.object_]
|
6 |
+
AR_M: npt.NDArray[np.datetime64]
|
7 |
+
|
8 |
+
np.linalg.tensorsolve(AR_O, AR_O) # E: incompatible type
|
9 |
+
|
10 |
+
np.linalg.solve(AR_O, AR_O) # E: incompatible type
|
11 |
+
|
12 |
+
np.linalg.tensorinv(AR_O) # E: incompatible type
|
13 |
+
|
14 |
+
np.linalg.inv(AR_O) # E: incompatible type
|
15 |
+
|
16 |
+
np.linalg.matrix_power(AR_M, 5) # E: incompatible type
|
17 |
+
|
18 |
+
np.linalg.cholesky(AR_O) # E: incompatible type
|
19 |
+
|
20 |
+
np.linalg.qr(AR_O) # E: incompatible type
|
21 |
+
np.linalg.qr(AR_f8, mode="bob") # E: No overload variant
|
22 |
+
|
23 |
+
np.linalg.eigvals(AR_O) # E: incompatible type
|
24 |
+
|
25 |
+
np.linalg.eigvalsh(AR_O) # E: incompatible type
|
26 |
+
np.linalg.eigvalsh(AR_O, UPLO="bob") # E: No overload variant
|
27 |
+
|
28 |
+
np.linalg.eig(AR_O) # E: incompatible type
|
29 |
+
|
30 |
+
np.linalg.eigh(AR_O) # E: incompatible type
|
31 |
+
np.linalg.eigh(AR_O, UPLO="bob") # E: No overload variant
|
32 |
+
|
33 |
+
np.linalg.svd(AR_O) # E: incompatible type
|
34 |
+
|
35 |
+
np.linalg.cond(AR_O) # E: incompatible type
|
36 |
+
np.linalg.cond(AR_f8, p="bob") # E: incompatible type
|
37 |
+
|
38 |
+
np.linalg.matrix_rank(AR_O) # E: incompatible type
|
39 |
+
|
40 |
+
np.linalg.pinv(AR_O) # E: incompatible type
|
41 |
+
|
42 |
+
np.linalg.slogdet(AR_O) # E: incompatible type
|
43 |
+
|
44 |
+
np.linalg.det(AR_O) # E: incompatible type
|
45 |
+
|
46 |
+
np.linalg.norm(AR_f8, ord="bob") # E: No overload variant
|
47 |
+
|
48 |
+
np.linalg.multi_dot([AR_M]) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/multiarray.pyi
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import numpy.typing as npt
|
3 |
+
|
4 |
+
i8: np.int64
|
5 |
+
|
6 |
+
AR_b: npt.NDArray[np.bool_]
|
7 |
+
AR_u1: npt.NDArray[np.uint8]
|
8 |
+
AR_i8: npt.NDArray[np.int64]
|
9 |
+
AR_f8: npt.NDArray[np.float64]
|
10 |
+
AR_M: npt.NDArray[np.datetime64]
|
11 |
+
|
12 |
+
M: np.datetime64
|
13 |
+
|
14 |
+
AR_LIKE_f: list[float]
|
15 |
+
|
16 |
+
def func(a: int) -> None: ...
|
17 |
+
|
18 |
+
np.where(AR_b, 1) # E: No overload variant
|
19 |
+
|
20 |
+
np.can_cast(AR_f8, 1) # E: incompatible type
|
21 |
+
|
22 |
+
np.vdot(AR_M, AR_M) # E: incompatible type
|
23 |
+
|
24 |
+
np.copyto(AR_LIKE_f, AR_f8) # E: incompatible type
|
25 |
+
|
26 |
+
np.putmask(AR_LIKE_f, [True, True, False], 1.5) # E: incompatible type
|
27 |
+
|
28 |
+
np.packbits(AR_f8) # E: incompatible type
|
29 |
+
np.packbits(AR_u1, bitorder=">") # E: incompatible type
|
30 |
+
|
31 |
+
np.unpackbits(AR_i8) # E: incompatible type
|
32 |
+
np.unpackbits(AR_u1, bitorder=">") # E: incompatible type
|
33 |
+
|
34 |
+
np.shares_memory(1, 1, max_work=i8) # E: incompatible type
|
35 |
+
np.may_share_memory(1, 1, max_work=i8) # E: incompatible type
|
36 |
+
|
37 |
+
np.arange(M) # E: No overload variant
|
38 |
+
np.arange(stop=10) # E: No overload variant
|
39 |
+
|
40 |
+
np.datetime_data(int) # E: incompatible type
|
41 |
+
|
42 |
+
np.busday_offset("2012", 10) # E: No overload variant
|
43 |
+
|
44 |
+
np.datetime_as_string("2012") # E: No overload variant
|
45 |
+
|
46 |
+
np.compare_chararrays("a", b"a", "==", False) # E: No overload variant
|
47 |
+
|
48 |
+
np.add_docstring(func, None) # E: incompatible type
|
49 |
+
|
50 |
+
np.nested_iters([AR_i8, AR_i8]) # E: Missing positional argument
|
51 |
+
np.nested_iters([AR_i8, AR_i8], 0) # E: incompatible type
|
52 |
+
np.nested_iters([AR_i8, AR_i8], [0]) # E: incompatible type
|
53 |
+
np.nested_iters([AR_i8, AR_i8], [[0], [1]], flags=["test"]) # E: incompatible type
|
54 |
+
np.nested_iters([AR_i8, AR_i8], [[0], [1]], op_flags=[["test"]]) # E: incompatible type
|
55 |
+
np.nested_iters([AR_i8, AR_i8], [[0], [1]], buffersize=1.0) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/npyio.pyi
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pathlib
|
2 |
+
from typing import IO
|
3 |
+
|
4 |
+
import numpy.typing as npt
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
str_path: str
|
8 |
+
bytes_path: bytes
|
9 |
+
pathlib_path: pathlib.Path
|
10 |
+
str_file: IO[str]
|
11 |
+
AR_i8: npt.NDArray[np.int64]
|
12 |
+
|
13 |
+
np.load(str_file) # E: incompatible type
|
14 |
+
|
15 |
+
np.save(bytes_path, AR_i8) # E: incompatible type
|
16 |
+
|
17 |
+
np.savez(bytes_path, AR_i8) # E: incompatible type
|
18 |
+
|
19 |
+
np.savez_compressed(bytes_path, AR_i8) # E: incompatible type
|
20 |
+
|
21 |
+
np.loadtxt(bytes_path) # E: incompatible type
|
22 |
+
|
23 |
+
np.fromregex(bytes_path, ".", np.int64) # E: No overload variant
|
24 |
+
|
25 |
+
np.recfromtxt(bytes_path) # E: incompatible type
|
26 |
+
|
27 |
+
np.recfromcsv(bytes_path) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/random.pyi
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
SEED_FLOAT: float = 457.3
|
5 |
+
SEED_ARR_FLOAT: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0, 2, 3, 4])
|
6 |
+
SEED_ARRLIKE_FLOAT: list[float] = [1.0, 2.0, 3.0, 4.0]
|
7 |
+
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)
|
8 |
+
SEED_STR: str = "String seeding not allowed"
|
9 |
+
# default rng
|
10 |
+
np.random.default_rng(SEED_FLOAT) # E: incompatible type
|
11 |
+
np.random.default_rng(SEED_ARR_FLOAT) # E: incompatible type
|
12 |
+
np.random.default_rng(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
13 |
+
np.random.default_rng(SEED_STR) # E: incompatible type
|
14 |
+
|
15 |
+
# Seed Sequence
|
16 |
+
np.random.SeedSequence(SEED_FLOAT) # E: incompatible type
|
17 |
+
np.random.SeedSequence(SEED_ARR_FLOAT) # E: incompatible type
|
18 |
+
np.random.SeedSequence(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
19 |
+
np.random.SeedSequence(SEED_SEED_SEQ) # E: incompatible type
|
20 |
+
np.random.SeedSequence(SEED_STR) # E: incompatible type
|
21 |
+
|
22 |
+
seed_seq: np.random.bit_generator.SeedSequence = np.random.SeedSequence()
|
23 |
+
seed_seq.spawn(11.5) # E: incompatible type
|
24 |
+
seed_seq.generate_state(3.14) # E: incompatible type
|
25 |
+
seed_seq.generate_state(3, np.uint8) # E: incompatible type
|
26 |
+
seed_seq.generate_state(3, "uint8") # E: incompatible type
|
27 |
+
seed_seq.generate_state(3, "u1") # E: incompatible type
|
28 |
+
seed_seq.generate_state(3, np.uint16) # E: incompatible type
|
29 |
+
seed_seq.generate_state(3, "uint16") # E: incompatible type
|
30 |
+
seed_seq.generate_state(3, "u2") # E: incompatible type
|
31 |
+
seed_seq.generate_state(3, np.int32) # E: incompatible type
|
32 |
+
seed_seq.generate_state(3, "int32") # E: incompatible type
|
33 |
+
seed_seq.generate_state(3, "i4") # E: incompatible type
|
34 |
+
|
35 |
+
# Bit Generators
|
36 |
+
np.random.MT19937(SEED_FLOAT) # E: incompatible type
|
37 |
+
np.random.MT19937(SEED_ARR_FLOAT) # E: incompatible type
|
38 |
+
np.random.MT19937(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
39 |
+
np.random.MT19937(SEED_STR) # E: incompatible type
|
40 |
+
|
41 |
+
np.random.PCG64(SEED_FLOAT) # E: incompatible type
|
42 |
+
np.random.PCG64(SEED_ARR_FLOAT) # E: incompatible type
|
43 |
+
np.random.PCG64(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
44 |
+
np.random.PCG64(SEED_STR) # E: incompatible type
|
45 |
+
|
46 |
+
np.random.Philox(SEED_FLOAT) # E: incompatible type
|
47 |
+
np.random.Philox(SEED_ARR_FLOAT) # E: incompatible type
|
48 |
+
np.random.Philox(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
49 |
+
np.random.Philox(SEED_STR) # E: incompatible type
|
50 |
+
|
51 |
+
np.random.SFC64(SEED_FLOAT) # E: incompatible type
|
52 |
+
np.random.SFC64(SEED_ARR_FLOAT) # E: incompatible type
|
53 |
+
np.random.SFC64(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
54 |
+
np.random.SFC64(SEED_STR) # E: incompatible type
|
55 |
+
|
56 |
+
# Generator
|
57 |
+
np.random.Generator(None) # E: incompatible type
|
58 |
+
np.random.Generator(12333283902830213) # E: incompatible type
|
59 |
+
np.random.Generator("OxFEEDF00D") # E: incompatible type
|
60 |
+
np.random.Generator([123, 234]) # E: incompatible type
|
61 |
+
np.random.Generator(np.array([123, 234], dtype="u4")) # E: incompatible type
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/scalars.pyi
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import numpy as np
|
3 |
+
|
4 |
+
f2: np.float16
|
5 |
+
f8: np.float64
|
6 |
+
c8: np.complex64
|
7 |
+
|
8 |
+
# Construction
|
9 |
+
|
10 |
+
np.float32(3j) # E: incompatible type
|
11 |
+
|
12 |
+
# Technically the following examples are valid NumPy code. But they
|
13 |
+
# are not considered a best practice, and people who wish to use the
|
14 |
+
# stubs should instead do
|
15 |
+
#
|
16 |
+
# np.array([1.0, 0.0, 0.0], dtype=np.float32)
|
17 |
+
# np.array([], dtype=np.complex64)
|
18 |
+
#
|
19 |
+
# See e.g. the discussion on the mailing list
|
20 |
+
#
|
21 |
+
# https://mail.python.org/pipermail/numpy-discussion/2020-April/080566.html
|
22 |
+
#
|
23 |
+
# and the issue
|
24 |
+
#
|
25 |
+
# https://github.com/numpy/numpy-stubs/issues/41
|
26 |
+
#
|
27 |
+
# for more context.
|
28 |
+
np.float32([1.0, 0.0, 0.0]) # E: incompatible type
|
29 |
+
np.complex64([]) # E: incompatible type
|
30 |
+
|
31 |
+
np.complex64(1, 2) # E: Too many arguments
|
32 |
+
# TODO: protocols (can't check for non-existent protocols w/ __getattr__)
|
33 |
+
|
34 |
+
np.datetime64(0) # E: No overload variant
|
35 |
+
|
36 |
+
class A:
|
37 |
+
def __float__(self):
|
38 |
+
return 1.0
|
39 |
+
|
40 |
+
|
41 |
+
np.int8(A()) # E: incompatible type
|
42 |
+
np.int16(A()) # E: incompatible type
|
43 |
+
np.int32(A()) # E: incompatible type
|
44 |
+
np.int64(A()) # E: incompatible type
|
45 |
+
np.uint8(A()) # E: incompatible type
|
46 |
+
np.uint16(A()) # E: incompatible type
|
47 |
+
np.uint32(A()) # E: incompatible type
|
48 |
+
np.uint64(A()) # E: incompatible type
|
49 |
+
|
50 |
+
np.void("test") # E: No overload variant
|
51 |
+
np.void("test", dtype=None) # E: No overload variant
|
52 |
+
|
53 |
+
np.generic(1) # E: Cannot instantiate abstract class
|
54 |
+
np.number(1) # E: Cannot instantiate abstract class
|
55 |
+
np.integer(1) # E: Cannot instantiate abstract class
|
56 |
+
np.inexact(1) # E: Cannot instantiate abstract class
|
57 |
+
np.character("test") # E: Cannot instantiate abstract class
|
58 |
+
np.flexible(b"test") # E: Cannot instantiate abstract class
|
59 |
+
|
60 |
+
np.float64(value=0.0) # E: Unexpected keyword argument
|
61 |
+
np.int64(value=0) # E: Unexpected keyword argument
|
62 |
+
np.uint64(value=0) # E: Unexpected keyword argument
|
63 |
+
np.complex128(value=0.0j) # E: Unexpected keyword argument
|
64 |
+
np.str_(value='bob') # E: No overload variant
|
65 |
+
np.bytes_(value=b'test') # E: No overload variant
|
66 |
+
np.void(value=b'test') # E: No overload variant
|
67 |
+
np.bool_(value=True) # E: Unexpected keyword argument
|
68 |
+
np.datetime64(value="2019") # E: No overload variant
|
69 |
+
np.timedelta64(value=0) # E: Unexpected keyword argument
|
70 |
+
|
71 |
+
np.bytes_(b"hello", encoding='utf-8') # E: No overload variant
|
72 |
+
np.str_("hello", encoding='utf-8') # E: No overload variant
|
73 |
+
|
74 |
+
f8.item(1) # E: incompatible type
|
75 |
+
f8.item((0, 1)) # E: incompatible type
|
76 |
+
f8.squeeze(axis=1) # E: incompatible type
|
77 |
+
f8.squeeze(axis=(0, 1)) # E: incompatible type
|
78 |
+
f8.transpose(1) # E: incompatible type
|
79 |
+
|
80 |
+
def func(a: np.float32) -> None: ...
|
81 |
+
|
82 |
+
func(f2) # E: incompatible type
|
83 |
+
func(f8) # E: incompatible type
|
84 |
+
|
85 |
+
round(c8) # E: No overload variant
|
86 |
+
|
87 |
+
c8.__getnewargs__() # E: Invalid self argument
|
88 |
+
f2.__getnewargs__() # E: Invalid self argument
|
89 |
+
f2.hex() # E: Invalid self argument
|
90 |
+
np.float16.fromhex("0x0.0p+0") # E: Invalid self argument
|
91 |
+
f2.__trunc__() # E: Invalid self argument
|
92 |
+
f2.__getformat__("float") # E: Invalid self argument
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/fail/stride_tricks.pyi
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import numpy.typing as npt
|
3 |
+
|
4 |
+
AR_f8: npt.NDArray[np.float64]
|
5 |
+
|
6 |
+
np.lib.stride_tricks.as_strided(AR_f8, shape=8) # E: No overload variant
|
7 |
+
np.lib.stride_tricks.as_strided(AR_f8, strides=8) # E: No overload variant
|
8 |
+
|
9 |
+
np.lib.stride_tricks.sliding_window_view(AR_f8, axis=(1,)) # E: No overload variant
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arithmetic.pyi
ADDED
@@ -0,0 +1,516 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
from numpy._typing import _32Bit,_64Bit, _128Bit
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
# Can't directly import `np.float128` as it is not available on all platforms
|
14 |
+
f16: np.floating[_128Bit]
|
15 |
+
|
16 |
+
c16 = np.complex128()
|
17 |
+
f8 = np.float64()
|
18 |
+
i8 = np.int64()
|
19 |
+
u8 = np.uint64()
|
20 |
+
|
21 |
+
c8 = np.complex64()
|
22 |
+
f4 = np.float32()
|
23 |
+
i4 = np.int32()
|
24 |
+
u4 = np.uint32()
|
25 |
+
|
26 |
+
dt = np.datetime64(0, "D")
|
27 |
+
td = np.timedelta64(0, "D")
|
28 |
+
|
29 |
+
b_ = np.bool_()
|
30 |
+
|
31 |
+
b = bool()
|
32 |
+
c = complex()
|
33 |
+
f = float()
|
34 |
+
i = int()
|
35 |
+
|
36 |
+
AR_b: npt.NDArray[np.bool_]
|
37 |
+
AR_u: npt.NDArray[np.uint32]
|
38 |
+
AR_i: npt.NDArray[np.int64]
|
39 |
+
AR_f: npt.NDArray[np.float64]
|
40 |
+
AR_c: npt.NDArray[np.complex128]
|
41 |
+
AR_m: npt.NDArray[np.timedelta64]
|
42 |
+
AR_M: npt.NDArray[np.datetime64]
|
43 |
+
AR_O: npt.NDArray[np.object_]
|
44 |
+
AR_number: npt.NDArray[np.number[Any]]
|
45 |
+
|
46 |
+
AR_LIKE_b: list[bool]
|
47 |
+
AR_LIKE_u: list[np.uint32]
|
48 |
+
AR_LIKE_i: list[int]
|
49 |
+
AR_LIKE_f: list[float]
|
50 |
+
AR_LIKE_c: list[complex]
|
51 |
+
AR_LIKE_m: list[np.timedelta64]
|
52 |
+
AR_LIKE_M: list[np.datetime64]
|
53 |
+
AR_LIKE_O: list[np.object_]
|
54 |
+
|
55 |
+
# Array subtraction
|
56 |
+
|
57 |
+
assert_type(AR_number - AR_number, npt.NDArray[np.number[Any]])
|
58 |
+
|
59 |
+
assert_type(AR_b - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
|
60 |
+
assert_type(AR_b - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
61 |
+
assert_type(AR_b - AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
62 |
+
assert_type(AR_b - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
|
63 |
+
assert_type(AR_b - AR_LIKE_m, npt.NDArray[np.timedelta64])
|
64 |
+
assert_type(AR_b - AR_LIKE_O, Any)
|
65 |
+
|
66 |
+
assert_type(AR_LIKE_u - AR_b, npt.NDArray[np.unsignedinteger[Any]])
|
67 |
+
assert_type(AR_LIKE_i - AR_b, npt.NDArray[np.signedinteger[Any]])
|
68 |
+
assert_type(AR_LIKE_f - AR_b, npt.NDArray[np.floating[Any]])
|
69 |
+
assert_type(AR_LIKE_c - AR_b, npt.NDArray[np.complexfloating[Any, Any]])
|
70 |
+
assert_type(AR_LIKE_m - AR_b, npt.NDArray[np.timedelta64])
|
71 |
+
assert_type(AR_LIKE_M - AR_b, npt.NDArray[np.datetime64])
|
72 |
+
assert_type(AR_LIKE_O - AR_b, Any)
|
73 |
+
|
74 |
+
assert_type(AR_u - AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])
|
75 |
+
assert_type(AR_u - AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
|
76 |
+
assert_type(AR_u - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
77 |
+
assert_type(AR_u - AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
78 |
+
assert_type(AR_u - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
|
79 |
+
assert_type(AR_u - AR_LIKE_m, npt.NDArray[np.timedelta64])
|
80 |
+
assert_type(AR_u - AR_LIKE_O, Any)
|
81 |
+
|
82 |
+
assert_type(AR_LIKE_b - AR_u, npt.NDArray[np.unsignedinteger[Any]])
|
83 |
+
assert_type(AR_LIKE_u - AR_u, npt.NDArray[np.unsignedinteger[Any]])
|
84 |
+
assert_type(AR_LIKE_i - AR_u, npt.NDArray[np.signedinteger[Any]])
|
85 |
+
assert_type(AR_LIKE_f - AR_u, npt.NDArray[np.floating[Any]])
|
86 |
+
assert_type(AR_LIKE_c - AR_u, npt.NDArray[np.complexfloating[Any, Any]])
|
87 |
+
assert_type(AR_LIKE_m - AR_u, npt.NDArray[np.timedelta64])
|
88 |
+
assert_type(AR_LIKE_M - AR_u, npt.NDArray[np.datetime64])
|
89 |
+
assert_type(AR_LIKE_O - AR_u, Any)
|
90 |
+
|
91 |
+
assert_type(AR_i - AR_LIKE_b, npt.NDArray[np.signedinteger[Any]])
|
92 |
+
assert_type(AR_i - AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])
|
93 |
+
assert_type(AR_i - AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
94 |
+
assert_type(AR_i - AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
95 |
+
assert_type(AR_i - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
|
96 |
+
assert_type(AR_i - AR_LIKE_m, npt.NDArray[np.timedelta64])
|
97 |
+
assert_type(AR_i - AR_LIKE_O, Any)
|
98 |
+
|
99 |
+
assert_type(AR_LIKE_b - AR_i, npt.NDArray[np.signedinteger[Any]])
|
100 |
+
assert_type(AR_LIKE_u - AR_i, npt.NDArray[np.signedinteger[Any]])
|
101 |
+
assert_type(AR_LIKE_i - AR_i, npt.NDArray[np.signedinteger[Any]])
|
102 |
+
assert_type(AR_LIKE_f - AR_i, npt.NDArray[np.floating[Any]])
|
103 |
+
assert_type(AR_LIKE_c - AR_i, npt.NDArray[np.complexfloating[Any, Any]])
|
104 |
+
assert_type(AR_LIKE_m - AR_i, npt.NDArray[np.timedelta64])
|
105 |
+
assert_type(AR_LIKE_M - AR_i, npt.NDArray[np.datetime64])
|
106 |
+
assert_type(AR_LIKE_O - AR_i, Any)
|
107 |
+
|
108 |
+
assert_type(AR_f - AR_LIKE_b, npt.NDArray[np.floating[Any]])
|
109 |
+
assert_type(AR_f - AR_LIKE_u, npt.NDArray[np.floating[Any]])
|
110 |
+
assert_type(AR_f - AR_LIKE_i, npt.NDArray[np.floating[Any]])
|
111 |
+
assert_type(AR_f - AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
112 |
+
assert_type(AR_f - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
|
113 |
+
assert_type(AR_f - AR_LIKE_O, Any)
|
114 |
+
|
115 |
+
assert_type(AR_LIKE_b - AR_f, npt.NDArray[np.floating[Any]])
|
116 |
+
assert_type(AR_LIKE_u - AR_f, npt.NDArray[np.floating[Any]])
|
117 |
+
assert_type(AR_LIKE_i - AR_f, npt.NDArray[np.floating[Any]])
|
118 |
+
assert_type(AR_LIKE_f - AR_f, npt.NDArray[np.floating[Any]])
|
119 |
+
assert_type(AR_LIKE_c - AR_f, npt.NDArray[np.complexfloating[Any, Any]])
|
120 |
+
assert_type(AR_LIKE_O - AR_f, Any)
|
121 |
+
|
122 |
+
assert_type(AR_c - AR_LIKE_b, npt.NDArray[np.complexfloating[Any, Any]])
|
123 |
+
assert_type(AR_c - AR_LIKE_u, npt.NDArray[np.complexfloating[Any, Any]])
|
124 |
+
assert_type(AR_c - AR_LIKE_i, npt.NDArray[np.complexfloating[Any, Any]])
|
125 |
+
assert_type(AR_c - AR_LIKE_f, npt.NDArray[np.complexfloating[Any, Any]])
|
126 |
+
assert_type(AR_c - AR_LIKE_c, npt.NDArray[np.complexfloating[Any, Any]])
|
127 |
+
assert_type(AR_c - AR_LIKE_O, Any)
|
128 |
+
|
129 |
+
assert_type(AR_LIKE_b - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
|
130 |
+
assert_type(AR_LIKE_u - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
|
131 |
+
assert_type(AR_LIKE_i - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
|
132 |
+
assert_type(AR_LIKE_f - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
|
133 |
+
assert_type(AR_LIKE_c - AR_c, npt.NDArray[np.complexfloating[Any, Any]])
|
134 |
+
assert_type(AR_LIKE_O - AR_c, Any)
|
135 |
+
|
136 |
+
assert_type(AR_m - AR_LIKE_b, npt.NDArray[np.timedelta64])
|
137 |
+
assert_type(AR_m - AR_LIKE_u, npt.NDArray[np.timedelta64])
|
138 |
+
assert_type(AR_m - AR_LIKE_i, npt.NDArray[np.timedelta64])
|
139 |
+
assert_type(AR_m - AR_LIKE_m, npt.NDArray[np.timedelta64])
|
140 |
+
assert_type(AR_m - AR_LIKE_O, Any)
|
141 |
+
|
142 |
+
assert_type(AR_LIKE_b - AR_m, npt.NDArray[np.timedelta64])
|
143 |
+
assert_type(AR_LIKE_u - AR_m, npt.NDArray[np.timedelta64])
|
144 |
+
assert_type(AR_LIKE_i - AR_m, npt.NDArray[np.timedelta64])
|
145 |
+
assert_type(AR_LIKE_m - AR_m, npt.NDArray[np.timedelta64])
|
146 |
+
assert_type(AR_LIKE_M - AR_m, npt.NDArray[np.datetime64])
|
147 |
+
assert_type(AR_LIKE_O - AR_m, Any)
|
148 |
+
|
149 |
+
assert_type(AR_M - AR_LIKE_b, npt.NDArray[np.datetime64])
|
150 |
+
assert_type(AR_M - AR_LIKE_u, npt.NDArray[np.datetime64])
|
151 |
+
assert_type(AR_M - AR_LIKE_i, npt.NDArray[np.datetime64])
|
152 |
+
assert_type(AR_M - AR_LIKE_m, npt.NDArray[np.datetime64])
|
153 |
+
assert_type(AR_M - AR_LIKE_M, npt.NDArray[np.timedelta64])
|
154 |
+
assert_type(AR_M - AR_LIKE_O, Any)
|
155 |
+
|
156 |
+
assert_type(AR_LIKE_M - AR_M, npt.NDArray[np.timedelta64])
|
157 |
+
assert_type(AR_LIKE_O - AR_M, Any)
|
158 |
+
|
159 |
+
assert_type(AR_O - AR_LIKE_b, Any)
|
160 |
+
assert_type(AR_O - AR_LIKE_u, Any)
|
161 |
+
assert_type(AR_O - AR_LIKE_i, Any)
|
162 |
+
assert_type(AR_O - AR_LIKE_f, Any)
|
163 |
+
assert_type(AR_O - AR_LIKE_c, Any)
|
164 |
+
assert_type(AR_O - AR_LIKE_m, Any)
|
165 |
+
assert_type(AR_O - AR_LIKE_M, Any)
|
166 |
+
assert_type(AR_O - AR_LIKE_O, Any)
|
167 |
+
|
168 |
+
assert_type(AR_LIKE_b - AR_O, Any)
|
169 |
+
assert_type(AR_LIKE_u - AR_O, Any)
|
170 |
+
assert_type(AR_LIKE_i - AR_O, Any)
|
171 |
+
assert_type(AR_LIKE_f - AR_O, Any)
|
172 |
+
assert_type(AR_LIKE_c - AR_O, Any)
|
173 |
+
assert_type(AR_LIKE_m - AR_O, Any)
|
174 |
+
assert_type(AR_LIKE_M - AR_O, Any)
|
175 |
+
assert_type(AR_LIKE_O - AR_O, Any)
|
176 |
+
|
177 |
+
# Array floor division
|
178 |
+
|
179 |
+
assert_type(AR_b // AR_LIKE_b, npt.NDArray[np.int8])
|
180 |
+
assert_type(AR_b // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
|
181 |
+
assert_type(AR_b // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
182 |
+
assert_type(AR_b // AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
183 |
+
assert_type(AR_b // AR_LIKE_O, Any)
|
184 |
+
|
185 |
+
assert_type(AR_LIKE_b // AR_b, npt.NDArray[np.int8])
|
186 |
+
assert_type(AR_LIKE_u // AR_b, npt.NDArray[np.unsignedinteger[Any]])
|
187 |
+
assert_type(AR_LIKE_i // AR_b, npt.NDArray[np.signedinteger[Any]])
|
188 |
+
assert_type(AR_LIKE_f // AR_b, npt.NDArray[np.floating[Any]])
|
189 |
+
assert_type(AR_LIKE_O // AR_b, Any)
|
190 |
+
|
191 |
+
assert_type(AR_u // AR_LIKE_b, npt.NDArray[np.unsignedinteger[Any]])
|
192 |
+
assert_type(AR_u // AR_LIKE_u, npt.NDArray[np.unsignedinteger[Any]])
|
193 |
+
assert_type(AR_u // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
194 |
+
assert_type(AR_u // AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
195 |
+
assert_type(AR_u // AR_LIKE_O, Any)
|
196 |
+
|
197 |
+
assert_type(AR_LIKE_b // AR_u, npt.NDArray[np.unsignedinteger[Any]])
|
198 |
+
assert_type(AR_LIKE_u // AR_u, npt.NDArray[np.unsignedinteger[Any]])
|
199 |
+
assert_type(AR_LIKE_i // AR_u, npt.NDArray[np.signedinteger[Any]])
|
200 |
+
assert_type(AR_LIKE_f // AR_u, npt.NDArray[np.floating[Any]])
|
201 |
+
assert_type(AR_LIKE_m // AR_u, npt.NDArray[np.timedelta64])
|
202 |
+
assert_type(AR_LIKE_O // AR_u, Any)
|
203 |
+
|
204 |
+
assert_type(AR_i // AR_LIKE_b, npt.NDArray[np.signedinteger[Any]])
|
205 |
+
assert_type(AR_i // AR_LIKE_u, npt.NDArray[np.signedinteger[Any]])
|
206 |
+
assert_type(AR_i // AR_LIKE_i, npt.NDArray[np.signedinteger[Any]])
|
207 |
+
assert_type(AR_i // AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
208 |
+
assert_type(AR_i // AR_LIKE_O, Any)
|
209 |
+
|
210 |
+
assert_type(AR_LIKE_b // AR_i, npt.NDArray[np.signedinteger[Any]])
|
211 |
+
assert_type(AR_LIKE_u // AR_i, npt.NDArray[np.signedinteger[Any]])
|
212 |
+
assert_type(AR_LIKE_i // AR_i, npt.NDArray[np.signedinteger[Any]])
|
213 |
+
assert_type(AR_LIKE_f // AR_i, npt.NDArray[np.floating[Any]])
|
214 |
+
assert_type(AR_LIKE_m // AR_i, npt.NDArray[np.timedelta64])
|
215 |
+
assert_type(AR_LIKE_O // AR_i, Any)
|
216 |
+
|
217 |
+
assert_type(AR_f // AR_LIKE_b, npt.NDArray[np.floating[Any]])
|
218 |
+
assert_type(AR_f // AR_LIKE_u, npt.NDArray[np.floating[Any]])
|
219 |
+
assert_type(AR_f // AR_LIKE_i, npt.NDArray[np.floating[Any]])
|
220 |
+
assert_type(AR_f // AR_LIKE_f, npt.NDArray[np.floating[Any]])
|
221 |
+
assert_type(AR_f // AR_LIKE_O, Any)
|
222 |
+
|
223 |
+
assert_type(AR_LIKE_b // AR_f, npt.NDArray[np.floating[Any]])
|
224 |
+
assert_type(AR_LIKE_u // AR_f, npt.NDArray[np.floating[Any]])
|
225 |
+
assert_type(AR_LIKE_i // AR_f, npt.NDArray[np.floating[Any]])
|
226 |
+
assert_type(AR_LIKE_f // AR_f, npt.NDArray[np.floating[Any]])
|
227 |
+
assert_type(AR_LIKE_m // AR_f, npt.NDArray[np.timedelta64])
|
228 |
+
assert_type(AR_LIKE_O // AR_f, Any)
|
229 |
+
|
230 |
+
assert_type(AR_m // AR_LIKE_u, npt.NDArray[np.timedelta64])
|
231 |
+
assert_type(AR_m // AR_LIKE_i, npt.NDArray[np.timedelta64])
|
232 |
+
assert_type(AR_m // AR_LIKE_f, npt.NDArray[np.timedelta64])
|
233 |
+
assert_type(AR_m // AR_LIKE_m, npt.NDArray[np.int64])
|
234 |
+
assert_type(AR_m // AR_LIKE_O, Any)
|
235 |
+
|
236 |
+
assert_type(AR_LIKE_m // AR_m, npt.NDArray[np.int64])
|
237 |
+
assert_type(AR_LIKE_O // AR_m, Any)
|
238 |
+
|
239 |
+
assert_type(AR_O // AR_LIKE_b, Any)
|
240 |
+
assert_type(AR_O // AR_LIKE_u, Any)
|
241 |
+
assert_type(AR_O // AR_LIKE_i, Any)
|
242 |
+
assert_type(AR_O // AR_LIKE_f, Any)
|
243 |
+
assert_type(AR_O // AR_LIKE_m, Any)
|
244 |
+
assert_type(AR_O // AR_LIKE_M, Any)
|
245 |
+
assert_type(AR_O // AR_LIKE_O, Any)
|
246 |
+
|
247 |
+
assert_type(AR_LIKE_b // AR_O, Any)
|
248 |
+
assert_type(AR_LIKE_u // AR_O, Any)
|
249 |
+
assert_type(AR_LIKE_i // AR_O, Any)
|
250 |
+
assert_type(AR_LIKE_f // AR_O, Any)
|
251 |
+
assert_type(AR_LIKE_m // AR_O, Any)
|
252 |
+
assert_type(AR_LIKE_M // AR_O, Any)
|
253 |
+
assert_type(AR_LIKE_O // AR_O, Any)
|
254 |
+
|
255 |
+
# unary ops
|
256 |
+
|
257 |
+
assert_type(-f16, np.floating[_128Bit])
|
258 |
+
assert_type(-c16, np.complex128)
|
259 |
+
assert_type(-c8, np.complex64)
|
260 |
+
assert_type(-f8, np.float64)
|
261 |
+
assert_type(-f4, np.float32)
|
262 |
+
assert_type(-i8, np.int64)
|
263 |
+
assert_type(-i4, np.int32)
|
264 |
+
assert_type(-u8, np.uint64)
|
265 |
+
assert_type(-u4, np.uint32)
|
266 |
+
assert_type(-td, np.timedelta64)
|
267 |
+
assert_type(-AR_f, npt.NDArray[np.float64])
|
268 |
+
|
269 |
+
assert_type(+f16, np.floating[_128Bit])
|
270 |
+
assert_type(+c16, np.complex128)
|
271 |
+
assert_type(+c8, np.complex64)
|
272 |
+
assert_type(+f8, np.float64)
|
273 |
+
assert_type(+f4, np.float32)
|
274 |
+
assert_type(+i8, np.int64)
|
275 |
+
assert_type(+i4, np.int32)
|
276 |
+
assert_type(+u8, np.uint64)
|
277 |
+
assert_type(+u4, np.uint32)
|
278 |
+
assert_type(+td, np.timedelta64)
|
279 |
+
assert_type(+AR_f, npt.NDArray[np.float64])
|
280 |
+
|
281 |
+
assert_type(abs(f16), np.floating[_128Bit])
|
282 |
+
assert_type(abs(c16), np.float64)
|
283 |
+
assert_type(abs(c8), np.float32)
|
284 |
+
assert_type(abs(f8), np.float64)
|
285 |
+
assert_type(abs(f4), np.float32)
|
286 |
+
assert_type(abs(i8), np.int64)
|
287 |
+
assert_type(abs(i4), np.int32)
|
288 |
+
assert_type(abs(u8), np.uint64)
|
289 |
+
assert_type(abs(u4), np.uint32)
|
290 |
+
assert_type(abs(td), np.timedelta64)
|
291 |
+
assert_type(abs(b_), np.bool_)
|
292 |
+
|
293 |
+
# Time structures
|
294 |
+
|
295 |
+
assert_type(dt + td, np.datetime64)
|
296 |
+
assert_type(dt + i, np.datetime64)
|
297 |
+
assert_type(dt + i4, np.datetime64)
|
298 |
+
assert_type(dt + i8, np.datetime64)
|
299 |
+
assert_type(dt - dt, np.timedelta64)
|
300 |
+
assert_type(dt - i, np.datetime64)
|
301 |
+
assert_type(dt - i4, np.datetime64)
|
302 |
+
assert_type(dt - i8, np.datetime64)
|
303 |
+
|
304 |
+
assert_type(td + td, np.timedelta64)
|
305 |
+
assert_type(td + i, np.timedelta64)
|
306 |
+
assert_type(td + i4, np.timedelta64)
|
307 |
+
assert_type(td + i8, np.timedelta64)
|
308 |
+
assert_type(td - td, np.timedelta64)
|
309 |
+
assert_type(td - i, np.timedelta64)
|
310 |
+
assert_type(td - i4, np.timedelta64)
|
311 |
+
assert_type(td - i8, np.timedelta64)
|
312 |
+
assert_type(td / f, np.timedelta64)
|
313 |
+
assert_type(td / f4, np.timedelta64)
|
314 |
+
assert_type(td / f8, np.timedelta64)
|
315 |
+
assert_type(td / td, np.float64)
|
316 |
+
assert_type(td // td, np.int64)
|
317 |
+
|
318 |
+
# boolean
|
319 |
+
|
320 |
+
assert_type(b_ / b, np.float64)
|
321 |
+
assert_type(b_ / b_, np.float64)
|
322 |
+
assert_type(b_ / i, np.float64)
|
323 |
+
assert_type(b_ / i8, np.float64)
|
324 |
+
assert_type(b_ / i4, np.float64)
|
325 |
+
assert_type(b_ / u8, np.float64)
|
326 |
+
assert_type(b_ / u4, np.float64)
|
327 |
+
assert_type(b_ / f, np.float64)
|
328 |
+
assert_type(b_ / f16, np.floating[_128Bit])
|
329 |
+
assert_type(b_ / f8, np.float64)
|
330 |
+
assert_type(b_ / f4, np.float32)
|
331 |
+
assert_type(b_ / c, np.complex128)
|
332 |
+
assert_type(b_ / c16, np.complex128)
|
333 |
+
assert_type(b_ / c8, np.complex64)
|
334 |
+
|
335 |
+
assert_type(b / b_, np.float64)
|
336 |
+
assert_type(b_ / b_, np.float64)
|
337 |
+
assert_type(i / b_, np.float64)
|
338 |
+
assert_type(i8 / b_, np.float64)
|
339 |
+
assert_type(i4 / b_, np.float64)
|
340 |
+
assert_type(u8 / b_, np.float64)
|
341 |
+
assert_type(u4 / b_, np.float64)
|
342 |
+
assert_type(f / b_, np.float64)
|
343 |
+
assert_type(f16 / b_, np.floating[_128Bit])
|
344 |
+
assert_type(f8 / b_, np.float64)
|
345 |
+
assert_type(f4 / b_, np.float32)
|
346 |
+
assert_type(c / b_, np.complex128)
|
347 |
+
assert_type(c16 / b_, np.complex128)
|
348 |
+
assert_type(c8 / b_, np.complex64)
|
349 |
+
|
350 |
+
# Complex
|
351 |
+
|
352 |
+
assert_type(c16 + f16, np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit])
|
353 |
+
assert_type(c16 + c16, np.complex128)
|
354 |
+
assert_type(c16 + f8, np.complex128)
|
355 |
+
assert_type(c16 + i8, np.complex128)
|
356 |
+
assert_type(c16 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
357 |
+
assert_type(c16 + f4, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
358 |
+
assert_type(c16 + i4, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
359 |
+
assert_type(c16 + b_, np.complex128)
|
360 |
+
assert_type(c16 + b, np.complex128)
|
361 |
+
assert_type(c16 + c, np.complex128)
|
362 |
+
assert_type(c16 + f, np.complex128)
|
363 |
+
assert_type(c16 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])
|
364 |
+
|
365 |
+
assert_type(f16 + c16, np.complexfloating[_64Bit | _128Bit, _64Bit | _128Bit])
|
366 |
+
assert_type(c16 + c16, np.complex128)
|
367 |
+
assert_type(f8 + c16, np.complex128)
|
368 |
+
assert_type(i8 + c16, np.complex128)
|
369 |
+
assert_type(c8 + c16, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
370 |
+
assert_type(f4 + c16, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
371 |
+
assert_type(i4 + c16, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
372 |
+
assert_type(b_ + c16, np.complex128)
|
373 |
+
assert_type(b + c16, np.complex128)
|
374 |
+
assert_type(c + c16, np.complex128)
|
375 |
+
assert_type(f + c16, np.complex128)
|
376 |
+
assert_type(AR_f + c16, npt.NDArray[np.complexfloating[Any, Any]])
|
377 |
+
|
378 |
+
assert_type(c8 + f16, np.complexfloating[_32Bit | _128Bit, _32Bit | _128Bit])
|
379 |
+
assert_type(c8 + c16, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
380 |
+
assert_type(c8 + f8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
381 |
+
assert_type(c8 + i8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
382 |
+
assert_type(c8 + c8, np.complex64)
|
383 |
+
assert_type(c8 + f4, np.complex64)
|
384 |
+
assert_type(c8 + i4, np.complex64)
|
385 |
+
assert_type(c8 + b_, np.complex64)
|
386 |
+
assert_type(c8 + b, np.complex64)
|
387 |
+
assert_type(c8 + c, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
388 |
+
assert_type(c8 + f, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
389 |
+
assert_type(c8 + AR_f, npt.NDArray[np.complexfloating[Any, Any]])
|
390 |
+
|
391 |
+
assert_type(f16 + c8, np.complexfloating[_32Bit | _128Bit, _32Bit | _128Bit])
|
392 |
+
assert_type(c16 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
393 |
+
assert_type(f8 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
394 |
+
assert_type(i8 + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
395 |
+
assert_type(c8 + c8, np.complex64)
|
396 |
+
assert_type(f4 + c8, np.complex64)
|
397 |
+
assert_type(i4 + c8, np.complex64)
|
398 |
+
assert_type(b_ + c8, np.complex64)
|
399 |
+
assert_type(b + c8, np.complex64)
|
400 |
+
assert_type(c + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
401 |
+
assert_type(f + c8, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
402 |
+
assert_type(AR_f + c8, npt.NDArray[np.complexfloating[Any, Any]])
|
403 |
+
|
404 |
+
# Float
|
405 |
+
|
406 |
+
assert_type(f8 + f16, np.floating[_64Bit | _128Bit])
|
407 |
+
assert_type(f8 + f8, np.float64)
|
408 |
+
assert_type(f8 + i8, np.float64)
|
409 |
+
assert_type(f8 + f4, np.floating[_32Bit | _64Bit])
|
410 |
+
assert_type(f8 + i4, np.floating[_32Bit | _64Bit])
|
411 |
+
assert_type(f8 + b_, np.float64)
|
412 |
+
assert_type(f8 + b, np.float64)
|
413 |
+
assert_type(f8 + c, np.complex128)
|
414 |
+
assert_type(f8 + f, np.float64)
|
415 |
+
assert_type(f8 + AR_f, npt.NDArray[np.floating[Any]])
|
416 |
+
|
417 |
+
assert_type(f16 + f8, np.floating[_64Bit | _128Bit])
|
418 |
+
assert_type(f8 + f8, np.float64)
|
419 |
+
assert_type(i8 + f8, np.float64)
|
420 |
+
assert_type(f4 + f8, np.floating[_32Bit | _64Bit])
|
421 |
+
assert_type(i4 + f8, np.floating[_32Bit | _64Bit])
|
422 |
+
assert_type(b_ + f8, np.float64)
|
423 |
+
assert_type(b + f8, np.float64)
|
424 |
+
assert_type(c + f8, np.complex128)
|
425 |
+
assert_type(f + f8, np.float64)
|
426 |
+
assert_type(AR_f + f8, npt.NDArray[np.floating[Any]])
|
427 |
+
|
428 |
+
assert_type(f4 + f16, np.floating[_32Bit | _128Bit])
|
429 |
+
assert_type(f4 + f8, np.floating[_32Bit | _64Bit])
|
430 |
+
assert_type(f4 + i8, np.floating[_32Bit | _64Bit])
|
431 |
+
assert_type(f4 + f4, np.float32)
|
432 |
+
assert_type(f4 + i4, np.float32)
|
433 |
+
assert_type(f4 + b_, np.float32)
|
434 |
+
assert_type(f4 + b, np.float32)
|
435 |
+
assert_type(f4 + c, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
436 |
+
assert_type(f4 + f, np.floating[_32Bit | _64Bit])
|
437 |
+
assert_type(f4 + AR_f, npt.NDArray[np.floating[Any]])
|
438 |
+
|
439 |
+
assert_type(f16 + f4, np.floating[_32Bit | _128Bit])
|
440 |
+
assert_type(f8 + f4, np.floating[_32Bit | _64Bit])
|
441 |
+
assert_type(i8 + f4, np.floating[_32Bit | _64Bit])
|
442 |
+
assert_type(f4 + f4, np.float32)
|
443 |
+
assert_type(i4 + f4, np.float32)
|
444 |
+
assert_type(b_ + f4, np.float32)
|
445 |
+
assert_type(b + f4, np.float32)
|
446 |
+
assert_type(c + f4, np.complexfloating[_32Bit | _64Bit, _32Bit | _64Bit])
|
447 |
+
assert_type(f + f4, np.floating[_32Bit | _64Bit])
|
448 |
+
assert_type(AR_f + f4, npt.NDArray[np.floating[Any]])
|
449 |
+
|
450 |
+
# Int
|
451 |
+
|
452 |
+
assert_type(i8 + i8, np.int64)
|
453 |
+
assert_type(i8 + u8, Any)
|
454 |
+
assert_type(i8 + i4, np.signedinteger[_32Bit | _64Bit])
|
455 |
+
assert_type(i8 + u4, Any)
|
456 |
+
assert_type(i8 + b_, np.int64)
|
457 |
+
assert_type(i8 + b, np.int64)
|
458 |
+
assert_type(i8 + c, np.complex128)
|
459 |
+
assert_type(i8 + f, np.float64)
|
460 |
+
assert_type(i8 + AR_f, npt.NDArray[np.floating[Any]])
|
461 |
+
|
462 |
+
assert_type(u8 + u8, np.uint64)
|
463 |
+
assert_type(u8 + i4, Any)
|
464 |
+
assert_type(u8 + u4, np.unsignedinteger[_32Bit | _64Bit])
|
465 |
+
assert_type(u8 + b_, np.uint64)
|
466 |
+
assert_type(u8 + b, np.uint64)
|
467 |
+
assert_type(u8 + c, np.complex128)
|
468 |
+
assert_type(u8 + f, np.float64)
|
469 |
+
assert_type(u8 + AR_f, npt.NDArray[np.floating[Any]])
|
470 |
+
|
471 |
+
assert_type(i8 + i8, np.int64)
|
472 |
+
assert_type(u8 + i8, Any)
|
473 |
+
assert_type(i4 + i8, np.signedinteger[_32Bit | _64Bit])
|
474 |
+
assert_type(u4 + i8, Any)
|
475 |
+
assert_type(b_ + i8, np.int64)
|
476 |
+
assert_type(b + i8, np.int64)
|
477 |
+
assert_type(c + i8, np.complex128)
|
478 |
+
assert_type(f + i8, np.float64)
|
479 |
+
assert_type(AR_f + i8, npt.NDArray[np.floating[Any]])
|
480 |
+
|
481 |
+
assert_type(u8 + u8, np.uint64)
|
482 |
+
assert_type(i4 + u8, Any)
|
483 |
+
assert_type(u4 + u8, np.unsignedinteger[_32Bit | _64Bit])
|
484 |
+
assert_type(b_ + u8, np.uint64)
|
485 |
+
assert_type(b + u8, np.uint64)
|
486 |
+
assert_type(c + u8, np.complex128)
|
487 |
+
assert_type(f + u8, np.float64)
|
488 |
+
assert_type(AR_f + u8, npt.NDArray[np.floating[Any]])
|
489 |
+
|
490 |
+
assert_type(i4 + i8, np.signedinteger[_32Bit | _64Bit])
|
491 |
+
assert_type(i4 + i4, np.int32)
|
492 |
+
assert_type(i4 + b_, np.int32)
|
493 |
+
assert_type(i4 + b, np.int32)
|
494 |
+
assert_type(i4 + AR_f, npt.NDArray[np.floating[Any]])
|
495 |
+
|
496 |
+
assert_type(u4 + i8, Any)
|
497 |
+
assert_type(u4 + i4, Any)
|
498 |
+
assert_type(u4 + u8, np.unsignedinteger[_32Bit | _64Bit])
|
499 |
+
assert_type(u4 + u4, np.uint32)
|
500 |
+
assert_type(u4 + b_, np.uint32)
|
501 |
+
assert_type(u4 + b, np.uint32)
|
502 |
+
assert_type(u4 + AR_f, npt.NDArray[np.floating[Any]])
|
503 |
+
|
504 |
+
assert_type(i8 + i4, np.signedinteger[_32Bit | _64Bit])
|
505 |
+
assert_type(i4 + i4, np.int32)
|
506 |
+
assert_type(b_ + i4, np.int32)
|
507 |
+
assert_type(b + i4, np.int32)
|
508 |
+
assert_type(AR_f + i4, npt.NDArray[np.floating[Any]])
|
509 |
+
|
510 |
+
assert_type(i8 + u4, Any)
|
511 |
+
assert_type(i4 + u4, Any)
|
512 |
+
assert_type(u8 + u4, np.unsignedinteger[_32Bit | _64Bit])
|
513 |
+
assert_type(u4 + u4, np.uint32)
|
514 |
+
assert_type(b_ + u4, np.uint32)
|
515 |
+
assert_type(b + u4, np.uint32)
|
516 |
+
assert_type(AR_f + u4, npt.NDArray[np.floating[Any]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/array_constructors.pyi
ADDED
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any, TypeVar
|
3 |
+
from pathlib import Path
|
4 |
+
from collections import deque
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
import numpy.typing as npt
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
_SCT = TypeVar("_SCT", bound=np.generic, covariant=True)
|
15 |
+
|
16 |
+
class SubClass(np.ndarray[Any, np.dtype[_SCT]]): ...
|
17 |
+
|
18 |
+
i8: np.int64
|
19 |
+
|
20 |
+
A: npt.NDArray[np.float64]
|
21 |
+
B: SubClass[np.float64]
|
22 |
+
C: list[int]
|
23 |
+
|
24 |
+
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
|
25 |
+
|
26 |
+
assert_type(np.empty_like(A), npt.NDArray[np.float64])
|
27 |
+
assert_type(np.empty_like(B), SubClass[np.float64])
|
28 |
+
assert_type(np.empty_like([1, 1.0]), npt.NDArray[Any])
|
29 |
+
assert_type(np.empty_like(A, dtype=np.int64), npt.NDArray[np.int64])
|
30 |
+
assert_type(np.empty_like(A, dtype='c16'), npt.NDArray[Any])
|
31 |
+
|
32 |
+
assert_type(np.array(A), npt.NDArray[np.float64])
|
33 |
+
assert_type(np.array(B), npt.NDArray[np.float64])
|
34 |
+
assert_type(np.array(B, subok=True), SubClass[np.float64])
|
35 |
+
assert_type(np.array([1, 1.0]), npt.NDArray[Any])
|
36 |
+
assert_type(np.array(deque([1, 2, 3])), npt.NDArray[Any])
|
37 |
+
assert_type(np.array(A, dtype=np.int64), npt.NDArray[np.int64])
|
38 |
+
assert_type(np.array(A, dtype='c16'), npt.NDArray[Any])
|
39 |
+
assert_type(np.array(A, like=A), npt.NDArray[np.float64])
|
40 |
+
|
41 |
+
assert_type(np.zeros([1, 5, 6]), npt.NDArray[np.float64])
|
42 |
+
assert_type(np.zeros([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])
|
43 |
+
assert_type(np.zeros([1, 5, 6], dtype='c16'), npt.NDArray[Any])
|
44 |
+
|
45 |
+
assert_type(np.empty([1, 5, 6]), npt.NDArray[np.float64])
|
46 |
+
assert_type(np.empty([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])
|
47 |
+
assert_type(np.empty([1, 5, 6], dtype='c16'), npt.NDArray[Any])
|
48 |
+
|
49 |
+
assert_type(np.concatenate(A), npt.NDArray[np.float64])
|
50 |
+
assert_type(np.concatenate([A, A]), Any)
|
51 |
+
assert_type(np.concatenate([[1], A]), npt.NDArray[Any])
|
52 |
+
assert_type(np.concatenate([[1], [1]]), npt.NDArray[Any])
|
53 |
+
assert_type(np.concatenate((A, A)), npt.NDArray[np.float64])
|
54 |
+
assert_type(np.concatenate(([1], [1])), npt.NDArray[Any])
|
55 |
+
assert_type(np.concatenate([1, 1.0]), npt.NDArray[Any])
|
56 |
+
assert_type(np.concatenate(A, dtype=np.int64), npt.NDArray[np.int64])
|
57 |
+
assert_type(np.concatenate(A, dtype='c16'), npt.NDArray[Any])
|
58 |
+
assert_type(np.concatenate([1, 1.0], out=A), npt.NDArray[np.float64])
|
59 |
+
|
60 |
+
assert_type(np.asarray(A), npt.NDArray[np.float64])
|
61 |
+
assert_type(np.asarray(B), npt.NDArray[np.float64])
|
62 |
+
assert_type(np.asarray([1, 1.0]), npt.NDArray[Any])
|
63 |
+
assert_type(np.asarray(A, dtype=np.int64), npt.NDArray[np.int64])
|
64 |
+
assert_type(np.asarray(A, dtype='c16'), npt.NDArray[Any])
|
65 |
+
|
66 |
+
assert_type(np.asanyarray(A), npt.NDArray[np.float64])
|
67 |
+
assert_type(np.asanyarray(B), SubClass[np.float64])
|
68 |
+
assert_type(np.asanyarray([1, 1.0]), npt.NDArray[Any])
|
69 |
+
assert_type(np.asanyarray(A, dtype=np.int64), npt.NDArray[np.int64])
|
70 |
+
assert_type(np.asanyarray(A, dtype='c16'), npt.NDArray[Any])
|
71 |
+
|
72 |
+
assert_type(np.ascontiguousarray(A), npt.NDArray[np.float64])
|
73 |
+
assert_type(np.ascontiguousarray(B), npt.NDArray[np.float64])
|
74 |
+
assert_type(np.ascontiguousarray([1, 1.0]), npt.NDArray[Any])
|
75 |
+
assert_type(np.ascontiguousarray(A, dtype=np.int64), npt.NDArray[np.int64])
|
76 |
+
assert_type(np.ascontiguousarray(A, dtype='c16'), npt.NDArray[Any])
|
77 |
+
|
78 |
+
assert_type(np.asfortranarray(A), npt.NDArray[np.float64])
|
79 |
+
assert_type(np.asfortranarray(B), npt.NDArray[np.float64])
|
80 |
+
assert_type(np.asfortranarray([1, 1.0]), npt.NDArray[Any])
|
81 |
+
assert_type(np.asfortranarray(A, dtype=np.int64), npt.NDArray[np.int64])
|
82 |
+
assert_type(np.asfortranarray(A, dtype='c16'), npt.NDArray[Any])
|
83 |
+
|
84 |
+
assert_type(np.fromstring("1 1 1", sep=" "), npt.NDArray[np.float64])
|
85 |
+
assert_type(np.fromstring(b"1 1 1", sep=" "), npt.NDArray[np.float64])
|
86 |
+
assert_type(np.fromstring("1 1 1", dtype=np.int64, sep=" "), npt.NDArray[np.int64])
|
87 |
+
assert_type(np.fromstring(b"1 1 1", dtype=np.int64, sep=" "), npt.NDArray[np.int64])
|
88 |
+
assert_type(np.fromstring("1 1 1", dtype="c16", sep=" "), npt.NDArray[Any])
|
89 |
+
assert_type(np.fromstring(b"1 1 1", dtype="c16", sep=" "), npt.NDArray[Any])
|
90 |
+
|
91 |
+
assert_type(np.fromfile("test.txt", sep=" "), npt.NDArray[np.float64])
|
92 |
+
assert_type(np.fromfile("test.txt", dtype=np.int64, sep=" "), npt.NDArray[np.int64])
|
93 |
+
assert_type(np.fromfile("test.txt", dtype="c16", sep=" "), npt.NDArray[Any])
|
94 |
+
with open("test.txt") as f:
|
95 |
+
assert_type(np.fromfile(f, sep=" "), npt.NDArray[np.float64])
|
96 |
+
assert_type(np.fromfile(b"test.txt", sep=" "), npt.NDArray[np.float64])
|
97 |
+
assert_type(np.fromfile(Path("test.txt"), sep=" "), npt.NDArray[np.float64])
|
98 |
+
|
99 |
+
assert_type(np.fromiter("12345", np.float64), npt.NDArray[np.float64])
|
100 |
+
assert_type(np.fromiter("12345", float), npt.NDArray[Any])
|
101 |
+
|
102 |
+
assert_type(np.frombuffer(A), npt.NDArray[np.float64])
|
103 |
+
assert_type(np.frombuffer(A, dtype=np.int64), npt.NDArray[np.int64])
|
104 |
+
assert_type(np.frombuffer(A, dtype="c16"), npt.NDArray[Any])
|
105 |
+
|
106 |
+
assert_type(np.arange(False, True), npt.NDArray[np.signedinteger[Any]])
|
107 |
+
assert_type(np.arange(10), npt.NDArray[np.signedinteger[Any]])
|
108 |
+
assert_type(np.arange(0, 10, step=2), npt.NDArray[np.signedinteger[Any]])
|
109 |
+
assert_type(np.arange(10.0), npt.NDArray[np.floating[Any]])
|
110 |
+
assert_type(np.arange(start=0, stop=10.0), npt.NDArray[np.floating[Any]])
|
111 |
+
assert_type(np.arange(np.timedelta64(0)), npt.NDArray[np.timedelta64])
|
112 |
+
assert_type(np.arange(0, np.timedelta64(10)), npt.NDArray[np.timedelta64])
|
113 |
+
assert_type(np.arange(np.datetime64("0"), np.datetime64("10")), npt.NDArray[np.datetime64])
|
114 |
+
assert_type(np.arange(10, dtype=np.float64), npt.NDArray[np.float64])
|
115 |
+
assert_type(np.arange(0, 10, step=2, dtype=np.int16), npt.NDArray[np.int16])
|
116 |
+
assert_type(np.arange(10, dtype=int), npt.NDArray[Any])
|
117 |
+
assert_type(np.arange(0, 10, dtype="f8"), npt.NDArray[Any])
|
118 |
+
|
119 |
+
assert_type(np.require(A), npt.NDArray[np.float64])
|
120 |
+
assert_type(np.require(B), SubClass[np.float64])
|
121 |
+
assert_type(np.require(B, requirements=None), SubClass[np.float64])
|
122 |
+
assert_type(np.require(B, dtype=int), np.ndarray[Any, Any])
|
123 |
+
assert_type(np.require(B, requirements="E"), np.ndarray[Any, Any])
|
124 |
+
assert_type(np.require(B, requirements=["ENSUREARRAY"]), np.ndarray[Any, Any])
|
125 |
+
assert_type(np.require(B, requirements={"F", "E"}), np.ndarray[Any, Any])
|
126 |
+
assert_type(np.require(B, requirements=["C", "OWNDATA"]), SubClass[np.float64])
|
127 |
+
assert_type(np.require(B, requirements="W"), SubClass[np.float64])
|
128 |
+
assert_type(np.require(B, requirements="A"), SubClass[np.float64])
|
129 |
+
assert_type(np.require(C), np.ndarray[Any, Any])
|
130 |
+
|
131 |
+
assert_type(np.linspace(0, 10), npt.NDArray[np.floating[Any]])
|
132 |
+
assert_type(np.linspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])
|
133 |
+
assert_type(np.linspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])
|
134 |
+
assert_type(np.linspace(0, 10, dtype=int), npt.NDArray[Any])
|
135 |
+
assert_type(np.linspace(0, 10, retstep=True), tuple[npt.NDArray[np.floating[Any]], np.floating[Any]])
|
136 |
+
assert_type(np.linspace(0j, 10, retstep=True), tuple[npt.NDArray[np.complexfloating[Any, Any]], np.complexfloating[Any, Any]])
|
137 |
+
assert_type(np.linspace(0, 10, retstep=True, dtype=np.int64), tuple[npt.NDArray[np.int64], np.int64])
|
138 |
+
assert_type(np.linspace(0j, 10, retstep=True, dtype=int), tuple[npt.NDArray[Any], Any])
|
139 |
+
|
140 |
+
assert_type(np.logspace(0, 10), npt.NDArray[np.floating[Any]])
|
141 |
+
assert_type(np.logspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])
|
142 |
+
assert_type(np.logspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])
|
143 |
+
assert_type(np.logspace(0, 10, dtype=int), npt.NDArray[Any])
|
144 |
+
|
145 |
+
assert_type(np.geomspace(0, 10), npt.NDArray[np.floating[Any]])
|
146 |
+
assert_type(np.geomspace(0, 10j), npt.NDArray[np.complexfloating[Any, Any]])
|
147 |
+
assert_type(np.geomspace(0, 10, dtype=np.int64), npt.NDArray[np.int64])
|
148 |
+
assert_type(np.geomspace(0, 10, dtype=int), npt.NDArray[Any])
|
149 |
+
|
150 |
+
assert_type(np.zeros_like(A), npt.NDArray[np.float64])
|
151 |
+
assert_type(np.zeros_like(C), npt.NDArray[Any])
|
152 |
+
assert_type(np.zeros_like(A, dtype=float), npt.NDArray[Any])
|
153 |
+
assert_type(np.zeros_like(B), SubClass[np.float64])
|
154 |
+
assert_type(np.zeros_like(B, dtype=np.int64), npt.NDArray[np.int64])
|
155 |
+
|
156 |
+
assert_type(np.ones_like(A), npt.NDArray[np.float64])
|
157 |
+
assert_type(np.ones_like(C), npt.NDArray[Any])
|
158 |
+
assert_type(np.ones_like(A, dtype=float), npt.NDArray[Any])
|
159 |
+
assert_type(np.ones_like(B), SubClass[np.float64])
|
160 |
+
assert_type(np.ones_like(B, dtype=np.int64), npt.NDArray[np.int64])
|
161 |
+
|
162 |
+
assert_type(np.full_like(A, i8), npt.NDArray[np.float64])
|
163 |
+
assert_type(np.full_like(C, i8), npt.NDArray[Any])
|
164 |
+
assert_type(np.full_like(A, i8, dtype=int), npt.NDArray[Any])
|
165 |
+
assert_type(np.full_like(B, i8), SubClass[np.float64])
|
166 |
+
assert_type(np.full_like(B, i8, dtype=np.int64), npt.NDArray[np.int64])
|
167 |
+
|
168 |
+
assert_type(np.ones(1), npt.NDArray[np.float64])
|
169 |
+
assert_type(np.ones([1, 1, 1]), npt.NDArray[np.float64])
|
170 |
+
assert_type(np.ones(5, dtype=np.int64), npt.NDArray[np.int64])
|
171 |
+
assert_type(np.ones(5, dtype=int), npt.NDArray[Any])
|
172 |
+
|
173 |
+
assert_type(np.full(1, i8), npt.NDArray[Any])
|
174 |
+
assert_type(np.full([1, 1, 1], i8), npt.NDArray[Any])
|
175 |
+
assert_type(np.full(1, i8, dtype=np.float64), npt.NDArray[np.float64])
|
176 |
+
assert_type(np.full(1, i8, dtype=float), npt.NDArray[Any])
|
177 |
+
|
178 |
+
assert_type(np.indices([1, 2, 3]), npt.NDArray[np.int_])
|
179 |
+
assert_type(np.indices([1, 2, 3], sparse=True), tuple[npt.NDArray[np.int_], ...])
|
180 |
+
|
181 |
+
assert_type(np.fromfunction(func, (3, 5)), SubClass[np.float64])
|
182 |
+
|
183 |
+
assert_type(np.identity(10), npt.NDArray[np.float64])
|
184 |
+
assert_type(np.identity(10, dtype=np.int64), npt.NDArray[np.int64])
|
185 |
+
assert_type(np.identity(10, dtype=int), npt.NDArray[Any])
|
186 |
+
|
187 |
+
assert_type(np.atleast_1d(A), npt.NDArray[np.float64])
|
188 |
+
assert_type(np.atleast_1d(C), npt.NDArray[Any])
|
189 |
+
assert_type(np.atleast_1d(A, A), list[npt.NDArray[Any]])
|
190 |
+
assert_type(np.atleast_1d(A, C), list[npt.NDArray[Any]])
|
191 |
+
assert_type(np.atleast_1d(C, C), list[npt.NDArray[Any]])
|
192 |
+
|
193 |
+
assert_type(np.atleast_2d(A), npt.NDArray[np.float64])
|
194 |
+
|
195 |
+
assert_type(np.atleast_3d(A), npt.NDArray[np.float64])
|
196 |
+
|
197 |
+
assert_type(np.vstack([A, A]), np.ndarray[Any, Any])
|
198 |
+
assert_type(np.vstack([A, A], dtype=np.float64), npt.NDArray[np.float64])
|
199 |
+
assert_type(np.vstack([A, C]), npt.NDArray[Any])
|
200 |
+
assert_type(np.vstack([C, C]), npt.NDArray[Any])
|
201 |
+
|
202 |
+
assert_type(np.hstack([A, A]), np.ndarray[Any, Any])
|
203 |
+
assert_type(np.hstack([A, A], dtype=np.float64), npt.NDArray[np.float64])
|
204 |
+
|
205 |
+
assert_type(np.stack([A, A]), Any)
|
206 |
+
assert_type(np.stack([A, A], dtype=np.float64), npt.NDArray[np.float64])
|
207 |
+
assert_type(np.stack([A, C]), npt.NDArray[Any])
|
208 |
+
assert_type(np.stack([C, C]), npt.NDArray[Any])
|
209 |
+
assert_type(np.stack([A, A], axis=0), Any)
|
210 |
+
assert_type(np.stack([A, A], out=B), SubClass[np.float64])
|
211 |
+
|
212 |
+
assert_type(np.block([[A, A], [A, A]]), npt.NDArray[Any])
|
213 |
+
assert_type(np.block(C), npt.NDArray[Any])
|
214 |
+
|
215 |
+
if sys.version_info >= (3, 12):
|
216 |
+
from collections.abc import Buffer
|
217 |
+
|
218 |
+
def create_array(obj: npt.ArrayLike) -> npt.NDArray[Any]: ...
|
219 |
+
|
220 |
+
buffer: Buffer
|
221 |
+
assert_type(create_array(buffer), npt.NDArray[Any])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arraypad.pyi
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from collections.abc import Mapping
|
3 |
+
from typing import Any, SupportsIndex
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
def mode_func(
|
14 |
+
ar: npt.NDArray[np.number[Any]],
|
15 |
+
width: tuple[int, int],
|
16 |
+
iaxis: SupportsIndex,
|
17 |
+
kwargs: Mapping[str, Any],
|
18 |
+
) -> None: ...
|
19 |
+
|
20 |
+
AR_i8: npt.NDArray[np.int64]
|
21 |
+
AR_f8: npt.NDArray[np.float64]
|
22 |
+
AR_LIKE: list[int]
|
23 |
+
|
24 |
+
assert_type(np.pad(AR_i8, (2, 3), "constant"), npt.NDArray[np.int64])
|
25 |
+
assert_type(np.pad(AR_LIKE, (2, 3), "constant"), npt.NDArray[Any])
|
26 |
+
|
27 |
+
assert_type(np.pad(AR_f8, (2, 3), mode_func), npt.NDArray[np.float64])
|
28 |
+
assert_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2), npt.NDArray[np.float64])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arrayprint.pyi
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import contextlib
|
3 |
+
from collections.abc import Callable
|
4 |
+
from typing import Any
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
from numpy.core.arrayprint import _FormatOptions
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
AR: np.ndarray[Any, Any]
|
15 |
+
func_float: Callable[[np.floating[Any]], str]
|
16 |
+
func_int: Callable[[np.integer[Any]], str]
|
17 |
+
|
18 |
+
assert_type(np.get_printoptions(), _FormatOptions)
|
19 |
+
assert_type(
|
20 |
+
np.array2string(AR, formatter={'float_kind': func_float, 'int_kind': func_int}),
|
21 |
+
str,
|
22 |
+
)
|
23 |
+
assert_type(np.format_float_scientific(1.0), str)
|
24 |
+
assert_type(np.format_float_positional(1), str)
|
25 |
+
assert_type(np.array_repr(AR), str)
|
26 |
+
assert_type(np.array_str(AR), str)
|
27 |
+
|
28 |
+
assert_type(np.printoptions(), contextlib._GeneratorContextManager[_FormatOptions])
|
29 |
+
with np.printoptions() as dct:
|
30 |
+
assert_type(dct, _FormatOptions)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arraysetops.pyi
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_b: npt.NDArray[np.bool_]
|
13 |
+
AR_i8: npt.NDArray[np.int64]
|
14 |
+
AR_f8: npt.NDArray[np.float64]
|
15 |
+
AR_M: npt.NDArray[np.datetime64]
|
16 |
+
AR_O: npt.NDArray[np.object_]
|
17 |
+
|
18 |
+
AR_LIKE_f8: list[float]
|
19 |
+
|
20 |
+
assert_type(np.ediff1d(AR_b), npt.NDArray[np.int8])
|
21 |
+
assert_type(np.ediff1d(AR_i8, to_end=[1, 2, 3]), npt.NDArray[np.int64])
|
22 |
+
assert_type(np.ediff1d(AR_M), npt.NDArray[np.timedelta64])
|
23 |
+
assert_type(np.ediff1d(AR_O), npt.NDArray[np.object_])
|
24 |
+
assert_type(np.ediff1d(AR_LIKE_f8, to_begin=[1, 1.5]), npt.NDArray[Any])
|
25 |
+
|
26 |
+
assert_type(np.intersect1d(AR_i8, AR_i8), npt.NDArray[np.int64])
|
27 |
+
assert_type(np.intersect1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])
|
28 |
+
assert_type(np.intersect1d(AR_f8, AR_i8), npt.NDArray[Any])
|
29 |
+
assert_type(np.intersect1d(AR_f8, AR_f8, return_indices=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
30 |
+
|
31 |
+
assert_type(np.setxor1d(AR_i8, AR_i8), npt.NDArray[np.int64])
|
32 |
+
assert_type(np.setxor1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])
|
33 |
+
assert_type(np.setxor1d(AR_f8, AR_i8), npt.NDArray[Any])
|
34 |
+
|
35 |
+
assert_type(np.in1d(AR_i8, AR_i8), npt.NDArray[np.bool_])
|
36 |
+
assert_type(np.in1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.bool_])
|
37 |
+
assert_type(np.in1d(AR_f8, AR_i8), npt.NDArray[np.bool_])
|
38 |
+
assert_type(np.in1d(AR_f8, AR_LIKE_f8, invert=True), npt.NDArray[np.bool_])
|
39 |
+
|
40 |
+
assert_type(np.isin(AR_i8, AR_i8), npt.NDArray[np.bool_])
|
41 |
+
assert_type(np.isin(AR_M, AR_M, assume_unique=True), npt.NDArray[np.bool_])
|
42 |
+
assert_type(np.isin(AR_f8, AR_i8), npt.NDArray[np.bool_])
|
43 |
+
assert_type(np.isin(AR_f8, AR_LIKE_f8, invert=True), npt.NDArray[np.bool_])
|
44 |
+
|
45 |
+
assert_type(np.union1d(AR_i8, AR_i8), npt.NDArray[np.int64])
|
46 |
+
assert_type(np.union1d(AR_M, AR_M), npt.NDArray[np.datetime64])
|
47 |
+
assert_type(np.union1d(AR_f8, AR_i8), npt.NDArray[Any])
|
48 |
+
|
49 |
+
assert_type(np.setdiff1d(AR_i8, AR_i8), npt.NDArray[np.int64])
|
50 |
+
assert_type(np.setdiff1d(AR_M, AR_M, assume_unique=True), npt.NDArray[np.datetime64])
|
51 |
+
assert_type(np.setdiff1d(AR_f8, AR_i8), npt.NDArray[Any])
|
52 |
+
|
53 |
+
assert_type(np.unique(AR_f8), npt.NDArray[np.float64])
|
54 |
+
assert_type(np.unique(AR_LIKE_f8, axis=0), npt.NDArray[Any])
|
55 |
+
assert_type(np.unique(AR_f8, return_index=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])
|
56 |
+
assert_type(np.unique(AR_LIKE_f8, return_index=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])
|
57 |
+
assert_type(np.unique(AR_f8, return_inverse=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])
|
58 |
+
assert_type(np.unique(AR_LIKE_f8, return_inverse=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])
|
59 |
+
assert_type(np.unique(AR_f8, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp]])
|
60 |
+
assert_type(np.unique(AR_LIKE_f8, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp]])
|
61 |
+
assert_type(np.unique(AR_f8, return_index=True, return_inverse=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
62 |
+
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
63 |
+
assert_type(np.unique(AR_f8, return_index=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
64 |
+
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
65 |
+
assert_type(np.unique(AR_f8, return_inverse=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
66 |
+
assert_type(np.unique(AR_LIKE_f8, return_inverse=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
67 |
+
assert_type(np.unique(AR_f8, return_index=True, return_inverse=True, return_counts=True), tuple[npt.NDArray[np.float64], npt.NDArray[np.intp], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
68 |
+
assert_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True, return_counts=True), tuple[npt.NDArray[Any], npt.NDArray[np.intp], npt.NDArray[np.intp], npt.NDArray[np.intp]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/arrayterator.pyi
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
from collections.abc import Generator
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
|
14 |
+
ar_iter = np.lib.Arrayterator(AR_i8)
|
15 |
+
|
16 |
+
assert_type(ar_iter.var, npt.NDArray[np.int64])
|
17 |
+
assert_type(ar_iter.buf_size, None | int)
|
18 |
+
assert_type(ar_iter.start, list[int])
|
19 |
+
assert_type(ar_iter.stop, list[int])
|
20 |
+
assert_type(ar_iter.step, list[int])
|
21 |
+
assert_type(ar_iter.shape, tuple[int, ...])
|
22 |
+
assert_type(ar_iter.flat, Generator[np.int64, None, None])
|
23 |
+
|
24 |
+
assert_type(ar_iter.__array__(), npt.NDArray[np.int64])
|
25 |
+
|
26 |
+
for i in ar_iter:
|
27 |
+
assert_type(i, npt.NDArray[np.int64])
|
28 |
+
|
29 |
+
assert_type(ar_iter[0], np.lib.Arrayterator[Any, np.dtype[np.int64]])
|
30 |
+
assert_type(ar_iter[...], np.lib.Arrayterator[Any, np.dtype[np.int64]])
|
31 |
+
assert_type(ar_iter[:], np.lib.Arrayterator[Any, np.dtype[np.int64]])
|
32 |
+
assert_type(ar_iter[0, 0, 0], np.lib.Arrayterator[Any, np.dtype[np.int64]])
|
33 |
+
assert_type(ar_iter[..., 0, :], np.lib.Arrayterator[Any, np.dtype[np.int64]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/bitwise_ops.pyi
ADDED
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
from numpy._typing import _64Bit, _32Bit
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
i8 = np.int64(1)
|
14 |
+
u8 = np.uint64(1)
|
15 |
+
|
16 |
+
i4 = np.int32(1)
|
17 |
+
u4 = np.uint32(1)
|
18 |
+
|
19 |
+
b_ = np.bool_(1)
|
20 |
+
|
21 |
+
b = bool(1)
|
22 |
+
i = int(1)
|
23 |
+
|
24 |
+
AR = np.array([0, 1, 2], dtype=np.int32)
|
25 |
+
AR.setflags(write=False)
|
26 |
+
|
27 |
+
|
28 |
+
assert_type(i8 << i8, np.int64)
|
29 |
+
assert_type(i8 >> i8, np.int64)
|
30 |
+
assert_type(i8 | i8, np.int64)
|
31 |
+
assert_type(i8 ^ i8, np.int64)
|
32 |
+
assert_type(i8 & i8, np.int64)
|
33 |
+
|
34 |
+
assert_type(i8 << AR, npt.NDArray[np.signedinteger[Any]])
|
35 |
+
assert_type(i8 >> AR, npt.NDArray[np.signedinteger[Any]])
|
36 |
+
assert_type(i8 | AR, npt.NDArray[np.signedinteger[Any]])
|
37 |
+
assert_type(i8 ^ AR, npt.NDArray[np.signedinteger[Any]])
|
38 |
+
assert_type(i8 & AR, npt.NDArray[np.signedinteger[Any]])
|
39 |
+
|
40 |
+
assert_type(i4 << i4, np.int32)
|
41 |
+
assert_type(i4 >> i4, np.int32)
|
42 |
+
assert_type(i4 | i4, np.int32)
|
43 |
+
assert_type(i4 ^ i4, np.int32)
|
44 |
+
assert_type(i4 & i4, np.int32)
|
45 |
+
|
46 |
+
assert_type(i8 << i4, np.signedinteger[_32Bit | _64Bit])
|
47 |
+
assert_type(i8 >> i4, np.signedinteger[_32Bit | _64Bit])
|
48 |
+
assert_type(i8 | i4, np.signedinteger[_32Bit | _64Bit])
|
49 |
+
assert_type(i8 ^ i4, np.signedinteger[_32Bit | _64Bit])
|
50 |
+
assert_type(i8 & i4, np.signedinteger[_32Bit | _64Bit])
|
51 |
+
|
52 |
+
assert_type(i8 << b_, np.int64)
|
53 |
+
assert_type(i8 >> b_, np.int64)
|
54 |
+
assert_type(i8 | b_, np.int64)
|
55 |
+
assert_type(i8 ^ b_, np.int64)
|
56 |
+
assert_type(i8 & b_, np.int64)
|
57 |
+
|
58 |
+
assert_type(i8 << b, np.int64)
|
59 |
+
assert_type(i8 >> b, np.int64)
|
60 |
+
assert_type(i8 | b, np.int64)
|
61 |
+
assert_type(i8 ^ b, np.int64)
|
62 |
+
assert_type(i8 & b, np.int64)
|
63 |
+
|
64 |
+
assert_type(u8 << u8, np.uint64)
|
65 |
+
assert_type(u8 >> u8, np.uint64)
|
66 |
+
assert_type(u8 | u8, np.uint64)
|
67 |
+
assert_type(u8 ^ u8, np.uint64)
|
68 |
+
assert_type(u8 & u8, np.uint64)
|
69 |
+
|
70 |
+
assert_type(u8 << AR, npt.NDArray[np.signedinteger[Any]])
|
71 |
+
assert_type(u8 >> AR, npt.NDArray[np.signedinteger[Any]])
|
72 |
+
assert_type(u8 | AR, npt.NDArray[np.signedinteger[Any]])
|
73 |
+
assert_type(u8 ^ AR, npt.NDArray[np.signedinteger[Any]])
|
74 |
+
assert_type(u8 & AR, npt.NDArray[np.signedinteger[Any]])
|
75 |
+
|
76 |
+
assert_type(u4 << u4, np.uint32)
|
77 |
+
assert_type(u4 >> u4, np.uint32)
|
78 |
+
assert_type(u4 | u4, np.uint32)
|
79 |
+
assert_type(u4 ^ u4, np.uint32)
|
80 |
+
assert_type(u4 & u4, np.uint32)
|
81 |
+
|
82 |
+
assert_type(u4 << i4, np.signedinteger[Any])
|
83 |
+
assert_type(u4 >> i4, np.signedinteger[Any])
|
84 |
+
assert_type(u4 | i4, np.signedinteger[Any])
|
85 |
+
assert_type(u4 ^ i4, np.signedinteger[Any])
|
86 |
+
assert_type(u4 & i4, np.signedinteger[Any])
|
87 |
+
|
88 |
+
assert_type(u4 << i, np.signedinteger[Any])
|
89 |
+
assert_type(u4 >> i, np.signedinteger[Any])
|
90 |
+
assert_type(u4 | i, np.signedinteger[Any])
|
91 |
+
assert_type(u4 ^ i, np.signedinteger[Any])
|
92 |
+
assert_type(u4 & i, np.signedinteger[Any])
|
93 |
+
|
94 |
+
assert_type(u8 << b_, np.uint64)
|
95 |
+
assert_type(u8 >> b_, np.uint64)
|
96 |
+
assert_type(u8 | b_, np.uint64)
|
97 |
+
assert_type(u8 ^ b_, np.uint64)
|
98 |
+
assert_type(u8 & b_, np.uint64)
|
99 |
+
|
100 |
+
assert_type(u8 << b, np.uint64)
|
101 |
+
assert_type(u8 >> b, np.uint64)
|
102 |
+
assert_type(u8 | b, np.uint64)
|
103 |
+
assert_type(u8 ^ b, np.uint64)
|
104 |
+
assert_type(u8 & b, np.uint64)
|
105 |
+
|
106 |
+
assert_type(b_ << b_, np.int8)
|
107 |
+
assert_type(b_ >> b_, np.int8)
|
108 |
+
assert_type(b_ | b_, np.bool_)
|
109 |
+
assert_type(b_ ^ b_, np.bool_)
|
110 |
+
assert_type(b_ & b_, np.bool_)
|
111 |
+
|
112 |
+
assert_type(b_ << AR, npt.NDArray[np.signedinteger[Any]])
|
113 |
+
assert_type(b_ >> AR, npt.NDArray[np.signedinteger[Any]])
|
114 |
+
assert_type(b_ | AR, npt.NDArray[np.signedinteger[Any]])
|
115 |
+
assert_type(b_ ^ AR, npt.NDArray[np.signedinteger[Any]])
|
116 |
+
assert_type(b_ & AR, npt.NDArray[np.signedinteger[Any]])
|
117 |
+
|
118 |
+
assert_type(b_ << b, np.int8)
|
119 |
+
assert_type(b_ >> b, np.int8)
|
120 |
+
assert_type(b_ | b, np.bool_)
|
121 |
+
assert_type(b_ ^ b, np.bool_)
|
122 |
+
assert_type(b_ & b, np.bool_)
|
123 |
+
|
124 |
+
assert_type(b_ << i, np.int_)
|
125 |
+
assert_type(b_ >> i, np.int_)
|
126 |
+
assert_type(b_ | i, np.int_)
|
127 |
+
assert_type(b_ ^ i, np.int_)
|
128 |
+
assert_type(b_ & i, np.int_)
|
129 |
+
|
130 |
+
assert_type(~i8, np.int64)
|
131 |
+
assert_type(~i4, np.int32)
|
132 |
+
assert_type(~u8, np.uint64)
|
133 |
+
assert_type(~u4, np.uint32)
|
134 |
+
assert_type(~b_, np.bool_)
|
135 |
+
assert_type(~AR, npt.NDArray[np.int32])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/char.pyi
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_U: npt.NDArray[np.str_]
|
13 |
+
AR_S: npt.NDArray[np.bytes_]
|
14 |
+
|
15 |
+
assert_type(np.char.equal(AR_U, AR_U), npt.NDArray[np.bool_])
|
16 |
+
assert_type(np.char.equal(AR_S, AR_S), npt.NDArray[np.bool_])
|
17 |
+
|
18 |
+
assert_type(np.char.not_equal(AR_U, AR_U), npt.NDArray[np.bool_])
|
19 |
+
assert_type(np.char.not_equal(AR_S, AR_S), npt.NDArray[np.bool_])
|
20 |
+
|
21 |
+
assert_type(np.char.greater_equal(AR_U, AR_U), npt.NDArray[np.bool_])
|
22 |
+
assert_type(np.char.greater_equal(AR_S, AR_S), npt.NDArray[np.bool_])
|
23 |
+
|
24 |
+
assert_type(np.char.less_equal(AR_U, AR_U), npt.NDArray[np.bool_])
|
25 |
+
assert_type(np.char.less_equal(AR_S, AR_S), npt.NDArray[np.bool_])
|
26 |
+
|
27 |
+
assert_type(np.char.greater(AR_U, AR_U), npt.NDArray[np.bool_])
|
28 |
+
assert_type(np.char.greater(AR_S, AR_S), npt.NDArray[np.bool_])
|
29 |
+
|
30 |
+
assert_type(np.char.less(AR_U, AR_U), npt.NDArray[np.bool_])
|
31 |
+
assert_type(np.char.less(AR_S, AR_S), npt.NDArray[np.bool_])
|
32 |
+
|
33 |
+
assert_type(np.char.multiply(AR_U, 5), npt.NDArray[np.str_])
|
34 |
+
assert_type(np.char.multiply(AR_S, [5, 4, 3]), npt.NDArray[np.bytes_])
|
35 |
+
|
36 |
+
assert_type(np.char.mod(AR_U, "test"), npt.NDArray[np.str_])
|
37 |
+
assert_type(np.char.mod(AR_S, "test"), npt.NDArray[np.bytes_])
|
38 |
+
|
39 |
+
assert_type(np.char.capitalize(AR_U), npt.NDArray[np.str_])
|
40 |
+
assert_type(np.char.capitalize(AR_S), npt.NDArray[np.bytes_])
|
41 |
+
|
42 |
+
assert_type(np.char.center(AR_U, 5), npt.NDArray[np.str_])
|
43 |
+
assert_type(np.char.center(AR_S, [2, 3, 4], b"a"), npt.NDArray[np.bytes_])
|
44 |
+
|
45 |
+
assert_type(np.char.encode(AR_U), npt.NDArray[np.bytes_])
|
46 |
+
assert_type(np.char.decode(AR_S), npt.NDArray[np.str_])
|
47 |
+
|
48 |
+
assert_type(np.char.expandtabs(AR_U), npt.NDArray[np.str_])
|
49 |
+
assert_type(np.char.expandtabs(AR_S, tabsize=4), npt.NDArray[np.bytes_])
|
50 |
+
|
51 |
+
assert_type(np.char.join(AR_U, "_"), npt.NDArray[np.str_])
|
52 |
+
assert_type(np.char.join(AR_S, [b"_", b""]), npt.NDArray[np.bytes_])
|
53 |
+
|
54 |
+
assert_type(np.char.ljust(AR_U, 5), npt.NDArray[np.str_])
|
55 |
+
assert_type(np.char.ljust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
56 |
+
assert_type(np.char.rjust(AR_U, 5), npt.NDArray[np.str_])
|
57 |
+
assert_type(np.char.rjust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
58 |
+
|
59 |
+
assert_type(np.char.lstrip(AR_U), npt.NDArray[np.str_])
|
60 |
+
assert_type(np.char.lstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])
|
61 |
+
assert_type(np.char.rstrip(AR_U), npt.NDArray[np.str_])
|
62 |
+
assert_type(np.char.rstrip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])
|
63 |
+
assert_type(np.char.strip(AR_U), npt.NDArray[np.str_])
|
64 |
+
assert_type(np.char.strip(AR_S, chars=b"_"), npt.NDArray[np.bytes_])
|
65 |
+
|
66 |
+
assert_type(np.char.partition(AR_U, "\n"), npt.NDArray[np.str_])
|
67 |
+
assert_type(np.char.partition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
68 |
+
assert_type(np.char.rpartition(AR_U, "\n"), npt.NDArray[np.str_])
|
69 |
+
assert_type(np.char.rpartition(AR_S, [b"a", b"b", b"c"]), npt.NDArray[np.bytes_])
|
70 |
+
|
71 |
+
assert_type(np.char.replace(AR_U, "_", "-"), npt.NDArray[np.str_])
|
72 |
+
assert_type(np.char.replace(AR_S, [b"_", b""], [b"a", b"b"]), npt.NDArray[np.bytes_])
|
73 |
+
|
74 |
+
assert_type(np.char.split(AR_U, "_"), npt.NDArray[np.object_])
|
75 |
+
assert_type(np.char.split(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
76 |
+
assert_type(np.char.rsplit(AR_U, "_"), npt.NDArray[np.object_])
|
77 |
+
assert_type(np.char.rsplit(AR_S, maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
78 |
+
|
79 |
+
assert_type(np.char.splitlines(AR_U), npt.NDArray[np.object_])
|
80 |
+
assert_type(np.char.splitlines(AR_S, keepends=[True, True, False]), npt.NDArray[np.object_])
|
81 |
+
|
82 |
+
assert_type(np.char.swapcase(AR_U), npt.NDArray[np.str_])
|
83 |
+
assert_type(np.char.swapcase(AR_S), npt.NDArray[np.bytes_])
|
84 |
+
|
85 |
+
assert_type(np.char.title(AR_U), npt.NDArray[np.str_])
|
86 |
+
assert_type(np.char.title(AR_S), npt.NDArray[np.bytes_])
|
87 |
+
|
88 |
+
assert_type(np.char.upper(AR_U), npt.NDArray[np.str_])
|
89 |
+
assert_type(np.char.upper(AR_S), npt.NDArray[np.bytes_])
|
90 |
+
|
91 |
+
assert_type(np.char.zfill(AR_U, 5), npt.NDArray[np.str_])
|
92 |
+
assert_type(np.char.zfill(AR_S, [2, 3, 4]), npt.NDArray[np.bytes_])
|
93 |
+
|
94 |
+
assert_type(np.char.count(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
95 |
+
assert_type(np.char.count(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
96 |
+
|
97 |
+
assert_type(np.char.endswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool_])
|
98 |
+
assert_type(np.char.endswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool_])
|
99 |
+
assert_type(np.char.startswith(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.bool_])
|
100 |
+
assert_type(np.char.startswith(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.bool_])
|
101 |
+
|
102 |
+
assert_type(np.char.find(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
103 |
+
assert_type(np.char.find(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
104 |
+
assert_type(np.char.rfind(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
105 |
+
assert_type(np.char.rfind(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
106 |
+
|
107 |
+
assert_type(np.char.index(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
108 |
+
assert_type(np.char.index(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
109 |
+
assert_type(np.char.rindex(AR_U, "a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
110 |
+
assert_type(np.char.rindex(AR_S, [b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
111 |
+
|
112 |
+
assert_type(np.char.isalpha(AR_U), npt.NDArray[np.bool_])
|
113 |
+
assert_type(np.char.isalpha(AR_S), npt.NDArray[np.bool_])
|
114 |
+
|
115 |
+
assert_type(np.char.isalnum(AR_U), npt.NDArray[np.bool_])
|
116 |
+
assert_type(np.char.isalnum(AR_S), npt.NDArray[np.bool_])
|
117 |
+
|
118 |
+
assert_type(np.char.isdecimal(AR_U), npt.NDArray[np.bool_])
|
119 |
+
assert_type(np.char.isdecimal(AR_S), npt.NDArray[np.bool_])
|
120 |
+
|
121 |
+
assert_type(np.char.isdigit(AR_U), npt.NDArray[np.bool_])
|
122 |
+
assert_type(np.char.isdigit(AR_S), npt.NDArray[np.bool_])
|
123 |
+
|
124 |
+
assert_type(np.char.islower(AR_U), npt.NDArray[np.bool_])
|
125 |
+
assert_type(np.char.islower(AR_S), npt.NDArray[np.bool_])
|
126 |
+
|
127 |
+
assert_type(np.char.isnumeric(AR_U), npt.NDArray[np.bool_])
|
128 |
+
assert_type(np.char.isnumeric(AR_S), npt.NDArray[np.bool_])
|
129 |
+
|
130 |
+
assert_type(np.char.isspace(AR_U), npt.NDArray[np.bool_])
|
131 |
+
assert_type(np.char.isspace(AR_S), npt.NDArray[np.bool_])
|
132 |
+
|
133 |
+
assert_type(np.char.istitle(AR_U), npt.NDArray[np.bool_])
|
134 |
+
assert_type(np.char.istitle(AR_S), npt.NDArray[np.bool_])
|
135 |
+
|
136 |
+
assert_type(np.char.isupper(AR_U), npt.NDArray[np.bool_])
|
137 |
+
assert_type(np.char.isupper(AR_S), npt.NDArray[np.bool_])
|
138 |
+
|
139 |
+
assert_type(np.char.str_len(AR_U), npt.NDArray[np.int_])
|
140 |
+
assert_type(np.char.str_len(AR_S), npt.NDArray[np.int_])
|
141 |
+
|
142 |
+
assert_type(np.char.array(AR_U), np.chararray[Any, np.dtype[np.str_]])
|
143 |
+
assert_type(np.char.array(AR_S, order="K"), np.chararray[Any, np.dtype[np.bytes_]])
|
144 |
+
assert_type(np.char.array("bob", copy=True), np.chararray[Any, np.dtype[np.str_]])
|
145 |
+
assert_type(np.char.array(b"bob", itemsize=5), np.chararray[Any, np.dtype[np.bytes_]])
|
146 |
+
assert_type(np.char.array(1, unicode=False), np.chararray[Any, np.dtype[np.bytes_]])
|
147 |
+
assert_type(np.char.array(1, unicode=True), np.chararray[Any, np.dtype[np.str_]])
|
148 |
+
|
149 |
+
assert_type(np.char.asarray(AR_U), np.chararray[Any, np.dtype[np.str_]])
|
150 |
+
assert_type(np.char.asarray(AR_S, order="K"), np.chararray[Any, np.dtype[np.bytes_]])
|
151 |
+
assert_type(np.char.asarray("bob"), np.chararray[Any, np.dtype[np.str_]])
|
152 |
+
assert_type(np.char.asarray(b"bob", itemsize=5), np.chararray[Any, np.dtype[np.bytes_]])
|
153 |
+
assert_type(np.char.asarray(1, unicode=False), np.chararray[Any, np.dtype[np.bytes_]])
|
154 |
+
assert_type(np.char.asarray(1, unicode=True), np.chararray[Any, np.dtype[np.str_]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/chararray.pyi
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_U: np.chararray[Any, np.dtype[np.str_]]
|
13 |
+
AR_S: np.chararray[Any, np.dtype[np.bytes_]]
|
14 |
+
|
15 |
+
assert_type(AR_U == AR_U, npt.NDArray[np.bool_])
|
16 |
+
assert_type(AR_S == AR_S, npt.NDArray[np.bool_])
|
17 |
+
|
18 |
+
assert_type(AR_U != AR_U, npt.NDArray[np.bool_])
|
19 |
+
assert_type(AR_S != AR_S, npt.NDArray[np.bool_])
|
20 |
+
|
21 |
+
assert_type(AR_U >= AR_U, npt.NDArray[np.bool_])
|
22 |
+
assert_type(AR_S >= AR_S, npt.NDArray[np.bool_])
|
23 |
+
|
24 |
+
assert_type(AR_U <= AR_U, npt.NDArray[np.bool_])
|
25 |
+
assert_type(AR_S <= AR_S, npt.NDArray[np.bool_])
|
26 |
+
|
27 |
+
assert_type(AR_U > AR_U, npt.NDArray[np.bool_])
|
28 |
+
assert_type(AR_S > AR_S, npt.NDArray[np.bool_])
|
29 |
+
|
30 |
+
assert_type(AR_U < AR_U, npt.NDArray[np.bool_])
|
31 |
+
assert_type(AR_S < AR_S, npt.NDArray[np.bool_])
|
32 |
+
|
33 |
+
assert_type(AR_U * 5, np.chararray[Any, np.dtype[np.str_]])
|
34 |
+
assert_type(AR_S * [5], np.chararray[Any, np.dtype[np.bytes_]])
|
35 |
+
|
36 |
+
assert_type(AR_U % "test", np.chararray[Any, np.dtype[np.str_]])
|
37 |
+
assert_type(AR_S % b"test", np.chararray[Any, np.dtype[np.bytes_]])
|
38 |
+
|
39 |
+
assert_type(AR_U.capitalize(), np.chararray[Any, np.dtype[np.str_]])
|
40 |
+
assert_type(AR_S.capitalize(), np.chararray[Any, np.dtype[np.bytes_]])
|
41 |
+
|
42 |
+
assert_type(AR_U.center(5), np.chararray[Any, np.dtype[np.str_]])
|
43 |
+
assert_type(AR_S.center([2, 3, 4], b"a"), np.chararray[Any, np.dtype[np.bytes_]])
|
44 |
+
|
45 |
+
assert_type(AR_U.encode(), np.chararray[Any, np.dtype[np.bytes_]])
|
46 |
+
assert_type(AR_S.decode(), np.chararray[Any, np.dtype[np.str_]])
|
47 |
+
|
48 |
+
assert_type(AR_U.expandtabs(), np.chararray[Any, np.dtype[np.str_]])
|
49 |
+
assert_type(AR_S.expandtabs(tabsize=4), np.chararray[Any, np.dtype[np.bytes_]])
|
50 |
+
|
51 |
+
assert_type(AR_U.join("_"), np.chararray[Any, np.dtype[np.str_]])
|
52 |
+
assert_type(AR_S.join([b"_", b""]), np.chararray[Any, np.dtype[np.bytes_]])
|
53 |
+
|
54 |
+
assert_type(AR_U.ljust(5), np.chararray[Any, np.dtype[np.str_]])
|
55 |
+
assert_type(AR_S.ljust([4, 3, 1], fillchar=[b"a", b"b", b"c"]), np.chararray[Any, np.dtype[np.bytes_]])
|
56 |
+
assert_type(AR_U.rjust(5), np.chararray[Any, np.dtype[np.str_]])
|
57 |
+
assert_type(AR_S.rjust([4, 3, 1], fillchar=[b"a", b"b", b"c"]), np.chararray[Any, np.dtype[np.bytes_]])
|
58 |
+
|
59 |
+
assert_type(AR_U.lstrip(), np.chararray[Any, np.dtype[np.str_]])
|
60 |
+
assert_type(AR_S.lstrip(chars=b"_"), np.chararray[Any, np.dtype[np.bytes_]])
|
61 |
+
assert_type(AR_U.rstrip(), np.chararray[Any, np.dtype[np.str_]])
|
62 |
+
assert_type(AR_S.rstrip(chars=b"_"), np.chararray[Any, np.dtype[np.bytes_]])
|
63 |
+
assert_type(AR_U.strip(), np.chararray[Any, np.dtype[np.str_]])
|
64 |
+
assert_type(AR_S.strip(chars=b"_"), np.chararray[Any, np.dtype[np.bytes_]])
|
65 |
+
|
66 |
+
assert_type(AR_U.partition("\n"), np.chararray[Any, np.dtype[np.str_]])
|
67 |
+
assert_type(AR_S.partition([b"a", b"b", b"c"]), np.chararray[Any, np.dtype[np.bytes_]])
|
68 |
+
assert_type(AR_U.rpartition("\n"), np.chararray[Any, np.dtype[np.str_]])
|
69 |
+
assert_type(AR_S.rpartition([b"a", b"b", b"c"]), np.chararray[Any, np.dtype[np.bytes_]])
|
70 |
+
|
71 |
+
assert_type(AR_U.replace("_", "-"), np.chararray[Any, np.dtype[np.str_]])
|
72 |
+
assert_type(AR_S.replace([b"_", b""], [b"a", b"b"]), np.chararray[Any, np.dtype[np.bytes_]])
|
73 |
+
|
74 |
+
assert_type(AR_U.split("_"), npt.NDArray[np.object_])
|
75 |
+
assert_type(AR_S.split(maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
76 |
+
assert_type(AR_U.rsplit("_"), npt.NDArray[np.object_])
|
77 |
+
assert_type(AR_S.rsplit(maxsplit=[1, 2, 3]), npt.NDArray[np.object_])
|
78 |
+
|
79 |
+
assert_type(AR_U.splitlines(), npt.NDArray[np.object_])
|
80 |
+
assert_type(AR_S.splitlines(keepends=[True, True, False]), npt.NDArray[np.object_])
|
81 |
+
|
82 |
+
assert_type(AR_U.swapcase(), np.chararray[Any, np.dtype[np.str_]])
|
83 |
+
assert_type(AR_S.swapcase(), np.chararray[Any, np.dtype[np.bytes_]])
|
84 |
+
|
85 |
+
assert_type(AR_U.title(), np.chararray[Any, np.dtype[np.str_]])
|
86 |
+
assert_type(AR_S.title(), np.chararray[Any, np.dtype[np.bytes_]])
|
87 |
+
|
88 |
+
assert_type(AR_U.upper(), np.chararray[Any, np.dtype[np.str_]])
|
89 |
+
assert_type(AR_S.upper(), np.chararray[Any, np.dtype[np.bytes_]])
|
90 |
+
|
91 |
+
assert_type(AR_U.zfill(5), np.chararray[Any, np.dtype[np.str_]])
|
92 |
+
assert_type(AR_S.zfill([2, 3, 4]), np.chararray[Any, np.dtype[np.bytes_]])
|
93 |
+
|
94 |
+
assert_type(AR_U.count("a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
95 |
+
assert_type(AR_S.count([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
96 |
+
|
97 |
+
assert_type(AR_U.endswith("a", start=[1, 2, 3]), npt.NDArray[np.bool_])
|
98 |
+
assert_type(AR_S.endswith([b"a", b"b", b"c"], end=9), npt.NDArray[np.bool_])
|
99 |
+
assert_type(AR_U.startswith("a", start=[1, 2, 3]), npt.NDArray[np.bool_])
|
100 |
+
assert_type(AR_S.startswith([b"a", b"b", b"c"], end=9), npt.NDArray[np.bool_])
|
101 |
+
|
102 |
+
assert_type(AR_U.find("a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
103 |
+
assert_type(AR_S.find([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
104 |
+
assert_type(AR_U.rfind("a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
105 |
+
assert_type(AR_S.rfind([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
106 |
+
|
107 |
+
assert_type(AR_U.index("a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
108 |
+
assert_type(AR_S.index([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
109 |
+
assert_type(AR_U.rindex("a", start=[1, 2, 3]), npt.NDArray[np.int_])
|
110 |
+
assert_type(AR_S.rindex([b"a", b"b", b"c"], end=9), npt.NDArray[np.int_])
|
111 |
+
|
112 |
+
assert_type(AR_U.isalpha(), npt.NDArray[np.bool_])
|
113 |
+
assert_type(AR_S.isalpha(), npt.NDArray[np.bool_])
|
114 |
+
|
115 |
+
assert_type(AR_U.isalnum(), npt.NDArray[np.bool_])
|
116 |
+
assert_type(AR_S.isalnum(), npt.NDArray[np.bool_])
|
117 |
+
|
118 |
+
assert_type(AR_U.isdecimal(), npt.NDArray[np.bool_])
|
119 |
+
assert_type(AR_S.isdecimal(), npt.NDArray[np.bool_])
|
120 |
+
|
121 |
+
assert_type(AR_U.isdigit(), npt.NDArray[np.bool_])
|
122 |
+
assert_type(AR_S.isdigit(), npt.NDArray[np.bool_])
|
123 |
+
|
124 |
+
assert_type(AR_U.islower(), npt.NDArray[np.bool_])
|
125 |
+
assert_type(AR_S.islower(), npt.NDArray[np.bool_])
|
126 |
+
|
127 |
+
assert_type(AR_U.isnumeric(), npt.NDArray[np.bool_])
|
128 |
+
assert_type(AR_S.isnumeric(), npt.NDArray[np.bool_])
|
129 |
+
|
130 |
+
assert_type(AR_U.isspace(), npt.NDArray[np.bool_])
|
131 |
+
assert_type(AR_S.isspace(), npt.NDArray[np.bool_])
|
132 |
+
|
133 |
+
assert_type(AR_U.istitle(), npt.NDArray[np.bool_])
|
134 |
+
assert_type(AR_S.istitle(), npt.NDArray[np.bool_])
|
135 |
+
|
136 |
+
assert_type(AR_U.isupper(), npt.NDArray[np.bool_])
|
137 |
+
assert_type(AR_S.isupper(), npt.NDArray[np.bool_])
|
138 |
+
|
139 |
+
assert_type(AR_U.__array_finalize__(object()), None)
|
140 |
+
assert_type(AR_S.__array_finalize__(object()), None)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/comparisons.pyi
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import fractions
|
3 |
+
import decimal
|
4 |
+
from typing import Any
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
import numpy.typing as npt
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
c16 = np.complex128()
|
15 |
+
f8 = np.float64()
|
16 |
+
i8 = np.int64()
|
17 |
+
u8 = np.uint64()
|
18 |
+
|
19 |
+
c8 = np.complex64()
|
20 |
+
f4 = np.float32()
|
21 |
+
i4 = np.int32()
|
22 |
+
u4 = np.uint32()
|
23 |
+
|
24 |
+
dt = np.datetime64(0, "D")
|
25 |
+
td = np.timedelta64(0, "D")
|
26 |
+
|
27 |
+
b_ = np.bool_()
|
28 |
+
|
29 |
+
b = bool()
|
30 |
+
c = complex()
|
31 |
+
f = float()
|
32 |
+
i = int()
|
33 |
+
|
34 |
+
AR = np.array([0], dtype=np.int64)
|
35 |
+
AR.setflags(write=False)
|
36 |
+
|
37 |
+
SEQ = (0, 1, 2, 3, 4)
|
38 |
+
|
39 |
+
# object-like comparisons
|
40 |
+
|
41 |
+
assert_type(i8 > fractions.Fraction(1, 5), Any)
|
42 |
+
assert_type(i8 > [fractions.Fraction(1, 5)], Any)
|
43 |
+
assert_type(i8 > decimal.Decimal("1.5"), Any)
|
44 |
+
assert_type(i8 > [decimal.Decimal("1.5")], Any)
|
45 |
+
|
46 |
+
# Time structures
|
47 |
+
|
48 |
+
assert_type(dt > dt, np.bool_)
|
49 |
+
|
50 |
+
assert_type(td > td, np.bool_)
|
51 |
+
assert_type(td > i, np.bool_)
|
52 |
+
assert_type(td > i4, np.bool_)
|
53 |
+
assert_type(td > i8, np.bool_)
|
54 |
+
|
55 |
+
assert_type(td > AR, npt.NDArray[np.bool_])
|
56 |
+
assert_type(td > SEQ, npt.NDArray[np.bool_])
|
57 |
+
assert_type(AR > SEQ, npt.NDArray[np.bool_])
|
58 |
+
assert_type(AR > td, npt.NDArray[np.bool_])
|
59 |
+
assert_type(SEQ > td, npt.NDArray[np.bool_])
|
60 |
+
assert_type(SEQ > AR, npt.NDArray[np.bool_])
|
61 |
+
|
62 |
+
# boolean
|
63 |
+
|
64 |
+
assert_type(b_ > b, np.bool_)
|
65 |
+
assert_type(b_ > b_, np.bool_)
|
66 |
+
assert_type(b_ > i, np.bool_)
|
67 |
+
assert_type(b_ > i8, np.bool_)
|
68 |
+
assert_type(b_ > i4, np.bool_)
|
69 |
+
assert_type(b_ > u8, np.bool_)
|
70 |
+
assert_type(b_ > u4, np.bool_)
|
71 |
+
assert_type(b_ > f, np.bool_)
|
72 |
+
assert_type(b_ > f8, np.bool_)
|
73 |
+
assert_type(b_ > f4, np.bool_)
|
74 |
+
assert_type(b_ > c, np.bool_)
|
75 |
+
assert_type(b_ > c16, np.bool_)
|
76 |
+
assert_type(b_ > c8, np.bool_)
|
77 |
+
assert_type(b_ > AR, npt.NDArray[np.bool_])
|
78 |
+
assert_type(b_ > SEQ, npt.NDArray[np.bool_])
|
79 |
+
|
80 |
+
# Complex
|
81 |
+
|
82 |
+
assert_type(c16 > c16, np.bool_)
|
83 |
+
assert_type(c16 > f8, np.bool_)
|
84 |
+
assert_type(c16 > i8, np.bool_)
|
85 |
+
assert_type(c16 > c8, np.bool_)
|
86 |
+
assert_type(c16 > f4, np.bool_)
|
87 |
+
assert_type(c16 > i4, np.bool_)
|
88 |
+
assert_type(c16 > b_, np.bool_)
|
89 |
+
assert_type(c16 > b, np.bool_)
|
90 |
+
assert_type(c16 > c, np.bool_)
|
91 |
+
assert_type(c16 > f, np.bool_)
|
92 |
+
assert_type(c16 > i, np.bool_)
|
93 |
+
assert_type(c16 > AR, npt.NDArray[np.bool_])
|
94 |
+
assert_type(c16 > SEQ, npt.NDArray[np.bool_])
|
95 |
+
|
96 |
+
assert_type(c16 > c16, np.bool_)
|
97 |
+
assert_type(f8 > c16, np.bool_)
|
98 |
+
assert_type(i8 > c16, np.bool_)
|
99 |
+
assert_type(c8 > c16, np.bool_)
|
100 |
+
assert_type(f4 > c16, np.bool_)
|
101 |
+
assert_type(i4 > c16, np.bool_)
|
102 |
+
assert_type(b_ > c16, np.bool_)
|
103 |
+
assert_type(b > c16, np.bool_)
|
104 |
+
assert_type(c > c16, np.bool_)
|
105 |
+
assert_type(f > c16, np.bool_)
|
106 |
+
assert_type(i > c16, np.bool_)
|
107 |
+
assert_type(AR > c16, npt.NDArray[np.bool_])
|
108 |
+
assert_type(SEQ > c16, npt.NDArray[np.bool_])
|
109 |
+
|
110 |
+
assert_type(c8 > c16, np.bool_)
|
111 |
+
assert_type(c8 > f8, np.bool_)
|
112 |
+
assert_type(c8 > i8, np.bool_)
|
113 |
+
assert_type(c8 > c8, np.bool_)
|
114 |
+
assert_type(c8 > f4, np.bool_)
|
115 |
+
assert_type(c8 > i4, np.bool_)
|
116 |
+
assert_type(c8 > b_, np.bool_)
|
117 |
+
assert_type(c8 > b, np.bool_)
|
118 |
+
assert_type(c8 > c, np.bool_)
|
119 |
+
assert_type(c8 > f, np.bool_)
|
120 |
+
assert_type(c8 > i, np.bool_)
|
121 |
+
assert_type(c8 > AR, npt.NDArray[np.bool_])
|
122 |
+
assert_type(c8 > SEQ, npt.NDArray[np.bool_])
|
123 |
+
|
124 |
+
assert_type(c16 > c8, np.bool_)
|
125 |
+
assert_type(f8 > c8, np.bool_)
|
126 |
+
assert_type(i8 > c8, np.bool_)
|
127 |
+
assert_type(c8 > c8, np.bool_)
|
128 |
+
assert_type(f4 > c8, np.bool_)
|
129 |
+
assert_type(i4 > c8, np.bool_)
|
130 |
+
assert_type(b_ > c8, np.bool_)
|
131 |
+
assert_type(b > c8, np.bool_)
|
132 |
+
assert_type(c > c8, np.bool_)
|
133 |
+
assert_type(f > c8, np.bool_)
|
134 |
+
assert_type(i > c8, np.bool_)
|
135 |
+
assert_type(AR > c8, npt.NDArray[np.bool_])
|
136 |
+
assert_type(SEQ > c8, npt.NDArray[np.bool_])
|
137 |
+
|
138 |
+
# Float
|
139 |
+
|
140 |
+
assert_type(f8 > f8, np.bool_)
|
141 |
+
assert_type(f8 > i8, np.bool_)
|
142 |
+
assert_type(f8 > f4, np.bool_)
|
143 |
+
assert_type(f8 > i4, np.bool_)
|
144 |
+
assert_type(f8 > b_, np.bool_)
|
145 |
+
assert_type(f8 > b, np.bool_)
|
146 |
+
assert_type(f8 > c, np.bool_)
|
147 |
+
assert_type(f8 > f, np.bool_)
|
148 |
+
assert_type(f8 > i, np.bool_)
|
149 |
+
assert_type(f8 > AR, npt.NDArray[np.bool_])
|
150 |
+
assert_type(f8 > SEQ, npt.NDArray[np.bool_])
|
151 |
+
|
152 |
+
assert_type(f8 > f8, np.bool_)
|
153 |
+
assert_type(i8 > f8, np.bool_)
|
154 |
+
assert_type(f4 > f8, np.bool_)
|
155 |
+
assert_type(i4 > f8, np.bool_)
|
156 |
+
assert_type(b_ > f8, np.bool_)
|
157 |
+
assert_type(b > f8, np.bool_)
|
158 |
+
assert_type(c > f8, np.bool_)
|
159 |
+
assert_type(f > f8, np.bool_)
|
160 |
+
assert_type(i > f8, np.bool_)
|
161 |
+
assert_type(AR > f8, npt.NDArray[np.bool_])
|
162 |
+
assert_type(SEQ > f8, npt.NDArray[np.bool_])
|
163 |
+
|
164 |
+
assert_type(f4 > f8, np.bool_)
|
165 |
+
assert_type(f4 > i8, np.bool_)
|
166 |
+
assert_type(f4 > f4, np.bool_)
|
167 |
+
assert_type(f4 > i4, np.bool_)
|
168 |
+
assert_type(f4 > b_, np.bool_)
|
169 |
+
assert_type(f4 > b, np.bool_)
|
170 |
+
assert_type(f4 > c, np.bool_)
|
171 |
+
assert_type(f4 > f, np.bool_)
|
172 |
+
assert_type(f4 > i, np.bool_)
|
173 |
+
assert_type(f4 > AR, npt.NDArray[np.bool_])
|
174 |
+
assert_type(f4 > SEQ, npt.NDArray[np.bool_])
|
175 |
+
|
176 |
+
assert_type(f8 > f4, np.bool_)
|
177 |
+
assert_type(i8 > f4, np.bool_)
|
178 |
+
assert_type(f4 > f4, np.bool_)
|
179 |
+
assert_type(i4 > f4, np.bool_)
|
180 |
+
assert_type(b_ > f4, np.bool_)
|
181 |
+
assert_type(b > f4, np.bool_)
|
182 |
+
assert_type(c > f4, np.bool_)
|
183 |
+
assert_type(f > f4, np.bool_)
|
184 |
+
assert_type(i > f4, np.bool_)
|
185 |
+
assert_type(AR > f4, npt.NDArray[np.bool_])
|
186 |
+
assert_type(SEQ > f4, npt.NDArray[np.bool_])
|
187 |
+
|
188 |
+
# Int
|
189 |
+
|
190 |
+
assert_type(i8 > i8, np.bool_)
|
191 |
+
assert_type(i8 > u8, np.bool_)
|
192 |
+
assert_type(i8 > i4, np.bool_)
|
193 |
+
assert_type(i8 > u4, np.bool_)
|
194 |
+
assert_type(i8 > b_, np.bool_)
|
195 |
+
assert_type(i8 > b, np.bool_)
|
196 |
+
assert_type(i8 > c, np.bool_)
|
197 |
+
assert_type(i8 > f, np.bool_)
|
198 |
+
assert_type(i8 > i, np.bool_)
|
199 |
+
assert_type(i8 > AR, npt.NDArray[np.bool_])
|
200 |
+
assert_type(i8 > SEQ, npt.NDArray[np.bool_])
|
201 |
+
|
202 |
+
assert_type(u8 > u8, np.bool_)
|
203 |
+
assert_type(u8 > i4, np.bool_)
|
204 |
+
assert_type(u8 > u4, np.bool_)
|
205 |
+
assert_type(u8 > b_, np.bool_)
|
206 |
+
assert_type(u8 > b, np.bool_)
|
207 |
+
assert_type(u8 > c, np.bool_)
|
208 |
+
assert_type(u8 > f, np.bool_)
|
209 |
+
assert_type(u8 > i, np.bool_)
|
210 |
+
assert_type(u8 > AR, npt.NDArray[np.bool_])
|
211 |
+
assert_type(u8 > SEQ, npt.NDArray[np.bool_])
|
212 |
+
|
213 |
+
assert_type(i8 > i8, np.bool_)
|
214 |
+
assert_type(u8 > i8, np.bool_)
|
215 |
+
assert_type(i4 > i8, np.bool_)
|
216 |
+
assert_type(u4 > i8, np.bool_)
|
217 |
+
assert_type(b_ > i8, np.bool_)
|
218 |
+
assert_type(b > i8, np.bool_)
|
219 |
+
assert_type(c > i8, np.bool_)
|
220 |
+
assert_type(f > i8, np.bool_)
|
221 |
+
assert_type(i > i8, np.bool_)
|
222 |
+
assert_type(AR > i8, npt.NDArray[np.bool_])
|
223 |
+
assert_type(SEQ > i8, npt.NDArray[np.bool_])
|
224 |
+
|
225 |
+
assert_type(u8 > u8, np.bool_)
|
226 |
+
assert_type(i4 > u8, np.bool_)
|
227 |
+
assert_type(u4 > u8, np.bool_)
|
228 |
+
assert_type(b_ > u8, np.bool_)
|
229 |
+
assert_type(b > u8, np.bool_)
|
230 |
+
assert_type(c > u8, np.bool_)
|
231 |
+
assert_type(f > u8, np.bool_)
|
232 |
+
assert_type(i > u8, np.bool_)
|
233 |
+
assert_type(AR > u8, npt.NDArray[np.bool_])
|
234 |
+
assert_type(SEQ > u8, npt.NDArray[np.bool_])
|
235 |
+
|
236 |
+
assert_type(i4 > i8, np.bool_)
|
237 |
+
assert_type(i4 > i4, np.bool_)
|
238 |
+
assert_type(i4 > i, np.bool_)
|
239 |
+
assert_type(i4 > b_, np.bool_)
|
240 |
+
assert_type(i4 > b, np.bool_)
|
241 |
+
assert_type(i4 > AR, npt.NDArray[np.bool_])
|
242 |
+
assert_type(i4 > SEQ, npt.NDArray[np.bool_])
|
243 |
+
|
244 |
+
assert_type(u4 > i8, np.bool_)
|
245 |
+
assert_type(u4 > i4, np.bool_)
|
246 |
+
assert_type(u4 > u8, np.bool_)
|
247 |
+
assert_type(u4 > u4, np.bool_)
|
248 |
+
assert_type(u4 > i, np.bool_)
|
249 |
+
assert_type(u4 > b_, np.bool_)
|
250 |
+
assert_type(u4 > b, np.bool_)
|
251 |
+
assert_type(u4 > AR, npt.NDArray[np.bool_])
|
252 |
+
assert_type(u4 > SEQ, npt.NDArray[np.bool_])
|
253 |
+
|
254 |
+
assert_type(i8 > i4, np.bool_)
|
255 |
+
assert_type(i4 > i4, np.bool_)
|
256 |
+
assert_type(i > i4, np.bool_)
|
257 |
+
assert_type(b_ > i4, np.bool_)
|
258 |
+
assert_type(b > i4, np.bool_)
|
259 |
+
assert_type(AR > i4, npt.NDArray[np.bool_])
|
260 |
+
assert_type(SEQ > i4, npt.NDArray[np.bool_])
|
261 |
+
|
262 |
+
assert_type(i8 > u4, np.bool_)
|
263 |
+
assert_type(i4 > u4, np.bool_)
|
264 |
+
assert_type(u8 > u4, np.bool_)
|
265 |
+
assert_type(u4 > u4, np.bool_)
|
266 |
+
assert_type(b_ > u4, np.bool_)
|
267 |
+
assert_type(b > u4, np.bool_)
|
268 |
+
assert_type(i > u4, np.bool_)
|
269 |
+
assert_type(AR > u4, npt.NDArray[np.bool_])
|
270 |
+
assert_type(SEQ > u4, npt.NDArray[np.bool_])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/constants.pyi
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Literal
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
from numpy.core._type_aliases import _SCTypes
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
assert_type(np.Inf, float)
|
13 |
+
assert_type(np.Infinity, float)
|
14 |
+
assert_type(np.NAN, float)
|
15 |
+
assert_type(np.NINF, float)
|
16 |
+
assert_type(np.NZERO, float)
|
17 |
+
assert_type(np.NaN, float)
|
18 |
+
assert_type(np.PINF, float)
|
19 |
+
assert_type(np.PZERO, float)
|
20 |
+
assert_type(np.e, float)
|
21 |
+
assert_type(np.euler_gamma, float)
|
22 |
+
assert_type(np.inf, float)
|
23 |
+
assert_type(np.infty, float)
|
24 |
+
assert_type(np.nan, float)
|
25 |
+
assert_type(np.pi, float)
|
26 |
+
|
27 |
+
assert_type(np.ALLOW_THREADS, int)
|
28 |
+
assert_type(np.BUFSIZE, Literal[8192])
|
29 |
+
assert_type(np.CLIP, Literal[0])
|
30 |
+
assert_type(np.ERR_CALL, Literal[3])
|
31 |
+
assert_type(np.ERR_DEFAULT, Literal[521])
|
32 |
+
assert_type(np.ERR_IGNORE, Literal[0])
|
33 |
+
assert_type(np.ERR_LOG, Literal[5])
|
34 |
+
assert_type(np.ERR_PRINT, Literal[4])
|
35 |
+
assert_type(np.ERR_RAISE, Literal[2])
|
36 |
+
assert_type(np.ERR_WARN, Literal[1])
|
37 |
+
assert_type(np.FLOATING_POINT_SUPPORT, Literal[1])
|
38 |
+
assert_type(np.FPE_DIVIDEBYZERO, Literal[1])
|
39 |
+
assert_type(np.FPE_INVALID, Literal[8])
|
40 |
+
assert_type(np.FPE_OVERFLOW, Literal[2])
|
41 |
+
assert_type(np.FPE_UNDERFLOW, Literal[4])
|
42 |
+
assert_type(np.MAXDIMS, Literal[32])
|
43 |
+
assert_type(np.MAY_SHARE_BOUNDS, Literal[0])
|
44 |
+
assert_type(np.MAY_SHARE_EXACT, Literal[-1])
|
45 |
+
assert_type(np.RAISE, Literal[2])
|
46 |
+
assert_type(np.SHIFT_DIVIDEBYZERO, Literal[0])
|
47 |
+
assert_type(np.SHIFT_INVALID, Literal[9])
|
48 |
+
assert_type(np.SHIFT_OVERFLOW, Literal[3])
|
49 |
+
assert_type(np.SHIFT_UNDERFLOW, Literal[6])
|
50 |
+
assert_type(np.UFUNC_BUFSIZE_DEFAULT, Literal[8192])
|
51 |
+
assert_type(np.WRAP, Literal[1])
|
52 |
+
assert_type(np.tracemalloc_domain, Literal[389047])
|
53 |
+
|
54 |
+
assert_type(np.little_endian, bool)
|
55 |
+
assert_type(np.True_, np.bool_)
|
56 |
+
assert_type(np.False_, np.bool_)
|
57 |
+
|
58 |
+
assert_type(np.UFUNC_PYVALS_NAME, Literal["UFUNC_PYVALS"])
|
59 |
+
|
60 |
+
assert_type(np.sctypeDict, dict[int | str, type[np.generic]])
|
61 |
+
assert_type(np.sctypes, _SCTypes)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/ctypeslib.pyi
ADDED
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import ctypes as ct
|
3 |
+
from typing import Any
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
from numpy import ctypeslib
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
AR_bool: npt.NDArray[np.bool_]
|
15 |
+
AR_ubyte: npt.NDArray[np.ubyte]
|
16 |
+
AR_ushort: npt.NDArray[np.ushort]
|
17 |
+
AR_uintc: npt.NDArray[np.uintc]
|
18 |
+
AR_uint: npt.NDArray[np.uint]
|
19 |
+
AR_ulonglong: npt.NDArray[np.ulonglong]
|
20 |
+
AR_byte: npt.NDArray[np.byte]
|
21 |
+
AR_short: npt.NDArray[np.short]
|
22 |
+
AR_intc: npt.NDArray[np.intc]
|
23 |
+
AR_int: npt.NDArray[np.int_]
|
24 |
+
AR_longlong: npt.NDArray[np.longlong]
|
25 |
+
AR_single: npt.NDArray[np.single]
|
26 |
+
AR_double: npt.NDArray[np.double]
|
27 |
+
AR_longdouble: npt.NDArray[np.longdouble]
|
28 |
+
AR_void: npt.NDArray[np.void]
|
29 |
+
|
30 |
+
pointer: ct._Pointer[Any]
|
31 |
+
|
32 |
+
assert_type(np.ctypeslib.c_intp(), ctypeslib.c_intp)
|
33 |
+
|
34 |
+
assert_type(np.ctypeslib.ndpointer(), type[ctypeslib._ndptr[None]])
|
35 |
+
assert_type(np.ctypeslib.ndpointer(dtype=np.float64), type[ctypeslib._ndptr[np.dtype[np.float64]]])
|
36 |
+
assert_type(np.ctypeslib.ndpointer(dtype=float), type[ctypeslib._ndptr[np.dtype[Any]]])
|
37 |
+
assert_type(np.ctypeslib.ndpointer(shape=(10, 3)), type[ctypeslib._ndptr[None]])
|
38 |
+
assert_type(np.ctypeslib.ndpointer(np.int64, shape=(10, 3)), type[ctypeslib._concrete_ndptr[np.dtype[np.int64]]])
|
39 |
+
assert_type(np.ctypeslib.ndpointer(int, shape=(1,)), type[np.ctypeslib._concrete_ndptr[np.dtype[Any]]])
|
40 |
+
|
41 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.bool_), type[ct.c_bool])
|
42 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.ubyte), type[ct.c_ubyte])
|
43 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.ushort), type[ct.c_ushort])
|
44 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.uintc), type[ct.c_uint])
|
45 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.byte), type[ct.c_byte])
|
46 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.short), type[ct.c_short])
|
47 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.intc), type[ct.c_int])
|
48 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.single), type[ct.c_float])
|
49 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.double), type[ct.c_double])
|
50 |
+
assert_type(np.ctypeslib.as_ctypes_type(ct.c_double), type[ct.c_double])
|
51 |
+
assert_type(np.ctypeslib.as_ctypes_type("q"), type[ct.c_longlong])
|
52 |
+
assert_type(np.ctypeslib.as_ctypes_type([("i8", np.int64), ("f8", np.float64)]), type[Any])
|
53 |
+
assert_type(np.ctypeslib.as_ctypes_type("i8"), type[Any])
|
54 |
+
assert_type(np.ctypeslib.as_ctypes_type("f8"), type[Any])
|
55 |
+
|
56 |
+
assert_type(np.ctypeslib.as_ctypes(AR_bool.take(0)), ct.c_bool)
|
57 |
+
assert_type(np.ctypeslib.as_ctypes(AR_ubyte.take(0)), ct.c_ubyte)
|
58 |
+
assert_type(np.ctypeslib.as_ctypes(AR_ushort.take(0)), ct.c_ushort)
|
59 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uintc.take(0)), ct.c_uint)
|
60 |
+
|
61 |
+
assert_type(np.ctypeslib.as_ctypes(AR_byte.take(0)), ct.c_byte)
|
62 |
+
assert_type(np.ctypeslib.as_ctypes(AR_short.take(0)), ct.c_short)
|
63 |
+
assert_type(np.ctypeslib.as_ctypes(AR_intc.take(0)), ct.c_int)
|
64 |
+
assert_type(np.ctypeslib.as_ctypes(AR_single.take(0)), ct.c_float)
|
65 |
+
assert_type(np.ctypeslib.as_ctypes(AR_double.take(0)), ct.c_double)
|
66 |
+
assert_type(np.ctypeslib.as_ctypes(AR_void.take(0)), Any)
|
67 |
+
assert_type(np.ctypeslib.as_ctypes(AR_bool), ct.Array[ct.c_bool])
|
68 |
+
assert_type(np.ctypeslib.as_ctypes(AR_ubyte), ct.Array[ct.c_ubyte])
|
69 |
+
assert_type(np.ctypeslib.as_ctypes(AR_ushort), ct.Array[ct.c_ushort])
|
70 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uintc), ct.Array[ct.c_uint])
|
71 |
+
assert_type(np.ctypeslib.as_ctypes(AR_byte), ct.Array[ct.c_byte])
|
72 |
+
assert_type(np.ctypeslib.as_ctypes(AR_short), ct.Array[ct.c_short])
|
73 |
+
assert_type(np.ctypeslib.as_ctypes(AR_intc), ct.Array[ct.c_int])
|
74 |
+
assert_type(np.ctypeslib.as_ctypes(AR_single), ct.Array[ct.c_float])
|
75 |
+
assert_type(np.ctypeslib.as_ctypes(AR_double), ct.Array[ct.c_double])
|
76 |
+
assert_type(np.ctypeslib.as_ctypes(AR_void), ct.Array[Any])
|
77 |
+
|
78 |
+
assert_type(np.ctypeslib.as_array(AR_ubyte), npt.NDArray[np.ubyte])
|
79 |
+
assert_type(np.ctypeslib.as_array(1), npt.NDArray[Any])
|
80 |
+
assert_type(np.ctypeslib.as_array(pointer), npt.NDArray[Any])
|
81 |
+
|
82 |
+
if sys.platform == "win32":
|
83 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.int_), type[ct.c_int])
|
84 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.uint), type[ct.c_uint])
|
85 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uint), ct.Array[ct.c_uint])
|
86 |
+
assert_type(np.ctypeslib.as_ctypes(AR_int), ct.Array[ct.c_int])
|
87 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uint.take(0)), ct.c_uint)
|
88 |
+
assert_type(np.ctypeslib.as_ctypes(AR_int.take(0)), ct.c_int)
|
89 |
+
else:
|
90 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.int_), type[ct.c_long])
|
91 |
+
assert_type(np.ctypeslib.as_ctypes_type(np.uint), type[ct.c_ulong])
|
92 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uint), ct.Array[ct.c_ulong])
|
93 |
+
assert_type(np.ctypeslib.as_ctypes(AR_int), ct.Array[ct.c_long])
|
94 |
+
assert_type(np.ctypeslib.as_ctypes(AR_uint.take(0)), ct.c_ulong)
|
95 |
+
assert_type(np.ctypeslib.as_ctypes(AR_int.take(0)), ct.c_long)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/datasource.pyi
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from pathlib import Path
|
3 |
+
from typing import IO, Any
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
path1: Path
|
13 |
+
path2: str
|
14 |
+
|
15 |
+
d1 = np.DataSource(path1)
|
16 |
+
d2 = np.DataSource(path2)
|
17 |
+
d3 = np.DataSource(None)
|
18 |
+
|
19 |
+
assert_type(d1.abspath("..."), str)
|
20 |
+
assert_type(d2.abspath("..."), str)
|
21 |
+
assert_type(d3.abspath("..."), str)
|
22 |
+
|
23 |
+
assert_type(d1.exists("..."), bool)
|
24 |
+
assert_type(d2.exists("..."), bool)
|
25 |
+
assert_type(d3.exists("..."), bool)
|
26 |
+
|
27 |
+
assert_type(d1.open("...", "r"), IO[Any])
|
28 |
+
assert_type(d2.open("...", encoding="utf8"), IO[Any])
|
29 |
+
assert_type(d3.open("...", newline="/n"), IO[Any])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/dtype.pyi
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
import ctypes as ct
|
3 |
+
from typing import Any
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
dtype_U: np.dtype[np.str_]
|
13 |
+
dtype_V: np.dtype[np.void]
|
14 |
+
dtype_i8: np.dtype[np.int64]
|
15 |
+
|
16 |
+
assert_type(np.dtype(np.float64), np.dtype[np.float64])
|
17 |
+
assert_type(np.dtype(np.float64, metadata={"test": "test"}), np.dtype[np.float64])
|
18 |
+
assert_type(np.dtype(np.int64), np.dtype[np.int64])
|
19 |
+
|
20 |
+
# String aliases
|
21 |
+
assert_type(np.dtype("float64"), np.dtype[np.float64])
|
22 |
+
assert_type(np.dtype("float32"), np.dtype[np.float32])
|
23 |
+
assert_type(np.dtype("int64"), np.dtype[np.int64])
|
24 |
+
assert_type(np.dtype("int32"), np.dtype[np.int32])
|
25 |
+
assert_type(np.dtype("bool"), np.dtype[np.bool_])
|
26 |
+
assert_type(np.dtype("bytes"), np.dtype[np.bytes_])
|
27 |
+
assert_type(np.dtype("str"), np.dtype[np.str_])
|
28 |
+
|
29 |
+
# Python types
|
30 |
+
assert_type(np.dtype(complex), np.dtype[np.cdouble])
|
31 |
+
assert_type(np.dtype(float), np.dtype[np.double])
|
32 |
+
assert_type(np.dtype(int), np.dtype[np.int_])
|
33 |
+
assert_type(np.dtype(bool), np.dtype[np.bool_])
|
34 |
+
assert_type(np.dtype(str), np.dtype[np.str_])
|
35 |
+
assert_type(np.dtype(bytes), np.dtype[np.bytes_])
|
36 |
+
assert_type(np.dtype(object), np.dtype[np.object_])
|
37 |
+
|
38 |
+
# ctypes
|
39 |
+
assert_type(np.dtype(ct.c_double), np.dtype[np.double])
|
40 |
+
assert_type(np.dtype(ct.c_longlong), np.dtype[np.longlong])
|
41 |
+
assert_type(np.dtype(ct.c_uint32), np.dtype[np.uint32])
|
42 |
+
assert_type(np.dtype(ct.c_bool), np.dtype[np.bool_])
|
43 |
+
assert_type(np.dtype(ct.c_char), np.dtype[np.bytes_])
|
44 |
+
assert_type(np.dtype(ct.py_object), np.dtype[np.object_])
|
45 |
+
|
46 |
+
# Special case for None
|
47 |
+
assert_type(np.dtype(None), np.dtype[np.double])
|
48 |
+
|
49 |
+
# Dtypes of dtypes
|
50 |
+
assert_type(np.dtype(np.dtype(np.float64)), np.dtype[np.float64])
|
51 |
+
|
52 |
+
# Parameterized dtypes
|
53 |
+
assert_type(np.dtype("S8"), np.dtype)
|
54 |
+
|
55 |
+
# Void
|
56 |
+
assert_type(np.dtype(("U", 10)), np.dtype[np.void])
|
57 |
+
|
58 |
+
# Methods and attributes
|
59 |
+
assert_type(dtype_U.base, np.dtype[Any])
|
60 |
+
assert_type(dtype_U.subdtype, None | tuple[np.dtype[Any], tuple[int, ...]])
|
61 |
+
assert_type(dtype_U.newbyteorder(), np.dtype[np.str_])
|
62 |
+
assert_type(dtype_U.type, type[np.str_])
|
63 |
+
assert_type(dtype_U.name, str)
|
64 |
+
assert_type(dtype_U.names, None | tuple[str, ...])
|
65 |
+
|
66 |
+
assert_type(dtype_U * 0, np.dtype[np.str_])
|
67 |
+
assert_type(dtype_U * 1, np.dtype[np.str_])
|
68 |
+
assert_type(dtype_U * 2, np.dtype[np.str_])
|
69 |
+
|
70 |
+
assert_type(dtype_i8 * 0, np.dtype[np.void])
|
71 |
+
assert_type(dtype_i8 * 1, np.dtype[np.int64])
|
72 |
+
assert_type(dtype_i8 * 2, np.dtype[np.void])
|
73 |
+
|
74 |
+
assert_type(0 * dtype_U, np.dtype[np.str_])
|
75 |
+
assert_type(1 * dtype_U, np.dtype[np.str_])
|
76 |
+
assert_type(2 * dtype_U, np.dtype[np.str_])
|
77 |
+
|
78 |
+
assert_type(0 * dtype_i8, np.dtype[Any])
|
79 |
+
assert_type(1 * dtype_i8, np.dtype[Any])
|
80 |
+
assert_type(2 * dtype_i8, np.dtype[Any])
|
81 |
+
|
82 |
+
assert_type(dtype_V["f0"], np.dtype[Any])
|
83 |
+
assert_type(dtype_V[0], np.dtype[Any])
|
84 |
+
assert_type(dtype_V[["f0", "f1"]], np.dtype[np.void])
|
85 |
+
assert_type(dtype_V[["f0"]], np.dtype[np.void])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/einsumfunc.pyi
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_LIKE_b: list[bool]
|
13 |
+
AR_LIKE_u: list[np.uint32]
|
14 |
+
AR_LIKE_i: list[int]
|
15 |
+
AR_LIKE_f: list[float]
|
16 |
+
AR_LIKE_c: list[complex]
|
17 |
+
AR_LIKE_U: list[str]
|
18 |
+
AR_o: npt.NDArray[np.object_]
|
19 |
+
|
20 |
+
OUT_f: npt.NDArray[np.float64]
|
21 |
+
|
22 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_b), Any)
|
23 |
+
assert_type(np.einsum("i,i->i", AR_o, AR_o), Any)
|
24 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_u, AR_LIKE_u), Any)
|
25 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_i, AR_LIKE_i), Any)
|
26 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f), Any)
|
27 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_c, AR_LIKE_c), Any)
|
28 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_i), Any)
|
29 |
+
assert_type(np.einsum("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c), Any)
|
30 |
+
|
31 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_c, AR_LIKE_c, out=OUT_f), npt.NDArray[np.float64])
|
32 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=bool, casting="unsafe", out=OUT_f), npt.NDArray[np.float64])
|
33 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f, dtype="c16"), Any)
|
34 |
+
assert_type(np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=bool, casting="unsafe"), Any)
|
35 |
+
|
36 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_b), tuple[list[Any], str])
|
37 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_u, AR_LIKE_u), tuple[list[Any], str])
|
38 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_i, AR_LIKE_i), tuple[list[Any], str])
|
39 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_f, AR_LIKE_f), tuple[list[Any], str])
|
40 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_c, AR_LIKE_c), tuple[list[Any], str])
|
41 |
+
assert_type(np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_i), tuple[list[Any], str])
|
42 |
+
assert_type(np.einsum_path("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c), tuple[list[Any], str])
|
43 |
+
|
44 |
+
assert_type(np.einsum([[1, 1], [1, 1]], AR_LIKE_i, AR_LIKE_i), Any)
|
45 |
+
assert_type(np.einsum_path([[1, 1], [1, 1]], AR_LIKE_i, AR_LIKE_i), tuple[list[Any], str])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/emath.pyi
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_f8: npt.NDArray[np.float64]
|
13 |
+
AR_c16: npt.NDArray[np.complex128]
|
14 |
+
f8: np.float64
|
15 |
+
c16: np.complex128
|
16 |
+
|
17 |
+
assert_type(np.emath.sqrt(f8), Any)
|
18 |
+
assert_type(np.emath.sqrt(AR_f8), npt.NDArray[Any])
|
19 |
+
assert_type(np.emath.sqrt(c16), np.complexfloating[Any, Any])
|
20 |
+
assert_type(np.emath.sqrt(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
21 |
+
|
22 |
+
assert_type(np.emath.log(f8), Any)
|
23 |
+
assert_type(np.emath.log(AR_f8), npt.NDArray[Any])
|
24 |
+
assert_type(np.emath.log(c16), np.complexfloating[Any, Any])
|
25 |
+
assert_type(np.emath.log(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
26 |
+
|
27 |
+
assert_type(np.emath.log10(f8), Any)
|
28 |
+
assert_type(np.emath.log10(AR_f8), npt.NDArray[Any])
|
29 |
+
assert_type(np.emath.log10(c16), np.complexfloating[Any, Any])
|
30 |
+
assert_type(np.emath.log10(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
31 |
+
|
32 |
+
assert_type(np.emath.log2(f8), Any)
|
33 |
+
assert_type(np.emath.log2(AR_f8), npt.NDArray[Any])
|
34 |
+
assert_type(np.emath.log2(c16), np.complexfloating[Any, Any])
|
35 |
+
assert_type(np.emath.log2(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
36 |
+
|
37 |
+
assert_type(np.emath.logn(f8, 2), Any)
|
38 |
+
assert_type(np.emath.logn(AR_f8, 4), npt.NDArray[Any])
|
39 |
+
assert_type(np.emath.logn(f8, 1j), np.complexfloating[Any, Any])
|
40 |
+
assert_type(np.emath.logn(AR_c16, 1.5), npt.NDArray[np.complexfloating[Any, Any]])
|
41 |
+
|
42 |
+
assert_type(np.emath.power(f8, 2), Any)
|
43 |
+
assert_type(np.emath.power(AR_f8, 4), npt.NDArray[Any])
|
44 |
+
assert_type(np.emath.power(f8, 2j), np.complexfloating[Any, Any])
|
45 |
+
assert_type(np.emath.power(AR_c16, 1.5), npt.NDArray[np.complexfloating[Any, Any]])
|
46 |
+
|
47 |
+
assert_type(np.emath.arccos(f8), Any)
|
48 |
+
assert_type(np.emath.arccos(AR_f8), npt.NDArray[Any])
|
49 |
+
assert_type(np.emath.arccos(c16), np.complexfloating[Any, Any])
|
50 |
+
assert_type(np.emath.arccos(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
51 |
+
|
52 |
+
assert_type(np.emath.arcsin(f8), Any)
|
53 |
+
assert_type(np.emath.arcsin(AR_f8), npt.NDArray[Any])
|
54 |
+
assert_type(np.emath.arcsin(c16), np.complexfloating[Any, Any])
|
55 |
+
assert_type(np.emath.arcsin(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
56 |
+
|
57 |
+
assert_type(np.emath.arctanh(f8), Any)
|
58 |
+
assert_type(np.emath.arctanh(AR_f8), npt.NDArray[Any])
|
59 |
+
assert_type(np.emath.arctanh(c16), np.complexfloating[Any, Any])
|
60 |
+
assert_type(np.emath.arctanh(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/false_positives.pyi
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_Any: npt.NDArray[Any]
|
13 |
+
|
14 |
+
# Mypy bug where overload ambiguity is ignored for `Any`-parametrized types;
|
15 |
+
# xref numpy/numpy#20099 and python/mypy#11347
|
16 |
+
#
|
17 |
+
# The expected output would be something akin to `npt.NDArray[Any]`
|
18 |
+
assert_type(AR_Any + 2, npt.NDArray[np.signedinteger[Any]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/fft.pyi
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_f8: npt.NDArray[np.float64]
|
13 |
+
AR_c16: npt.NDArray[np.complex128]
|
14 |
+
AR_LIKE_f8: list[float]
|
15 |
+
|
16 |
+
assert_type(np.fft.fftshift(AR_f8), npt.NDArray[np.float64])
|
17 |
+
assert_type(np.fft.fftshift(AR_LIKE_f8, axes=0), npt.NDArray[Any])
|
18 |
+
|
19 |
+
assert_type(np.fft.ifftshift(AR_f8), npt.NDArray[np.float64])
|
20 |
+
assert_type(np.fft.ifftshift(AR_LIKE_f8, axes=0), npt.NDArray[Any])
|
21 |
+
|
22 |
+
assert_type(np.fft.fftfreq(5, AR_f8), npt.NDArray[np.floating[Any]])
|
23 |
+
assert_type(np.fft.fftfreq(np.int64(), AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
24 |
+
|
25 |
+
assert_type(np.fft.fftfreq(5, AR_f8), npt.NDArray[np.floating[Any]])
|
26 |
+
assert_type(np.fft.fftfreq(np.int64(), AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
27 |
+
|
28 |
+
assert_type(np.fft.fft(AR_f8), npt.NDArray[np.complex128])
|
29 |
+
assert_type(np.fft.ifft(AR_f8, axis=1), npt.NDArray[np.complex128])
|
30 |
+
assert_type(np.fft.rfft(AR_f8, n=None), npt.NDArray[np.complex128])
|
31 |
+
assert_type(np.fft.irfft(AR_f8, norm="ortho"), npt.NDArray[np.float64])
|
32 |
+
assert_type(np.fft.hfft(AR_f8, n=2), npt.NDArray[np.float64])
|
33 |
+
assert_type(np.fft.ihfft(AR_f8), npt.NDArray[np.complex128])
|
34 |
+
|
35 |
+
assert_type(np.fft.fftn(AR_f8), npt.NDArray[np.complex128])
|
36 |
+
assert_type(np.fft.ifftn(AR_f8), npt.NDArray[np.complex128])
|
37 |
+
assert_type(np.fft.rfftn(AR_f8), npt.NDArray[np.complex128])
|
38 |
+
assert_type(np.fft.irfftn(AR_f8), npt.NDArray[np.float64])
|
39 |
+
|
40 |
+
assert_type(np.fft.rfft2(AR_f8), npt.NDArray[np.complex128])
|
41 |
+
assert_type(np.fft.ifft2(AR_f8), npt.NDArray[np.complex128])
|
42 |
+
assert_type(np.fft.fft2(AR_f8), npt.NDArray[np.complex128])
|
43 |
+
assert_type(np.fft.irfft2(AR_f8), npt.NDArray[np.float64])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/flatiter.pyi
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
a: np.flatiter[npt.NDArray[np.str_]]
|
13 |
+
|
14 |
+
assert_type(a.base, npt.NDArray[np.str_])
|
15 |
+
assert_type(a.copy(), npt.NDArray[np.str_])
|
16 |
+
assert_type(a.coords, tuple[int, ...])
|
17 |
+
assert_type(a.index, int)
|
18 |
+
assert_type(iter(a), np.flatiter[npt.NDArray[np.str_]])
|
19 |
+
assert_type(next(a), np.str_)
|
20 |
+
assert_type(a[0], np.str_)
|
21 |
+
assert_type(a[[0, 1, 2]], npt.NDArray[np.str_])
|
22 |
+
assert_type(a[...], npt.NDArray[np.str_])
|
23 |
+
assert_type(a[:], npt.NDArray[np.str_])
|
24 |
+
assert_type(a[(...,)], npt.NDArray[np.str_])
|
25 |
+
assert_type(a[(0,)], np.str_)
|
26 |
+
assert_type(a.__array__(), npt.NDArray[np.str_])
|
27 |
+
assert_type(a.__array__(np.dtype(np.float64)), npt.NDArray[np.float64])
|
28 |
+
a[0] = "a"
|
29 |
+
a[:5] = "a"
|
30 |
+
a[...] = "a"
|
31 |
+
a[(...,)] = "a"
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/fromnumeric.pyi
ADDED
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Tests for :mod:`core.fromnumeric`."""
|
2 |
+
|
3 |
+
import sys
|
4 |
+
from typing import Any
|
5 |
+
|
6 |
+
import numpy as np
|
7 |
+
import numpy.typing as npt
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
class NDArraySubclass(npt.NDArray[np.complex128]):
|
15 |
+
...
|
16 |
+
|
17 |
+
AR_b: npt.NDArray[np.bool_]
|
18 |
+
AR_f4: npt.NDArray[np.float32]
|
19 |
+
AR_c16: npt.NDArray[np.complex128]
|
20 |
+
AR_u8: npt.NDArray[np.uint64]
|
21 |
+
AR_i8: npt.NDArray[np.int64]
|
22 |
+
AR_O: npt.NDArray[np.object_]
|
23 |
+
AR_subclass: NDArraySubclass
|
24 |
+
|
25 |
+
b: np.bool_
|
26 |
+
f4: np.float32
|
27 |
+
i8: np.int64
|
28 |
+
f: float
|
29 |
+
|
30 |
+
assert_type(np.take(b, 0), np.bool_)
|
31 |
+
assert_type(np.take(f4, 0), np.float32)
|
32 |
+
assert_type(np.take(f, 0), Any)
|
33 |
+
assert_type(np.take(AR_b, 0), np.bool_)
|
34 |
+
assert_type(np.take(AR_f4, 0), np.float32)
|
35 |
+
assert_type(np.take(AR_b, [0]), npt.NDArray[np.bool_])
|
36 |
+
assert_type(np.take(AR_f4, [0]), npt.NDArray[np.float32])
|
37 |
+
assert_type(np.take([1], [0]), npt.NDArray[Any])
|
38 |
+
assert_type(np.take(AR_f4, [0], out=AR_subclass), NDArraySubclass)
|
39 |
+
|
40 |
+
assert_type(np.reshape(b, 1), npt.NDArray[np.bool_])
|
41 |
+
assert_type(np.reshape(f4, 1), npt.NDArray[np.float32])
|
42 |
+
assert_type(np.reshape(f, 1), npt.NDArray[Any])
|
43 |
+
assert_type(np.reshape(AR_b, 1), npt.NDArray[np.bool_])
|
44 |
+
assert_type(np.reshape(AR_f4, 1), npt.NDArray[np.float32])
|
45 |
+
|
46 |
+
assert_type(np.choose(1, [True, True]), Any)
|
47 |
+
assert_type(np.choose([1], [True, True]), npt.NDArray[Any])
|
48 |
+
assert_type(np.choose([1], AR_b), npt.NDArray[np.bool_])
|
49 |
+
assert_type(np.choose([1], AR_b, out=AR_f4), npt.NDArray[np.float32])
|
50 |
+
|
51 |
+
assert_type(np.repeat(b, 1), npt.NDArray[np.bool_])
|
52 |
+
assert_type(np.repeat(f4, 1), npt.NDArray[np.float32])
|
53 |
+
assert_type(np.repeat(f, 1), npt.NDArray[Any])
|
54 |
+
assert_type(np.repeat(AR_b, 1), npt.NDArray[np.bool_])
|
55 |
+
assert_type(np.repeat(AR_f4, 1), npt.NDArray[np.float32])
|
56 |
+
|
57 |
+
# TODO: array_bdd tests for np.put()
|
58 |
+
|
59 |
+
assert_type(np.swapaxes([[0, 1]], 0, 0), npt.NDArray[Any])
|
60 |
+
assert_type(np.swapaxes(AR_b, 0, 0), npt.NDArray[np.bool_])
|
61 |
+
assert_type(np.swapaxes(AR_f4, 0, 0), npt.NDArray[np.float32])
|
62 |
+
|
63 |
+
assert_type(np.transpose(b), npt.NDArray[np.bool_])
|
64 |
+
assert_type(np.transpose(f4), npt.NDArray[np.float32])
|
65 |
+
assert_type(np.transpose(f), npt.NDArray[Any])
|
66 |
+
assert_type(np.transpose(AR_b), npt.NDArray[np.bool_])
|
67 |
+
assert_type(np.transpose(AR_f4), npt.NDArray[np.float32])
|
68 |
+
|
69 |
+
assert_type(np.partition(b, 0, axis=None), npt.NDArray[np.bool_])
|
70 |
+
assert_type(np.partition(f4, 0, axis=None), npt.NDArray[np.float32])
|
71 |
+
assert_type(np.partition(f, 0, axis=None), npt.NDArray[Any])
|
72 |
+
assert_type(np.partition(AR_b, 0), npt.NDArray[np.bool_])
|
73 |
+
assert_type(np.partition(AR_f4, 0), npt.NDArray[np.float32])
|
74 |
+
|
75 |
+
assert_type(np.argpartition(b, 0), npt.NDArray[np.intp])
|
76 |
+
assert_type(np.argpartition(f4, 0), npt.NDArray[np.intp])
|
77 |
+
assert_type(np.argpartition(f, 0), npt.NDArray[np.intp])
|
78 |
+
assert_type(np.argpartition(AR_b, 0), npt.NDArray[np.intp])
|
79 |
+
assert_type(np.argpartition(AR_f4, 0), npt.NDArray[np.intp])
|
80 |
+
|
81 |
+
assert_type(np.sort([2, 1], 0), npt.NDArray[Any])
|
82 |
+
assert_type(np.sort(AR_b, 0), npt.NDArray[np.bool_])
|
83 |
+
assert_type(np.sort(AR_f4, 0), npt.NDArray[np.float32])
|
84 |
+
|
85 |
+
assert_type(np.argsort(AR_b, 0), npt.NDArray[np.intp])
|
86 |
+
assert_type(np.argsort(AR_f4, 0), npt.NDArray[np.intp])
|
87 |
+
|
88 |
+
assert_type(np.argmax(AR_b), np.intp)
|
89 |
+
assert_type(np.argmax(AR_f4), np.intp)
|
90 |
+
assert_type(np.argmax(AR_b, axis=0), Any)
|
91 |
+
assert_type(np.argmax(AR_f4, axis=0), Any)
|
92 |
+
assert_type(np.argmax(AR_f4, out=AR_subclass), NDArraySubclass)
|
93 |
+
|
94 |
+
assert_type(np.argmin(AR_b), np.intp)
|
95 |
+
assert_type(np.argmin(AR_f4), np.intp)
|
96 |
+
assert_type(np.argmin(AR_b, axis=0), Any)
|
97 |
+
assert_type(np.argmin(AR_f4, axis=0), Any)
|
98 |
+
assert_type(np.argmin(AR_f4, out=AR_subclass), NDArraySubclass)
|
99 |
+
|
100 |
+
assert_type(np.searchsorted(AR_b[0], 0), np.intp)
|
101 |
+
assert_type(np.searchsorted(AR_f4[0], 0), np.intp)
|
102 |
+
assert_type(np.searchsorted(AR_b[0], [0]), npt.NDArray[np.intp])
|
103 |
+
assert_type(np.searchsorted(AR_f4[0], [0]), npt.NDArray[np.intp])
|
104 |
+
|
105 |
+
assert_type(np.resize(b, (5, 5)), npt.NDArray[np.bool_])
|
106 |
+
assert_type(np.resize(f4, (5, 5)), npt.NDArray[np.float32])
|
107 |
+
assert_type(np.resize(f, (5, 5)), npt.NDArray[Any])
|
108 |
+
assert_type(np.resize(AR_b, (5, 5)), npt.NDArray[np.bool_])
|
109 |
+
assert_type(np.resize(AR_f4, (5, 5)), npt.NDArray[np.float32])
|
110 |
+
|
111 |
+
assert_type(np.squeeze(b), np.bool_)
|
112 |
+
assert_type(np.squeeze(f4), np.float32)
|
113 |
+
assert_type(np.squeeze(f), npt.NDArray[Any])
|
114 |
+
assert_type(np.squeeze(AR_b), npt.NDArray[np.bool_])
|
115 |
+
assert_type(np.squeeze(AR_f4), npt.NDArray[np.float32])
|
116 |
+
|
117 |
+
assert_type(np.diagonal(AR_b), npt.NDArray[np.bool_])
|
118 |
+
assert_type(np.diagonal(AR_f4), npt.NDArray[np.float32])
|
119 |
+
|
120 |
+
assert_type(np.trace(AR_b), Any)
|
121 |
+
assert_type(np.trace(AR_f4), Any)
|
122 |
+
assert_type(np.trace(AR_f4, out=AR_subclass), NDArraySubclass)
|
123 |
+
|
124 |
+
assert_type(np.ravel(b), npt.NDArray[np.bool_])
|
125 |
+
assert_type(np.ravel(f4), npt.NDArray[np.float32])
|
126 |
+
assert_type(np.ravel(f), npt.NDArray[Any])
|
127 |
+
assert_type(np.ravel(AR_b), npt.NDArray[np.bool_])
|
128 |
+
assert_type(np.ravel(AR_f4), npt.NDArray[np.float32])
|
129 |
+
|
130 |
+
assert_type(np.nonzero(b), tuple[npt.NDArray[np.intp], ...])
|
131 |
+
assert_type(np.nonzero(f4), tuple[npt.NDArray[np.intp], ...])
|
132 |
+
assert_type(np.nonzero(f), tuple[npt.NDArray[np.intp], ...])
|
133 |
+
assert_type(np.nonzero(AR_b), tuple[npt.NDArray[np.intp], ...])
|
134 |
+
assert_type(np.nonzero(AR_f4), tuple[npt.NDArray[np.intp], ...])
|
135 |
+
|
136 |
+
assert_type(np.shape(b), tuple[int, ...])
|
137 |
+
assert_type(np.shape(f4), tuple[int, ...])
|
138 |
+
assert_type(np.shape(f), tuple[int, ...])
|
139 |
+
assert_type(np.shape(AR_b), tuple[int, ...])
|
140 |
+
assert_type(np.shape(AR_f4), tuple[int, ...])
|
141 |
+
|
142 |
+
assert_type(np.compress([True], b), npt.NDArray[np.bool_])
|
143 |
+
assert_type(np.compress([True], f4), npt.NDArray[np.float32])
|
144 |
+
assert_type(np.compress([True], f), npt.NDArray[Any])
|
145 |
+
assert_type(np.compress([True], AR_b), npt.NDArray[np.bool_])
|
146 |
+
assert_type(np.compress([True], AR_f4), npt.NDArray[np.float32])
|
147 |
+
|
148 |
+
assert_type(np.clip(b, 0, 1.0), np.bool_)
|
149 |
+
assert_type(np.clip(f4, -1, 1), np.float32)
|
150 |
+
assert_type(np.clip(f, 0, 1), Any)
|
151 |
+
assert_type(np.clip(AR_b, 0, 1), npt.NDArray[np.bool_])
|
152 |
+
assert_type(np.clip(AR_f4, 0, 1), npt.NDArray[np.float32])
|
153 |
+
assert_type(np.clip([0], 0, 1), npt.NDArray[Any])
|
154 |
+
assert_type(np.clip(AR_b, 0, 1, out=AR_subclass), NDArraySubclass)
|
155 |
+
|
156 |
+
assert_type(np.sum(b), np.bool_)
|
157 |
+
assert_type(np.sum(f4), np.float32)
|
158 |
+
assert_type(np.sum(f), Any)
|
159 |
+
assert_type(np.sum(AR_b), np.bool_)
|
160 |
+
assert_type(np.sum(AR_f4), np.float32)
|
161 |
+
assert_type(np.sum(AR_b, axis=0), Any)
|
162 |
+
assert_type(np.sum(AR_f4, axis=0), Any)
|
163 |
+
assert_type(np.sum(AR_f4, out=AR_subclass), NDArraySubclass)
|
164 |
+
|
165 |
+
assert_type(np.all(b), np.bool_)
|
166 |
+
assert_type(np.all(f4), np.bool_)
|
167 |
+
assert_type(np.all(f), np.bool_)
|
168 |
+
assert_type(np.all(AR_b), np.bool_)
|
169 |
+
assert_type(np.all(AR_f4), np.bool_)
|
170 |
+
assert_type(np.all(AR_b, axis=0), Any)
|
171 |
+
assert_type(np.all(AR_f4, axis=0), Any)
|
172 |
+
assert_type(np.all(AR_b, keepdims=True), Any)
|
173 |
+
assert_type(np.all(AR_f4, keepdims=True), Any)
|
174 |
+
assert_type(np.all(AR_f4, out=AR_subclass), NDArraySubclass)
|
175 |
+
|
176 |
+
assert_type(np.any(b), np.bool_)
|
177 |
+
assert_type(np.any(f4), np.bool_)
|
178 |
+
assert_type(np.any(f), np.bool_)
|
179 |
+
assert_type(np.any(AR_b), np.bool_)
|
180 |
+
assert_type(np.any(AR_f4), np.bool_)
|
181 |
+
assert_type(np.any(AR_b, axis=0), Any)
|
182 |
+
assert_type(np.any(AR_f4, axis=0), Any)
|
183 |
+
assert_type(np.any(AR_b, keepdims=True), Any)
|
184 |
+
assert_type(np.any(AR_f4, keepdims=True), Any)
|
185 |
+
assert_type(np.any(AR_f4, out=AR_subclass), NDArraySubclass)
|
186 |
+
|
187 |
+
assert_type(np.cumsum(b), npt.NDArray[np.bool_])
|
188 |
+
assert_type(np.cumsum(f4), npt.NDArray[np.float32])
|
189 |
+
assert_type(np.cumsum(f), npt.NDArray[Any])
|
190 |
+
assert_type(np.cumsum(AR_b), npt.NDArray[np.bool_])
|
191 |
+
assert_type(np.cumsum(AR_f4), npt.NDArray[np.float32])
|
192 |
+
assert_type(np.cumsum(f, dtype=float), npt.NDArray[Any])
|
193 |
+
assert_type(np.cumsum(f, dtype=np.float64), npt.NDArray[np.float64])
|
194 |
+
assert_type(np.cumsum(AR_f4, out=AR_subclass), NDArraySubclass)
|
195 |
+
|
196 |
+
assert_type(np.ptp(b), np.bool_)
|
197 |
+
assert_type(np.ptp(f4), np.float32)
|
198 |
+
assert_type(np.ptp(f), Any)
|
199 |
+
assert_type(np.ptp(AR_b), np.bool_)
|
200 |
+
assert_type(np.ptp(AR_f4), np.float32)
|
201 |
+
assert_type(np.ptp(AR_b, axis=0), Any)
|
202 |
+
assert_type(np.ptp(AR_f4, axis=0), Any)
|
203 |
+
assert_type(np.ptp(AR_b, keepdims=True), Any)
|
204 |
+
assert_type(np.ptp(AR_f4, keepdims=True), Any)
|
205 |
+
assert_type(np.ptp(AR_f4, out=AR_subclass), NDArraySubclass)
|
206 |
+
|
207 |
+
assert_type(np.amax(b), np.bool_)
|
208 |
+
assert_type(np.amax(f4), np.float32)
|
209 |
+
assert_type(np.amax(f), Any)
|
210 |
+
assert_type(np.amax(AR_b), np.bool_)
|
211 |
+
assert_type(np.amax(AR_f4), np.float32)
|
212 |
+
assert_type(np.amax(AR_b, axis=0), Any)
|
213 |
+
assert_type(np.amax(AR_f4, axis=0), Any)
|
214 |
+
assert_type(np.amax(AR_b, keepdims=True), Any)
|
215 |
+
assert_type(np.amax(AR_f4, keepdims=True), Any)
|
216 |
+
assert_type(np.amax(AR_f4, out=AR_subclass), NDArraySubclass)
|
217 |
+
|
218 |
+
assert_type(np.amin(b), np.bool_)
|
219 |
+
assert_type(np.amin(f4), np.float32)
|
220 |
+
assert_type(np.amin(f), Any)
|
221 |
+
assert_type(np.amin(AR_b), np.bool_)
|
222 |
+
assert_type(np.amin(AR_f4), np.float32)
|
223 |
+
assert_type(np.amin(AR_b, axis=0), Any)
|
224 |
+
assert_type(np.amin(AR_f4, axis=0), Any)
|
225 |
+
assert_type(np.amin(AR_b, keepdims=True), Any)
|
226 |
+
assert_type(np.amin(AR_f4, keepdims=True), Any)
|
227 |
+
assert_type(np.amin(AR_f4, out=AR_subclass), NDArraySubclass)
|
228 |
+
|
229 |
+
assert_type(np.prod(AR_b), np.int_)
|
230 |
+
assert_type(np.prod(AR_u8), np.uint64)
|
231 |
+
assert_type(np.prod(AR_i8), np.int64)
|
232 |
+
assert_type(np.prod(AR_f4), np.floating[Any])
|
233 |
+
assert_type(np.prod(AR_c16), np.complexfloating[Any, Any])
|
234 |
+
assert_type(np.prod(AR_O), Any)
|
235 |
+
assert_type(np.prod(AR_f4, axis=0), Any)
|
236 |
+
assert_type(np.prod(AR_f4, keepdims=True), Any)
|
237 |
+
assert_type(np.prod(AR_f4, dtype=np.float64), np.float64)
|
238 |
+
assert_type(np.prod(AR_f4, dtype=float), Any)
|
239 |
+
assert_type(np.prod(AR_f4, out=AR_subclass), NDArraySubclass)
|
240 |
+
|
241 |
+
assert_type(np.cumprod(AR_b), npt.NDArray[np.int_])
|
242 |
+
assert_type(np.cumprod(AR_u8), npt.NDArray[np.uint64])
|
243 |
+
assert_type(np.cumprod(AR_i8), npt.NDArray[np.int64])
|
244 |
+
assert_type(np.cumprod(AR_f4), npt.NDArray[np.floating[Any]])
|
245 |
+
assert_type(np.cumprod(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
246 |
+
assert_type(np.cumprod(AR_O), npt.NDArray[np.object_])
|
247 |
+
assert_type(np.cumprod(AR_f4, axis=0), npt.NDArray[np.floating[Any]])
|
248 |
+
assert_type(np.cumprod(AR_f4, dtype=np.float64), npt.NDArray[np.float64])
|
249 |
+
assert_type(np.cumprod(AR_f4, dtype=float), npt.NDArray[Any])
|
250 |
+
assert_type(np.cumprod(AR_f4, out=AR_subclass), NDArraySubclass)
|
251 |
+
|
252 |
+
assert_type(np.ndim(b), int)
|
253 |
+
assert_type(np.ndim(f4), int)
|
254 |
+
assert_type(np.ndim(f), int)
|
255 |
+
assert_type(np.ndim(AR_b), int)
|
256 |
+
assert_type(np.ndim(AR_f4), int)
|
257 |
+
|
258 |
+
assert_type(np.size(b), int)
|
259 |
+
assert_type(np.size(f4), int)
|
260 |
+
assert_type(np.size(f), int)
|
261 |
+
assert_type(np.size(AR_b), int)
|
262 |
+
assert_type(np.size(AR_f4), int)
|
263 |
+
|
264 |
+
assert_type(np.around(b), np.float16)
|
265 |
+
assert_type(np.around(f), Any)
|
266 |
+
assert_type(np.around(i8), np.int64)
|
267 |
+
assert_type(np.around(f4), np.float32)
|
268 |
+
assert_type(np.around(AR_b), npt.NDArray[np.float16])
|
269 |
+
assert_type(np.around(AR_i8), npt.NDArray[np.int64])
|
270 |
+
assert_type(np.around(AR_f4), npt.NDArray[np.float32])
|
271 |
+
assert_type(np.around([1.5]), npt.NDArray[Any])
|
272 |
+
assert_type(np.around(AR_f4, out=AR_subclass), NDArraySubclass)
|
273 |
+
|
274 |
+
assert_type(np.mean(AR_b), np.floating[Any])
|
275 |
+
assert_type(np.mean(AR_i8), np.floating[Any])
|
276 |
+
assert_type(np.mean(AR_f4), np.floating[Any])
|
277 |
+
assert_type(np.mean(AR_c16), np.complexfloating[Any, Any])
|
278 |
+
assert_type(np.mean(AR_O), Any)
|
279 |
+
assert_type(np.mean(AR_f4, axis=0), Any)
|
280 |
+
assert_type(np.mean(AR_f4, keepdims=True), Any)
|
281 |
+
assert_type(np.mean(AR_f4, dtype=float), Any)
|
282 |
+
assert_type(np.mean(AR_f4, dtype=np.float64), np.float64)
|
283 |
+
assert_type(np.mean(AR_f4, out=AR_subclass), NDArraySubclass)
|
284 |
+
|
285 |
+
assert_type(np.std(AR_b), np.floating[Any])
|
286 |
+
assert_type(np.std(AR_i8), np.floating[Any])
|
287 |
+
assert_type(np.std(AR_f4), np.floating[Any])
|
288 |
+
assert_type(np.std(AR_c16), np.floating[Any])
|
289 |
+
assert_type(np.std(AR_O), Any)
|
290 |
+
assert_type(np.std(AR_f4, axis=0), Any)
|
291 |
+
assert_type(np.std(AR_f4, keepdims=True), Any)
|
292 |
+
assert_type(np.std(AR_f4, dtype=float), Any)
|
293 |
+
assert_type(np.std(AR_f4, dtype=np.float64), np.float64)
|
294 |
+
assert_type(np.std(AR_f4, out=AR_subclass), NDArraySubclass)
|
295 |
+
|
296 |
+
assert_type(np.var(AR_b), np.floating[Any])
|
297 |
+
assert_type(np.var(AR_i8), np.floating[Any])
|
298 |
+
assert_type(np.var(AR_f4), np.floating[Any])
|
299 |
+
assert_type(np.var(AR_c16), np.floating[Any])
|
300 |
+
assert_type(np.var(AR_O), Any)
|
301 |
+
assert_type(np.var(AR_f4, axis=0), Any)
|
302 |
+
assert_type(np.var(AR_f4, keepdims=True), Any)
|
303 |
+
assert_type(np.var(AR_f4, dtype=float), Any)
|
304 |
+
assert_type(np.var(AR_f4, dtype=np.float64), np.float64)
|
305 |
+
assert_type(np.var(AR_f4, out=AR_subclass), NDArraySubclass)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/getlimits.pyi
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
|
6 |
+
if sys.version_info >= (3, 11):
|
7 |
+
from typing import assert_type
|
8 |
+
else:
|
9 |
+
from typing_extensions import assert_type
|
10 |
+
|
11 |
+
f: float
|
12 |
+
f8: np.float64
|
13 |
+
c8: np.complex64
|
14 |
+
|
15 |
+
i: int
|
16 |
+
i8: np.int64
|
17 |
+
u4: np.uint32
|
18 |
+
|
19 |
+
finfo_f8: np.finfo[np.float64]
|
20 |
+
iinfo_i8: np.iinfo[np.int64]
|
21 |
+
|
22 |
+
assert_type(np.finfo(f), np.finfo[np.double])
|
23 |
+
assert_type(np.finfo(f8), np.finfo[np.float64])
|
24 |
+
assert_type(np.finfo(c8), np.finfo[np.float32])
|
25 |
+
assert_type(np.finfo('f2'), np.finfo[np.floating[Any]])
|
26 |
+
|
27 |
+
assert_type(finfo_f8.dtype, np.dtype[np.float64])
|
28 |
+
assert_type(finfo_f8.bits, int)
|
29 |
+
assert_type(finfo_f8.eps, np.float64)
|
30 |
+
assert_type(finfo_f8.epsneg, np.float64)
|
31 |
+
assert_type(finfo_f8.iexp, int)
|
32 |
+
assert_type(finfo_f8.machep, int)
|
33 |
+
assert_type(finfo_f8.max, np.float64)
|
34 |
+
assert_type(finfo_f8.maxexp, int)
|
35 |
+
assert_type(finfo_f8.min, np.float64)
|
36 |
+
assert_type(finfo_f8.minexp, int)
|
37 |
+
assert_type(finfo_f8.negep, int)
|
38 |
+
assert_type(finfo_f8.nexp, int)
|
39 |
+
assert_type(finfo_f8.nmant, int)
|
40 |
+
assert_type(finfo_f8.precision, int)
|
41 |
+
assert_type(finfo_f8.resolution, np.float64)
|
42 |
+
assert_type(finfo_f8.tiny, np.float64)
|
43 |
+
assert_type(finfo_f8.smallest_normal, np.float64)
|
44 |
+
assert_type(finfo_f8.smallest_subnormal, np.float64)
|
45 |
+
|
46 |
+
assert_type(np.iinfo(i), np.iinfo[np.int_])
|
47 |
+
assert_type(np.iinfo(i8), np.iinfo[np.int64])
|
48 |
+
assert_type(np.iinfo(u4), np.iinfo[np.uint32])
|
49 |
+
assert_type(np.iinfo('i2'), np.iinfo[Any])
|
50 |
+
|
51 |
+
assert_type(iinfo_i8.dtype, np.dtype[np.int64])
|
52 |
+
assert_type(iinfo_i8.kind, str)
|
53 |
+
assert_type(iinfo_i8.bits, int)
|
54 |
+
assert_type(iinfo_i8.key, str)
|
55 |
+
assert_type(iinfo_i8.min, int)
|
56 |
+
assert_type(iinfo_i8.max, int)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/histograms.pyi
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_i8: npt.NDArray[np.int64]
|
13 |
+
AR_f8: npt.NDArray[np.float64]
|
14 |
+
|
15 |
+
assert_type(np.histogram_bin_edges(AR_i8, bins="auto"), npt.NDArray[Any])
|
16 |
+
assert_type(np.histogram_bin_edges(AR_i8, bins="rice", range=(0, 3)), npt.NDArray[Any])
|
17 |
+
assert_type(np.histogram_bin_edges(AR_i8, bins="scott", weights=AR_f8), npt.NDArray[Any])
|
18 |
+
|
19 |
+
assert_type(np.histogram(AR_i8, bins="auto"), tuple[npt.NDArray[Any], npt.NDArray[Any]])
|
20 |
+
assert_type(np.histogram(AR_i8, bins="rice", range=(0, 3)), tuple[npt.NDArray[Any], npt.NDArray[Any]])
|
21 |
+
assert_type(np.histogram(AR_i8, bins="scott", weights=AR_f8), tuple[npt.NDArray[Any], npt.NDArray[Any]])
|
22 |
+
assert_type(np.histogram(AR_f8, bins=1, density=True), tuple[npt.NDArray[Any], npt.NDArray[Any]])
|
23 |
+
|
24 |
+
assert_type(np.histogramdd(AR_i8, bins=[1]), tuple[npt.NDArray[Any], list[npt.NDArray[Any]]])
|
25 |
+
assert_type(np.histogramdd(AR_i8, range=[(0, 3)]), tuple[npt.NDArray[Any], list[npt.NDArray[Any]]])
|
26 |
+
assert_type(np.histogramdd(AR_i8, weights=AR_f8), tuple[npt.NDArray[Any], list[npt.NDArray[Any]]])
|
27 |
+
assert_type(np.histogramdd(AR_f8, density=True), tuple[npt.NDArray[Any], list[npt.NDArray[Any]]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/index_tricks.pyi
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any, Literal
|
3 |
+
|
4 |
+
import numpy as np
|
5 |
+
import numpy.typing as npt
|
6 |
+
|
7 |
+
if sys.version_info >= (3, 11):
|
8 |
+
from typing import assert_type
|
9 |
+
else:
|
10 |
+
from typing_extensions import assert_type
|
11 |
+
|
12 |
+
AR_LIKE_b: list[bool]
|
13 |
+
AR_LIKE_i: list[int]
|
14 |
+
AR_LIKE_f: list[float]
|
15 |
+
AR_LIKE_U: list[str]
|
16 |
+
|
17 |
+
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
|
18 |
+
|
19 |
+
assert_type(np.ndenumerate(AR_i8), np.ndenumerate[np.int64])
|
20 |
+
assert_type(np.ndenumerate(AR_LIKE_f), np.ndenumerate[np.float64])
|
21 |
+
assert_type(np.ndenumerate(AR_LIKE_U), np.ndenumerate[np.str_])
|
22 |
+
|
23 |
+
assert_type(np.ndenumerate(AR_i8).iter, np.flatiter[npt.NDArray[np.int64]])
|
24 |
+
assert_type(np.ndenumerate(AR_LIKE_f).iter, np.flatiter[npt.NDArray[np.float64]])
|
25 |
+
assert_type(np.ndenumerate(AR_LIKE_U).iter, np.flatiter[npt.NDArray[np.str_]])
|
26 |
+
|
27 |
+
assert_type(next(np.ndenumerate(AR_i8)), tuple[tuple[int, ...], np.int64])
|
28 |
+
assert_type(next(np.ndenumerate(AR_LIKE_f)), tuple[tuple[int, ...], np.float64])
|
29 |
+
assert_type(next(np.ndenumerate(AR_LIKE_U)), tuple[tuple[int, ...], np.str_])
|
30 |
+
|
31 |
+
assert_type(iter(np.ndenumerate(AR_i8)), np.ndenumerate[np.int64])
|
32 |
+
assert_type(iter(np.ndenumerate(AR_LIKE_f)), np.ndenumerate[np.float64])
|
33 |
+
assert_type(iter(np.ndenumerate(AR_LIKE_U)), np.ndenumerate[np.str_])
|
34 |
+
|
35 |
+
assert_type(np.ndindex(1, 2, 3), np.ndindex)
|
36 |
+
assert_type(np.ndindex((1, 2, 3)), np.ndindex)
|
37 |
+
assert_type(iter(np.ndindex(1, 2, 3)), np.ndindex)
|
38 |
+
assert_type(next(np.ndindex(1, 2, 3)), tuple[int, ...])
|
39 |
+
|
40 |
+
assert_type(np.unravel_index([22, 41, 37], (7, 6)), tuple[npt.NDArray[np.intp], ...])
|
41 |
+
assert_type(np.unravel_index([31, 41, 13], (7, 6), order="F"), tuple[npt.NDArray[np.intp], ...])
|
42 |
+
assert_type(np.unravel_index(1621, (6, 7, 8, 9)), tuple[np.intp, ...])
|
43 |
+
|
44 |
+
assert_type(np.ravel_multi_index([[1]], (7, 6)), npt.NDArray[np.intp])
|
45 |
+
assert_type(np.ravel_multi_index(AR_LIKE_i, (7, 6)), np.intp)
|
46 |
+
assert_type(np.ravel_multi_index(AR_LIKE_i, (7, 6), order="F"), np.intp)
|
47 |
+
assert_type(np.ravel_multi_index(AR_LIKE_i, (4, 6), mode="clip"), np.intp)
|
48 |
+
assert_type(np.ravel_multi_index(AR_LIKE_i, (4, 4), mode=("clip", "wrap")), np.intp)
|
49 |
+
assert_type(np.ravel_multi_index((3, 1, 4, 1), (6, 7, 8, 9)), np.intp)
|
50 |
+
|
51 |
+
assert_type(np.mgrid[1:1:2], npt.NDArray[Any])
|
52 |
+
assert_type(np.mgrid[1:1:2, None:10], npt.NDArray[Any])
|
53 |
+
|
54 |
+
assert_type(np.ogrid[1:1:2], list[npt.NDArray[Any]])
|
55 |
+
assert_type(np.ogrid[1:1:2, None:10], list[npt.NDArray[Any]])
|
56 |
+
|
57 |
+
assert_type(np.index_exp[0:1], tuple[slice])
|
58 |
+
assert_type(np.index_exp[0:1, None:3], tuple[slice, slice])
|
59 |
+
assert_type(np.index_exp[0, 0:1, ..., [0, 1, 3]], tuple[Literal[0], slice, ellipsis, list[int]])
|
60 |
+
|
61 |
+
assert_type(np.s_[0:1], slice)
|
62 |
+
assert_type(np.s_[0:1, None:3], tuple[slice, slice])
|
63 |
+
assert_type(np.s_[0, 0:1, ..., [0, 1, 3]], tuple[Literal[0], slice, ellipsis, list[int]])
|
64 |
+
|
65 |
+
assert_type(np.ix_(AR_LIKE_b), tuple[npt.NDArray[np.bool_], ...])
|
66 |
+
assert_type(np.ix_(AR_LIKE_i, AR_LIKE_f), tuple[npt.NDArray[np.float64], ...])
|
67 |
+
assert_type(np.ix_(AR_i8), tuple[npt.NDArray[np.int64], ...])
|
68 |
+
|
69 |
+
assert_type(np.fill_diagonal(AR_i8, 5), None)
|
70 |
+
|
71 |
+
assert_type(np.diag_indices(4), tuple[npt.NDArray[np.int_], ...])
|
72 |
+
assert_type(np.diag_indices(2, 3), tuple[npt.NDArray[np.int_], ...])
|
73 |
+
|
74 |
+
assert_type(np.diag_indices_from(AR_i8), tuple[npt.NDArray[np.int_], ...])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_function_base.pyi
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any
|
3 |
+
from collections.abc import Callable
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
vectorized_func: np.vectorize
|
14 |
+
|
15 |
+
f8: np.float64
|
16 |
+
AR_LIKE_f8: list[float]
|
17 |
+
|
18 |
+
AR_i8: npt.NDArray[np.int64]
|
19 |
+
AR_f8: npt.NDArray[np.float64]
|
20 |
+
AR_c16: npt.NDArray[np.complex128]
|
21 |
+
AR_m: npt.NDArray[np.timedelta64]
|
22 |
+
AR_M: npt.NDArray[np.datetime64]
|
23 |
+
AR_O: npt.NDArray[np.object_]
|
24 |
+
AR_b: npt.NDArray[np.bool_]
|
25 |
+
AR_U: npt.NDArray[np.str_]
|
26 |
+
CHAR_AR_U: np.chararray[Any, np.dtype[np.str_]]
|
27 |
+
|
28 |
+
def func(*args: Any, **kwargs: Any) -> Any: ...
|
29 |
+
|
30 |
+
assert_type(vectorized_func.pyfunc, Callable[..., Any])
|
31 |
+
assert_type(vectorized_func.cache, bool)
|
32 |
+
assert_type(vectorized_func.signature, None | str)
|
33 |
+
assert_type(vectorized_func.otypes, None | str)
|
34 |
+
assert_type(vectorized_func.excluded, set[int | str])
|
35 |
+
assert_type(vectorized_func.__doc__, None | str)
|
36 |
+
assert_type(vectorized_func([1]), Any)
|
37 |
+
assert_type(np.vectorize(int), np.vectorize)
|
38 |
+
assert_type(
|
39 |
+
np.vectorize(int, otypes="i", doc="doc", excluded=(), cache=True, signature=None),
|
40 |
+
np.vectorize,
|
41 |
+
)
|
42 |
+
|
43 |
+
assert_type(np.add_newdoc("__main__", "blabla", doc="test doc"), None)
|
44 |
+
assert_type(np.add_newdoc("__main__", "blabla", doc=("meth", "test doc")), None)
|
45 |
+
assert_type(np.add_newdoc("__main__", "blabla", doc=[("meth", "test doc")]), None)
|
46 |
+
|
47 |
+
assert_type(np.rot90(AR_f8, k=2), npt.NDArray[np.float64])
|
48 |
+
assert_type(np.rot90(AR_LIKE_f8, axes=(0, 1)), npt.NDArray[Any])
|
49 |
+
|
50 |
+
assert_type(np.flip(f8), np.float64)
|
51 |
+
assert_type(np.flip(1.0), Any)
|
52 |
+
assert_type(np.flip(AR_f8, axis=(0, 1)), npt.NDArray[np.float64])
|
53 |
+
assert_type(np.flip(AR_LIKE_f8, axis=0), npt.NDArray[Any])
|
54 |
+
|
55 |
+
assert_type(np.iterable(1), bool)
|
56 |
+
assert_type(np.iterable([1]), bool)
|
57 |
+
|
58 |
+
assert_type(np.average(AR_f8), np.floating[Any])
|
59 |
+
assert_type(np.average(AR_f8, weights=AR_c16), np.complexfloating[Any, Any])
|
60 |
+
assert_type(np.average(AR_O), Any)
|
61 |
+
assert_type(np.average(AR_f8, returned=True), tuple[np.floating[Any], np.floating[Any]])
|
62 |
+
assert_type(np.average(AR_f8, weights=AR_c16, returned=True), tuple[np.complexfloating[Any, Any], np.complexfloating[Any, Any]])
|
63 |
+
assert_type(np.average(AR_O, returned=True), tuple[Any, Any])
|
64 |
+
assert_type(np.average(AR_f8, axis=0), Any)
|
65 |
+
assert_type(np.average(AR_f8, axis=0, returned=True), tuple[Any, Any])
|
66 |
+
|
67 |
+
assert_type(np.asarray_chkfinite(AR_f8), npt.NDArray[np.float64])
|
68 |
+
assert_type(np.asarray_chkfinite(AR_LIKE_f8), npt.NDArray[Any])
|
69 |
+
assert_type(np.asarray_chkfinite(AR_f8, dtype=np.float64), npt.NDArray[np.float64])
|
70 |
+
assert_type(np.asarray_chkfinite(AR_f8, dtype=float), npt.NDArray[Any])
|
71 |
+
|
72 |
+
assert_type(np.piecewise(AR_f8, AR_b, [func]), npt.NDArray[np.float64])
|
73 |
+
assert_type(np.piecewise(AR_LIKE_f8, AR_b, [func]), npt.NDArray[Any])
|
74 |
+
|
75 |
+
assert_type(np.select([AR_f8], [AR_f8]), npt.NDArray[Any])
|
76 |
+
|
77 |
+
assert_type(np.copy(AR_LIKE_f8), npt.NDArray[Any])
|
78 |
+
assert_type(np.copy(AR_U), npt.NDArray[np.str_])
|
79 |
+
assert_type(np.copy(CHAR_AR_U), np.ndarray[Any, Any])
|
80 |
+
assert_type(np.copy(CHAR_AR_U, "K", subok=True), np.chararray[Any, np.dtype[np.str_]])
|
81 |
+
assert_type(np.copy(CHAR_AR_U, subok=True), np.chararray[Any, np.dtype[np.str_]])
|
82 |
+
|
83 |
+
assert_type(np.gradient(AR_f8, axis=None), Any)
|
84 |
+
assert_type(np.gradient(AR_LIKE_f8, edge_order=2), Any)
|
85 |
+
|
86 |
+
assert_type(np.diff("bob", n=0), str)
|
87 |
+
assert_type(np.diff(AR_f8, axis=0), npt.NDArray[Any])
|
88 |
+
assert_type(np.diff(AR_LIKE_f8, prepend=1.5), npt.NDArray[Any])
|
89 |
+
|
90 |
+
assert_type(np.angle(f8), np.floating[Any])
|
91 |
+
assert_type(np.angle(AR_f8), npt.NDArray[np.floating[Any]])
|
92 |
+
assert_type(np.angle(AR_c16, deg=True), npt.NDArray[np.floating[Any]])
|
93 |
+
assert_type(np.angle(AR_O), npt.NDArray[np.object_])
|
94 |
+
|
95 |
+
assert_type(np.unwrap(AR_f8), npt.NDArray[np.floating[Any]])
|
96 |
+
assert_type(np.unwrap(AR_O), npt.NDArray[np.object_])
|
97 |
+
|
98 |
+
assert_type(np.sort_complex(AR_f8), npt.NDArray[np.complexfloating[Any, Any]])
|
99 |
+
|
100 |
+
assert_type(np.trim_zeros(AR_f8), npt.NDArray[np.float64])
|
101 |
+
assert_type(np.trim_zeros(AR_LIKE_f8), list[float])
|
102 |
+
|
103 |
+
assert_type(np.extract(AR_i8, AR_f8), npt.NDArray[np.float64])
|
104 |
+
assert_type(np.extract(AR_i8, AR_LIKE_f8), npt.NDArray[Any])
|
105 |
+
|
106 |
+
assert_type(np.place(AR_f8, mask=AR_i8, vals=5.0), None)
|
107 |
+
|
108 |
+
assert_type(np.disp(1, linefeed=True), None)
|
109 |
+
with open("test", "w") as f:
|
110 |
+
assert_type(np.disp("message", device=f), None)
|
111 |
+
|
112 |
+
assert_type(np.cov(AR_f8, bias=True), npt.NDArray[np.floating[Any]])
|
113 |
+
assert_type(np.cov(AR_f8, AR_c16, ddof=1), npt.NDArray[np.complexfloating[Any, Any]])
|
114 |
+
assert_type(np.cov(AR_f8, aweights=AR_f8, dtype=np.float32), npt.NDArray[np.float32])
|
115 |
+
assert_type(np.cov(AR_f8, fweights=AR_f8, dtype=float), npt.NDArray[Any])
|
116 |
+
|
117 |
+
assert_type(np.corrcoef(AR_f8, rowvar=True), npt.NDArray[np.floating[Any]])
|
118 |
+
assert_type(np.corrcoef(AR_f8, AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
119 |
+
assert_type(np.corrcoef(AR_f8, dtype=np.float32), npt.NDArray[np.float32])
|
120 |
+
assert_type(np.corrcoef(AR_f8, dtype=float), npt.NDArray[Any])
|
121 |
+
|
122 |
+
assert_type(np.blackman(5), npt.NDArray[np.floating[Any]])
|
123 |
+
assert_type(np.bartlett(6), npt.NDArray[np.floating[Any]])
|
124 |
+
assert_type(np.hanning(4.5), npt.NDArray[np.floating[Any]])
|
125 |
+
assert_type(np.hamming(0), npt.NDArray[np.floating[Any]])
|
126 |
+
assert_type(np.i0(AR_i8), npt.NDArray[np.floating[Any]])
|
127 |
+
assert_type(np.kaiser(4, 5.9), npt.NDArray[np.floating[Any]])
|
128 |
+
|
129 |
+
assert_type(np.sinc(1.0), np.floating[Any])
|
130 |
+
assert_type(np.sinc(1j), np.complexfloating[Any, Any])
|
131 |
+
assert_type(np.sinc(AR_f8), npt.NDArray[np.floating[Any]])
|
132 |
+
assert_type(np.sinc(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
133 |
+
|
134 |
+
assert_type(np.median(AR_f8, keepdims=False), np.floating[Any])
|
135 |
+
assert_type(np.median(AR_c16, overwrite_input=True), np.complexfloating[Any, Any])
|
136 |
+
assert_type(np.median(AR_m), np.timedelta64)
|
137 |
+
assert_type(np.median(AR_O), Any)
|
138 |
+
assert_type(np.median(AR_f8, keepdims=True), Any)
|
139 |
+
assert_type(np.median(AR_c16, axis=0), Any)
|
140 |
+
assert_type(np.median(AR_LIKE_f8, out=AR_c16), npt.NDArray[np.complex128])
|
141 |
+
|
142 |
+
assert_type(np.add_newdoc_ufunc(np.add, "docstring"), None)
|
143 |
+
|
144 |
+
assert_type(np.percentile(AR_f8, 50), np.floating[Any])
|
145 |
+
assert_type(np.percentile(AR_c16, 50), np.complexfloating[Any, Any])
|
146 |
+
assert_type(np.percentile(AR_m, 50), np.timedelta64)
|
147 |
+
assert_type(np.percentile(AR_M, 50, overwrite_input=True), np.datetime64)
|
148 |
+
assert_type(np.percentile(AR_O, 50), Any)
|
149 |
+
assert_type(np.percentile(AR_f8, [50]), npt.NDArray[np.floating[Any]])
|
150 |
+
assert_type(np.percentile(AR_c16, [50]), npt.NDArray[np.complexfloating[Any, Any]])
|
151 |
+
assert_type(np.percentile(AR_m, [50]), npt.NDArray[np.timedelta64])
|
152 |
+
assert_type(np.percentile(AR_M, [50], method="nearest"), npt.NDArray[np.datetime64])
|
153 |
+
assert_type(np.percentile(AR_O, [50]), npt.NDArray[np.object_])
|
154 |
+
assert_type(np.percentile(AR_f8, [50], keepdims=True), Any)
|
155 |
+
assert_type(np.percentile(AR_f8, [50], axis=[1]), Any)
|
156 |
+
assert_type(np.percentile(AR_f8, [50], out=AR_c16), npt.NDArray[np.complex128])
|
157 |
+
|
158 |
+
assert_type(np.quantile(AR_f8, 0.5), np.floating[Any])
|
159 |
+
assert_type(np.quantile(AR_c16, 0.5), np.complexfloating[Any, Any])
|
160 |
+
assert_type(np.quantile(AR_m, 0.5), np.timedelta64)
|
161 |
+
assert_type(np.quantile(AR_M, 0.5, overwrite_input=True), np.datetime64)
|
162 |
+
assert_type(np.quantile(AR_O, 0.5), Any)
|
163 |
+
assert_type(np.quantile(AR_f8, [0.5]), npt.NDArray[np.floating[Any]])
|
164 |
+
assert_type(np.quantile(AR_c16, [0.5]), npt.NDArray[np.complexfloating[Any, Any]])
|
165 |
+
assert_type(np.quantile(AR_m, [0.5]), npt.NDArray[np.timedelta64])
|
166 |
+
assert_type(np.quantile(AR_M, [0.5], method="nearest"), npt.NDArray[np.datetime64])
|
167 |
+
assert_type(np.quantile(AR_O, [0.5]), npt.NDArray[np.object_])
|
168 |
+
assert_type(np.quantile(AR_f8, [0.5], keepdims=True), Any)
|
169 |
+
assert_type(np.quantile(AR_f8, [0.5], axis=[1]), Any)
|
170 |
+
assert_type(np.quantile(AR_f8, [0.5], out=AR_c16), npt.NDArray[np.complex128])
|
171 |
+
|
172 |
+
assert_type(np.meshgrid(AR_f8, AR_i8, copy=False), list[npt.NDArray[Any]])
|
173 |
+
assert_type(np.meshgrid(AR_f8, AR_i8, AR_c16, indexing="ij"), list[npt.NDArray[Any]])
|
174 |
+
|
175 |
+
assert_type(np.delete(AR_f8, np.s_[:5]), npt.NDArray[np.float64])
|
176 |
+
assert_type(np.delete(AR_LIKE_f8, [0, 4, 9], axis=0), npt.NDArray[Any])
|
177 |
+
|
178 |
+
assert_type(np.insert(AR_f8, np.s_[:5], 5), npt.NDArray[np.float64])
|
179 |
+
assert_type(np.insert(AR_LIKE_f8, [0, 4, 9], [0.5, 9.2, 7], axis=0), npt.NDArray[Any])
|
180 |
+
|
181 |
+
assert_type(np.append(AR_f8, 5), npt.NDArray[Any])
|
182 |
+
assert_type(np.append(AR_LIKE_f8, 1j, axis=0), npt.NDArray[Any])
|
183 |
+
|
184 |
+
assert_type(np.digitize(4.5, [1]), np.intp)
|
185 |
+
assert_type(np.digitize(AR_f8, [1, 2, 3]), npt.NDArray[np.intp])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_polynomial.pyi
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from typing import Any, NoReturn
|
3 |
+
from collections.abc import Iterator
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
|
8 |
+
if sys.version_info >= (3, 11):
|
9 |
+
from typing import assert_type
|
10 |
+
else:
|
11 |
+
from typing_extensions import assert_type
|
12 |
+
|
13 |
+
AR_b: npt.NDArray[np.bool_]
|
14 |
+
AR_u4: npt.NDArray[np.uint32]
|
15 |
+
AR_i8: npt.NDArray[np.int64]
|
16 |
+
AR_f8: npt.NDArray[np.float64]
|
17 |
+
AR_c16: npt.NDArray[np.complex128]
|
18 |
+
AR_O: npt.NDArray[np.object_]
|
19 |
+
|
20 |
+
poly_obj: np.poly1d
|
21 |
+
|
22 |
+
assert_type(poly_obj.variable, str)
|
23 |
+
assert_type(poly_obj.order, int)
|
24 |
+
assert_type(poly_obj.o, int)
|
25 |
+
assert_type(poly_obj.roots, npt.NDArray[Any])
|
26 |
+
assert_type(poly_obj.r, npt.NDArray[Any])
|
27 |
+
assert_type(poly_obj.coeffs, npt.NDArray[Any])
|
28 |
+
assert_type(poly_obj.c, npt.NDArray[Any])
|
29 |
+
assert_type(poly_obj.coef, npt.NDArray[Any])
|
30 |
+
assert_type(poly_obj.coefficients, npt.NDArray[Any])
|
31 |
+
assert_type(poly_obj.__hash__, None)
|
32 |
+
|
33 |
+
assert_type(poly_obj(1), Any)
|
34 |
+
assert_type(poly_obj([1]), npt.NDArray[Any])
|
35 |
+
assert_type(poly_obj(poly_obj), np.poly1d)
|
36 |
+
|
37 |
+
assert_type(len(poly_obj), int)
|
38 |
+
assert_type(-poly_obj, np.poly1d)
|
39 |
+
assert_type(+poly_obj, np.poly1d)
|
40 |
+
|
41 |
+
assert_type(poly_obj * 5, np.poly1d)
|
42 |
+
assert_type(5 * poly_obj, np.poly1d)
|
43 |
+
assert_type(poly_obj + 5, np.poly1d)
|
44 |
+
assert_type(5 + poly_obj, np.poly1d)
|
45 |
+
assert_type(poly_obj - 5, np.poly1d)
|
46 |
+
assert_type(5 - poly_obj, np.poly1d)
|
47 |
+
assert_type(poly_obj**1, np.poly1d)
|
48 |
+
assert_type(poly_obj**1.0, np.poly1d)
|
49 |
+
assert_type(poly_obj / 5, np.poly1d)
|
50 |
+
assert_type(5 / poly_obj, np.poly1d)
|
51 |
+
|
52 |
+
assert_type(poly_obj[0], Any)
|
53 |
+
poly_obj[0] = 5
|
54 |
+
assert_type(iter(poly_obj), Iterator[Any])
|
55 |
+
assert_type(poly_obj.deriv(), np.poly1d)
|
56 |
+
assert_type(poly_obj.integ(), np.poly1d)
|
57 |
+
|
58 |
+
assert_type(np.poly(poly_obj), npt.NDArray[np.floating[Any]])
|
59 |
+
assert_type(np.poly(AR_f8), npt.NDArray[np.floating[Any]])
|
60 |
+
assert_type(np.poly(AR_c16), npt.NDArray[np.floating[Any]])
|
61 |
+
|
62 |
+
assert_type(np.polyint(poly_obj), np.poly1d)
|
63 |
+
assert_type(np.polyint(AR_f8), npt.NDArray[np.floating[Any]])
|
64 |
+
assert_type(np.polyint(AR_f8, k=AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
65 |
+
assert_type(np.polyint(AR_O, m=2), npt.NDArray[np.object_])
|
66 |
+
|
67 |
+
assert_type(np.polyder(poly_obj), np.poly1d)
|
68 |
+
assert_type(np.polyder(AR_f8), npt.NDArray[np.floating[Any]])
|
69 |
+
assert_type(np.polyder(AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
70 |
+
assert_type(np.polyder(AR_O, m=2), npt.NDArray[np.object_])
|
71 |
+
|
72 |
+
assert_type(np.polyfit(AR_f8, AR_f8, 2), npt.NDArray[np.float64])
|
73 |
+
assert_type(
|
74 |
+
np.polyfit(AR_f8, AR_i8, 1, full=True),
|
75 |
+
tuple[
|
76 |
+
npt.NDArray[np.float64],
|
77 |
+
npt.NDArray[np.float64],
|
78 |
+
npt.NDArray[np.int32],
|
79 |
+
npt.NDArray[np.float64],
|
80 |
+
npt.NDArray[np.float64],
|
81 |
+
],
|
82 |
+
)
|
83 |
+
assert_type(
|
84 |
+
np.polyfit(AR_u4, AR_f8, 1.0, cov="unscaled"),
|
85 |
+
tuple[
|
86 |
+
npt.NDArray[np.float64],
|
87 |
+
npt.NDArray[np.float64],
|
88 |
+
],
|
89 |
+
)
|
90 |
+
assert_type(np.polyfit(AR_c16, AR_f8, 2), npt.NDArray[np.complex128])
|
91 |
+
assert_type(
|
92 |
+
np.polyfit(AR_f8, AR_c16, 1, full=True),
|
93 |
+
tuple[
|
94 |
+
npt.NDArray[np.complex128],
|
95 |
+
npt.NDArray[np.float64],
|
96 |
+
npt.NDArray[np.int32],
|
97 |
+
npt.NDArray[np.float64],
|
98 |
+
npt.NDArray[np.float64],
|
99 |
+
],
|
100 |
+
)
|
101 |
+
assert_type(
|
102 |
+
np.polyfit(AR_u4, AR_c16, 1.0, cov=True),
|
103 |
+
tuple[
|
104 |
+
npt.NDArray[np.complex128],
|
105 |
+
npt.NDArray[np.complex128],
|
106 |
+
],
|
107 |
+
)
|
108 |
+
|
109 |
+
assert_type(np.polyval(AR_b, AR_b), npt.NDArray[np.int64])
|
110 |
+
assert_type(np.polyval(AR_u4, AR_b), npt.NDArray[np.unsignedinteger[Any]])
|
111 |
+
assert_type(np.polyval(AR_i8, AR_i8), npt.NDArray[np.signedinteger[Any]])
|
112 |
+
assert_type(np.polyval(AR_f8, AR_i8), npt.NDArray[np.floating[Any]])
|
113 |
+
assert_type(np.polyval(AR_i8, AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
114 |
+
assert_type(np.polyval(AR_O, AR_O), npt.NDArray[np.object_])
|
115 |
+
|
116 |
+
assert_type(np.polyadd(poly_obj, AR_i8), np.poly1d)
|
117 |
+
assert_type(np.polyadd(AR_f8, poly_obj), np.poly1d)
|
118 |
+
assert_type(np.polyadd(AR_b, AR_b), npt.NDArray[np.bool_])
|
119 |
+
assert_type(np.polyadd(AR_u4, AR_b), npt.NDArray[np.unsignedinteger[Any]])
|
120 |
+
assert_type(np.polyadd(AR_i8, AR_i8), npt.NDArray[np.signedinteger[Any]])
|
121 |
+
assert_type(np.polyadd(AR_f8, AR_i8), npt.NDArray[np.floating[Any]])
|
122 |
+
assert_type(np.polyadd(AR_i8, AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
123 |
+
assert_type(np.polyadd(AR_O, AR_O), npt.NDArray[np.object_])
|
124 |
+
|
125 |
+
assert_type(np.polysub(poly_obj, AR_i8), np.poly1d)
|
126 |
+
assert_type(np.polysub(AR_f8, poly_obj), np.poly1d)
|
127 |
+
assert_type(np.polysub(AR_b, AR_b), NoReturn)
|
128 |
+
assert_type(np.polysub(AR_u4, AR_b), npt.NDArray[np.unsignedinteger[Any]])
|
129 |
+
assert_type(np.polysub(AR_i8, AR_i8), npt.NDArray[np.signedinteger[Any]])
|
130 |
+
assert_type(np.polysub(AR_f8, AR_i8), npt.NDArray[np.floating[Any]])
|
131 |
+
assert_type(np.polysub(AR_i8, AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
132 |
+
assert_type(np.polysub(AR_O, AR_O), npt.NDArray[np.object_])
|
133 |
+
|
134 |
+
assert_type(np.polymul(poly_obj, AR_i8), np.poly1d)
|
135 |
+
assert_type(np.polymul(AR_f8, poly_obj), np.poly1d)
|
136 |
+
assert_type(np.polymul(AR_b, AR_b), npt.NDArray[np.bool_])
|
137 |
+
assert_type(np.polymul(AR_u4, AR_b), npt.NDArray[np.unsignedinteger[Any]])
|
138 |
+
assert_type(np.polymul(AR_i8, AR_i8), npt.NDArray[np.signedinteger[Any]])
|
139 |
+
assert_type(np.polymul(AR_f8, AR_i8), npt.NDArray[np.floating[Any]])
|
140 |
+
assert_type(np.polymul(AR_i8, AR_c16), npt.NDArray[np.complexfloating[Any, Any]])
|
141 |
+
assert_type(np.polymul(AR_O, AR_O), npt.NDArray[np.object_])
|
142 |
+
|
143 |
+
assert_type(np.polydiv(poly_obj, AR_i8), tuple[np.poly1d, np.poly1d])
|
144 |
+
assert_type(np.polydiv(AR_f8, poly_obj), tuple[np.poly1d, np.poly1d])
|
145 |
+
assert_type(np.polydiv(AR_b, AR_b), tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]])
|
146 |
+
assert_type(np.polydiv(AR_u4, AR_b), tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]])
|
147 |
+
assert_type(np.polydiv(AR_i8, AR_i8), tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]])
|
148 |
+
assert_type(np.polydiv(AR_f8, AR_i8), tuple[npt.NDArray[np.floating[Any]], npt.NDArray[np.floating[Any]]])
|
149 |
+
assert_type(np.polydiv(AR_i8, AR_c16), tuple[npt.NDArray[np.complexfloating[Any, Any]], npt.NDArray[np.complexfloating[Any, Any]]])
|
150 |
+
assert_type(np.polydiv(AR_O, AR_O), tuple[npt.NDArray[Any], npt.NDArray[Any]])
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_utils.pyi
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from io import StringIO
|
3 |
+
from typing import Any, Protocol
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import numpy.typing as npt
|
7 |
+
from numpy.lib.utils import _Deprecate
|
8 |
+
|
9 |
+
if sys.version_info >= (3, 11):
|
10 |
+
from typing import assert_type
|
11 |
+
else:
|
12 |
+
from typing_extensions import assert_type
|
13 |
+
|
14 |
+
AR: npt.NDArray[np.float64]
|
15 |
+
AR_DICT: dict[str, npt.NDArray[np.float64]]
|
16 |
+
FILE: StringIO
|
17 |
+
|
18 |
+
def func(a: int) -> bool: ...
|
19 |
+
|
20 |
+
class FuncProtocol(Protocol):
|
21 |
+
def __call__(self, a: int) -> bool: ...
|
22 |
+
|
23 |
+
assert_type(np.deprecate(func), FuncProtocol)
|
24 |
+
assert_type(np.deprecate(), _Deprecate)
|
25 |
+
|
26 |
+
assert_type(np.deprecate_with_doc("test"), _Deprecate)
|
27 |
+
assert_type(np.deprecate_with_doc(None), _Deprecate)
|
28 |
+
|
29 |
+
assert_type(np.byte_bounds(AR), tuple[int, int])
|
30 |
+
assert_type(np.byte_bounds(np.float64()), tuple[int, int])
|
31 |
+
|
32 |
+
assert_type(np.who(None), None)
|
33 |
+
assert_type(np.who(AR_DICT), None)
|
34 |
+
|
35 |
+
assert_type(np.info(1, output=FILE), None)
|
36 |
+
|
37 |
+
assert_type(np.source(np.interp, output=FILE), None)
|
38 |
+
|
39 |
+
assert_type(np.lookfor("binary representation", output=FILE), None)
|
40 |
+
|
41 |
+
assert_type(np.safe_eval("1 + 1"), Any)
|
env-llmeval/lib/python3.10/site-packages/numpy/typing/tests/data/reveal/lib_version.pyi
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
|
3 |
+
from numpy.lib import NumpyVersion
|
4 |
+
|
5 |
+
if sys.version_info >= (3, 11):
|
6 |
+
from typing import assert_type
|
7 |
+
else:
|
8 |
+
from typing_extensions import assert_type
|
9 |
+
|
10 |
+
version = NumpyVersion("1.8.0")
|
11 |
+
|
12 |
+
assert_type(version.vstring, str)
|
13 |
+
assert_type(version.version, str)
|
14 |
+
assert_type(version.major, int)
|
15 |
+
assert_type(version.minor, int)
|
16 |
+
assert_type(version.bugfix, int)
|
17 |
+
assert_type(version.pre_release, str)
|
18 |
+
assert_type(version.is_devversion, bool)
|
19 |
+
|
20 |
+
assert_type(version == version, bool)
|
21 |
+
assert_type(version != version, bool)
|
22 |
+
assert_type(version < "1.8.0", bool)
|
23 |
+
assert_type(version <= version, bool)
|
24 |
+
assert_type(version > version, bool)
|
25 |
+
assert_type(version >= "1.8.0", bool)
|