Merging PR_218 openai_rev package with new streamlit chat app
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
b_ = np.bool_()
|
||||
dt = np.datetime64(0, "D")
|
||||
td = np.timedelta64(0, "D")
|
||||
|
||||
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
|
||||
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
||||
|
||||
ANY: Any
|
||||
|
||||
AR_LIKE_b: list[bool]
|
||||
AR_LIKE_u: list[np.uint32]
|
||||
AR_LIKE_i: list[int]
|
||||
AR_LIKE_f: list[float]
|
||||
AR_LIKE_c: list[complex]
|
||||
AR_LIKE_m: list[np.timedelta64]
|
||||
AR_LIKE_M: list[np.datetime64]
|
||||
|
||||
# Array subtraction
|
||||
|
||||
# NOTE: mypys `NoReturn` errors are, unfortunately, not that great
|
||||
_1 = AR_b - AR_LIKE_b # E: Need type annotation
|
||||
_2 = AR_LIKE_b - AR_b # E: Need type annotation
|
||||
AR_i - bytes() # E: No overload variant
|
||||
|
||||
AR_f - AR_LIKE_m # E: Unsupported operand types
|
||||
AR_f - AR_LIKE_M # E: Unsupported operand types
|
||||
AR_c - AR_LIKE_m # E: Unsupported operand types
|
||||
AR_c - AR_LIKE_M # E: Unsupported operand types
|
||||
|
||||
AR_m - AR_LIKE_f # E: Unsupported operand types
|
||||
AR_M - AR_LIKE_f # E: Unsupported operand types
|
||||
AR_m - AR_LIKE_c # E: Unsupported operand types
|
||||
AR_M - AR_LIKE_c # E: Unsupported operand types
|
||||
|
||||
AR_m - AR_LIKE_M # E: Unsupported operand types
|
||||
AR_LIKE_m - AR_M # E: Unsupported operand types
|
||||
|
||||
# array floor division
|
||||
|
||||
AR_M // AR_LIKE_b # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_u # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_i # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_f # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_c # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_m # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_M # E: Unsupported operand types
|
||||
|
||||
AR_b // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_u // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_i // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_f // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_c // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_m // AR_LIKE_M # E: Unsupported operand types
|
||||
AR_M // AR_LIKE_M # E: Unsupported operand types
|
||||
|
||||
_3 = AR_m // AR_LIKE_b # E: Need type annotation
|
||||
AR_m // AR_LIKE_c # E: Unsupported operand types
|
||||
|
||||
AR_b // AR_LIKE_m # E: Unsupported operand types
|
||||
AR_u // AR_LIKE_m # E: Unsupported operand types
|
||||
AR_i // AR_LIKE_m # E: Unsupported operand types
|
||||
AR_f // AR_LIKE_m # E: Unsupported operand types
|
||||
AR_c // AR_LIKE_m # E: Unsupported operand types
|
||||
|
||||
# Array multiplication
|
||||
|
||||
AR_b *= AR_LIKE_u # E: incompatible type
|
||||
AR_b *= AR_LIKE_i # E: incompatible type
|
||||
AR_b *= AR_LIKE_f # E: incompatible type
|
||||
AR_b *= AR_LIKE_c # E: incompatible type
|
||||
AR_b *= AR_LIKE_m # E: incompatible type
|
||||
|
||||
AR_u *= AR_LIKE_i # E: incompatible type
|
||||
AR_u *= AR_LIKE_f # E: incompatible type
|
||||
AR_u *= AR_LIKE_c # E: incompatible type
|
||||
AR_u *= AR_LIKE_m # E: incompatible type
|
||||
|
||||
AR_i *= AR_LIKE_f # E: incompatible type
|
||||
AR_i *= AR_LIKE_c # E: incompatible type
|
||||
AR_i *= AR_LIKE_m # E: incompatible type
|
||||
|
||||
AR_f *= AR_LIKE_c # E: incompatible type
|
||||
AR_f *= AR_LIKE_m # E: incompatible type
|
||||
|
||||
# Array power
|
||||
|
||||
AR_b **= AR_LIKE_b # E: Invalid self argument
|
||||
AR_b **= AR_LIKE_u # E: Invalid self argument
|
||||
AR_b **= AR_LIKE_i # E: Invalid self argument
|
||||
AR_b **= AR_LIKE_f # E: Invalid self argument
|
||||
AR_b **= AR_LIKE_c # E: Invalid self argument
|
||||
|
||||
AR_u **= AR_LIKE_i # E: incompatible type
|
||||
AR_u **= AR_LIKE_f # E: incompatible type
|
||||
AR_u **= AR_LIKE_c # E: incompatible type
|
||||
|
||||
AR_i **= AR_LIKE_f # E: incompatible type
|
||||
AR_i **= AR_LIKE_c # E: incompatible type
|
||||
|
||||
AR_f **= AR_LIKE_c # E: incompatible type
|
||||
|
||||
# Scalars
|
||||
|
||||
b_ - b_ # E: No overload variant
|
||||
|
||||
dt + dt # E: Unsupported operand types
|
||||
td - dt # E: Unsupported operand types
|
||||
td % 1 # E: Unsupported operand types
|
||||
td / dt # E: No overload
|
||||
td % dt # E: Unsupported operand types
|
||||
|
||||
-b_ # E: Unsupported operand type
|
||||
+b_ # E: Unsupported operand type
|
||||
@@ -0,0 +1,33 @@
|
||||
import numpy as np
|
||||
|
||||
a: np.ndarray
|
||||
generator = (i for i in range(10))
|
||||
|
||||
np.require(a, requirements=1) # E: No overload variant
|
||||
np.require(a, requirements="TEST") # E: incompatible type
|
||||
|
||||
np.zeros("test") # E: incompatible type
|
||||
np.zeros() # E: require at least one argument
|
||||
|
||||
np.ones("test") # E: incompatible type
|
||||
np.ones() # E: require at least one argument
|
||||
|
||||
np.array(0, float, True) # E: No overload variant
|
||||
|
||||
np.linspace(None, 'bob') # E: No overload variant
|
||||
np.linspace(0, 2, num=10.0) # E: No overload variant
|
||||
np.linspace(0, 2, endpoint='True') # E: No overload variant
|
||||
np.linspace(0, 2, retstep=b'False') # E: No overload variant
|
||||
np.linspace(0, 2, dtype=0) # E: No overload variant
|
||||
np.linspace(0, 2, axis=None) # E: No overload variant
|
||||
|
||||
np.logspace(None, 'bob') # E: No overload variant
|
||||
np.logspace(0, 2, base=None) # E: No overload variant
|
||||
|
||||
np.geomspace(None, 'bob') # E: No overload variant
|
||||
|
||||
np.stack(generator) # E: No overload variant
|
||||
np.hstack({1, 2}) # E: No overload variant
|
||||
np.vstack(1) # E: No overload variant
|
||||
|
||||
np.array([1], like=1) # E: No overload variant
|
||||
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
from numpy._typing import ArrayLike
|
||||
|
||||
|
||||
class A:
|
||||
pass
|
||||
|
||||
|
||||
x1: ArrayLike = (i for i in range(10)) # E: Incompatible types in assignment
|
||||
x2: ArrayLike = A() # E: Incompatible types in assignment
|
||||
x3: ArrayLike = {1: "foo", 2: "bar"} # E: Incompatible types in assignment
|
||||
|
||||
scalar = np.int64(1)
|
||||
scalar.__array__(dtype=np.float64) # E: No overload variant
|
||||
array = np.array([1])
|
||||
array.__array__(dtype=np.float64) # E: No overload variant
|
||||
@@ -0,0 +1,6 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
|
||||
np.pad(AR_i8, 2, mode="bob") # E: No overload variant
|
||||
@@ -0,0 +1,14 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR: np.ndarray
|
||||
func1: Callable[[Any], str]
|
||||
func2: Callable[[np.integer[Any]], str]
|
||||
|
||||
np.array2string(AR, style=None) # E: Unexpected keyword argument
|
||||
np.array2string(AR, legacy="1.14") # E: incompatible type
|
||||
np.array2string(AR, sign="*") # E: incompatible type
|
||||
np.array2string(AR, floatmode="default") # E: incompatible type
|
||||
np.array2string(AR, formatter={"A": func1}) # E: incompatible type
|
||||
np.array2string(AR, formatter={"float": func2}) # E: Incompatible types
|
||||
@@ -0,0 +1,14 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
|
||||
ar_iter = np.lib.Arrayterator(AR_i8)
|
||||
|
||||
np.lib.Arrayterator(np.int64()) # E: incompatible type
|
||||
ar_iter.shape = (10, 5) # E: is read-only
|
||||
ar_iter[None] # E: Invalid index type
|
||||
ar_iter[None, 1] # E: Invalid index type
|
||||
ar_iter[np.intp()] # E: Invalid index type
|
||||
ar_iter[np.intp(), ...] # E: Invalid index type
|
||||
ar_iter[AR_i8] # E: Invalid index type
|
||||
ar_iter[AR_i8, :] # E: Invalid index type
|
||||
@@ -0,0 +1,20 @@
|
||||
import numpy as np
|
||||
|
||||
i8 = np.int64()
|
||||
i4 = np.int32()
|
||||
u8 = np.uint64()
|
||||
b_ = np.bool_()
|
||||
i = int()
|
||||
|
||||
f8 = np.float64()
|
||||
|
||||
b_ >> f8 # E: No overload variant
|
||||
i8 << f8 # E: No overload variant
|
||||
i | f8 # E: Unsupported operand types
|
||||
i8 ^ f8 # E: No overload variant
|
||||
u8 & f8 # E: No overload variant
|
||||
~f8 # E: Unsupported operand type
|
||||
|
||||
# mypys' error message for `NoReturn` is unfortunately pretty bad
|
||||
# TODO: Re-enable this once we add support for numerical precision for `number`s
|
||||
# a = u8 | 0 # E: Need type annotation
|
||||
@@ -0,0 +1,66 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_U: npt.NDArray[np.str_]
|
||||
AR_S: npt.NDArray[np.bytes_]
|
||||
|
||||
np.char.equal(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.not_equal(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.greater_equal(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.less_equal(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.greater(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.less(AR_U, AR_S) # E: incompatible type
|
||||
|
||||
np.char.encode(AR_S) # E: incompatible type
|
||||
np.char.decode(AR_U) # E: incompatible type
|
||||
|
||||
np.char.join(AR_U, b"_") # E: incompatible type
|
||||
np.char.join(AR_S, "_") # E: incompatible type
|
||||
|
||||
np.char.ljust(AR_U, 5, fillchar=b"a") # E: incompatible type
|
||||
np.char.ljust(AR_S, 5, fillchar="a") # E: incompatible type
|
||||
np.char.rjust(AR_U, 5, fillchar=b"a") # E: incompatible type
|
||||
np.char.rjust(AR_S, 5, fillchar="a") # E: incompatible type
|
||||
|
||||
np.char.lstrip(AR_U, chars=b"a") # E: incompatible type
|
||||
np.char.lstrip(AR_S, chars="a") # E: incompatible type
|
||||
np.char.strip(AR_U, chars=b"a") # E: incompatible type
|
||||
np.char.strip(AR_S, chars="a") # E: incompatible type
|
||||
np.char.rstrip(AR_U, chars=b"a") # E: incompatible type
|
||||
np.char.rstrip(AR_S, chars="a") # E: incompatible type
|
||||
|
||||
np.char.partition(AR_U, b"a") # E: incompatible type
|
||||
np.char.partition(AR_S, "a") # E: incompatible type
|
||||
np.char.rpartition(AR_U, b"a") # E: incompatible type
|
||||
np.char.rpartition(AR_S, "a") # E: incompatible type
|
||||
|
||||
np.char.replace(AR_U, b"_", b"-") # E: incompatible type
|
||||
np.char.replace(AR_S, "_", "-") # E: incompatible type
|
||||
|
||||
np.char.split(AR_U, b"_") # E: incompatible type
|
||||
np.char.split(AR_S, "_") # E: incompatible type
|
||||
np.char.rsplit(AR_U, b"_") # E: incompatible type
|
||||
np.char.rsplit(AR_S, "_") # E: incompatible type
|
||||
|
||||
np.char.count(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.count(AR_S, "a", end=9) # E: incompatible type
|
||||
|
||||
np.char.endswith(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.endswith(AR_S, "a", end=9) # E: incompatible type
|
||||
np.char.startswith(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.startswith(AR_S, "a", end=9) # E: incompatible type
|
||||
|
||||
np.char.find(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.find(AR_S, "a", end=9) # E: incompatible type
|
||||
np.char.rfind(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.rfind(AR_S, "a", end=9) # E: incompatible type
|
||||
|
||||
np.char.index(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.index(AR_S, "a", end=9) # E: incompatible type
|
||||
np.char.rindex(AR_U, b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
np.char.rindex(AR_S, "a", end=9) # E: incompatible type
|
||||
@@ -0,0 +1,62 @@
|
||||
import numpy as np
|
||||
from typing import Any
|
||||
|
||||
AR_U: np.chararray[Any, np.dtype[np.str_]]
|
||||
AR_S: np.chararray[Any, np.dtype[np.bytes_]]
|
||||
|
||||
AR_S.encode() # E: Invalid self argument
|
||||
AR_U.decode() # E: Invalid self argument
|
||||
|
||||
AR_U.join(b"_") # E: incompatible type
|
||||
AR_S.join("_") # E: incompatible type
|
||||
|
||||
AR_U.ljust(5, fillchar=b"a") # E: incompatible type
|
||||
AR_S.ljust(5, fillchar="a") # E: incompatible type
|
||||
AR_U.rjust(5, fillchar=b"a") # E: incompatible type
|
||||
AR_S.rjust(5, fillchar="a") # E: incompatible type
|
||||
|
||||
AR_U.lstrip(chars=b"a") # E: incompatible type
|
||||
AR_S.lstrip(chars="a") # E: incompatible type
|
||||
AR_U.strip(chars=b"a") # E: incompatible type
|
||||
AR_S.strip(chars="a") # E: incompatible type
|
||||
AR_U.rstrip(chars=b"a") # E: incompatible type
|
||||
AR_S.rstrip(chars="a") # E: incompatible type
|
||||
|
||||
AR_U.partition(b"a") # E: incompatible type
|
||||
AR_S.partition("a") # E: incompatible type
|
||||
AR_U.rpartition(b"a") # E: incompatible type
|
||||
AR_S.rpartition("a") # E: incompatible type
|
||||
|
||||
AR_U.replace(b"_", b"-") # E: incompatible type
|
||||
AR_S.replace("_", "-") # E: incompatible type
|
||||
|
||||
AR_U.split(b"_") # E: incompatible type
|
||||
AR_S.split("_") # E: incompatible type
|
||||
AR_S.split(1) # E: incompatible type
|
||||
AR_U.rsplit(b"_") # E: incompatible type
|
||||
AR_S.rsplit("_") # E: incompatible type
|
||||
|
||||
AR_U.count(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.count("a", end=9) # E: incompatible type
|
||||
|
||||
AR_U.endswith(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.endswith("a", end=9) # E: incompatible type
|
||||
AR_U.startswith(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.startswith("a", end=9) # E: incompatible type
|
||||
|
||||
AR_U.find(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.find("a", end=9) # E: incompatible type
|
||||
AR_U.rfind(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.rfind("a", end=9) # E: incompatible type
|
||||
|
||||
AR_U.index(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.index("a", end=9) # E: incompatible type
|
||||
AR_U.rindex(b"a", start=[1, 2, 3]) # E: incompatible type
|
||||
AR_S.rindex("a", end=9) # E: incompatible type
|
||||
|
||||
AR_U == AR_S # E: Unsupported operand types
|
||||
AR_U != AR_S # E: Unsupported operand types
|
||||
AR_U >= AR_S # E: Unsupported operand types
|
||||
AR_U <= AR_S # E: Unsupported operand types
|
||||
AR_U > AR_S # E: Unsupported operand types
|
||||
AR_U < AR_S # E: Unsupported operand types
|
||||
@@ -0,0 +1,27 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
||||
|
||||
AR_f > AR_m # E: Unsupported operand types
|
||||
AR_c > AR_m # E: Unsupported operand types
|
||||
|
||||
AR_m > AR_f # E: Unsupported operand types
|
||||
AR_m > AR_c # E: Unsupported operand types
|
||||
|
||||
AR_i > AR_M # E: Unsupported operand types
|
||||
AR_f > AR_M # E: Unsupported operand types
|
||||
AR_m > AR_M # E: Unsupported operand types
|
||||
|
||||
AR_M > AR_i # E: Unsupported operand types
|
||||
AR_M > AR_f # E: Unsupported operand types
|
||||
AR_M > AR_m # E: Unsupported operand types
|
||||
|
||||
AR_i > str() # E: No overload variant
|
||||
AR_i > bytes() # E: No overload variant
|
||||
str() > AR_M # E: Unsupported operand types
|
||||
bytes() > AR_M # E: Unsupported operand types
|
||||
@@ -0,0 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
np.Inf = np.Inf # E: Cannot assign to final
|
||||
np.ALLOW_THREADS = np.ALLOW_THREADS # E: Cannot assign to final
|
||||
np.little_endian = np.little_endian # E: Cannot assign to final
|
||||
np.UFUNC_PYVALS_NAME = "bob" # E: Incompatible types
|
||||
np.CLIP = 2 # E: Incompatible types
|
||||
@@ -0,0 +1,15 @@
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
|
||||
path: Path
|
||||
d1: np.DataSource
|
||||
|
||||
d1.abspath(path) # E: incompatible type
|
||||
d1.abspath(b"...") # E: incompatible type
|
||||
|
||||
d1.exists(path) # E: incompatible type
|
||||
d1.exists(b"...") # E: incompatible type
|
||||
|
||||
d1.open(path, "r") # E: incompatible type
|
||||
d1.open(b"...", encoding="utf8") # E: incompatible type
|
||||
d1.open(None, newline="/n") # E: incompatible type
|
||||
@@ -0,0 +1,20 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Test1:
|
||||
not_dtype = np.dtype(float)
|
||||
|
||||
|
||||
class Test2:
|
||||
dtype = float
|
||||
|
||||
|
||||
np.dtype(Test1()) # E: No overload variant of "dtype" matches
|
||||
np.dtype(Test2()) # E: incompatible type
|
||||
|
||||
np.dtype( # E: No overload variant of "dtype" matches
|
||||
{
|
||||
"field1": (float, 1),
|
||||
"field2": (int, 3),
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
||||
AR_O: np.ndarray[Any, np.dtype[np.object_]]
|
||||
AR_U: np.ndarray[Any, np.dtype[np.str_]]
|
||||
|
||||
np.einsum("i,i->i", AR_i, AR_m) # E: incompatible type
|
||||
np.einsum("i,i->i", AR_O, AR_O) # E: incompatible type
|
||||
np.einsum("i,i->i", AR_f, AR_f, dtype=np.int32) # E: incompatible type
|
||||
np.einsum("i,i->i", AR_i, AR_i, dtype=np.timedelta64, casting="unsafe") # E: No overload variant
|
||||
np.einsum("i,i->i", AR_i, AR_i, out=AR_U) # E: Value of type variable "_ArrayType" of "einsum" cannot be
|
||||
np.einsum("i,i->i", AR_i, AR_i, out=AR_U, casting="unsafe") # E: No overload variant
|
||||
@@ -0,0 +1,11 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
|
||||
# NOTE: Mypy bug presumably due to the special-casing of heterogeneous tuples;
|
||||
# xref numpy/numpy#20901
|
||||
#
|
||||
# The expected output should be no different than, e.g., when using a
|
||||
# list instead of a tuple
|
||||
np.concatenate(([1], AR_f8)) # E: Argument 1 to "concatenate" has incompatible type
|
||||
@@ -0,0 +1,25 @@
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
from numpy._typing import _SupportsArray
|
||||
|
||||
|
||||
class Index:
|
||||
def __index__(self) -> int:
|
||||
...
|
||||
|
||||
|
||||
a: "np.flatiter[np.ndarray]"
|
||||
supports_array: _SupportsArray
|
||||
|
||||
a.base = Any # E: Property "base" defined in "flatiter" is read-only
|
||||
a.coords = Any # E: Property "coords" defined in "flatiter" is read-only
|
||||
a.index = Any # E: Property "index" defined in "flatiter" is read-only
|
||||
a.copy(order='C') # E: Unexpected keyword argument
|
||||
|
||||
# NOTE: Contrary to `ndarray.__getitem__` its counterpart in `flatiter`
|
||||
# does not accept objects with the `__array__` or `__index__` protocols;
|
||||
# boolean indexing is just plain broken (gh-17175)
|
||||
a[np.bool_()] # E: No overload variant of "__getitem__"
|
||||
a[Index()] # E: No overload variant of "__getitem__"
|
||||
a[supports_array] # E: No overload variant of "__getitem__"
|
||||
@@ -0,0 +1,161 @@
|
||||
"""Tests for :mod:`numpy.core.fromnumeric`."""
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
A = np.array(True, ndmin=2, dtype=bool)
|
||||
A.setflags(write=False)
|
||||
AR_U: npt.NDArray[np.str_]
|
||||
|
||||
a = np.bool_(True)
|
||||
|
||||
np.take(a, None) # E: No overload variant
|
||||
np.take(a, axis=1.0) # E: No overload variant
|
||||
np.take(A, out=1) # E: No overload variant
|
||||
np.take(A, mode="bob") # E: No overload variant
|
||||
|
||||
np.reshape(a, None) # E: No overload variant
|
||||
np.reshape(A, 1, order="bob") # E: No overload variant
|
||||
|
||||
np.choose(a, None) # E: No overload variant
|
||||
np.choose(a, out=1.0) # E: No overload variant
|
||||
np.choose(A, mode="bob") # E: No overload variant
|
||||
|
||||
np.repeat(a, None) # E: No overload variant
|
||||
np.repeat(A, 1, axis=1.0) # E: No overload variant
|
||||
|
||||
np.swapaxes(A, None, 1) # E: No overload variant
|
||||
np.swapaxes(A, 1, [0]) # E: No overload variant
|
||||
|
||||
np.transpose(A, axes=1.0) # E: No overload variant
|
||||
|
||||
np.partition(a, None) # E: No overload variant
|
||||
np.partition( # E: No overload variant
|
||||
a, 0, axis="bob"
|
||||
)
|
||||
np.partition( # E: No overload variant
|
||||
A, 0, kind="bob"
|
||||
)
|
||||
np.partition(
|
||||
A, 0, order=range(5) # E: Argument "order" to "partition" has incompatible type
|
||||
)
|
||||
|
||||
np.argpartition(
|
||||
a, None # E: incompatible type
|
||||
)
|
||||
np.argpartition(
|
||||
a, 0, axis="bob" # E: incompatible type
|
||||
)
|
||||
np.argpartition(
|
||||
A, 0, kind="bob" # E: incompatible type
|
||||
)
|
||||
np.argpartition(
|
||||
A, 0, order=range(5) # E: Argument "order" to "argpartition" has incompatible type
|
||||
)
|
||||
|
||||
np.sort(A, axis="bob") # E: No overload variant
|
||||
np.sort(A, kind="bob") # E: No overload variant
|
||||
np.sort(A, order=range(5)) # E: Argument "order" to "sort" has incompatible type
|
||||
|
||||
np.argsort(A, axis="bob") # E: Argument "axis" to "argsort" has incompatible type
|
||||
np.argsort(A, kind="bob") # E: Argument "kind" to "argsort" has incompatible type
|
||||
np.argsort(A, order=range(5)) # E: Argument "order" to "argsort" has incompatible type
|
||||
|
||||
np.argmax(A, axis="bob") # E: No overload variant of "argmax" matches argument type
|
||||
np.argmax(A, kind="bob") # E: No overload variant of "argmax" matches argument type
|
||||
|
||||
np.argmin(A, axis="bob") # E: No overload variant of "argmin" matches argument type
|
||||
np.argmin(A, kind="bob") # E: No overload variant of "argmin" matches argument type
|
||||
|
||||
np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
|
||||
A[0], 0, side="bob"
|
||||
)
|
||||
np.searchsorted( # E: No overload variant of "searchsorted" matches argument type
|
||||
A[0], 0, sorter=1.0
|
||||
)
|
||||
|
||||
np.resize(A, 1.0) # E: No overload variant
|
||||
|
||||
np.squeeze(A, 1.0) # E: No overload variant of "squeeze" matches argument type
|
||||
|
||||
np.diagonal(A, offset=None) # E: No overload variant
|
||||
np.diagonal(A, axis1="bob") # E: No overload variant
|
||||
np.diagonal(A, axis2=[]) # E: No overload variant
|
||||
|
||||
np.trace(A, offset=None) # E: No overload variant
|
||||
np.trace(A, axis1="bob") # E: No overload variant
|
||||
np.trace(A, axis2=[]) # E: No overload variant
|
||||
|
||||
np.ravel(a, order="bob") # E: No overload variant
|
||||
|
||||
np.compress( # E: No overload variant
|
||||
[True], A, axis=1.0
|
||||
)
|
||||
|
||||
np.clip(a, 1, 2, out=1) # E: No overload variant of "clip" matches argument type
|
||||
|
||||
np.sum(a, axis=1.0) # E: No overload variant
|
||||
np.sum(a, keepdims=1.0) # E: No overload variant
|
||||
np.sum(a, initial=[1]) # E: No overload variant
|
||||
|
||||
np.all(a, axis=1.0) # E: No overload variant
|
||||
np.all(a, keepdims=1.0) # E: No overload variant
|
||||
np.all(a, out=1.0) # E: No overload variant
|
||||
|
||||
np.any(a, axis=1.0) # E: No overload variant
|
||||
np.any(a, keepdims=1.0) # E: No overload variant
|
||||
np.any(a, out=1.0) # E: No overload variant
|
||||
|
||||
np.cumsum(a, axis=1.0) # E: No overload variant
|
||||
np.cumsum(a, dtype=1.0) # E: No overload variant
|
||||
np.cumsum(a, out=1.0) # E: No overload variant
|
||||
|
||||
np.ptp(a, axis=1.0) # E: No overload variant
|
||||
np.ptp(a, keepdims=1.0) # E: No overload variant
|
||||
np.ptp(a, out=1.0) # E: No overload variant
|
||||
|
||||
np.amax(a, axis=1.0) # E: No overload variant
|
||||
np.amax(a, keepdims=1.0) # E: No overload variant
|
||||
np.amax(a, out=1.0) # E: No overload variant
|
||||
np.amax(a, initial=[1.0]) # E: No overload variant
|
||||
np.amax(a, where=[1.0]) # E: incompatible type
|
||||
|
||||
np.amin(a, axis=1.0) # E: No overload variant
|
||||
np.amin(a, keepdims=1.0) # E: No overload variant
|
||||
np.amin(a, out=1.0) # E: No overload variant
|
||||
np.amin(a, initial=[1.0]) # E: No overload variant
|
||||
np.amin(a, where=[1.0]) # E: incompatible type
|
||||
|
||||
np.prod(a, axis=1.0) # E: No overload variant
|
||||
np.prod(a, out=False) # E: No overload variant
|
||||
np.prod(a, keepdims=1.0) # E: No overload variant
|
||||
np.prod(a, initial=int) # E: No overload variant
|
||||
np.prod(a, where=1.0) # E: No overload variant
|
||||
np.prod(AR_U) # E: incompatible type
|
||||
|
||||
np.cumprod(a, axis=1.0) # E: No overload variant
|
||||
np.cumprod(a, out=False) # E: No overload variant
|
||||
np.cumprod(AR_U) # E: incompatible type
|
||||
|
||||
np.size(a, axis=1.0) # E: Argument "axis" to "size" has incompatible type
|
||||
|
||||
np.around(a, decimals=1.0) # E: No overload variant
|
||||
np.around(a, out=type) # E: No overload variant
|
||||
np.around(AR_U) # E: incompatible type
|
||||
|
||||
np.mean(a, axis=1.0) # E: No overload variant
|
||||
np.mean(a, out=False) # E: No overload variant
|
||||
np.mean(a, keepdims=1.0) # E: No overload variant
|
||||
np.mean(AR_U) # E: incompatible type
|
||||
|
||||
np.std(a, axis=1.0) # E: No overload variant
|
||||
np.std(a, out=False) # E: No overload variant
|
||||
np.std(a, ddof='test') # E: No overload variant
|
||||
np.std(a, keepdims=1.0) # E: No overload variant
|
||||
np.std(AR_U) # E: incompatible type
|
||||
|
||||
np.var(a, axis=1.0) # E: No overload variant
|
||||
np.var(a, out=False) # E: No overload variant
|
||||
np.var(a, ddof='test') # E: No overload variant
|
||||
np.var(a, keepdims=1.0) # E: No overload variant
|
||||
np.var(AR_U) # E: incompatible type
|
||||
@@ -0,0 +1,12 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
|
||||
np.histogram_bin_edges(AR_i8, range=(0, 1, 2)) # E: incompatible type
|
||||
|
||||
np.histogram(AR_i8, range=(0, 1, 2)) # E: incompatible type
|
||||
|
||||
np.histogramdd(AR_i8, range=(0, 1)) # E: incompatible type
|
||||
np.histogramdd(AR_i8, range=[(0, 1, 2)]) # E: incompatible type
|
||||
@@ -0,0 +1,14 @@
|
||||
import numpy as np
|
||||
|
||||
AR_LIKE_i: list[int]
|
||||
AR_LIKE_f: list[float]
|
||||
|
||||
np.ndindex([1, 2, 3]) # E: No overload variant
|
||||
np.unravel_index(AR_LIKE_f, (1, 2, 3)) # E: incompatible type
|
||||
np.ravel_multi_index(AR_LIKE_i, (1, 2, 3), mode="bob") # E: No overload variant
|
||||
np.mgrid[1] # E: Invalid index type
|
||||
np.mgrid[...] # E: Invalid index type
|
||||
np.ogrid[1] # E: Invalid index type
|
||||
np.ogrid[...] # E: Invalid index type
|
||||
np.fill_diagonal(AR_LIKE_f, 2) # E: incompatible type
|
||||
np.diag_indices(1.0) # E: incompatible type
|
||||
@@ -0,0 +1,53 @@
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_c16: npt.NDArray[np.complex128]
|
||||
AR_m: npt.NDArray[np.timedelta64]
|
||||
AR_M: npt.NDArray[np.datetime64]
|
||||
AR_O: npt.NDArray[np.object_]
|
||||
|
||||
def func(a: int) -> None: ...
|
||||
|
||||
np.average(AR_m) # E: incompatible type
|
||||
np.select(1, [AR_f8]) # E: incompatible type
|
||||
np.angle(AR_m) # E: incompatible type
|
||||
np.unwrap(AR_m) # E: incompatible type
|
||||
np.unwrap(AR_c16) # E: incompatible type
|
||||
np.trim_zeros(1) # E: incompatible type
|
||||
np.place(1, [True], 1.5) # E: incompatible type
|
||||
np.vectorize(1) # E: incompatible type
|
||||
np.add_newdoc("__main__", 1.5, "docstring") # E: incompatible type
|
||||
np.place(AR_f8, slice(None), 5) # E: incompatible type
|
||||
|
||||
np.interp(AR_f8, AR_c16, AR_f8) # E: incompatible type
|
||||
np.interp(AR_c16, AR_f8, AR_f8) # E: incompatible type
|
||||
np.interp(AR_f8, AR_f8, AR_f8, period=AR_c16) # E: No overload variant
|
||||
np.interp(AR_f8, AR_f8, AR_O) # E: incompatible type
|
||||
|
||||
np.cov(AR_m) # E: incompatible type
|
||||
np.cov(AR_O) # E: incompatible type
|
||||
np.corrcoef(AR_m) # E: incompatible type
|
||||
np.corrcoef(AR_O) # E: incompatible type
|
||||
np.corrcoef(AR_f8, bias=True) # E: No overload variant
|
||||
np.corrcoef(AR_f8, ddof=2) # E: No overload variant
|
||||
np.blackman(1j) # E: incompatible type
|
||||
np.bartlett(1j) # E: incompatible type
|
||||
np.hanning(1j) # E: incompatible type
|
||||
np.hamming(1j) # E: incompatible type
|
||||
np.hamming(AR_c16) # E: incompatible type
|
||||
np.kaiser(1j, 1) # E: incompatible type
|
||||
np.sinc(AR_O) # E: incompatible type
|
||||
np.median(AR_M) # E: incompatible type
|
||||
|
||||
np.add_newdoc_ufunc(func, "docstring") # E: incompatible type
|
||||
np.percentile(AR_f8, 50j) # E: No overload variant
|
||||
np.percentile(AR_f8, 50, interpolation="bob") # E: No overload variant
|
||||
np.quantile(AR_f8, 0.5j) # E: No overload variant
|
||||
np.quantile(AR_f8, 0.5, interpolation="bob") # E: No overload variant
|
||||
np.meshgrid(AR_f8, AR_f8, indexing="bob") # E: incompatible type
|
||||
np.delete(AR_f8, AR_f8) # E: incompatible type
|
||||
np.insert(AR_f8, AR_f8, 1.5) # E: incompatible type
|
||||
np.digitize(AR_f8, 1j) # E: No overload variant
|
||||
@@ -0,0 +1,29 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_c16: npt.NDArray[np.complex128]
|
||||
AR_O: npt.NDArray[np.object_]
|
||||
AR_U: npt.NDArray[np.str_]
|
||||
|
||||
poly_obj: np.poly1d
|
||||
|
||||
np.polyint(AR_U) # E: incompatible type
|
||||
np.polyint(AR_f8, m=1j) # E: No overload variant
|
||||
|
||||
np.polyder(AR_U) # E: incompatible type
|
||||
np.polyder(AR_f8, m=1j) # E: No overload variant
|
||||
|
||||
np.polyfit(AR_O, AR_f8, 1) # E: incompatible type
|
||||
np.polyfit(AR_f8, AR_f8, 1, rcond=1j) # E: No overload variant
|
||||
np.polyfit(AR_f8, AR_f8, 1, w=AR_c16) # E: incompatible type
|
||||
np.polyfit(AR_f8, AR_f8, 1, cov="bob") # E: No overload variant
|
||||
|
||||
np.polyval(AR_f8, AR_U) # E: incompatible type
|
||||
np.polyadd(AR_f8, AR_U) # E: incompatible type
|
||||
np.polysub(AR_f8, AR_U) # E: incompatible type
|
||||
np.polymul(AR_f8, AR_U) # E: incompatible type
|
||||
np.polydiv(AR_f8, AR_U) # E: incompatible type
|
||||
|
||||
5**poly_obj # E: No overload variant
|
||||
hash(poly_obj)
|
||||
@@ -0,0 +1,13 @@
|
||||
import numpy as np
|
||||
|
||||
np.deprecate(1) # E: No overload variant
|
||||
|
||||
np.deprecate_with_doc(1) # E: incompatible type
|
||||
|
||||
np.byte_bounds(1) # E: incompatible type
|
||||
|
||||
np.who(1) # E: incompatible type
|
||||
|
||||
np.lookfor(None) # E: incompatible type
|
||||
|
||||
np.safe_eval(None) # E: incompatible type
|
||||
@@ -0,0 +1,6 @@
|
||||
from numpy.lib import NumpyVersion
|
||||
|
||||
version: NumpyVersion
|
||||
|
||||
NumpyVersion(b"1.8.0") # E: incompatible type
|
||||
version >= b"1.8.0" # E: Unsupported operand types
|
||||
@@ -0,0 +1,48 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_O: npt.NDArray[np.object_]
|
||||
AR_M: npt.NDArray[np.datetime64]
|
||||
|
||||
np.linalg.tensorsolve(AR_O, AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.solve(AR_O, AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.tensorinv(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.inv(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.matrix_power(AR_M, 5) # E: incompatible type
|
||||
|
||||
np.linalg.cholesky(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.qr(AR_O) # E: incompatible type
|
||||
np.linalg.qr(AR_f8, mode="bob") # E: No overload variant
|
||||
|
||||
np.linalg.eigvals(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.eigvalsh(AR_O) # E: incompatible type
|
||||
np.linalg.eigvalsh(AR_O, UPLO="bob") # E: No overload variant
|
||||
|
||||
np.linalg.eig(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.eigh(AR_O) # E: incompatible type
|
||||
np.linalg.eigh(AR_O, UPLO="bob") # E: No overload variant
|
||||
|
||||
np.linalg.svd(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.cond(AR_O) # E: incompatible type
|
||||
np.linalg.cond(AR_f8, p="bob") # E: incompatible type
|
||||
|
||||
np.linalg.matrix_rank(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.pinv(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.slogdet(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.det(AR_O) # E: incompatible type
|
||||
|
||||
np.linalg.norm(AR_f8, ord="bob") # E: No overload variant
|
||||
|
||||
np.linalg.multi_dot([AR_M]) # E: incompatible type
|
||||
@@ -0,0 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
with open("file.txt", "r") as f:
|
||||
np.memmap(f) # E: No overload variant
|
||||
np.memmap("test.txt", shape=[10, 5]) # E: No overload variant
|
||||
@@ -0,0 +1,18 @@
|
||||
import numpy as np
|
||||
|
||||
np.testing.bob # E: Module has no attribute
|
||||
np.bob # E: Module has no attribute
|
||||
|
||||
# Stdlib modules in the namespace by accident
|
||||
np.warnings # E: Module has no attribute
|
||||
np.sys # E: Module has no attribute
|
||||
np.os # E: Module has no attribute
|
||||
np.math # E: Module has no attribute
|
||||
|
||||
# Public sub-modules that are not imported to their parent module by default;
|
||||
# e.g. one must first execute `import numpy.lib.recfunctions`
|
||||
np.lib.recfunctions # E: Module has no attribute
|
||||
|
||||
np.__NUMPY_SETUP__ # E: Module has no attribute
|
||||
np.__deprecated_attrs__ # E: Module has no attribute
|
||||
np.__expired_functions__ # E: Module has no attribute
|
||||
@@ -0,0 +1,55 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
i8: np.int64
|
||||
|
||||
AR_b: npt.NDArray[np.bool_]
|
||||
AR_u1: npt.NDArray[np.uint8]
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_M: npt.NDArray[np.datetime64]
|
||||
|
||||
M: np.datetime64
|
||||
|
||||
AR_LIKE_f: list[float]
|
||||
|
||||
def func(a: int) -> None: ...
|
||||
|
||||
np.where(AR_b, 1) # E: No overload variant
|
||||
|
||||
np.can_cast(AR_f8, 1) # E: incompatible type
|
||||
|
||||
np.vdot(AR_M, AR_M) # E: incompatible type
|
||||
|
||||
np.copyto(AR_LIKE_f, AR_f8) # E: incompatible type
|
||||
|
||||
np.putmask(AR_LIKE_f, [True, True, False], 1.5) # E: incompatible type
|
||||
|
||||
np.packbits(AR_f8) # E: incompatible type
|
||||
np.packbits(AR_u1, bitorder=">") # E: incompatible type
|
||||
|
||||
np.unpackbits(AR_i8) # E: incompatible type
|
||||
np.unpackbits(AR_u1, bitorder=">") # E: incompatible type
|
||||
|
||||
np.shares_memory(1, 1, max_work=i8) # E: incompatible type
|
||||
np.may_share_memory(1, 1, max_work=i8) # E: incompatible type
|
||||
|
||||
np.arange(M) # E: No overload variant
|
||||
np.arange(stop=10) # E: No overload variant
|
||||
|
||||
np.datetime_data(int) # E: incompatible type
|
||||
|
||||
np.busday_offset("2012", 10) # E: No overload variant
|
||||
|
||||
np.datetime_as_string("2012") # E: No overload variant
|
||||
|
||||
np.compare_chararrays("a", b"a", "==", False) # E: No overload variant
|
||||
|
||||
np.add_docstring(func, None) # E: incompatible type
|
||||
|
||||
np.nested_iters([AR_i8, AR_i8]) # E: Missing positional argument
|
||||
np.nested_iters([AR_i8, AR_i8], 0) # E: incompatible type
|
||||
np.nested_iters([AR_i8, AR_i8], [0]) # E: incompatible type
|
||||
np.nested_iters([AR_i8, AR_i8], [[0], [1]], flags=["test"]) # E: incompatible type
|
||||
np.nested_iters([AR_i8, AR_i8], [[0], [1]], op_flags=[["test"]]) # E: incompatible type
|
||||
np.nested_iters([AR_i8, AR_i8], [[0], [1]], buffersize=1.0) # E: incompatible type
|
||||
@@ -0,0 +1,11 @@
|
||||
import numpy as np
|
||||
|
||||
# Ban setting dtype since mutating the type of the array in place
|
||||
# makes having ndarray be generic over dtype impossible. Generally
|
||||
# users should use `ndarray.view` in this situation anyway. See
|
||||
#
|
||||
# https://github.com/numpy/numpy-stubs/issues/7
|
||||
#
|
||||
# for more context.
|
||||
float_array = np.array([1.0])
|
||||
float_array.dtype = np.bool_ # E: Property "dtype" defined in "ndarray" is read-only
|
||||
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
Tests for miscellaneous (non-magic) ``np.ndarray``/``np.generic`` methods.
|
||||
|
||||
More extensive tests are performed for the methods'
|
||||
function-based counterpart in `../from_numeric.py`.
|
||||
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
f8: np.float64
|
||||
AR_f8: np.ndarray[Any, np.dtype[np.float64]]
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
||||
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
|
||||
|
||||
ctypes_obj = AR_f8.ctypes
|
||||
|
||||
reveal_type(ctypes_obj.get_data()) # E: has no attribute
|
||||
reveal_type(ctypes_obj.get_shape()) # E: has no attribute
|
||||
reveal_type(ctypes_obj.get_strides()) # E: has no attribute
|
||||
reveal_type(ctypes_obj.get_as_parameter()) # E: has no attribute
|
||||
|
||||
f8.argpartition(0) # E: has no attribute
|
||||
f8.diagonal() # E: has no attribute
|
||||
f8.dot(1) # E: has no attribute
|
||||
f8.nonzero() # E: has no attribute
|
||||
f8.partition(0) # E: has no attribute
|
||||
f8.put(0, 2) # E: has no attribute
|
||||
f8.setfield(2, np.float64) # E: has no attribute
|
||||
f8.sort() # E: has no attribute
|
||||
f8.trace() # E: has no attribute
|
||||
|
||||
AR_M.__int__() # E: Invalid self argument
|
||||
AR_M.__float__() # E: Invalid self argument
|
||||
AR_M.__complex__() # E: Invalid self argument
|
||||
AR_b.__index__() # E: Invalid self argument
|
||||
|
||||
AR_f8[1.5] # E: No overload variant
|
||||
AR_f8["field_a"] # E: No overload variant
|
||||
AR_f8[["field_a", "field_b"]] # E: Invalid index type
|
||||
|
||||
AR_f8.__array_finalize__(object()) # E: incompatible type
|
||||
@@ -0,0 +1,8 @@
|
||||
import numpy as np
|
||||
|
||||
class Test(np.nditer): ... # E: Cannot inherit from final class
|
||||
|
||||
np.nditer([0, 1], flags=["test"]) # E: incompatible type
|
||||
np.nditer([0, 1], op_flags=[["test"]]) # E: incompatible type
|
||||
np.nditer([0, 1], itershape=(1.0,)) # E: incompatible type
|
||||
np.nditer([0, 1], buffersize=1.0) # E: incompatible type
|
||||
@@ -0,0 +1,17 @@
|
||||
from collections.abc import Sequence
|
||||
from numpy._typing import _NestedSequence
|
||||
|
||||
a: Sequence[float]
|
||||
b: list[complex]
|
||||
c: tuple[str, ...]
|
||||
d: int
|
||||
e: str
|
||||
|
||||
def func(a: _NestedSequence[int]) -> None:
|
||||
...
|
||||
|
||||
reveal_type(func(a)) # E: incompatible type
|
||||
reveal_type(func(b)) # E: incompatible type
|
||||
reveal_type(func(c)) # E: incompatible type
|
||||
reveal_type(func(d)) # E: incompatible type
|
||||
reveal_type(func(e)) # E: incompatible type
|
||||
@@ -0,0 +1,30 @@
|
||||
import pathlib
|
||||
from typing import IO
|
||||
|
||||
import numpy.typing as npt
|
||||
import numpy as np
|
||||
|
||||
str_path: str
|
||||
bytes_path: bytes
|
||||
pathlib_path: pathlib.Path
|
||||
str_file: IO[str]
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
|
||||
np.load(str_file) # E: incompatible type
|
||||
|
||||
np.save(bytes_path, AR_i8) # E: incompatible type
|
||||
np.save(str_file, AR_i8) # E: incompatible type
|
||||
|
||||
np.savez(bytes_path, AR_i8) # E: incompatible type
|
||||
np.savez(str_file, AR_i8) # E: incompatible type
|
||||
|
||||
np.savez_compressed(bytes_path, AR_i8) # E: incompatible type
|
||||
np.savez_compressed(str_file, AR_i8) # E: incompatible type
|
||||
|
||||
np.loadtxt(bytes_path) # E: incompatible type
|
||||
|
||||
np.fromregex(bytes_path, ".", np.int64) # E: No overload variant
|
||||
|
||||
np.recfromtxt(bytes_path) # E: incompatible type
|
||||
|
||||
np.recfromcsv(bytes_path) # E: incompatible type
|
||||
@@ -0,0 +1,13 @@
|
||||
import numpy as np
|
||||
|
||||
# Technically this works, but probably shouldn't. See
|
||||
#
|
||||
# https://github.com/numpy/numpy/issues/16366
|
||||
#
|
||||
np.maximum_sctype(1) # E: No overload variant
|
||||
|
||||
np.issubsctype(1, np.int64) # E: incompatible type
|
||||
|
||||
np.issubdtype(1, np.int64) # E: incompatible type
|
||||
|
||||
np.find_common_type(np.int64, np.int64) # E: incompatible type
|
||||
@@ -0,0 +1,61 @@
|
||||
import numpy as np
|
||||
from typing import Any
|
||||
|
||||
SEED_FLOAT: float = 457.3
|
||||
SEED_ARR_FLOAT: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0, 2, 3, 4])
|
||||
SEED_ARRLIKE_FLOAT: list[float] = [1.0, 2.0, 3.0, 4.0]
|
||||
SEED_SEED_SEQ: np.random.SeedSequence = np.random.SeedSequence(0)
|
||||
SEED_STR: str = "String seeding not allowed"
|
||||
# default rng
|
||||
np.random.default_rng(SEED_FLOAT) # E: incompatible type
|
||||
np.random.default_rng(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.default_rng(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.default_rng(SEED_STR) # E: incompatible type
|
||||
|
||||
# Seed Sequence
|
||||
np.random.SeedSequence(SEED_FLOAT) # E: incompatible type
|
||||
np.random.SeedSequence(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.SeedSequence(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.SeedSequence(SEED_SEED_SEQ) # E: incompatible type
|
||||
np.random.SeedSequence(SEED_STR) # E: incompatible type
|
||||
|
||||
seed_seq: np.random.bit_generator.SeedSequence = np.random.SeedSequence()
|
||||
seed_seq.spawn(11.5) # E: incompatible type
|
||||
seed_seq.generate_state(3.14) # E: incompatible type
|
||||
seed_seq.generate_state(3, np.uint8) # E: incompatible type
|
||||
seed_seq.generate_state(3, "uint8") # E: incompatible type
|
||||
seed_seq.generate_state(3, "u1") # E: incompatible type
|
||||
seed_seq.generate_state(3, np.uint16) # E: incompatible type
|
||||
seed_seq.generate_state(3, "uint16") # E: incompatible type
|
||||
seed_seq.generate_state(3, "u2") # E: incompatible type
|
||||
seed_seq.generate_state(3, np.int32) # E: incompatible type
|
||||
seed_seq.generate_state(3, "int32") # E: incompatible type
|
||||
seed_seq.generate_state(3, "i4") # E: incompatible type
|
||||
|
||||
# Bit Generators
|
||||
np.random.MT19937(SEED_FLOAT) # E: incompatible type
|
||||
np.random.MT19937(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.MT19937(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.MT19937(SEED_STR) # E: incompatible type
|
||||
|
||||
np.random.PCG64(SEED_FLOAT) # E: incompatible type
|
||||
np.random.PCG64(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.PCG64(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.PCG64(SEED_STR) # E: incompatible type
|
||||
|
||||
np.random.Philox(SEED_FLOAT) # E: incompatible type
|
||||
np.random.Philox(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.Philox(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.Philox(SEED_STR) # E: incompatible type
|
||||
|
||||
np.random.SFC64(SEED_FLOAT) # E: incompatible type
|
||||
np.random.SFC64(SEED_ARR_FLOAT) # E: incompatible type
|
||||
np.random.SFC64(SEED_ARRLIKE_FLOAT) # E: incompatible type
|
||||
np.random.SFC64(SEED_STR) # E: incompatible type
|
||||
|
||||
# Generator
|
||||
np.random.Generator(None) # E: incompatible type
|
||||
np.random.Generator(12333283902830213) # E: incompatible type
|
||||
np.random.Generator("OxFEEDF00D") # E: incompatible type
|
||||
np.random.Generator([123, 234]) # E: incompatible type
|
||||
np.random.Generator(np.array([123, 234], dtype="u4")) # E: incompatible type
|
||||
@@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
|
||||
np.rec.fromarrays(1) # E: No overload variant
|
||||
np.rec.fromarrays([1, 2, 3], dtype=[("f8", "f8")], formats=["f8", "f8"]) # E: No overload variant
|
||||
|
||||
np.rec.fromrecords(AR_i8) # E: incompatible type
|
||||
np.rec.fromrecords([(1.5,)], dtype=[("f8", "f8")], formats=["f8", "f8"]) # E: No overload variant
|
||||
|
||||
np.rec.fromstring("string", dtype=[("f8", "f8")]) # E: No overload variant
|
||||
np.rec.fromstring(b"bytes") # E: No overload variant
|
||||
np.rec.fromstring(b"(1.5,)", dtype=[("f8", "f8")], formats=["f8", "f8"]) # E: No overload variant
|
||||
|
||||
with open("test", "r") as f:
|
||||
np.rec.fromfile(f, dtype=[("f8", "f8")]) # E: No overload variant
|
||||
@@ -0,0 +1,92 @@
|
||||
import sys
|
||||
import numpy as np
|
||||
|
||||
f2: np.float16
|
||||
f8: np.float64
|
||||
c8: np.complex64
|
||||
|
||||
# Construction
|
||||
|
||||
np.float32(3j) # E: incompatible type
|
||||
|
||||
# Technically the following examples are valid NumPy code. But they
|
||||
# are not considered a best practice, and people who wish to use the
|
||||
# stubs should instead do
|
||||
#
|
||||
# np.array([1.0, 0.0, 0.0], dtype=np.float32)
|
||||
# np.array([], dtype=np.complex64)
|
||||
#
|
||||
# See e.g. the discussion on the mailing list
|
||||
#
|
||||
# https://mail.python.org/pipermail/numpy-discussion/2020-April/080566.html
|
||||
#
|
||||
# and the issue
|
||||
#
|
||||
# https://github.com/numpy/numpy-stubs/issues/41
|
||||
#
|
||||
# for more context.
|
||||
np.float32([1.0, 0.0, 0.0]) # E: incompatible type
|
||||
np.complex64([]) # E: incompatible type
|
||||
|
||||
np.complex64(1, 2) # E: Too many arguments
|
||||
# TODO: protocols (can't check for non-existent protocols w/ __getattr__)
|
||||
|
||||
np.datetime64(0) # E: No overload variant
|
||||
|
||||
class A:
|
||||
def __float__(self):
|
||||
return 1.0
|
||||
|
||||
|
||||
np.int8(A()) # E: incompatible type
|
||||
np.int16(A()) # E: incompatible type
|
||||
np.int32(A()) # E: incompatible type
|
||||
np.int64(A()) # E: incompatible type
|
||||
np.uint8(A()) # E: incompatible type
|
||||
np.uint16(A()) # E: incompatible type
|
||||
np.uint32(A()) # E: incompatible type
|
||||
np.uint64(A()) # E: incompatible type
|
||||
|
||||
np.void("test") # E: No overload variant
|
||||
np.void("test", dtype=None) # E: No overload variant
|
||||
|
||||
np.generic(1) # E: Cannot instantiate abstract class
|
||||
np.number(1) # E: Cannot instantiate abstract class
|
||||
np.integer(1) # E: Cannot instantiate abstract class
|
||||
np.inexact(1) # E: Cannot instantiate abstract class
|
||||
np.character("test") # E: Cannot instantiate abstract class
|
||||
np.flexible(b"test") # E: Cannot instantiate abstract class
|
||||
|
||||
np.float64(value=0.0) # E: Unexpected keyword argument
|
||||
np.int64(value=0) # E: Unexpected keyword argument
|
||||
np.uint64(value=0) # E: Unexpected keyword argument
|
||||
np.complex128(value=0.0j) # E: Unexpected keyword argument
|
||||
np.str_(value='bob') # E: No overload variant
|
||||
np.bytes_(value=b'test') # E: No overload variant
|
||||
np.void(value=b'test') # E: No overload variant
|
||||
np.bool_(value=True) # E: Unexpected keyword argument
|
||||
np.datetime64(value="2019") # E: No overload variant
|
||||
np.timedelta64(value=0) # E: Unexpected keyword argument
|
||||
|
||||
np.bytes_(b"hello", encoding='utf-8') # E: No overload variant
|
||||
np.str_("hello", encoding='utf-8') # E: No overload variant
|
||||
|
||||
f8.item(1) # E: incompatible type
|
||||
f8.item((0, 1)) # E: incompatible type
|
||||
f8.squeeze(axis=1) # E: incompatible type
|
||||
f8.squeeze(axis=(0, 1)) # E: incompatible type
|
||||
f8.transpose(1) # E: incompatible type
|
||||
|
||||
def func(a: np.float32) -> None: ...
|
||||
|
||||
func(f2) # E: incompatible type
|
||||
func(f8) # E: incompatible type
|
||||
|
||||
round(c8) # E: No overload variant
|
||||
|
||||
c8.__getnewargs__() # E: Invalid self argument
|
||||
f2.__getnewargs__() # E: Invalid self argument
|
||||
f2.hex() # E: Invalid self argument
|
||||
np.float16.fromhex("0x0.0p+0") # E: Invalid self argument
|
||||
f2.__trunc__() # E: Invalid self argument
|
||||
f2.__getformat__("float") # E: Invalid self argument
|
||||
@@ -0,0 +1,8 @@
|
||||
import numpy as np
|
||||
|
||||
class DTypeLike:
|
||||
dtype: np.dtype[np.int_]
|
||||
|
||||
dtype_like: DTypeLike
|
||||
|
||||
np.expand_dims(dtype_like, (5, 10)) # E: No overload variant
|
||||
@@ -0,0 +1,9 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
|
||||
np.lib.stride_tricks.as_strided(AR_f8, shape=8) # E: No overload variant
|
||||
np.lib.stride_tricks.as_strided(AR_f8, strides=8) # E: No overload variant
|
||||
|
||||
np.lib.stride_tricks.sliding_window_view(AR_f8, axis=(1,)) # E: No overload variant
|
||||
@@ -0,0 +1,28 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_U: npt.NDArray[np.str_]
|
||||
|
||||
def func() -> bool: ...
|
||||
|
||||
np.testing.assert_(True, msg=1) # E: incompatible type
|
||||
np.testing.build_err_msg(1, "test") # E: incompatible type
|
||||
np.testing.assert_almost_equal(AR_U, AR_U) # E: incompatible type
|
||||
np.testing.assert_approx_equal([1, 2, 3], [1, 2, 3]) # E: incompatible type
|
||||
np.testing.assert_array_almost_equal(AR_U, AR_U) # E: incompatible type
|
||||
np.testing.assert_array_less(AR_U, AR_U) # E: incompatible type
|
||||
np.testing.assert_string_equal(b"a", b"a") # E: incompatible type
|
||||
|
||||
np.testing.assert_raises(expected_exception=TypeError, callable=func) # E: No overload variant
|
||||
np.testing.assert_raises_regex(expected_exception=TypeError, expected_regex="T", callable=func) # E: No overload variant
|
||||
|
||||
np.testing.assert_allclose(AR_U, AR_U) # E: incompatible type
|
||||
np.testing.assert_array_almost_equal_nulp(AR_U, AR_U) # E: incompatible type
|
||||
np.testing.assert_array_max_ulp(AR_U, AR_U) # E: incompatible type
|
||||
|
||||
np.testing.assert_warns(warning_class=RuntimeWarning, func=func) # E: No overload variant
|
||||
np.testing.assert_no_warnings(func=func) # E: No overload variant
|
||||
np.testing.assert_no_warnings(func, None) # E: Too many arguments
|
||||
np.testing.assert_no_warnings(func, test=None) # E: Unexpected keyword argument
|
||||
|
||||
np.testing.assert_no_gc_cycles(func=func) # E: No overload variant
|
||||
@@ -0,0 +1,37 @@
|
||||
from typing import Any, TypeVar
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
|
||||
def func1(ar: npt.NDArray[Any], a: int) -> npt.NDArray[np.str_]:
|
||||
pass
|
||||
|
||||
|
||||
def func2(ar: npt.NDArray[Any], a: float) -> float:
|
||||
pass
|
||||
|
||||
|
||||
AR_b: npt.NDArray[np.bool_]
|
||||
AR_m: npt.NDArray[np.timedelta64]
|
||||
|
||||
AR_LIKE_b: list[bool]
|
||||
|
||||
np.eye(10, M=20.0) # E: No overload variant
|
||||
np.eye(10, k=2.5, dtype=int) # E: No overload variant
|
||||
|
||||
np.diag(AR_b, k=0.5) # E: No overload variant
|
||||
np.diagflat(AR_b, k=0.5) # E: No overload variant
|
||||
|
||||
np.tri(10, M=20.0) # E: No overload variant
|
||||
np.tri(10, k=2.5, dtype=int) # E: No overload variant
|
||||
|
||||
np.tril(AR_b, k=0.5) # E: No overload variant
|
||||
np.triu(AR_b, k=0.5) # E: No overload variant
|
||||
|
||||
np.vander(AR_m) # E: incompatible type
|
||||
|
||||
np.histogram2d(AR_m) # E: No overload variant
|
||||
|
||||
np.mask_indices(10, func1) # E: incompatible type
|
||||
np.mask_indices(10, func2, 10.5) # E: incompatible type
|
||||
@@ -0,0 +1,13 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
DTYPE_i8: np.dtype[np.int64]
|
||||
|
||||
np.mintypecode(DTYPE_i8) # E: incompatible type
|
||||
np.iscomplexobj(DTYPE_i8) # E: incompatible type
|
||||
np.isrealobj(DTYPE_i8) # E: incompatible type
|
||||
|
||||
np.typename(DTYPE_i8) # E: No overload variant
|
||||
np.typename("invalid") # E: No overload variant
|
||||
|
||||
np.common_type(np.timedelta64()) # E: incompatible type
|
||||
@@ -0,0 +1,21 @@
|
||||
"""Typing tests for `numpy.core._ufunc_config`."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
def func1(a: str, b: int, c: float) -> None: ...
|
||||
def func2(a: str, *, b: int) -> None: ...
|
||||
|
||||
class Write1:
|
||||
def write1(self, a: str) -> None: ...
|
||||
|
||||
class Write2:
|
||||
def write(self, a: str, b: str) -> None: ...
|
||||
|
||||
class Write3:
|
||||
def write(self, *, a: str) -> None: ...
|
||||
|
||||
np.seterrcall(func1) # E: Argument 1 to "seterrcall" has incompatible type
|
||||
np.seterrcall(func2) # E: Argument 1 to "seterrcall" has incompatible type
|
||||
np.seterrcall(Write1()) # E: Argument 1 to "seterrcall" has incompatible type
|
||||
np.seterrcall(Write2()) # E: Argument 1 to "seterrcall" has incompatible type
|
||||
np.seterrcall(Write3()) # E: Argument 1 to "seterrcall" has incompatible type
|
||||
@@ -0,0 +1,21 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
||||
AR_O: np.ndarray[Any, np.dtype[np.object_]]
|
||||
|
||||
np.fix(AR_c) # E: incompatible type
|
||||
np.fix(AR_m) # E: incompatible type
|
||||
np.fix(AR_M) # E: incompatible type
|
||||
|
||||
np.isposinf(AR_c) # E: incompatible type
|
||||
np.isposinf(AR_m) # E: incompatible type
|
||||
np.isposinf(AR_M) # E: incompatible type
|
||||
np.isposinf(AR_O) # E: incompatible type
|
||||
|
||||
np.isneginf(AR_c) # E: incompatible type
|
||||
np.isneginf(AR_m) # E: incompatible type
|
||||
np.isneginf(AR_M) # E: incompatible type
|
||||
np.isneginf(AR_O) # E: incompatible type
|
||||
@@ -0,0 +1,41 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
|
||||
np.sin.nin + "foo" # E: Unsupported operand types
|
||||
np.sin(1, foo="bar") # E: No overload variant
|
||||
|
||||
np.abs(None) # E: No overload variant
|
||||
|
||||
np.add(1, 1, 1) # E: No overload variant
|
||||
np.add(1, 1, axis=0) # E: No overload variant
|
||||
|
||||
np.matmul(AR_f8, AR_f8, where=True) # E: No overload variant
|
||||
|
||||
np.frexp(AR_f8, out=None) # E: No overload variant
|
||||
np.frexp(AR_f8, out=AR_f8) # E: No overload variant
|
||||
|
||||
np.absolute.outer() # E: "None" not callable
|
||||
np.frexp.outer() # E: "None" not callable
|
||||
np.divmod.outer() # E: "None" not callable
|
||||
np.matmul.outer() # E: "None" not callable
|
||||
|
||||
np.absolute.reduceat() # E: "None" not callable
|
||||
np.frexp.reduceat() # E: "None" not callable
|
||||
np.divmod.reduceat() # E: "None" not callable
|
||||
np.matmul.reduceat() # E: "None" not callable
|
||||
|
||||
np.absolute.reduce() # E: "None" not callable
|
||||
np.frexp.reduce() # E: "None" not callable
|
||||
np.divmod.reduce() # E: "None" not callable
|
||||
np.matmul.reduce() # E: "None" not callable
|
||||
|
||||
np.absolute.accumulate() # E: "None" not callable
|
||||
np.frexp.accumulate() # E: "None" not callable
|
||||
np.divmod.accumulate() # E: "None" not callable
|
||||
np.matmul.accumulate() # E: "None" not callable
|
||||
|
||||
np.frexp.at() # E: "None" not callable
|
||||
np.divmod.at() # E: "None" not callable
|
||||
np.matmul.at() # E: "None" not callable
|
||||
@@ -0,0 +1,5 @@
|
||||
import numpy as np
|
||||
|
||||
np.AxisError(1.0) # E: No overload variant
|
||||
np.AxisError(1, ndim=2.0) # E: No overload variant
|
||||
np.AxisError(2, msg_prefix=404) # E: No overload variant
|
||||
@@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
|
||||
reveal_type(np.uint128())
|
||||
reveal_type(np.uint256())
|
||||
|
||||
reveal_type(np.int128())
|
||||
reveal_type(np.int256())
|
||||
|
||||
reveal_type(np.float80())
|
||||
reveal_type(np.float96())
|
||||
reveal_type(np.float128())
|
||||
reveal_type(np.float256())
|
||||
|
||||
reveal_type(np.complex160())
|
||||
reveal_type(np.complex192())
|
||||
reveal_type(np.complex256())
|
||||
reveal_type(np.complex512())
|
||||
@@ -0,0 +1,10 @@
|
||||
[mypy]
|
||||
plugins = numpy.typing.mypy_plugin
|
||||
show_absolute_path = True
|
||||
implicit_reexport = False
|
||||
|
||||
[mypy-numpy]
|
||||
ignore_errors = True
|
||||
|
||||
[mypy-numpy.*]
|
||||
ignore_errors = True
|
||||
@@ -0,0 +1,594 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
c16 = np.complex128(1)
|
||||
f8 = np.float64(1)
|
||||
i8 = np.int64(1)
|
||||
u8 = np.uint64(1)
|
||||
|
||||
c8 = np.complex64(1)
|
||||
f4 = np.float32(1)
|
||||
i4 = np.int32(1)
|
||||
u4 = np.uint32(1)
|
||||
|
||||
dt = np.datetime64(1, "D")
|
||||
td = np.timedelta64(1, "D")
|
||||
|
||||
b_ = np.bool_(1)
|
||||
|
||||
b = bool(1)
|
||||
c = complex(1)
|
||||
f = float(1)
|
||||
i = int(1)
|
||||
|
||||
|
||||
class Object:
|
||||
def __array__(self) -> np.ndarray[Any, np.dtype[np.object_]]:
|
||||
ret = np.empty((), dtype=object)
|
||||
ret[()] = self
|
||||
return ret
|
||||
|
||||
def __sub__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __rsub__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __floordiv__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __rfloordiv__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __mul__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __rmul__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __pow__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
def __rpow__(self, value: Any) -> Object:
|
||||
return self
|
||||
|
||||
|
||||
AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
|
||||
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int64]] = np.array([1])
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float64]] = np.array([1.0])
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex128]] = np.array([1j])
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64(1, "D")])
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64(1, "D")])
|
||||
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([Object()])
|
||||
|
||||
AR_LIKE_b = [True]
|
||||
AR_LIKE_u = [np.uint32(1)]
|
||||
AR_LIKE_i = [1]
|
||||
AR_LIKE_f = [1.0]
|
||||
AR_LIKE_c = [1j]
|
||||
AR_LIKE_m = [np.timedelta64(1, "D")]
|
||||
AR_LIKE_M = [np.datetime64(1, "D")]
|
||||
AR_LIKE_O = [Object()]
|
||||
|
||||
# Array subtractions
|
||||
|
||||
AR_b - AR_LIKE_u
|
||||
AR_b - AR_LIKE_i
|
||||
AR_b - AR_LIKE_f
|
||||
AR_b - AR_LIKE_c
|
||||
AR_b - AR_LIKE_m
|
||||
AR_b - AR_LIKE_O
|
||||
|
||||
AR_LIKE_u - AR_b
|
||||
AR_LIKE_i - AR_b
|
||||
AR_LIKE_f - AR_b
|
||||
AR_LIKE_c - AR_b
|
||||
AR_LIKE_m - AR_b
|
||||
AR_LIKE_M - AR_b
|
||||
AR_LIKE_O - AR_b
|
||||
|
||||
AR_u - AR_LIKE_b
|
||||
AR_u - AR_LIKE_u
|
||||
AR_u - AR_LIKE_i
|
||||
AR_u - AR_LIKE_f
|
||||
AR_u - AR_LIKE_c
|
||||
AR_u - AR_LIKE_m
|
||||
AR_u - AR_LIKE_O
|
||||
|
||||
AR_LIKE_b - AR_u
|
||||
AR_LIKE_u - AR_u
|
||||
AR_LIKE_i - AR_u
|
||||
AR_LIKE_f - AR_u
|
||||
AR_LIKE_c - AR_u
|
||||
AR_LIKE_m - AR_u
|
||||
AR_LIKE_M - AR_u
|
||||
AR_LIKE_O - AR_u
|
||||
|
||||
AR_i - AR_LIKE_b
|
||||
AR_i - AR_LIKE_u
|
||||
AR_i - AR_LIKE_i
|
||||
AR_i - AR_LIKE_f
|
||||
AR_i - AR_LIKE_c
|
||||
AR_i - AR_LIKE_m
|
||||
AR_i - AR_LIKE_O
|
||||
|
||||
AR_LIKE_b - AR_i
|
||||
AR_LIKE_u - AR_i
|
||||
AR_LIKE_i - AR_i
|
||||
AR_LIKE_f - AR_i
|
||||
AR_LIKE_c - AR_i
|
||||
AR_LIKE_m - AR_i
|
||||
AR_LIKE_M - AR_i
|
||||
AR_LIKE_O - AR_i
|
||||
|
||||
AR_f - AR_LIKE_b
|
||||
AR_f - AR_LIKE_u
|
||||
AR_f - AR_LIKE_i
|
||||
AR_f - AR_LIKE_f
|
||||
AR_f - AR_LIKE_c
|
||||
AR_f - AR_LIKE_O
|
||||
|
||||
AR_LIKE_b - AR_f
|
||||
AR_LIKE_u - AR_f
|
||||
AR_LIKE_i - AR_f
|
||||
AR_LIKE_f - AR_f
|
||||
AR_LIKE_c - AR_f
|
||||
AR_LIKE_O - AR_f
|
||||
|
||||
AR_c - AR_LIKE_b
|
||||
AR_c - AR_LIKE_u
|
||||
AR_c - AR_LIKE_i
|
||||
AR_c - AR_LIKE_f
|
||||
AR_c - AR_LIKE_c
|
||||
AR_c - AR_LIKE_O
|
||||
|
||||
AR_LIKE_b - AR_c
|
||||
AR_LIKE_u - AR_c
|
||||
AR_LIKE_i - AR_c
|
||||
AR_LIKE_f - AR_c
|
||||
AR_LIKE_c - AR_c
|
||||
AR_LIKE_O - AR_c
|
||||
|
||||
AR_m - AR_LIKE_b
|
||||
AR_m - AR_LIKE_u
|
||||
AR_m - AR_LIKE_i
|
||||
AR_m - AR_LIKE_m
|
||||
|
||||
AR_LIKE_b - AR_m
|
||||
AR_LIKE_u - AR_m
|
||||
AR_LIKE_i - AR_m
|
||||
AR_LIKE_m - AR_m
|
||||
AR_LIKE_M - AR_m
|
||||
|
||||
AR_M - AR_LIKE_b
|
||||
AR_M - AR_LIKE_u
|
||||
AR_M - AR_LIKE_i
|
||||
AR_M - AR_LIKE_m
|
||||
AR_M - AR_LIKE_M
|
||||
|
||||
AR_LIKE_M - AR_M
|
||||
|
||||
AR_O - AR_LIKE_b
|
||||
AR_O - AR_LIKE_u
|
||||
AR_O - AR_LIKE_i
|
||||
AR_O - AR_LIKE_f
|
||||
AR_O - AR_LIKE_c
|
||||
AR_O - AR_LIKE_O
|
||||
|
||||
AR_LIKE_b - AR_O
|
||||
AR_LIKE_u - AR_O
|
||||
AR_LIKE_i - AR_O
|
||||
AR_LIKE_f - AR_O
|
||||
AR_LIKE_c - AR_O
|
||||
AR_LIKE_O - AR_O
|
||||
|
||||
AR_u += AR_b
|
||||
AR_u += AR_u
|
||||
AR_u += 1 # Allowed during runtime as long as the object is 0D and >=0
|
||||
|
||||
# Array floor division
|
||||
|
||||
AR_b // AR_LIKE_b
|
||||
AR_b // AR_LIKE_u
|
||||
AR_b // AR_LIKE_i
|
||||
AR_b // AR_LIKE_f
|
||||
AR_b // AR_LIKE_O
|
||||
|
||||
AR_LIKE_b // AR_b
|
||||
AR_LIKE_u // AR_b
|
||||
AR_LIKE_i // AR_b
|
||||
AR_LIKE_f // AR_b
|
||||
AR_LIKE_O // AR_b
|
||||
|
||||
AR_u // AR_LIKE_b
|
||||
AR_u // AR_LIKE_u
|
||||
AR_u // AR_LIKE_i
|
||||
AR_u // AR_LIKE_f
|
||||
AR_u // AR_LIKE_O
|
||||
|
||||
AR_LIKE_b // AR_u
|
||||
AR_LIKE_u // AR_u
|
||||
AR_LIKE_i // AR_u
|
||||
AR_LIKE_f // AR_u
|
||||
AR_LIKE_m // AR_u
|
||||
AR_LIKE_O // AR_u
|
||||
|
||||
AR_i // AR_LIKE_b
|
||||
AR_i // AR_LIKE_u
|
||||
AR_i // AR_LIKE_i
|
||||
AR_i // AR_LIKE_f
|
||||
AR_i // AR_LIKE_O
|
||||
|
||||
AR_LIKE_b // AR_i
|
||||
AR_LIKE_u // AR_i
|
||||
AR_LIKE_i // AR_i
|
||||
AR_LIKE_f // AR_i
|
||||
AR_LIKE_m // AR_i
|
||||
AR_LIKE_O // AR_i
|
||||
|
||||
AR_f // AR_LIKE_b
|
||||
AR_f // AR_LIKE_u
|
||||
AR_f // AR_LIKE_i
|
||||
AR_f // AR_LIKE_f
|
||||
AR_f // AR_LIKE_O
|
||||
|
||||
AR_LIKE_b // AR_f
|
||||
AR_LIKE_u // AR_f
|
||||
AR_LIKE_i // AR_f
|
||||
AR_LIKE_f // AR_f
|
||||
AR_LIKE_m // AR_f
|
||||
AR_LIKE_O // AR_f
|
||||
|
||||
AR_m // AR_LIKE_u
|
||||
AR_m // AR_LIKE_i
|
||||
AR_m // AR_LIKE_f
|
||||
AR_m // AR_LIKE_m
|
||||
|
||||
AR_LIKE_m // AR_m
|
||||
|
||||
AR_O // AR_LIKE_b
|
||||
AR_O // AR_LIKE_u
|
||||
AR_O // AR_LIKE_i
|
||||
AR_O // AR_LIKE_f
|
||||
AR_O // AR_LIKE_O
|
||||
|
||||
AR_LIKE_b // AR_O
|
||||
AR_LIKE_u // AR_O
|
||||
AR_LIKE_i // AR_O
|
||||
AR_LIKE_f // AR_O
|
||||
AR_LIKE_O // AR_O
|
||||
|
||||
# Inplace multiplication
|
||||
|
||||
AR_b *= AR_LIKE_b
|
||||
|
||||
AR_u *= AR_LIKE_b
|
||||
AR_u *= AR_LIKE_u
|
||||
|
||||
AR_i *= AR_LIKE_b
|
||||
AR_i *= AR_LIKE_u
|
||||
AR_i *= AR_LIKE_i
|
||||
|
||||
AR_f *= AR_LIKE_b
|
||||
AR_f *= AR_LIKE_u
|
||||
AR_f *= AR_LIKE_i
|
||||
AR_f *= AR_LIKE_f
|
||||
|
||||
AR_c *= AR_LIKE_b
|
||||
AR_c *= AR_LIKE_u
|
||||
AR_c *= AR_LIKE_i
|
||||
AR_c *= AR_LIKE_f
|
||||
AR_c *= AR_LIKE_c
|
||||
|
||||
AR_m *= AR_LIKE_b
|
||||
AR_m *= AR_LIKE_u
|
||||
AR_m *= AR_LIKE_i
|
||||
AR_m *= AR_LIKE_f
|
||||
|
||||
AR_O *= AR_LIKE_b
|
||||
AR_O *= AR_LIKE_u
|
||||
AR_O *= AR_LIKE_i
|
||||
AR_O *= AR_LIKE_f
|
||||
AR_O *= AR_LIKE_c
|
||||
AR_O *= AR_LIKE_O
|
||||
|
||||
# Inplace power
|
||||
|
||||
AR_u **= AR_LIKE_b
|
||||
AR_u **= AR_LIKE_u
|
||||
|
||||
AR_i **= AR_LIKE_b
|
||||
AR_i **= AR_LIKE_u
|
||||
AR_i **= AR_LIKE_i
|
||||
|
||||
AR_f **= AR_LIKE_b
|
||||
AR_f **= AR_LIKE_u
|
||||
AR_f **= AR_LIKE_i
|
||||
AR_f **= AR_LIKE_f
|
||||
|
||||
AR_c **= AR_LIKE_b
|
||||
AR_c **= AR_LIKE_u
|
||||
AR_c **= AR_LIKE_i
|
||||
AR_c **= AR_LIKE_f
|
||||
AR_c **= AR_LIKE_c
|
||||
|
||||
AR_O **= AR_LIKE_b
|
||||
AR_O **= AR_LIKE_u
|
||||
AR_O **= AR_LIKE_i
|
||||
AR_O **= AR_LIKE_f
|
||||
AR_O **= AR_LIKE_c
|
||||
AR_O **= AR_LIKE_O
|
||||
|
||||
# unary ops
|
||||
|
||||
-c16
|
||||
-c8
|
||||
-f8
|
||||
-f4
|
||||
-i8
|
||||
-i4
|
||||
with pytest.warns(RuntimeWarning):
|
||||
-u8
|
||||
-u4
|
||||
-td
|
||||
-AR_f
|
||||
|
||||
+c16
|
||||
+c8
|
||||
+f8
|
||||
+f4
|
||||
+i8
|
||||
+i4
|
||||
+u8
|
||||
+u4
|
||||
+td
|
||||
+AR_f
|
||||
|
||||
abs(c16)
|
||||
abs(c8)
|
||||
abs(f8)
|
||||
abs(f4)
|
||||
abs(i8)
|
||||
abs(i4)
|
||||
abs(u8)
|
||||
abs(u4)
|
||||
abs(td)
|
||||
abs(b_)
|
||||
abs(AR_f)
|
||||
|
||||
# Time structures
|
||||
|
||||
dt + td
|
||||
dt + i
|
||||
dt + i4
|
||||
dt + i8
|
||||
dt - dt
|
||||
dt - i
|
||||
dt - i4
|
||||
dt - i8
|
||||
|
||||
td + td
|
||||
td + i
|
||||
td + i4
|
||||
td + i8
|
||||
td - td
|
||||
td - i
|
||||
td - i4
|
||||
td - i8
|
||||
td / f
|
||||
td / f4
|
||||
td / f8
|
||||
td / td
|
||||
td // td
|
||||
td % td
|
||||
|
||||
|
||||
# boolean
|
||||
|
||||
b_ / b
|
||||
b_ / b_
|
||||
b_ / i
|
||||
b_ / i8
|
||||
b_ / i4
|
||||
b_ / u8
|
||||
b_ / u4
|
||||
b_ / f
|
||||
b_ / f8
|
||||
b_ / f4
|
||||
b_ / c
|
||||
b_ / c16
|
||||
b_ / c8
|
||||
|
||||
b / b_
|
||||
b_ / b_
|
||||
i / b_
|
||||
i8 / b_
|
||||
i4 / b_
|
||||
u8 / b_
|
||||
u4 / b_
|
||||
f / b_
|
||||
f8 / b_
|
||||
f4 / b_
|
||||
c / b_
|
||||
c16 / b_
|
||||
c8 / b_
|
||||
|
||||
# Complex
|
||||
|
||||
c16 + c16
|
||||
c16 + f8
|
||||
c16 + i8
|
||||
c16 + c8
|
||||
c16 + f4
|
||||
c16 + i4
|
||||
c16 + b_
|
||||
c16 + b
|
||||
c16 + c
|
||||
c16 + f
|
||||
c16 + i
|
||||
c16 + AR_f
|
||||
|
||||
c16 + c16
|
||||
f8 + c16
|
||||
i8 + c16
|
||||
c8 + c16
|
||||
f4 + c16
|
||||
i4 + c16
|
||||
b_ + c16
|
||||
b + c16
|
||||
c + c16
|
||||
f + c16
|
||||
i + c16
|
||||
AR_f + c16
|
||||
|
||||
c8 + c16
|
||||
c8 + f8
|
||||
c8 + i8
|
||||
c8 + c8
|
||||
c8 + f4
|
||||
c8 + i4
|
||||
c8 + b_
|
||||
c8 + b
|
||||
c8 + c
|
||||
c8 + f
|
||||
c8 + i
|
||||
c8 + AR_f
|
||||
|
||||
c16 + c8
|
||||
f8 + c8
|
||||
i8 + c8
|
||||
c8 + c8
|
||||
f4 + c8
|
||||
i4 + c8
|
||||
b_ + c8
|
||||
b + c8
|
||||
c + c8
|
||||
f + c8
|
||||
i + c8
|
||||
AR_f + c8
|
||||
|
||||
# Float
|
||||
|
||||
f8 + f8
|
||||
f8 + i8
|
||||
f8 + f4
|
||||
f8 + i4
|
||||
f8 + b_
|
||||
f8 + b
|
||||
f8 + c
|
||||
f8 + f
|
||||
f8 + i
|
||||
f8 + AR_f
|
||||
|
||||
f8 + f8
|
||||
i8 + f8
|
||||
f4 + f8
|
||||
i4 + f8
|
||||
b_ + f8
|
||||
b + f8
|
||||
c + f8
|
||||
f + f8
|
||||
i + f8
|
||||
AR_f + f8
|
||||
|
||||
f4 + f8
|
||||
f4 + i8
|
||||
f4 + f4
|
||||
f4 + i4
|
||||
f4 + b_
|
||||
f4 + b
|
||||
f4 + c
|
||||
f4 + f
|
||||
f4 + i
|
||||
f4 + AR_f
|
||||
|
||||
f8 + f4
|
||||
i8 + f4
|
||||
f4 + f4
|
||||
i4 + f4
|
||||
b_ + f4
|
||||
b + f4
|
||||
c + f4
|
||||
f + f4
|
||||
i + f4
|
||||
AR_f + f4
|
||||
|
||||
# Int
|
||||
|
||||
i8 + i8
|
||||
i8 + u8
|
||||
i8 + i4
|
||||
i8 + u4
|
||||
i8 + b_
|
||||
i8 + b
|
||||
i8 + c
|
||||
i8 + f
|
||||
i8 + i
|
||||
i8 + AR_f
|
||||
|
||||
u8 + u8
|
||||
u8 + i4
|
||||
u8 + u4
|
||||
u8 + b_
|
||||
u8 + b
|
||||
u8 + c
|
||||
u8 + f
|
||||
u8 + i
|
||||
u8 + AR_f
|
||||
|
||||
i8 + i8
|
||||
u8 + i8
|
||||
i4 + i8
|
||||
u4 + i8
|
||||
b_ + i8
|
||||
b + i8
|
||||
c + i8
|
||||
f + i8
|
||||
i + i8
|
||||
AR_f + i8
|
||||
|
||||
u8 + u8
|
||||
i4 + u8
|
||||
u4 + u8
|
||||
b_ + u8
|
||||
b + u8
|
||||
c + u8
|
||||
f + u8
|
||||
i + u8
|
||||
AR_f + u8
|
||||
|
||||
i4 + i8
|
||||
i4 + i4
|
||||
i4 + i
|
||||
i4 + b_
|
||||
i4 + b
|
||||
i4 + AR_f
|
||||
|
||||
u4 + i8
|
||||
u4 + i4
|
||||
u4 + u8
|
||||
u4 + u4
|
||||
u4 + i
|
||||
u4 + b_
|
||||
u4 + b
|
||||
u4 + AR_f
|
||||
|
||||
i8 + i4
|
||||
i4 + i4
|
||||
i + i4
|
||||
b_ + i4
|
||||
b + i4
|
||||
AR_f + i4
|
||||
|
||||
i8 + u4
|
||||
i4 + u4
|
||||
u8 + u4
|
||||
u4 + u4
|
||||
b_ + u4
|
||||
b + u4
|
||||
i + u4
|
||||
AR_f + u4
|
||||
@@ -0,0 +1,137 @@
|
||||
import sys
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Index:
|
||||
def __index__(self) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
class SubClass(np.ndarray):
|
||||
pass
|
||||
|
||||
|
||||
def func(i: int, j: int, **kwargs: Any) -> SubClass:
|
||||
return B
|
||||
|
||||
|
||||
i8 = np.int64(1)
|
||||
|
||||
A = np.array([1])
|
||||
B = A.view(SubClass).copy()
|
||||
B_stack = np.array([[1], [1]]).view(SubClass)
|
||||
C = [1]
|
||||
|
||||
np.ndarray(Index())
|
||||
np.ndarray([Index()])
|
||||
|
||||
np.array(1, dtype=float)
|
||||
np.array(1, copy=False)
|
||||
np.array(1, order='F')
|
||||
np.array(1, order=None)
|
||||
np.array(1, subok=True)
|
||||
np.array(1, ndmin=3)
|
||||
np.array(1, str, copy=True, order='C', subok=False, ndmin=2)
|
||||
|
||||
np.asarray(A)
|
||||
np.asarray(B)
|
||||
np.asarray(C)
|
||||
|
||||
np.asanyarray(A)
|
||||
np.asanyarray(B)
|
||||
np.asanyarray(B, dtype=int)
|
||||
np.asanyarray(C)
|
||||
|
||||
np.ascontiguousarray(A)
|
||||
np.ascontiguousarray(B)
|
||||
np.ascontiguousarray(C)
|
||||
|
||||
np.asfortranarray(A)
|
||||
np.asfortranarray(B)
|
||||
np.asfortranarray(C)
|
||||
|
||||
np.require(A)
|
||||
np.require(B)
|
||||
np.require(B, dtype=int)
|
||||
np.require(B, requirements=None)
|
||||
np.require(B, requirements="E")
|
||||
np.require(B, requirements=["ENSUREARRAY"])
|
||||
np.require(B, requirements={"F", "E"})
|
||||
np.require(B, requirements=["C", "OWNDATA"])
|
||||
np.require(B, requirements="W")
|
||||
np.require(B, requirements="A")
|
||||
np.require(C)
|
||||
|
||||
np.linspace(0, 2)
|
||||
np.linspace(0.5, [0, 1, 2])
|
||||
np.linspace([0, 1, 2], 3)
|
||||
np.linspace(0j, 2)
|
||||
np.linspace(0, 2, num=10)
|
||||
np.linspace(0, 2, endpoint=True)
|
||||
np.linspace(0, 2, retstep=True)
|
||||
np.linspace(0j, 2j, retstep=True)
|
||||
np.linspace(0, 2, dtype=bool)
|
||||
np.linspace([0, 1], [2, 3], axis=Index())
|
||||
|
||||
np.logspace(0, 2, base=2)
|
||||
np.logspace(0, 2, base=2)
|
||||
np.logspace(0, 2, base=[1j, 2j], num=2)
|
||||
|
||||
np.geomspace(1, 2)
|
||||
|
||||
np.zeros_like(A)
|
||||
np.zeros_like(C)
|
||||
np.zeros_like(B)
|
||||
np.zeros_like(B, dtype=np.int64)
|
||||
|
||||
np.ones_like(A)
|
||||
np.ones_like(C)
|
||||
np.ones_like(B)
|
||||
np.ones_like(B, dtype=np.int64)
|
||||
|
||||
np.empty_like(A)
|
||||
np.empty_like(C)
|
||||
np.empty_like(B)
|
||||
np.empty_like(B, dtype=np.int64)
|
||||
|
||||
np.full_like(A, i8)
|
||||
np.full_like(C, i8)
|
||||
np.full_like(B, i8)
|
||||
np.full_like(B, i8, dtype=np.int64)
|
||||
|
||||
np.ones(1)
|
||||
np.ones([1, 1, 1])
|
||||
|
||||
np.full(1, i8)
|
||||
np.full([1, 1, 1], i8)
|
||||
|
||||
np.indices([1, 2, 3])
|
||||
np.indices([1, 2, 3], sparse=True)
|
||||
|
||||
np.fromfunction(func, (3, 5))
|
||||
|
||||
np.identity(10)
|
||||
|
||||
np.atleast_1d(C)
|
||||
np.atleast_1d(A)
|
||||
np.atleast_1d(C, C)
|
||||
np.atleast_1d(C, A)
|
||||
np.atleast_1d(A, A)
|
||||
|
||||
np.atleast_2d(C)
|
||||
|
||||
np.atleast_3d(C)
|
||||
|
||||
np.vstack([C, C])
|
||||
np.vstack([C, A])
|
||||
np.vstack([A, A])
|
||||
|
||||
np.hstack([C, C])
|
||||
|
||||
np.stack([C, C])
|
||||
np.stack([C, C], axis=0)
|
||||
np.stack([C, C], out=B_stack)
|
||||
|
||||
np.block([[C, C], [C, C]])
|
||||
np.block(A)
|
||||
@@ -0,0 +1,41 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
from numpy._typing import ArrayLike, _SupportsArray
|
||||
|
||||
x1: ArrayLike = True
|
||||
x2: ArrayLike = 5
|
||||
x3: ArrayLike = 1.0
|
||||
x4: ArrayLike = 1 + 1j
|
||||
x5: ArrayLike = np.int8(1)
|
||||
x6: ArrayLike = np.float64(1)
|
||||
x7: ArrayLike = np.complex128(1)
|
||||
x8: ArrayLike = np.array([1, 2, 3])
|
||||
x9: ArrayLike = [1, 2, 3]
|
||||
x10: ArrayLike = (1, 2, 3)
|
||||
x11: ArrayLike = "foo"
|
||||
x12: ArrayLike = memoryview(b'foo')
|
||||
|
||||
|
||||
class A:
|
||||
def __array__(self, dtype: None | np.dtype[Any] = None) -> np.ndarray:
|
||||
return np.array([1, 2, 3])
|
||||
|
||||
|
||||
x13: ArrayLike = A()
|
||||
|
||||
scalar: _SupportsArray = np.int64(1)
|
||||
scalar.__array__()
|
||||
array: _SupportsArray = np.array(1)
|
||||
array.__array__()
|
||||
|
||||
a: _SupportsArray = A()
|
||||
a.__array__()
|
||||
a.__array__()
|
||||
|
||||
# Escape hatch for when you mean to make something like an object
|
||||
# array.
|
||||
object_array_scalar: Any = (i for i in range(10))
|
||||
np.array(object_array_scalar)
|
||||
@@ -0,0 +1,37 @@
|
||||
import numpy as np
|
||||
|
||||
AR = np.arange(10)
|
||||
AR.setflags(write=False)
|
||||
|
||||
with np.printoptions():
|
||||
np.set_printoptions(
|
||||
precision=1,
|
||||
threshold=2,
|
||||
edgeitems=3,
|
||||
linewidth=4,
|
||||
suppress=False,
|
||||
nanstr="Bob",
|
||||
infstr="Bill",
|
||||
formatter={},
|
||||
sign="+",
|
||||
floatmode="unique",
|
||||
)
|
||||
np.get_printoptions()
|
||||
str(AR)
|
||||
|
||||
np.array2string(
|
||||
AR,
|
||||
max_line_width=5,
|
||||
precision=2,
|
||||
suppress_small=True,
|
||||
separator=";",
|
||||
prefix="test",
|
||||
threshold=5,
|
||||
floatmode="fixed",
|
||||
suffix="?",
|
||||
legacy="1.13",
|
||||
)
|
||||
np.format_float_scientific(1, precision=5)
|
||||
np.format_float_positional(1, trim="k")
|
||||
np.array_repr(AR)
|
||||
np.array_str(AR)
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_i8: np.ndarray[Any, np.dtype[np.int_]] = np.arange(10)
|
||||
ar_iter = np.lib.Arrayterator(AR_i8)
|
||||
|
||||
ar_iter.var
|
||||
ar_iter.buf_size
|
||||
ar_iter.start
|
||||
ar_iter.stop
|
||||
ar_iter.step
|
||||
ar_iter.shape
|
||||
ar_iter.flat
|
||||
|
||||
ar_iter.__array__()
|
||||
|
||||
for i in ar_iter:
|
||||
pass
|
||||
|
||||
ar_iter[0]
|
||||
ar_iter[...]
|
||||
ar_iter[:]
|
||||
ar_iter[0, 0, 0]
|
||||
ar_iter[..., 0, :]
|
||||
@@ -0,0 +1,131 @@
|
||||
import numpy as np
|
||||
|
||||
i8 = np.int64(1)
|
||||
u8 = np.uint64(1)
|
||||
|
||||
i4 = np.int32(1)
|
||||
u4 = np.uint32(1)
|
||||
|
||||
b_ = np.bool_(1)
|
||||
|
||||
b = bool(1)
|
||||
i = int(1)
|
||||
|
||||
AR = np.array([0, 1, 2], dtype=np.int32)
|
||||
AR.setflags(write=False)
|
||||
|
||||
|
||||
i8 << i8
|
||||
i8 >> i8
|
||||
i8 | i8
|
||||
i8 ^ i8
|
||||
i8 & i8
|
||||
|
||||
i8 << AR
|
||||
i8 >> AR
|
||||
i8 | AR
|
||||
i8 ^ AR
|
||||
i8 & AR
|
||||
|
||||
i4 << i4
|
||||
i4 >> i4
|
||||
i4 | i4
|
||||
i4 ^ i4
|
||||
i4 & i4
|
||||
|
||||
i8 << i4
|
||||
i8 >> i4
|
||||
i8 | i4
|
||||
i8 ^ i4
|
||||
i8 & i4
|
||||
|
||||
i8 << i
|
||||
i8 >> i
|
||||
i8 | i
|
||||
i8 ^ i
|
||||
i8 & i
|
||||
|
||||
i8 << b_
|
||||
i8 >> b_
|
||||
i8 | b_
|
||||
i8 ^ b_
|
||||
i8 & b_
|
||||
|
||||
i8 << b
|
||||
i8 >> b
|
||||
i8 | b
|
||||
i8 ^ b
|
||||
i8 & b
|
||||
|
||||
u8 << u8
|
||||
u8 >> u8
|
||||
u8 | u8
|
||||
u8 ^ u8
|
||||
u8 & u8
|
||||
|
||||
u8 << AR
|
||||
u8 >> AR
|
||||
u8 | AR
|
||||
u8 ^ AR
|
||||
u8 & AR
|
||||
|
||||
u4 << u4
|
||||
u4 >> u4
|
||||
u4 | u4
|
||||
u4 ^ u4
|
||||
u4 & u4
|
||||
|
||||
u4 << i4
|
||||
u4 >> i4
|
||||
u4 | i4
|
||||
u4 ^ i4
|
||||
u4 & i4
|
||||
|
||||
u4 << i
|
||||
u4 >> i
|
||||
u4 | i
|
||||
u4 ^ i
|
||||
u4 & i
|
||||
|
||||
u8 << b_
|
||||
u8 >> b_
|
||||
u8 | b_
|
||||
u8 ^ b_
|
||||
u8 & b_
|
||||
|
||||
u8 << b
|
||||
u8 >> b
|
||||
u8 | b
|
||||
u8 ^ b
|
||||
u8 & b
|
||||
|
||||
b_ << b_
|
||||
b_ >> b_
|
||||
b_ | b_
|
||||
b_ ^ b_
|
||||
b_ & b_
|
||||
|
||||
b_ << AR
|
||||
b_ >> AR
|
||||
b_ | AR
|
||||
b_ ^ AR
|
||||
b_ & AR
|
||||
|
||||
b_ << b
|
||||
b_ >> b
|
||||
b_ | b
|
||||
b_ ^ b
|
||||
b_ & b
|
||||
|
||||
b_ << i
|
||||
b_ >> i
|
||||
b_ | i
|
||||
b_ ^ i
|
||||
b_ & i
|
||||
|
||||
~i8
|
||||
~i4
|
||||
~u8
|
||||
~u4
|
||||
~b_
|
||||
~AR
|
||||
@@ -0,0 +1,301 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
c16 = np.complex128()
|
||||
f8 = np.float64()
|
||||
i8 = np.int64()
|
||||
u8 = np.uint64()
|
||||
|
||||
c8 = np.complex64()
|
||||
f4 = np.float32()
|
||||
i4 = np.int32()
|
||||
u4 = np.uint32()
|
||||
|
||||
dt = np.datetime64(0, "D")
|
||||
td = np.timedelta64(0, "D")
|
||||
|
||||
b_ = np.bool_()
|
||||
|
||||
b = bool()
|
||||
c = complex()
|
||||
f = float()
|
||||
i = int()
|
||||
|
||||
SEQ = (0, 1, 2, 3, 4)
|
||||
|
||||
AR_b: np.ndarray[Any, np.dtype[np.bool_]] = np.array([True])
|
||||
AR_u: np.ndarray[Any, np.dtype[np.uint32]] = np.array([1], dtype=np.uint32)
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int_]] = np.array([1])
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float_]] = np.array([1.0])
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex_]] = np.array([1.0j])
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]] = np.array([np.timedelta64("1")])
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]] = np.array([np.datetime64("1")])
|
||||
AR_O: np.ndarray[Any, np.dtype[np.object_]] = np.array([1], dtype=object)
|
||||
|
||||
# Arrays
|
||||
|
||||
AR_b > AR_b
|
||||
AR_b > AR_u
|
||||
AR_b > AR_i
|
||||
AR_b > AR_f
|
||||
AR_b > AR_c
|
||||
|
||||
AR_u > AR_b
|
||||
AR_u > AR_u
|
||||
AR_u > AR_i
|
||||
AR_u > AR_f
|
||||
AR_u > AR_c
|
||||
|
||||
AR_i > AR_b
|
||||
AR_i > AR_u
|
||||
AR_i > AR_i
|
||||
AR_i > AR_f
|
||||
AR_i > AR_c
|
||||
|
||||
AR_f > AR_b
|
||||
AR_f > AR_u
|
||||
AR_f > AR_i
|
||||
AR_f > AR_f
|
||||
AR_f > AR_c
|
||||
|
||||
AR_c > AR_b
|
||||
AR_c > AR_u
|
||||
AR_c > AR_i
|
||||
AR_c > AR_f
|
||||
AR_c > AR_c
|
||||
|
||||
AR_m > AR_b
|
||||
AR_m > AR_u
|
||||
AR_m > AR_i
|
||||
AR_b > AR_m
|
||||
AR_u > AR_m
|
||||
AR_i > AR_m
|
||||
|
||||
AR_M > AR_M
|
||||
|
||||
AR_O > AR_O
|
||||
1 > AR_O
|
||||
AR_O > 1
|
||||
|
||||
# Time structures
|
||||
|
||||
dt > dt
|
||||
|
||||
td > td
|
||||
td > i
|
||||
td > i4
|
||||
td > i8
|
||||
td > AR_i
|
||||
td > SEQ
|
||||
|
||||
# boolean
|
||||
|
||||
b_ > b
|
||||
b_ > b_
|
||||
b_ > i
|
||||
b_ > i8
|
||||
b_ > i4
|
||||
b_ > u8
|
||||
b_ > u4
|
||||
b_ > f
|
||||
b_ > f8
|
||||
b_ > f4
|
||||
b_ > c
|
||||
b_ > c16
|
||||
b_ > c8
|
||||
b_ > AR_i
|
||||
b_ > SEQ
|
||||
|
||||
# Complex
|
||||
|
||||
c16 > c16
|
||||
c16 > f8
|
||||
c16 > i8
|
||||
c16 > c8
|
||||
c16 > f4
|
||||
c16 > i4
|
||||
c16 > b_
|
||||
c16 > b
|
||||
c16 > c
|
||||
c16 > f
|
||||
c16 > i
|
||||
c16 > AR_i
|
||||
c16 > SEQ
|
||||
|
||||
c16 > c16
|
||||
f8 > c16
|
||||
i8 > c16
|
||||
c8 > c16
|
||||
f4 > c16
|
||||
i4 > c16
|
||||
b_ > c16
|
||||
b > c16
|
||||
c > c16
|
||||
f > c16
|
||||
i > c16
|
||||
AR_i > c16
|
||||
SEQ > c16
|
||||
|
||||
c8 > c16
|
||||
c8 > f8
|
||||
c8 > i8
|
||||
c8 > c8
|
||||
c8 > f4
|
||||
c8 > i4
|
||||
c8 > b_
|
||||
c8 > b
|
||||
c8 > c
|
||||
c8 > f
|
||||
c8 > i
|
||||
c8 > AR_i
|
||||
c8 > SEQ
|
||||
|
||||
c16 > c8
|
||||
f8 > c8
|
||||
i8 > c8
|
||||
c8 > c8
|
||||
f4 > c8
|
||||
i4 > c8
|
||||
b_ > c8
|
||||
b > c8
|
||||
c > c8
|
||||
f > c8
|
||||
i > c8
|
||||
AR_i > c8
|
||||
SEQ > c8
|
||||
|
||||
# Float
|
||||
|
||||
f8 > f8
|
||||
f8 > i8
|
||||
f8 > f4
|
||||
f8 > i4
|
||||
f8 > b_
|
||||
f8 > b
|
||||
f8 > c
|
||||
f8 > f
|
||||
f8 > i
|
||||
f8 > AR_i
|
||||
f8 > SEQ
|
||||
|
||||
f8 > f8
|
||||
i8 > f8
|
||||
f4 > f8
|
||||
i4 > f8
|
||||
b_ > f8
|
||||
b > f8
|
||||
c > f8
|
||||
f > f8
|
||||
i > f8
|
||||
AR_i > f8
|
||||
SEQ > f8
|
||||
|
||||
f4 > f8
|
||||
f4 > i8
|
||||
f4 > f4
|
||||
f4 > i4
|
||||
f4 > b_
|
||||
f4 > b
|
||||
f4 > c
|
||||
f4 > f
|
||||
f4 > i
|
||||
f4 > AR_i
|
||||
f4 > SEQ
|
||||
|
||||
f8 > f4
|
||||
i8 > f4
|
||||
f4 > f4
|
||||
i4 > f4
|
||||
b_ > f4
|
||||
b > f4
|
||||
c > f4
|
||||
f > f4
|
||||
i > f4
|
||||
AR_i > f4
|
||||
SEQ > f4
|
||||
|
||||
# Int
|
||||
|
||||
i8 > i8
|
||||
i8 > u8
|
||||
i8 > i4
|
||||
i8 > u4
|
||||
i8 > b_
|
||||
i8 > b
|
||||
i8 > c
|
||||
i8 > f
|
||||
i8 > i
|
||||
i8 > AR_i
|
||||
i8 > SEQ
|
||||
|
||||
u8 > u8
|
||||
u8 > i4
|
||||
u8 > u4
|
||||
u8 > b_
|
||||
u8 > b
|
||||
u8 > c
|
||||
u8 > f
|
||||
u8 > i
|
||||
u8 > AR_i
|
||||
u8 > SEQ
|
||||
|
||||
i8 > i8
|
||||
u8 > i8
|
||||
i4 > i8
|
||||
u4 > i8
|
||||
b_ > i8
|
||||
b > i8
|
||||
c > i8
|
||||
f > i8
|
||||
i > i8
|
||||
AR_i > i8
|
||||
SEQ > i8
|
||||
|
||||
u8 > u8
|
||||
i4 > u8
|
||||
u4 > u8
|
||||
b_ > u8
|
||||
b > u8
|
||||
c > u8
|
||||
f > u8
|
||||
i > u8
|
||||
AR_i > u8
|
||||
SEQ > u8
|
||||
|
||||
i4 > i8
|
||||
i4 > i4
|
||||
i4 > i
|
||||
i4 > b_
|
||||
i4 > b
|
||||
i4 > AR_i
|
||||
i4 > SEQ
|
||||
|
||||
u4 > i8
|
||||
u4 > i4
|
||||
u4 > u8
|
||||
u4 > u4
|
||||
u4 > i
|
||||
u4 > b_
|
||||
u4 > b
|
||||
u4 > AR_i
|
||||
u4 > SEQ
|
||||
|
||||
i8 > i4
|
||||
i4 > i4
|
||||
i > i4
|
||||
b_ > i4
|
||||
b > i4
|
||||
AR_i > i4
|
||||
SEQ > i4
|
||||
|
||||
i8 > u4
|
||||
i4 > u4
|
||||
u8 > u4
|
||||
u4 > u4
|
||||
b_ > u4
|
||||
b > u4
|
||||
i > u4
|
||||
AR_i > u4
|
||||
SEQ > u4
|
||||
@@ -0,0 +1,57 @@
|
||||
import numpy as np
|
||||
|
||||
dtype_obj = np.dtype(np.str_)
|
||||
void_dtype_obj = np.dtype([("f0", np.float64), ("f1", np.float32)])
|
||||
|
||||
np.dtype(dtype=np.int64)
|
||||
np.dtype(int)
|
||||
np.dtype("int")
|
||||
np.dtype(None)
|
||||
|
||||
np.dtype((int, 2))
|
||||
np.dtype((int, (1,)))
|
||||
|
||||
np.dtype({"names": ["a", "b"], "formats": [int, float]})
|
||||
np.dtype({"names": ["a"], "formats": [int], "titles": [object]})
|
||||
np.dtype({"names": ["a"], "formats": [int], "titles": [object()]})
|
||||
|
||||
np.dtype([("name", np.unicode_, 16), ("grades", np.float64, (2,)), ("age", "int32")])
|
||||
|
||||
np.dtype(
|
||||
{
|
||||
"names": ["a", "b"],
|
||||
"formats": [int, float],
|
||||
"itemsize": 9,
|
||||
"aligned": False,
|
||||
"titles": ["x", "y"],
|
||||
"offsets": [0, 1],
|
||||
}
|
||||
)
|
||||
|
||||
np.dtype((np.float_, float))
|
||||
|
||||
|
||||
class Test:
|
||||
dtype = np.dtype(float)
|
||||
|
||||
|
||||
np.dtype(Test())
|
||||
|
||||
# Methods and attributes
|
||||
dtype_obj.base
|
||||
dtype_obj.subdtype
|
||||
dtype_obj.newbyteorder()
|
||||
dtype_obj.type
|
||||
dtype_obj.name
|
||||
dtype_obj.names
|
||||
|
||||
dtype_obj * 0
|
||||
dtype_obj * 2
|
||||
|
||||
0 * dtype_obj
|
||||
2 * dtype_obj
|
||||
|
||||
void_dtype_obj["f0"]
|
||||
void_dtype_obj[0]
|
||||
void_dtype_obj[["f0", "f1"]]
|
||||
void_dtype_obj[["f0"]]
|
||||
@@ -0,0 +1,36 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
AR_LIKE_b = [True, True, True]
|
||||
AR_LIKE_u = [np.uint32(1), np.uint32(2), np.uint32(3)]
|
||||
AR_LIKE_i = [1, 2, 3]
|
||||
AR_LIKE_f = [1.0, 2.0, 3.0]
|
||||
AR_LIKE_c = [1j, 2j, 3j]
|
||||
AR_LIKE_U = ["1", "2", "3"]
|
||||
|
||||
OUT_f: np.ndarray[Any, np.dtype[np.float64]] = np.empty(3, dtype=np.float64)
|
||||
OUT_c: np.ndarray[Any, np.dtype[np.complex128]] = np.empty(3, dtype=np.complex128)
|
||||
|
||||
np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_b)
|
||||
np.einsum("i,i->i", AR_LIKE_u, AR_LIKE_u)
|
||||
np.einsum("i,i->i", AR_LIKE_i, AR_LIKE_i)
|
||||
np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f)
|
||||
np.einsum("i,i->i", AR_LIKE_c, AR_LIKE_c)
|
||||
np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_i)
|
||||
np.einsum("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c)
|
||||
|
||||
np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f, dtype="c16")
|
||||
np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=bool, casting="unsafe")
|
||||
np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f, out=OUT_c)
|
||||
np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=int, casting="unsafe", out=OUT_f)
|
||||
|
||||
np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_b)
|
||||
np.einsum_path("i,i->i", AR_LIKE_u, AR_LIKE_u)
|
||||
np.einsum_path("i,i->i", AR_LIKE_i, AR_LIKE_i)
|
||||
np.einsum_path("i,i->i", AR_LIKE_f, AR_LIKE_f)
|
||||
np.einsum_path("i,i->i", AR_LIKE_c, AR_LIKE_c)
|
||||
np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_i)
|
||||
np.einsum_path("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c)
|
||||
@@ -0,0 +1,16 @@
|
||||
import numpy as np
|
||||
|
||||
a = np.empty((2, 2)).flat
|
||||
|
||||
a.base
|
||||
a.copy()
|
||||
a.coords
|
||||
a.index
|
||||
iter(a)
|
||||
next(a)
|
||||
a[0]
|
||||
a[[0, 1, 2]]
|
||||
a[...]
|
||||
a[:]
|
||||
a.__array__()
|
||||
a.__array__(np.dtype(np.float64))
|
||||
@@ -0,0 +1,260 @@
|
||||
"""Tests for :mod:`numpy.core.fromnumeric`."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
A = np.array(True, ndmin=2, dtype=bool)
|
||||
B = np.array(1.0, ndmin=2, dtype=np.float32)
|
||||
A.setflags(write=False)
|
||||
B.setflags(write=False)
|
||||
|
||||
a = np.bool_(True)
|
||||
b = np.float32(1.0)
|
||||
c = 1.0
|
||||
d = np.array(1.0, dtype=np.float32) # writeable
|
||||
|
||||
np.take(a, 0)
|
||||
np.take(b, 0)
|
||||
np.take(c, 0)
|
||||
np.take(A, 0)
|
||||
np.take(B, 0)
|
||||
np.take(A, [0])
|
||||
np.take(B, [0])
|
||||
|
||||
np.reshape(a, 1)
|
||||
np.reshape(b, 1)
|
||||
np.reshape(c, 1)
|
||||
np.reshape(A, 1)
|
||||
np.reshape(B, 1)
|
||||
|
||||
np.choose(a, [True, True])
|
||||
np.choose(A, [1.0, 1.0])
|
||||
|
||||
np.repeat(a, 1)
|
||||
np.repeat(b, 1)
|
||||
np.repeat(c, 1)
|
||||
np.repeat(A, 1)
|
||||
np.repeat(B, 1)
|
||||
|
||||
np.swapaxes(A, 0, 0)
|
||||
np.swapaxes(B, 0, 0)
|
||||
|
||||
np.transpose(a)
|
||||
np.transpose(b)
|
||||
np.transpose(c)
|
||||
np.transpose(A)
|
||||
np.transpose(B)
|
||||
|
||||
np.partition(a, 0, axis=None)
|
||||
np.partition(b, 0, axis=None)
|
||||
np.partition(c, 0, axis=None)
|
||||
np.partition(A, 0)
|
||||
np.partition(B, 0)
|
||||
|
||||
np.argpartition(a, 0)
|
||||
np.argpartition(b, 0)
|
||||
np.argpartition(c, 0)
|
||||
np.argpartition(A, 0)
|
||||
np.argpartition(B, 0)
|
||||
|
||||
np.sort(A, 0)
|
||||
np.sort(B, 0)
|
||||
|
||||
np.argsort(A, 0)
|
||||
np.argsort(B, 0)
|
||||
|
||||
np.argmax(A)
|
||||
np.argmax(B)
|
||||
np.argmax(A, axis=0)
|
||||
np.argmax(B, axis=0)
|
||||
|
||||
np.argmin(A)
|
||||
np.argmin(B)
|
||||
np.argmin(A, axis=0)
|
||||
np.argmin(B, axis=0)
|
||||
|
||||
np.searchsorted(A[0], 0)
|
||||
np.searchsorted(B[0], 0)
|
||||
np.searchsorted(A[0], [0])
|
||||
np.searchsorted(B[0], [0])
|
||||
|
||||
np.resize(a, (5, 5))
|
||||
np.resize(b, (5, 5))
|
||||
np.resize(c, (5, 5))
|
||||
np.resize(A, (5, 5))
|
||||
np.resize(B, (5, 5))
|
||||
|
||||
np.squeeze(a)
|
||||
np.squeeze(b)
|
||||
np.squeeze(c)
|
||||
np.squeeze(A)
|
||||
np.squeeze(B)
|
||||
|
||||
np.diagonal(A)
|
||||
np.diagonal(B)
|
||||
|
||||
np.trace(A)
|
||||
np.trace(B)
|
||||
|
||||
np.ravel(a)
|
||||
np.ravel(b)
|
||||
np.ravel(c)
|
||||
np.ravel(A)
|
||||
np.ravel(B)
|
||||
|
||||
np.nonzero(A)
|
||||
np.nonzero(B)
|
||||
|
||||
np.shape(a)
|
||||
np.shape(b)
|
||||
np.shape(c)
|
||||
np.shape(A)
|
||||
np.shape(B)
|
||||
|
||||
np.compress([True], a)
|
||||
np.compress([True], b)
|
||||
np.compress([True], c)
|
||||
np.compress([True], A)
|
||||
np.compress([True], B)
|
||||
|
||||
np.clip(a, 0, 1.0)
|
||||
np.clip(b, -1, 1)
|
||||
np.clip(a, 0, None)
|
||||
np.clip(b, None, 1)
|
||||
np.clip(c, 0, 1)
|
||||
np.clip(A, 0, 1)
|
||||
np.clip(B, 0, 1)
|
||||
np.clip(B, [0, 1], [1, 2])
|
||||
|
||||
np.sum(a)
|
||||
np.sum(b)
|
||||
np.sum(c)
|
||||
np.sum(A)
|
||||
np.sum(B)
|
||||
np.sum(A, axis=0)
|
||||
np.sum(B, axis=0)
|
||||
|
||||
np.all(a)
|
||||
np.all(b)
|
||||
np.all(c)
|
||||
np.all(A)
|
||||
np.all(B)
|
||||
np.all(A, axis=0)
|
||||
np.all(B, axis=0)
|
||||
np.all(A, keepdims=True)
|
||||
np.all(B, keepdims=True)
|
||||
|
||||
np.any(a)
|
||||
np.any(b)
|
||||
np.any(c)
|
||||
np.any(A)
|
||||
np.any(B)
|
||||
np.any(A, axis=0)
|
||||
np.any(B, axis=0)
|
||||
np.any(A, keepdims=True)
|
||||
np.any(B, keepdims=True)
|
||||
|
||||
np.cumsum(a)
|
||||
np.cumsum(b)
|
||||
np.cumsum(c)
|
||||
np.cumsum(A)
|
||||
np.cumsum(B)
|
||||
|
||||
np.ptp(b)
|
||||
np.ptp(c)
|
||||
np.ptp(B)
|
||||
np.ptp(B, axis=0)
|
||||
np.ptp(B, keepdims=True)
|
||||
|
||||
np.amax(a)
|
||||
np.amax(b)
|
||||
np.amax(c)
|
||||
np.amax(A)
|
||||
np.amax(B)
|
||||
np.amax(A, axis=0)
|
||||
np.amax(B, axis=0)
|
||||
np.amax(A, keepdims=True)
|
||||
np.amax(B, keepdims=True)
|
||||
|
||||
np.amin(a)
|
||||
np.amin(b)
|
||||
np.amin(c)
|
||||
np.amin(A)
|
||||
np.amin(B)
|
||||
np.amin(A, axis=0)
|
||||
np.amin(B, axis=0)
|
||||
np.amin(A, keepdims=True)
|
||||
np.amin(B, keepdims=True)
|
||||
|
||||
np.prod(a)
|
||||
np.prod(b)
|
||||
np.prod(c)
|
||||
np.prod(A)
|
||||
np.prod(B)
|
||||
np.prod(a, dtype=None)
|
||||
np.prod(A, dtype=None)
|
||||
np.prod(A, axis=0)
|
||||
np.prod(B, axis=0)
|
||||
np.prod(A, keepdims=True)
|
||||
np.prod(B, keepdims=True)
|
||||
np.prod(b, out=d)
|
||||
np.prod(B, out=d)
|
||||
|
||||
np.cumprod(a)
|
||||
np.cumprod(b)
|
||||
np.cumprod(c)
|
||||
np.cumprod(A)
|
||||
np.cumprod(B)
|
||||
|
||||
np.ndim(a)
|
||||
np.ndim(b)
|
||||
np.ndim(c)
|
||||
np.ndim(A)
|
||||
np.ndim(B)
|
||||
|
||||
np.size(a)
|
||||
np.size(b)
|
||||
np.size(c)
|
||||
np.size(A)
|
||||
np.size(B)
|
||||
|
||||
np.around(a)
|
||||
np.around(b)
|
||||
np.around(c)
|
||||
np.around(A)
|
||||
np.around(B)
|
||||
|
||||
np.mean(a)
|
||||
np.mean(b)
|
||||
np.mean(c)
|
||||
np.mean(A)
|
||||
np.mean(B)
|
||||
np.mean(A, axis=0)
|
||||
np.mean(B, axis=0)
|
||||
np.mean(A, keepdims=True)
|
||||
np.mean(B, keepdims=True)
|
||||
np.mean(b, out=d)
|
||||
np.mean(B, out=d)
|
||||
|
||||
np.std(a)
|
||||
np.std(b)
|
||||
np.std(c)
|
||||
np.std(A)
|
||||
np.std(B)
|
||||
np.std(A, axis=0)
|
||||
np.std(B, axis=0)
|
||||
np.std(A, keepdims=True)
|
||||
np.std(B, keepdims=True)
|
||||
np.std(b, out=d)
|
||||
np.std(B, out=d)
|
||||
|
||||
np.var(a)
|
||||
np.var(b)
|
||||
np.var(c)
|
||||
np.var(A)
|
||||
np.var(B)
|
||||
np.var(A, axis=0)
|
||||
np.var(B, axis=0)
|
||||
np.var(A, keepdims=True)
|
||||
np.var(B, keepdims=True)
|
||||
np.var(b, out=d)
|
||||
np.var(B, out=d)
|
||||
@@ -0,0 +1,64 @@
|
||||
from __future__ import annotations
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_LIKE_b = [[True, True], [True, True]]
|
||||
AR_LIKE_i = [[1, 2], [3, 4]]
|
||||
AR_LIKE_f = [[1.0, 2.0], [3.0, 4.0]]
|
||||
AR_LIKE_U = [["1", "2"], ["3", "4"]]
|
||||
|
||||
AR_i8: np.ndarray[Any, np.dtype[np.int64]] = np.array(AR_LIKE_i, dtype=np.int64)
|
||||
|
||||
np.ndenumerate(AR_i8)
|
||||
np.ndenumerate(AR_LIKE_f)
|
||||
np.ndenumerate(AR_LIKE_U)
|
||||
|
||||
np.ndenumerate(AR_i8).iter
|
||||
np.ndenumerate(AR_LIKE_f).iter
|
||||
np.ndenumerate(AR_LIKE_U).iter
|
||||
|
||||
next(np.ndenumerate(AR_i8))
|
||||
next(np.ndenumerate(AR_LIKE_f))
|
||||
next(np.ndenumerate(AR_LIKE_U))
|
||||
|
||||
iter(np.ndenumerate(AR_i8))
|
||||
iter(np.ndenumerate(AR_LIKE_f))
|
||||
iter(np.ndenumerate(AR_LIKE_U))
|
||||
|
||||
iter(np.ndindex(1, 2, 3))
|
||||
next(np.ndindex(1, 2, 3))
|
||||
|
||||
np.unravel_index([22, 41, 37], (7, 6))
|
||||
np.unravel_index([31, 41, 13], (7, 6), order='F')
|
||||
np.unravel_index(1621, (6, 7, 8, 9))
|
||||
|
||||
np.ravel_multi_index(AR_LIKE_i, (7, 6))
|
||||
np.ravel_multi_index(AR_LIKE_i, (7, 6), order='F')
|
||||
np.ravel_multi_index(AR_LIKE_i, (4, 6), mode='clip')
|
||||
np.ravel_multi_index(AR_LIKE_i, (4, 4), mode=('clip', 'wrap'))
|
||||
np.ravel_multi_index((3, 1, 4, 1), (6, 7, 8, 9))
|
||||
|
||||
np.mgrid[1:1:2]
|
||||
np.mgrid[1:1:2, None:10]
|
||||
|
||||
np.ogrid[1:1:2]
|
||||
np.ogrid[1:1:2, None:10]
|
||||
|
||||
np.index_exp[0:1]
|
||||
np.index_exp[0:1, None:3]
|
||||
np.index_exp[0, 0:1, ..., [0, 1, 3]]
|
||||
|
||||
np.s_[0:1]
|
||||
np.s_[0:1, None:3]
|
||||
np.s_[0, 0:1, ..., [0, 1, 3]]
|
||||
|
||||
np.ix_(AR_LIKE_b[0])
|
||||
np.ix_(AR_LIKE_i[0], AR_LIKE_f[0])
|
||||
np.ix_(AR_i8[0])
|
||||
|
||||
np.fill_diagonal(AR_i8, 5)
|
||||
|
||||
np.diag_indices(4)
|
||||
np.diag_indices(2, 3)
|
||||
|
||||
np.diag_indices_from(AR_i8)
|
||||
@@ -0,0 +1,25 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from io import StringIO
|
||||
|
||||
import numpy as np
|
||||
|
||||
FILE = StringIO()
|
||||
AR = np.arange(10, dtype=np.float64)
|
||||
|
||||
def func(a: int) -> bool: ...
|
||||
|
||||
np.deprecate(func)
|
||||
np.deprecate()
|
||||
|
||||
np.deprecate_with_doc("test")
|
||||
np.deprecate_with_doc(None)
|
||||
|
||||
np.byte_bounds(AR)
|
||||
np.byte_bounds(np.float64())
|
||||
|
||||
np.info(1, output=FILE)
|
||||
|
||||
np.source(np.interp, output=FILE)
|
||||
|
||||
np.lookfor("binary representation", output=FILE)
|
||||
@@ -0,0 +1,18 @@
|
||||
from numpy.lib import NumpyVersion
|
||||
|
||||
version = NumpyVersion("1.8.0")
|
||||
|
||||
version.vstring
|
||||
version.version
|
||||
version.major
|
||||
version.minor
|
||||
version.bugfix
|
||||
version.pre_release
|
||||
version.is_devversion
|
||||
|
||||
version == version
|
||||
version != version
|
||||
version < "1.8.0"
|
||||
version <= version
|
||||
version > version
|
||||
version >= "1.8.0"
|
||||
@@ -0,0 +1,47 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from functools import partial
|
||||
from collections.abc import Callable
|
||||
|
||||
import pytest # type: ignore
|
||||
import numpy as np
|
||||
|
||||
AR = np.array(0)
|
||||
AR.setflags(write=False)
|
||||
|
||||
KACF = frozenset({None, "K", "A", "C", "F"})
|
||||
ACF = frozenset({None, "A", "C", "F"})
|
||||
CF = frozenset({None, "C", "F"})
|
||||
|
||||
order_list: list[tuple[frozenset, Callable]] = [
|
||||
(KACF, partial(np.ndarray, 1)),
|
||||
(KACF, AR.tobytes),
|
||||
(KACF, partial(AR.astype, int)),
|
||||
(KACF, AR.copy),
|
||||
(ACF, partial(AR.reshape, 1)),
|
||||
(KACF, AR.flatten),
|
||||
(KACF, AR.ravel),
|
||||
(KACF, partial(np.array, 1)),
|
||||
(CF, partial(np.zeros, 1)),
|
||||
(CF, partial(np.ones, 1)),
|
||||
(CF, partial(np.empty, 1)),
|
||||
(CF, partial(np.full, 1, 1)),
|
||||
(KACF, partial(np.zeros_like, AR)),
|
||||
(KACF, partial(np.ones_like, AR)),
|
||||
(KACF, partial(np.empty_like, AR)),
|
||||
(KACF, partial(np.full_like, AR, 1)),
|
||||
(KACF, partial(np.add, 1, 1)), # i.e. np.ufunc.__call__
|
||||
(ACF, partial(np.reshape, AR, 1)),
|
||||
(KACF, partial(np.ravel, AR)),
|
||||
(KACF, partial(np.asarray, 1)),
|
||||
(KACF, partial(np.asanyarray, 1)),
|
||||
]
|
||||
|
||||
for order_set, func in order_list:
|
||||
for order in order_set:
|
||||
func(order=order)
|
||||
|
||||
invalid_orders = KACF - order_set
|
||||
for order in invalid_orders:
|
||||
with pytest.raises(ValueError):
|
||||
func(order=order)
|
||||
@@ -0,0 +1,149 @@
|
||||
import numpy as np
|
||||
|
||||
f8 = np.float64(1)
|
||||
i8 = np.int64(1)
|
||||
u8 = np.uint64(1)
|
||||
|
||||
f4 = np.float32(1)
|
||||
i4 = np.int32(1)
|
||||
u4 = np.uint32(1)
|
||||
|
||||
td = np.timedelta64(1, "D")
|
||||
b_ = np.bool_(1)
|
||||
|
||||
b = bool(1)
|
||||
f = float(1)
|
||||
i = int(1)
|
||||
|
||||
AR = np.array([1], dtype=np.bool_)
|
||||
AR.setflags(write=False)
|
||||
|
||||
AR2 = np.array([1], dtype=np.timedelta64)
|
||||
AR2.setflags(write=False)
|
||||
|
||||
# Time structures
|
||||
|
||||
td % td
|
||||
td % AR2
|
||||
AR2 % td
|
||||
|
||||
divmod(td, td)
|
||||
divmod(td, AR2)
|
||||
divmod(AR2, td)
|
||||
|
||||
# Bool
|
||||
|
||||
b_ % b
|
||||
b_ % i
|
||||
b_ % f
|
||||
b_ % b_
|
||||
b_ % i8
|
||||
b_ % u8
|
||||
b_ % f8
|
||||
b_ % AR
|
||||
|
||||
divmod(b_, b)
|
||||
divmod(b_, i)
|
||||
divmod(b_, f)
|
||||
divmod(b_, b_)
|
||||
divmod(b_, i8)
|
||||
divmod(b_, u8)
|
||||
divmod(b_, f8)
|
||||
divmod(b_, AR)
|
||||
|
||||
b % b_
|
||||
i % b_
|
||||
f % b_
|
||||
b_ % b_
|
||||
i8 % b_
|
||||
u8 % b_
|
||||
f8 % b_
|
||||
AR % b_
|
||||
|
||||
divmod(b, b_)
|
||||
divmod(i, b_)
|
||||
divmod(f, b_)
|
||||
divmod(b_, b_)
|
||||
divmod(i8, b_)
|
||||
divmod(u8, b_)
|
||||
divmod(f8, b_)
|
||||
divmod(AR, b_)
|
||||
|
||||
# int
|
||||
|
||||
i8 % b
|
||||
i8 % i
|
||||
i8 % f
|
||||
i8 % i8
|
||||
i8 % f8
|
||||
i4 % i8
|
||||
i4 % f8
|
||||
i4 % i4
|
||||
i4 % f4
|
||||
i8 % AR
|
||||
|
||||
divmod(i8, b)
|
||||
divmod(i8, i)
|
||||
divmod(i8, f)
|
||||
divmod(i8, i8)
|
||||
divmod(i8, f8)
|
||||
divmod(i8, i4)
|
||||
divmod(i8, f4)
|
||||
divmod(i4, i4)
|
||||
divmod(i4, f4)
|
||||
divmod(i8, AR)
|
||||
|
||||
b % i8
|
||||
i % i8
|
||||
f % i8
|
||||
i8 % i8
|
||||
f8 % i8
|
||||
i8 % i4
|
||||
f8 % i4
|
||||
i4 % i4
|
||||
f4 % i4
|
||||
AR % i8
|
||||
|
||||
divmod(b, i8)
|
||||
divmod(i, i8)
|
||||
divmod(f, i8)
|
||||
divmod(i8, i8)
|
||||
divmod(f8, i8)
|
||||
divmod(i4, i8)
|
||||
divmod(f4, i8)
|
||||
divmod(i4, i4)
|
||||
divmod(f4, i4)
|
||||
divmod(AR, i8)
|
||||
|
||||
# float
|
||||
|
||||
f8 % b
|
||||
f8 % i
|
||||
f8 % f
|
||||
i8 % f4
|
||||
f4 % f4
|
||||
f8 % AR
|
||||
|
||||
divmod(f8, b)
|
||||
divmod(f8, i)
|
||||
divmod(f8, f)
|
||||
divmod(f8, f8)
|
||||
divmod(f8, f4)
|
||||
divmod(f4, f4)
|
||||
divmod(f8, AR)
|
||||
|
||||
b % f8
|
||||
i % f8
|
||||
f % f8
|
||||
f8 % f8
|
||||
f8 % f8
|
||||
f4 % f4
|
||||
AR % f8
|
||||
|
||||
divmod(b, f8)
|
||||
divmod(i, f8)
|
||||
divmod(f, f8)
|
||||
divmod(f8, f8)
|
||||
divmod(f4, f8)
|
||||
divmod(f4, f4)
|
||||
divmod(AR, f8)
|
||||
@@ -0,0 +1,43 @@
|
||||
import numpy as np
|
||||
from numpy import f2py
|
||||
|
||||
np.char
|
||||
np.ctypeslib
|
||||
np.emath
|
||||
np.fft
|
||||
np.lib
|
||||
np.linalg
|
||||
np.ma
|
||||
np.matrixlib
|
||||
np.polynomial
|
||||
np.random
|
||||
np.rec
|
||||
np.testing
|
||||
np.version
|
||||
|
||||
np.lib.format
|
||||
np.lib.mixins
|
||||
np.lib.scimath
|
||||
np.lib.stride_tricks
|
||||
np.ma.extras
|
||||
np.polynomial.chebyshev
|
||||
np.polynomial.hermite
|
||||
np.polynomial.hermite_e
|
||||
np.polynomial.laguerre
|
||||
np.polynomial.legendre
|
||||
np.polynomial.polynomial
|
||||
|
||||
np.__path__
|
||||
np.__version__
|
||||
np.__git_version__
|
||||
|
||||
np.__all__
|
||||
np.char.__all__
|
||||
np.ctypeslib.__all__
|
||||
np.emath.__all__
|
||||
np.lib.__all__
|
||||
np.ma.__all__
|
||||
np.random.__all__
|
||||
np.rec.__all__
|
||||
np.testing.__all__
|
||||
f2py.__all__
|
||||
@@ -0,0 +1,76 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64] = np.array([1.0])
|
||||
AR_i4 = np.array([1], dtype=np.int32)
|
||||
AR_u1 = np.array([1], dtype=np.uint8)
|
||||
|
||||
AR_LIKE_f = [1.5]
|
||||
AR_LIKE_i = [1]
|
||||
|
||||
b_f8 = np.broadcast(AR_f8)
|
||||
b_i4_f8_f8 = np.broadcast(AR_i4, AR_f8, AR_f8)
|
||||
|
||||
next(b_f8)
|
||||
b_f8.reset()
|
||||
b_f8.index
|
||||
b_f8.iters
|
||||
b_f8.nd
|
||||
b_f8.ndim
|
||||
b_f8.numiter
|
||||
b_f8.shape
|
||||
b_f8.size
|
||||
|
||||
next(b_i4_f8_f8)
|
||||
b_i4_f8_f8.reset()
|
||||
b_i4_f8_f8.ndim
|
||||
b_i4_f8_f8.index
|
||||
b_i4_f8_f8.iters
|
||||
b_i4_f8_f8.nd
|
||||
b_i4_f8_f8.numiter
|
||||
b_i4_f8_f8.shape
|
||||
b_i4_f8_f8.size
|
||||
|
||||
np.inner(AR_f8, AR_i4)
|
||||
|
||||
np.where([True, True, False])
|
||||
np.where([True, True, False], 1, 0)
|
||||
|
||||
np.lexsort([0, 1, 2])
|
||||
|
||||
np.can_cast(np.dtype("i8"), int)
|
||||
np.can_cast(AR_f8, "f8")
|
||||
np.can_cast(AR_f8, np.complex128, casting="unsafe")
|
||||
|
||||
np.min_scalar_type([1])
|
||||
np.min_scalar_type(AR_f8)
|
||||
|
||||
np.result_type(int, AR_i4)
|
||||
np.result_type(AR_f8, AR_u1)
|
||||
np.result_type(AR_f8, np.complex128)
|
||||
|
||||
np.dot(AR_LIKE_f, AR_i4)
|
||||
np.dot(AR_u1, 1)
|
||||
np.dot(1.5j, 1)
|
||||
np.dot(AR_u1, 1, out=AR_f8)
|
||||
|
||||
np.vdot(AR_LIKE_f, AR_i4)
|
||||
np.vdot(AR_u1, 1)
|
||||
np.vdot(1.5j, 1)
|
||||
|
||||
np.bincount(AR_i4)
|
||||
|
||||
np.copyto(AR_f8, [1.6])
|
||||
|
||||
np.putmask(AR_f8, [True], 1.5)
|
||||
|
||||
np.packbits(AR_i4)
|
||||
np.packbits(AR_u1)
|
||||
|
||||
np.unpackbits(AR_u1)
|
||||
|
||||
np.shares_memory(1, 2)
|
||||
np.shares_memory(AR_f8, AR_f8, max_work=1)
|
||||
|
||||
np.may_share_memory(1, 2)
|
||||
np.may_share_memory(AR_f8, AR_f8, max_work=1)
|
||||
@@ -0,0 +1,94 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import numpy as np
|
||||
|
||||
nd = np.array([[1, 2], [3, 4]])
|
||||
scalar_array = np.array(1)
|
||||
|
||||
# item
|
||||
scalar_array.item()
|
||||
nd.item(1)
|
||||
nd.item(0, 1)
|
||||
nd.item((0, 1))
|
||||
|
||||
# tolist is pretty simple
|
||||
|
||||
# itemset
|
||||
scalar_array.itemset(3)
|
||||
nd.itemset(3, 0)
|
||||
nd.itemset((0, 0), 3)
|
||||
|
||||
# tobytes
|
||||
nd.tobytes()
|
||||
nd.tobytes("C")
|
||||
nd.tobytes(None)
|
||||
|
||||
# tofile
|
||||
if os.name != "nt":
|
||||
with tempfile.NamedTemporaryFile(suffix=".txt") as tmp:
|
||||
nd.tofile(tmp.name)
|
||||
nd.tofile(tmp.name, "")
|
||||
nd.tofile(tmp.name, sep="")
|
||||
|
||||
nd.tofile(tmp.name, "", "%s")
|
||||
nd.tofile(tmp.name, format="%s")
|
||||
|
||||
nd.tofile(tmp)
|
||||
|
||||
# dump is pretty simple
|
||||
# dumps is pretty simple
|
||||
|
||||
# astype
|
||||
nd.astype("float")
|
||||
nd.astype(float)
|
||||
|
||||
nd.astype(float, "K")
|
||||
nd.astype(float, order="K")
|
||||
|
||||
nd.astype(float, "K", "unsafe")
|
||||
nd.astype(float, casting="unsafe")
|
||||
|
||||
nd.astype(float, "K", "unsafe", True)
|
||||
nd.astype(float, subok=True)
|
||||
|
||||
nd.astype(float, "K", "unsafe", True, True)
|
||||
nd.astype(float, copy=True)
|
||||
|
||||
# byteswap
|
||||
nd.byteswap()
|
||||
nd.byteswap(True)
|
||||
|
||||
# copy
|
||||
nd.copy()
|
||||
nd.copy("C")
|
||||
|
||||
# view
|
||||
nd.view()
|
||||
nd.view(np.int64)
|
||||
nd.view(dtype=np.int64)
|
||||
nd.view(np.int64, np.matrix)
|
||||
nd.view(type=np.matrix)
|
||||
|
||||
# getfield
|
||||
complex_array = np.array([[1 + 1j, 0], [0, 1 - 1j]], dtype=np.complex128)
|
||||
|
||||
complex_array.getfield("float")
|
||||
complex_array.getfield(float)
|
||||
|
||||
complex_array.getfield("float", 8)
|
||||
complex_array.getfield(float, offset=8)
|
||||
|
||||
# setflags
|
||||
nd.setflags()
|
||||
|
||||
nd.setflags(True)
|
||||
nd.setflags(write=True)
|
||||
|
||||
nd.setflags(True, True)
|
||||
nd.setflags(write=True, align=True)
|
||||
|
||||
nd.setflags(True, True, False)
|
||||
nd.setflags(write=True, align=True, uic=False)
|
||||
|
||||
# fill is pretty simple
|
||||
@@ -0,0 +1,185 @@
|
||||
"""
|
||||
Tests for miscellaneous (non-magic) ``np.ndarray``/``np.generic`` methods.
|
||||
|
||||
More extensive tests are performed for the methods'
|
||||
function-based counterpart in `../from_numeric.py`.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import operator
|
||||
from typing import cast, Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
class SubClass(np.ndarray): ...
|
||||
|
||||
i4 = np.int32(1)
|
||||
A: np.ndarray[Any, np.dtype[np.int32]] = np.array([[1]], dtype=np.int32)
|
||||
B0 = np.empty((), dtype=np.int32).view(SubClass)
|
||||
B1 = np.empty((1,), dtype=np.int32).view(SubClass)
|
||||
B2 = np.empty((1, 1), dtype=np.int32).view(SubClass)
|
||||
C: np.ndarray[Any, np.dtype[np.int32]] = np.array([0, 1, 2], dtype=np.int32)
|
||||
D = np.ones(3).view(SubClass)
|
||||
|
||||
i4.all()
|
||||
A.all()
|
||||
A.all(axis=0)
|
||||
A.all(keepdims=True)
|
||||
A.all(out=B0)
|
||||
|
||||
i4.any()
|
||||
A.any()
|
||||
A.any(axis=0)
|
||||
A.any(keepdims=True)
|
||||
A.any(out=B0)
|
||||
|
||||
i4.argmax()
|
||||
A.argmax()
|
||||
A.argmax(axis=0)
|
||||
A.argmax(out=B0)
|
||||
|
||||
i4.argmin()
|
||||
A.argmin()
|
||||
A.argmin(axis=0)
|
||||
A.argmin(out=B0)
|
||||
|
||||
i4.argsort()
|
||||
A.argsort()
|
||||
|
||||
i4.choose([()])
|
||||
_choices = np.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]], dtype=np.int32)
|
||||
C.choose(_choices)
|
||||
C.choose(_choices, out=D)
|
||||
|
||||
i4.clip(1)
|
||||
A.clip(1)
|
||||
A.clip(None, 1)
|
||||
A.clip(1, out=B2)
|
||||
A.clip(None, 1, out=B2)
|
||||
|
||||
i4.compress([1])
|
||||
A.compress([1])
|
||||
A.compress([1], out=B1)
|
||||
|
||||
i4.conj()
|
||||
A.conj()
|
||||
B0.conj()
|
||||
|
||||
i4.conjugate()
|
||||
A.conjugate()
|
||||
B0.conjugate()
|
||||
|
||||
i4.cumprod()
|
||||
A.cumprod()
|
||||
A.cumprod(out=B1)
|
||||
|
||||
i4.cumsum()
|
||||
A.cumsum()
|
||||
A.cumsum(out=B1)
|
||||
|
||||
i4.max()
|
||||
A.max()
|
||||
A.max(axis=0)
|
||||
A.max(keepdims=True)
|
||||
A.max(out=B0)
|
||||
|
||||
i4.mean()
|
||||
A.mean()
|
||||
A.mean(axis=0)
|
||||
A.mean(keepdims=True)
|
||||
A.mean(out=B0)
|
||||
|
||||
i4.min()
|
||||
A.min()
|
||||
A.min(axis=0)
|
||||
A.min(keepdims=True)
|
||||
A.min(out=B0)
|
||||
|
||||
i4.newbyteorder()
|
||||
A.newbyteorder()
|
||||
B0.newbyteorder('|')
|
||||
|
||||
i4.prod()
|
||||
A.prod()
|
||||
A.prod(axis=0)
|
||||
A.prod(keepdims=True)
|
||||
A.prod(out=B0)
|
||||
|
||||
i4.ptp()
|
||||
A.ptp()
|
||||
A.ptp(axis=0)
|
||||
A.ptp(keepdims=True)
|
||||
A.astype(int).ptp(out=B0)
|
||||
|
||||
i4.round()
|
||||
A.round()
|
||||
A.round(out=B2)
|
||||
|
||||
i4.repeat(1)
|
||||
A.repeat(1)
|
||||
B0.repeat(1)
|
||||
|
||||
i4.std()
|
||||
A.std()
|
||||
A.std(axis=0)
|
||||
A.std(keepdims=True)
|
||||
A.std(out=B0.astype(np.float64))
|
||||
|
||||
i4.sum()
|
||||
A.sum()
|
||||
A.sum(axis=0)
|
||||
A.sum(keepdims=True)
|
||||
A.sum(out=B0)
|
||||
|
||||
i4.take(0)
|
||||
A.take(0)
|
||||
A.take([0])
|
||||
A.take(0, out=B0)
|
||||
A.take([0], out=B1)
|
||||
|
||||
i4.var()
|
||||
A.var()
|
||||
A.var(axis=0)
|
||||
A.var(keepdims=True)
|
||||
A.var(out=B0)
|
||||
|
||||
A.argpartition([0])
|
||||
|
||||
A.diagonal()
|
||||
|
||||
A.dot(1)
|
||||
A.dot(1, out=B0)
|
||||
|
||||
A.nonzero()
|
||||
|
||||
C.searchsorted(1)
|
||||
|
||||
A.trace()
|
||||
A.trace(out=B0)
|
||||
|
||||
void = cast(np.void, np.array(1, dtype=[("f", np.float64)]).take(0))
|
||||
void.setfield(10, np.float64)
|
||||
|
||||
A.item(0)
|
||||
C.item(0)
|
||||
|
||||
A.ravel()
|
||||
C.ravel()
|
||||
|
||||
A.flatten()
|
||||
C.flatten()
|
||||
|
||||
A.reshape(1)
|
||||
C.reshape(3)
|
||||
|
||||
int(np.array(1.0, dtype=np.float64))
|
||||
int(np.array("1", dtype=np.str_))
|
||||
|
||||
float(np.array(1.0, dtype=np.float64))
|
||||
float(np.array("1", dtype=np.str_))
|
||||
|
||||
complex(np.array(1.0, dtype=np.float64))
|
||||
|
||||
operator.index(np.array(1, dtype=np.int64))
|
||||
@@ -0,0 +1,47 @@
|
||||
import numpy as np
|
||||
|
||||
nd1 = np.array([[1, 2], [3, 4]])
|
||||
|
||||
# reshape
|
||||
nd1.reshape(4)
|
||||
nd1.reshape(2, 2)
|
||||
nd1.reshape((2, 2))
|
||||
|
||||
nd1.reshape((2, 2), order="C")
|
||||
nd1.reshape(4, order="C")
|
||||
|
||||
# resize
|
||||
nd1.resize()
|
||||
nd1.resize(4)
|
||||
nd1.resize(2, 2)
|
||||
nd1.resize((2, 2))
|
||||
|
||||
nd1.resize((2, 2), refcheck=True)
|
||||
nd1.resize(4, refcheck=True)
|
||||
|
||||
nd2 = np.array([[1, 2], [3, 4]])
|
||||
|
||||
# transpose
|
||||
nd2.transpose()
|
||||
nd2.transpose(1, 0)
|
||||
nd2.transpose((1, 0))
|
||||
|
||||
# swapaxes
|
||||
nd2.swapaxes(0, 1)
|
||||
|
||||
# flatten
|
||||
nd2.flatten()
|
||||
nd2.flatten("C")
|
||||
|
||||
# ravel
|
||||
nd2.ravel()
|
||||
nd2.ravel("C")
|
||||
|
||||
# squeeze
|
||||
nd2.squeeze()
|
||||
|
||||
nd3 = np.array([[1, 2]])
|
||||
nd3.squeeze(0)
|
||||
|
||||
nd4 = np.array([[[1, 2]]])
|
||||
nd4.squeeze((0, 1))
|
||||
@@ -0,0 +1,90 @@
|
||||
"""
|
||||
Tests for :mod:`numpy.core.numeric`.
|
||||
|
||||
Does not include tests which fall under ``array_constructors``.
|
||||
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import numpy as np
|
||||
|
||||
class SubClass(np.ndarray):
|
||||
...
|
||||
|
||||
i8 = np.int64(1)
|
||||
|
||||
A = np.arange(27).reshape(3, 3, 3)
|
||||
B: list[list[list[int]]] = A.tolist()
|
||||
C = np.empty((27, 27)).view(SubClass)
|
||||
|
||||
np.count_nonzero(i8)
|
||||
np.count_nonzero(A)
|
||||
np.count_nonzero(B)
|
||||
np.count_nonzero(A, keepdims=True)
|
||||
np.count_nonzero(A, axis=0)
|
||||
|
||||
np.isfortran(i8)
|
||||
np.isfortran(A)
|
||||
|
||||
np.argwhere(i8)
|
||||
np.argwhere(A)
|
||||
|
||||
np.flatnonzero(i8)
|
||||
np.flatnonzero(A)
|
||||
|
||||
np.correlate(B[0][0], A.ravel(), mode="valid")
|
||||
np.correlate(A.ravel(), A.ravel(), mode="same")
|
||||
|
||||
np.convolve(B[0][0], A.ravel(), mode="valid")
|
||||
np.convolve(A.ravel(), A.ravel(), mode="same")
|
||||
|
||||
np.outer(i8, A)
|
||||
np.outer(B, A)
|
||||
np.outer(A, A)
|
||||
np.outer(A, A, out=C)
|
||||
|
||||
np.tensordot(B, A)
|
||||
np.tensordot(A, A)
|
||||
np.tensordot(A, A, axes=0)
|
||||
np.tensordot(A, A, axes=(0, 1))
|
||||
|
||||
np.isscalar(i8)
|
||||
np.isscalar(A)
|
||||
np.isscalar(B)
|
||||
|
||||
np.roll(A, 1)
|
||||
np.roll(A, (1, 2))
|
||||
np.roll(B, 1)
|
||||
|
||||
np.rollaxis(A, 0, 1)
|
||||
|
||||
np.moveaxis(A, 0, 1)
|
||||
np.moveaxis(A, (0, 1), (1, 2))
|
||||
|
||||
np.cross(B, A)
|
||||
np.cross(A, A)
|
||||
|
||||
np.indices([0, 1, 2])
|
||||
np.indices([0, 1, 2], sparse=False)
|
||||
np.indices([0, 1, 2], sparse=True)
|
||||
|
||||
np.binary_repr(1)
|
||||
|
||||
np.base_repr(1)
|
||||
|
||||
np.allclose(i8, A)
|
||||
np.allclose(B, A)
|
||||
np.allclose(A, A)
|
||||
|
||||
np.isclose(i8, A)
|
||||
np.isclose(B, A)
|
||||
np.isclose(A, A)
|
||||
|
||||
np.array_equal(i8, A)
|
||||
np.array_equal(B, A)
|
||||
np.array_equal(A, A)
|
||||
|
||||
np.array_equiv(i8, A)
|
||||
np.array_equiv(B, A)
|
||||
np.array_equiv(A, A)
|
||||
@@ -0,0 +1,47 @@
|
||||
import numpy as np
|
||||
|
||||
np.maximum_sctype("S8")
|
||||
np.maximum_sctype(object)
|
||||
|
||||
np.issctype(object)
|
||||
np.issctype("S8")
|
||||
|
||||
np.obj2sctype(list)
|
||||
np.obj2sctype(list, default=None)
|
||||
np.obj2sctype(list, default=np.string_)
|
||||
|
||||
np.issubclass_(np.int32, int)
|
||||
np.issubclass_(np.float64, float)
|
||||
np.issubclass_(np.float64, (int, float))
|
||||
|
||||
np.issubsctype("int64", int)
|
||||
np.issubsctype(np.array([1]), np.array([1]))
|
||||
|
||||
np.issubdtype("S1", np.string_)
|
||||
np.issubdtype(np.float64, np.float32)
|
||||
|
||||
np.sctype2char("S1")
|
||||
np.sctype2char(list)
|
||||
|
||||
np.find_common_type([], [np.int64, np.float32, complex])
|
||||
np.find_common_type((), (np.int64, np.float32, complex))
|
||||
np.find_common_type([np.int64, np.float32], [])
|
||||
np.find_common_type([np.float32], [np.int64, np.float64])
|
||||
|
||||
np.cast[int]
|
||||
np.cast["i8"]
|
||||
np.cast[np.int64]
|
||||
|
||||
np.nbytes[int]
|
||||
np.nbytes["i8"]
|
||||
np.nbytes[np.int64]
|
||||
|
||||
np.ScalarType
|
||||
np.ScalarType[0]
|
||||
np.ScalarType[3]
|
||||
np.ScalarType[8]
|
||||
np.ScalarType[10]
|
||||
|
||||
np.typecodes["Character"]
|
||||
np.typecodes["Complex"]
|
||||
np.typecodes["All"]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,248 @@
|
||||
import sys
|
||||
import datetime as dt
|
||||
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
b = np.bool_()
|
||||
u8 = np.uint64()
|
||||
i8 = np.int64()
|
||||
f8 = np.float64()
|
||||
c16 = np.complex128()
|
||||
U = np.str_()
|
||||
S = np.bytes_()
|
||||
|
||||
|
||||
# Construction
|
||||
class D:
|
||||
def __index__(self) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
class C:
|
||||
def __complex__(self) -> complex:
|
||||
return 3j
|
||||
|
||||
|
||||
class B:
|
||||
def __int__(self) -> int:
|
||||
return 4
|
||||
|
||||
|
||||
class A:
|
||||
def __float__(self) -> float:
|
||||
return 4.0
|
||||
|
||||
|
||||
np.complex64(3j)
|
||||
np.complex64(A())
|
||||
np.complex64(C())
|
||||
np.complex128(3j)
|
||||
np.complex128(C())
|
||||
np.complex128(None)
|
||||
np.complex64("1.2")
|
||||
np.complex128(b"2j")
|
||||
|
||||
np.int8(4)
|
||||
np.int16(3.4)
|
||||
np.int32(4)
|
||||
np.int64(-1)
|
||||
np.uint8(B())
|
||||
np.uint32()
|
||||
np.int32("1")
|
||||
np.int64(b"2")
|
||||
|
||||
np.float16(A())
|
||||
np.float32(16)
|
||||
np.float64(3.0)
|
||||
np.float64(None)
|
||||
np.float32("1")
|
||||
np.float16(b"2.5")
|
||||
|
||||
np.uint64(D())
|
||||
np.float32(D())
|
||||
np.complex64(D())
|
||||
|
||||
np.bytes_(b"hello")
|
||||
np.bytes_("hello", 'utf-8')
|
||||
np.bytes_("hello", encoding='utf-8')
|
||||
np.str_("hello")
|
||||
np.str_(b"hello", 'utf-8')
|
||||
np.str_(b"hello", encoding='utf-8')
|
||||
|
||||
# Array-ish semantics
|
||||
np.int8().real
|
||||
np.int16().imag
|
||||
np.int32().data
|
||||
np.int64().flags
|
||||
|
||||
np.uint8().itemsize * 2
|
||||
np.uint16().ndim + 1
|
||||
np.uint32().strides
|
||||
np.uint64().shape
|
||||
|
||||
# Time structures
|
||||
np.datetime64()
|
||||
np.datetime64(0, "D")
|
||||
np.datetime64(0, b"D")
|
||||
np.datetime64(0, ('ms', 3))
|
||||
np.datetime64("2019")
|
||||
np.datetime64(b"2019")
|
||||
np.datetime64("2019", "D")
|
||||
np.datetime64(np.datetime64())
|
||||
np.datetime64(dt.datetime(2000, 5, 3))
|
||||
np.datetime64(dt.date(2000, 5, 3))
|
||||
np.datetime64(None)
|
||||
np.datetime64(None, "D")
|
||||
|
||||
np.timedelta64()
|
||||
np.timedelta64(0)
|
||||
np.timedelta64(0, "D")
|
||||
np.timedelta64(0, ('ms', 3))
|
||||
np.timedelta64(0, b"D")
|
||||
np.timedelta64("3")
|
||||
np.timedelta64(b"5")
|
||||
np.timedelta64(np.timedelta64(2))
|
||||
np.timedelta64(dt.timedelta(2))
|
||||
np.timedelta64(None)
|
||||
np.timedelta64(None, "D")
|
||||
|
||||
np.void(1)
|
||||
np.void(np.int64(1))
|
||||
np.void(True)
|
||||
np.void(np.bool_(True))
|
||||
np.void(b"test")
|
||||
np.void(np.bytes_("test"))
|
||||
np.void(object(), [("a", "O"), ("b", "O")])
|
||||
np.void(object(), dtype=[("a", "O"), ("b", "O")])
|
||||
|
||||
# Protocols
|
||||
i8 = np.int64()
|
||||
u8 = np.uint64()
|
||||
f8 = np.float64()
|
||||
c16 = np.complex128()
|
||||
b_ = np.bool_()
|
||||
td = np.timedelta64()
|
||||
U = np.str_("1")
|
||||
S = np.bytes_("1")
|
||||
AR = np.array(1, dtype=np.float64)
|
||||
|
||||
int(i8)
|
||||
int(u8)
|
||||
int(f8)
|
||||
int(b_)
|
||||
int(td)
|
||||
int(U)
|
||||
int(S)
|
||||
int(AR)
|
||||
with pytest.warns(np.ComplexWarning):
|
||||
int(c16)
|
||||
|
||||
float(i8)
|
||||
float(u8)
|
||||
float(f8)
|
||||
float(b_)
|
||||
float(td)
|
||||
float(U)
|
||||
float(S)
|
||||
float(AR)
|
||||
with pytest.warns(np.ComplexWarning):
|
||||
float(c16)
|
||||
|
||||
complex(i8)
|
||||
complex(u8)
|
||||
complex(f8)
|
||||
complex(c16)
|
||||
complex(b_)
|
||||
complex(td)
|
||||
complex(U)
|
||||
complex(AR)
|
||||
|
||||
|
||||
# Misc
|
||||
c16.dtype
|
||||
c16.real
|
||||
c16.imag
|
||||
c16.real.real
|
||||
c16.real.imag
|
||||
c16.ndim
|
||||
c16.size
|
||||
c16.itemsize
|
||||
c16.shape
|
||||
c16.strides
|
||||
c16.squeeze()
|
||||
c16.byteswap()
|
||||
c16.transpose()
|
||||
|
||||
# Aliases
|
||||
np.string_()
|
||||
|
||||
np.byte()
|
||||
np.short()
|
||||
np.intc()
|
||||
np.intp()
|
||||
np.int_()
|
||||
np.longlong()
|
||||
|
||||
np.ubyte()
|
||||
np.ushort()
|
||||
np.uintc()
|
||||
np.uintp()
|
||||
np.uint()
|
||||
np.ulonglong()
|
||||
|
||||
np.half()
|
||||
np.single()
|
||||
np.double()
|
||||
np.float_()
|
||||
np.longdouble()
|
||||
np.longfloat()
|
||||
|
||||
np.csingle()
|
||||
np.singlecomplex()
|
||||
np.cdouble()
|
||||
np.complex_()
|
||||
np.cfloat()
|
||||
np.clongdouble()
|
||||
np.clongfloat()
|
||||
np.longcomplex()
|
||||
|
||||
b.item()
|
||||
i8.item()
|
||||
u8.item()
|
||||
f8.item()
|
||||
c16.item()
|
||||
U.item()
|
||||
S.item()
|
||||
|
||||
b.tolist()
|
||||
i8.tolist()
|
||||
u8.tolist()
|
||||
f8.tolist()
|
||||
c16.tolist()
|
||||
U.tolist()
|
||||
S.tolist()
|
||||
|
||||
b.ravel()
|
||||
i8.ravel()
|
||||
u8.ravel()
|
||||
f8.ravel()
|
||||
c16.ravel()
|
||||
U.ravel()
|
||||
S.ravel()
|
||||
|
||||
b.flatten()
|
||||
i8.flatten()
|
||||
u8.flatten()
|
||||
f8.flatten()
|
||||
c16.flatten()
|
||||
U.flatten()
|
||||
S.flatten()
|
||||
|
||||
b.reshape(1)
|
||||
i8.reshape(1)
|
||||
u8.reshape(1)
|
||||
f8.reshape(1)
|
||||
c16.reshape(1)
|
||||
U.reshape(1)
|
||||
S.reshape(1)
|
||||
@@ -0,0 +1,165 @@
|
||||
"""Simple expression that should pass with mypy."""
|
||||
import operator
|
||||
|
||||
import numpy as np
|
||||
from collections.abc import Iterable
|
||||
|
||||
# Basic checks
|
||||
array = np.array([1, 2])
|
||||
|
||||
|
||||
def ndarray_func(x):
|
||||
# type: (np.ndarray) -> np.ndarray
|
||||
return x
|
||||
|
||||
|
||||
ndarray_func(np.array([1, 2]))
|
||||
array == 1
|
||||
array.dtype == float
|
||||
|
||||
# Dtype construction
|
||||
np.dtype(float)
|
||||
np.dtype(np.float64)
|
||||
np.dtype(None)
|
||||
np.dtype("float64")
|
||||
np.dtype(np.dtype(float))
|
||||
np.dtype(("U", 10))
|
||||
np.dtype((np.int32, (2, 2)))
|
||||
# Define the arguments on the previous line to prevent bidirectional
|
||||
# type inference in mypy from broadening the types.
|
||||
two_tuples_dtype = [("R", "u1"), ("G", "u1"), ("B", "u1")]
|
||||
np.dtype(two_tuples_dtype)
|
||||
|
||||
three_tuples_dtype = [("R", "u1", 2)]
|
||||
np.dtype(three_tuples_dtype)
|
||||
|
||||
mixed_tuples_dtype = [("R", "u1"), ("G", np.unicode_, 1)]
|
||||
np.dtype(mixed_tuples_dtype)
|
||||
|
||||
shape_tuple_dtype = [("R", "u1", (2, 2))]
|
||||
np.dtype(shape_tuple_dtype)
|
||||
|
||||
shape_like_dtype = [("R", "u1", (2, 2)), ("G", np.unicode_, 1)]
|
||||
np.dtype(shape_like_dtype)
|
||||
|
||||
object_dtype = [("field1", object)]
|
||||
np.dtype(object_dtype)
|
||||
|
||||
np.dtype((np.int32, (np.int8, 4)))
|
||||
|
||||
# Dtype comparison
|
||||
np.dtype(float) == float
|
||||
np.dtype(float) != np.float64
|
||||
np.dtype(float) < None
|
||||
np.dtype(float) <= "float64"
|
||||
np.dtype(float) > np.dtype(float)
|
||||
np.dtype(float) >= np.dtype(("U", 10))
|
||||
|
||||
# Iteration and indexing
|
||||
def iterable_func(x):
|
||||
# type: (Iterable) -> Iterable
|
||||
return x
|
||||
|
||||
|
||||
iterable_func(array)
|
||||
[element for element in array]
|
||||
iter(array)
|
||||
zip(array, array)
|
||||
array[1]
|
||||
array[:]
|
||||
array[...]
|
||||
array[:] = 0
|
||||
|
||||
array_2d = np.ones((3, 3))
|
||||
array_2d[:2, :2]
|
||||
array_2d[..., 0]
|
||||
array_2d[:2, :2] = 0
|
||||
|
||||
# Other special methods
|
||||
len(array)
|
||||
str(array)
|
||||
array_scalar = np.array(1)
|
||||
int(array_scalar)
|
||||
float(array_scalar)
|
||||
# currently does not work due to https://github.com/python/typeshed/issues/1904
|
||||
# complex(array_scalar)
|
||||
bytes(array_scalar)
|
||||
operator.index(array_scalar)
|
||||
bool(array_scalar)
|
||||
|
||||
# comparisons
|
||||
array < 1
|
||||
array <= 1
|
||||
array == 1
|
||||
array != 1
|
||||
array > 1
|
||||
array >= 1
|
||||
1 < array
|
||||
1 <= array
|
||||
1 == array
|
||||
1 != array
|
||||
1 > array
|
||||
1 >= array
|
||||
|
||||
# binary arithmetic
|
||||
array + 1
|
||||
1 + array
|
||||
array += 1
|
||||
|
||||
array - 1
|
||||
1 - array
|
||||
array -= 1
|
||||
|
||||
array * 1
|
||||
1 * array
|
||||
array *= 1
|
||||
|
||||
nonzero_array = np.array([1, 2])
|
||||
array / 1
|
||||
1 / nonzero_array
|
||||
float_array = np.array([1.0, 2.0])
|
||||
float_array /= 1
|
||||
|
||||
array // 1
|
||||
1 // nonzero_array
|
||||
array //= 1
|
||||
|
||||
array % 1
|
||||
1 % nonzero_array
|
||||
array %= 1
|
||||
|
||||
divmod(array, 1)
|
||||
divmod(1, nonzero_array)
|
||||
|
||||
array ** 1
|
||||
1 ** array
|
||||
array **= 1
|
||||
|
||||
array << 1
|
||||
1 << array
|
||||
array <<= 1
|
||||
|
||||
array >> 1
|
||||
1 >> array
|
||||
array >>= 1
|
||||
|
||||
array & 1
|
||||
1 & array
|
||||
array &= 1
|
||||
|
||||
array ^ 1
|
||||
1 ^ array
|
||||
array ^= 1
|
||||
|
||||
array | 1
|
||||
1 | array
|
||||
array |= 1
|
||||
|
||||
# unary arithmetic
|
||||
-array
|
||||
+array
|
||||
abs(array)
|
||||
~array
|
||||
|
||||
# Other methods
|
||||
np.array([1, 2]).transpose()
|
||||
@@ -0,0 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
array = np.array([1, 2])
|
||||
|
||||
# The @ operator is not in python 2
|
||||
array @ array
|
||||
@@ -0,0 +1,50 @@
|
||||
"""Typing tests for `numpy.core._ufunc_config`."""
|
||||
|
||||
import numpy as np
|
||||
|
||||
def func1(a: str, b: int) -> None: ...
|
||||
def func2(a: str, b: int, c: float = ...) -> None: ...
|
||||
def func3(a: str, b: int) -> int: ...
|
||||
|
||||
class Write1:
|
||||
def write(self, a: str) -> None: ...
|
||||
|
||||
class Write2:
|
||||
def write(self, a: str, b: int = ...) -> None: ...
|
||||
|
||||
class Write3:
|
||||
def write(self, a: str) -> int: ...
|
||||
|
||||
|
||||
_err_default = np.geterr()
|
||||
_bufsize_default = np.getbufsize()
|
||||
_errcall_default = np.geterrcall()
|
||||
|
||||
try:
|
||||
np.seterr(all=None)
|
||||
np.seterr(divide="ignore")
|
||||
np.seterr(over="warn")
|
||||
np.seterr(under="call")
|
||||
np.seterr(invalid="raise")
|
||||
np.geterr()
|
||||
|
||||
np.setbufsize(4096)
|
||||
np.getbufsize()
|
||||
|
||||
np.seterrcall(func1)
|
||||
np.seterrcall(func2)
|
||||
np.seterrcall(func3)
|
||||
np.seterrcall(Write1())
|
||||
np.seterrcall(Write2())
|
||||
np.seterrcall(Write3())
|
||||
np.geterrcall()
|
||||
|
||||
with np.errstate(call=func1, all="call"):
|
||||
pass
|
||||
with np.errstate(call=Write1(), divide="log", over="log"):
|
||||
pass
|
||||
|
||||
finally:
|
||||
np.seterr(**_err_default)
|
||||
np.setbufsize(_bufsize_default)
|
||||
np.seterrcall(_errcall_default)
|
||||
@@ -0,0 +1,46 @@
|
||||
from __future__ import annotations
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Object:
|
||||
def __ceil__(self) -> Object:
|
||||
return self
|
||||
|
||||
def __floor__(self) -> Object:
|
||||
return self
|
||||
|
||||
def __ge__(self, value: object) -> bool:
|
||||
return True
|
||||
|
||||
def __array__(self) -> np.ndarray[Any, np.dtype[np.object_]]:
|
||||
ret = np.empty((), dtype=object)
|
||||
ret[()] = self
|
||||
return ret
|
||||
|
||||
|
||||
AR_LIKE_b = [True, True, False]
|
||||
AR_LIKE_u = [np.uint32(1), np.uint32(2), np.uint32(3)]
|
||||
AR_LIKE_i = [1, 2, 3]
|
||||
AR_LIKE_f = [1.0, 2.0, 3.0]
|
||||
AR_LIKE_O = [Object(), Object(), Object()]
|
||||
AR_U: np.ndarray[Any, np.dtype[np.str_]] = np.zeros(3, dtype="U5")
|
||||
|
||||
np.fix(AR_LIKE_b)
|
||||
np.fix(AR_LIKE_u)
|
||||
np.fix(AR_LIKE_i)
|
||||
np.fix(AR_LIKE_f)
|
||||
np.fix(AR_LIKE_O)
|
||||
np.fix(AR_LIKE_f, out=AR_U)
|
||||
|
||||
np.isposinf(AR_LIKE_b)
|
||||
np.isposinf(AR_LIKE_u)
|
||||
np.isposinf(AR_LIKE_i)
|
||||
np.isposinf(AR_LIKE_f)
|
||||
np.isposinf(AR_LIKE_f, out=AR_U)
|
||||
|
||||
np.isneginf(AR_LIKE_b)
|
||||
np.isneginf(AR_LIKE_u)
|
||||
np.isneginf(AR_LIKE_i)
|
||||
np.isneginf(AR_LIKE_f)
|
||||
np.isneginf(AR_LIKE_f, out=AR_U)
|
||||
@@ -0,0 +1,17 @@
|
||||
import numpy as np
|
||||
|
||||
np.sin(1)
|
||||
np.sin([1, 2, 3])
|
||||
np.sin(1, out=np.empty(1))
|
||||
np.matmul(np.ones((2, 2, 2)), np.ones((2, 2, 2)), axes=[(0, 1), (0, 1), (0, 1)])
|
||||
np.sin(1, signature="D->D")
|
||||
np.sin(1, extobj=[16, 1, lambda: None])
|
||||
# NOTE: `np.generic` subclasses are not guaranteed to support addition;
|
||||
# re-enable this we can infer the exact return type of `np.sin(...)`.
|
||||
#
|
||||
# np.sin(1) + np.sin(1)
|
||||
np.sin.types[0]
|
||||
np.sin.__name__
|
||||
np.sin.__doc__
|
||||
|
||||
np.abs(np.array([1]))
|
||||
@@ -0,0 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
np.AxisError("test")
|
||||
np.AxisError(1, ndim=2)
|
||||
np.AxisError(1, ndim=2, msg_prefix="error")
|
||||
np.AxisError(1, ndim=2, msg_prefix=None)
|
||||
@@ -0,0 +1,526 @@
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
from numpy._typing import NDArray, _128Bit
|
||||
|
||||
# Can't directly import `np.float128` as it is not available on all platforms
|
||||
f16: np.floating[_128Bit]
|
||||
|
||||
c16 = np.complex128()
|
||||
f8 = np.float64()
|
||||
i8 = np.int64()
|
||||
u8 = np.uint64()
|
||||
|
||||
c8 = np.complex64()
|
||||
f4 = np.float32()
|
||||
i4 = np.int32()
|
||||
u4 = np.uint32()
|
||||
|
||||
dt = np.datetime64(0, "D")
|
||||
td = np.timedelta64(0, "D")
|
||||
|
||||
b_ = np.bool_()
|
||||
|
||||
b = bool()
|
||||
c = complex()
|
||||
f = float()
|
||||
i = int()
|
||||
|
||||
AR_b: np.ndarray[Any, np.dtype[np.bool_]]
|
||||
AR_u: np.ndarray[Any, np.dtype[np.uint32]]
|
||||
AR_i: np.ndarray[Any, np.dtype[np.int64]]
|
||||
AR_f: np.ndarray[Any, np.dtype[np.float64]]
|
||||
AR_c: np.ndarray[Any, np.dtype[np.complex128]]
|
||||
AR_m: np.ndarray[Any, np.dtype[np.timedelta64]]
|
||||
AR_M: np.ndarray[Any, np.dtype[np.datetime64]]
|
||||
AR_O: np.ndarray[Any, np.dtype[np.object_]]
|
||||
AR_number: NDArray[np.number[Any]]
|
||||
|
||||
AR_LIKE_b: list[bool]
|
||||
AR_LIKE_u: list[np.uint32]
|
||||
AR_LIKE_i: list[int]
|
||||
AR_LIKE_f: list[float]
|
||||
AR_LIKE_c: list[complex]
|
||||
AR_LIKE_m: list[np.timedelta64]
|
||||
AR_LIKE_M: list[np.datetime64]
|
||||
AR_LIKE_O: list[np.object_]
|
||||
|
||||
# Array subtraction
|
||||
|
||||
reveal_type(AR_number - AR_number) # E: ndarray[Any, dtype[number[Any]]]
|
||||
|
||||
reveal_type(AR_b - AR_LIKE_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_b - AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_b - AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_b - AR_LIKE_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_b - AR_LIKE_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_b - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_u - AR_b) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i - AR_b) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f - AR_b) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_c - AR_b) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_m - AR_b) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_M - AR_b) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_LIKE_O - AR_b) # E: Any
|
||||
|
||||
reveal_type(AR_u - AR_LIKE_b) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_u - AR_LIKE_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_u - AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_u - AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_u - AR_LIKE_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_u - AR_LIKE_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_u - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_u - AR_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i - AR_u) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f - AR_u) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_c - AR_u) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_m - AR_u) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_M - AR_u) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_LIKE_O - AR_u) # E: Any
|
||||
|
||||
reveal_type(AR_i - AR_LIKE_b) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i - AR_LIKE_u) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i - AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i - AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_i - AR_LIKE_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_i - AR_LIKE_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_i - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_u - AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i - AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f - AR_i) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_c - AR_i) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_m - AR_i) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_M - AR_i) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_LIKE_O - AR_i) # E: Any
|
||||
|
||||
reveal_type(AR_f - AR_LIKE_b) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f - AR_LIKE_u) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f - AR_LIKE_i) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f - AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f - AR_LIKE_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_f - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_u - AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_i - AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_f - AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_c - AR_f) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_O - AR_f) # E: Any
|
||||
|
||||
reveal_type(AR_c - AR_LIKE_b) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_c - AR_LIKE_u) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_c - AR_LIKE_i) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_c - AR_LIKE_f) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_c - AR_LIKE_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_c - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_u - AR_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_i - AR_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_f - AR_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_c - AR_c) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(AR_LIKE_O - AR_c) # E: Any
|
||||
|
||||
reveal_type(AR_m - AR_LIKE_b) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m - AR_LIKE_u) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m - AR_LIKE_i) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m - AR_LIKE_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_u - AR_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_i - AR_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_m - AR_m) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_M - AR_m) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_LIKE_O - AR_m) # E: Any
|
||||
|
||||
reveal_type(AR_M - AR_LIKE_b) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_M - AR_LIKE_u) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_M - AR_LIKE_i) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_M - AR_LIKE_m) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(AR_M - AR_LIKE_M) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_M - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_M - AR_M) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_O - AR_M) # E: Any
|
||||
|
||||
reveal_type(AR_O - AR_LIKE_b) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_u) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_i) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_f) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_c) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_m) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_M) # E: Any
|
||||
reveal_type(AR_O - AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_u - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_i - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_f - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_c - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_m - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_M - AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_O - AR_O) # E: Any
|
||||
|
||||
# Array floor division
|
||||
|
||||
reveal_type(AR_b // AR_LIKE_b) # E: ndarray[Any, dtype[{int8}]]
|
||||
reveal_type(AR_b // AR_LIKE_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_b // AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_b // AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_b // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b // AR_b) # E: ndarray[Any, dtype[{int8}]]
|
||||
reveal_type(AR_LIKE_u // AR_b) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i // AR_b) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f // AR_b) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_O // AR_b) # E: Any
|
||||
|
||||
reveal_type(AR_u // AR_LIKE_b) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_u // AR_LIKE_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_u // AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_u // AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_u // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b // AR_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_u // AR_u) # E: ndarray[Any, dtype[unsignedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i // AR_u) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f // AR_u) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_m // AR_u) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_O // AR_u) # E: Any
|
||||
|
||||
reveal_type(AR_i // AR_LIKE_b) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i // AR_LIKE_u) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i // AR_LIKE_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_i // AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_i // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b // AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_u // AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_i // AR_i) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(AR_LIKE_f // AR_i) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_m // AR_i) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_O // AR_i) # E: Any
|
||||
|
||||
reveal_type(AR_f // AR_LIKE_b) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f // AR_LIKE_u) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f // AR_LIKE_i) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f // AR_LIKE_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_f // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b // AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_u // AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_i // AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_f // AR_f) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(AR_LIKE_m // AR_f) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_LIKE_O // AR_f) # E: Any
|
||||
|
||||
reveal_type(AR_m // AR_LIKE_u) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m // AR_LIKE_i) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m // AR_LIKE_f) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(AR_m // AR_LIKE_m) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(AR_m // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_m // AR_m) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(AR_LIKE_O // AR_m) # E: Any
|
||||
|
||||
reveal_type(AR_O // AR_LIKE_b) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_u) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_i) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_f) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_m) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_M) # E: Any
|
||||
reveal_type(AR_O // AR_LIKE_O) # E: Any
|
||||
|
||||
reveal_type(AR_LIKE_b // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_u // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_i // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_f // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_m // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_M // AR_O) # E: Any
|
||||
reveal_type(AR_LIKE_O // AR_O) # E: Any
|
||||
|
||||
# unary ops
|
||||
|
||||
reveal_type(-f16) # E: {float128}
|
||||
reveal_type(-c16) # E: {complex128}
|
||||
reveal_type(-c8) # E: {complex64}
|
||||
reveal_type(-f8) # E: {float64}
|
||||
reveal_type(-f4) # E: {float32}
|
||||
reveal_type(-i8) # E: {int64}
|
||||
reveal_type(-i4) # E: {int32}
|
||||
reveal_type(-u8) # E: {uint64}
|
||||
reveal_type(-u4) # E: {uint32}
|
||||
reveal_type(-td) # E: timedelta64
|
||||
reveal_type(-AR_f) # E: Any
|
||||
|
||||
reveal_type(+f16) # E: {float128}
|
||||
reveal_type(+c16) # E: {complex128}
|
||||
reveal_type(+c8) # E: {complex64}
|
||||
reveal_type(+f8) # E: {float64}
|
||||
reveal_type(+f4) # E: {float32}
|
||||
reveal_type(+i8) # E: {int64}
|
||||
reveal_type(+i4) # E: {int32}
|
||||
reveal_type(+u8) # E: {uint64}
|
||||
reveal_type(+u4) # E: {uint32}
|
||||
reveal_type(+td) # E: timedelta64
|
||||
reveal_type(+AR_f) # E: Any
|
||||
|
||||
reveal_type(abs(f16)) # E: {float128}
|
||||
reveal_type(abs(c16)) # E: {float64}
|
||||
reveal_type(abs(c8)) # E: {float32}
|
||||
reveal_type(abs(f8)) # E: {float64}
|
||||
reveal_type(abs(f4)) # E: {float32}
|
||||
reveal_type(abs(i8)) # E: {int64}
|
||||
reveal_type(abs(i4)) # E: {int32}
|
||||
reveal_type(abs(u8)) # E: {uint64}
|
||||
reveal_type(abs(u4)) # E: {uint32}
|
||||
reveal_type(abs(td)) # E: timedelta64
|
||||
reveal_type(abs(b_)) # E: bool_
|
||||
reveal_type(abs(AR_f)) # E: Any
|
||||
|
||||
# Time structures
|
||||
|
||||
reveal_type(dt + td) # E: datetime64
|
||||
reveal_type(dt + i) # E: datetime64
|
||||
reveal_type(dt + i4) # E: datetime64
|
||||
reveal_type(dt + i8) # E: datetime64
|
||||
reveal_type(dt - dt) # E: timedelta64
|
||||
reveal_type(dt - i) # E: datetime64
|
||||
reveal_type(dt - i4) # E: datetime64
|
||||
reveal_type(dt - i8) # E: datetime64
|
||||
|
||||
reveal_type(td + td) # E: timedelta64
|
||||
reveal_type(td + i) # E: timedelta64
|
||||
reveal_type(td + i4) # E: timedelta64
|
||||
reveal_type(td + i8) # E: timedelta64
|
||||
reveal_type(td - td) # E: timedelta64
|
||||
reveal_type(td - i) # E: timedelta64
|
||||
reveal_type(td - i4) # E: timedelta64
|
||||
reveal_type(td - i8) # E: timedelta64
|
||||
reveal_type(td / f) # E: timedelta64
|
||||
reveal_type(td / f4) # E: timedelta64
|
||||
reveal_type(td / f8) # E: timedelta64
|
||||
reveal_type(td / td) # E: {float64}
|
||||
reveal_type(td // td) # E: {int64}
|
||||
|
||||
# boolean
|
||||
|
||||
reveal_type(b_ / b) # E: {float64}
|
||||
reveal_type(b_ / b_) # E: {float64}
|
||||
reveal_type(b_ / i) # E: {float64}
|
||||
reveal_type(b_ / i8) # E: {float64}
|
||||
reveal_type(b_ / i4) # E: {float64}
|
||||
reveal_type(b_ / u8) # E: {float64}
|
||||
reveal_type(b_ / u4) # E: {float64}
|
||||
reveal_type(b_ / f) # E: {float64}
|
||||
reveal_type(b_ / f16) # E: {float128}
|
||||
reveal_type(b_ / f8) # E: {float64}
|
||||
reveal_type(b_ / f4) # E: {float32}
|
||||
reveal_type(b_ / c) # E: {complex128}
|
||||
reveal_type(b_ / c16) # E: {complex128}
|
||||
reveal_type(b_ / c8) # E: {complex64}
|
||||
|
||||
reveal_type(b / b_) # E: {float64}
|
||||
reveal_type(b_ / b_) # E: {float64}
|
||||
reveal_type(i / b_) # E: {float64}
|
||||
reveal_type(i8 / b_) # E: {float64}
|
||||
reveal_type(i4 / b_) # E: {float64}
|
||||
reveal_type(u8 / b_) # E: {float64}
|
||||
reveal_type(u4 / b_) # E: {float64}
|
||||
reveal_type(f / b_) # E: {float64}
|
||||
reveal_type(f16 / b_) # E: {float128}
|
||||
reveal_type(f8 / b_) # E: {float64}
|
||||
reveal_type(f4 / b_) # E: {float32}
|
||||
reveal_type(c / b_) # E: {complex128}
|
||||
reveal_type(c16 / b_) # E: {complex128}
|
||||
reveal_type(c8 / b_) # E: {complex64}
|
||||
|
||||
# Complex
|
||||
|
||||
reveal_type(c16 + f16) # E: {complex256}
|
||||
reveal_type(c16 + c16) # E: {complex128}
|
||||
reveal_type(c16 + f8) # E: {complex128}
|
||||
reveal_type(c16 + i8) # E: {complex128}
|
||||
reveal_type(c16 + c8) # E: {complex128}
|
||||
reveal_type(c16 + f4) # E: {complex128}
|
||||
reveal_type(c16 + i4) # E: {complex128}
|
||||
reveal_type(c16 + b_) # E: {complex128}
|
||||
reveal_type(c16 + b) # E: {complex128}
|
||||
reveal_type(c16 + c) # E: {complex128}
|
||||
reveal_type(c16 + f) # E: {complex128}
|
||||
reveal_type(c16 + i) # E: {complex128}
|
||||
reveal_type(c16 + AR_f) # E: Any
|
||||
|
||||
reveal_type(f16 + c16) # E: {complex256}
|
||||
reveal_type(c16 + c16) # E: {complex128}
|
||||
reveal_type(f8 + c16) # E: {complex128}
|
||||
reveal_type(i8 + c16) # E: {complex128}
|
||||
reveal_type(c8 + c16) # E: {complex128}
|
||||
reveal_type(f4 + c16) # E: {complex128}
|
||||
reveal_type(i4 + c16) # E: {complex128}
|
||||
reveal_type(b_ + c16) # E: {complex128}
|
||||
reveal_type(b + c16) # E: {complex128}
|
||||
reveal_type(c + c16) # E: {complex128}
|
||||
reveal_type(f + c16) # E: {complex128}
|
||||
reveal_type(i + c16) # E: {complex128}
|
||||
reveal_type(AR_f + c16) # E: Any
|
||||
|
||||
reveal_type(c8 + f16) # E: {complex256}
|
||||
reveal_type(c8 + c16) # E: {complex128}
|
||||
reveal_type(c8 + f8) # E: {complex128}
|
||||
reveal_type(c8 + i8) # E: {complex128}
|
||||
reveal_type(c8 + c8) # E: {complex64}
|
||||
reveal_type(c8 + f4) # E: {complex64}
|
||||
reveal_type(c8 + i4) # E: {complex64}
|
||||
reveal_type(c8 + b_) # E: {complex64}
|
||||
reveal_type(c8 + b) # E: {complex64}
|
||||
reveal_type(c8 + c) # E: {complex128}
|
||||
reveal_type(c8 + f) # E: {complex128}
|
||||
reveal_type(c8 + i) # E: complexfloating[{_NBitInt}, {_NBitInt}]
|
||||
reveal_type(c8 + AR_f) # E: Any
|
||||
|
||||
reveal_type(f16 + c8) # E: {complex256}
|
||||
reveal_type(c16 + c8) # E: {complex128}
|
||||
reveal_type(f8 + c8) # E: {complex128}
|
||||
reveal_type(i8 + c8) # E: {complex128}
|
||||
reveal_type(c8 + c8) # E: {complex64}
|
||||
reveal_type(f4 + c8) # E: {complex64}
|
||||
reveal_type(i4 + c8) # E: {complex64}
|
||||
reveal_type(b_ + c8) # E: {complex64}
|
||||
reveal_type(b + c8) # E: {complex64}
|
||||
reveal_type(c + c8) # E: {complex128}
|
||||
reveal_type(f + c8) # E: {complex128}
|
||||
reveal_type(i + c8) # E: complexfloating[{_NBitInt}, {_NBitInt}]
|
||||
reveal_type(AR_f + c8) # E: Any
|
||||
|
||||
# Float
|
||||
|
||||
reveal_type(f8 + f16) # E: {float128}
|
||||
reveal_type(f8 + f8) # E: {float64}
|
||||
reveal_type(f8 + i8) # E: {float64}
|
||||
reveal_type(f8 + f4) # E: {float64}
|
||||
reveal_type(f8 + i4) # E: {float64}
|
||||
reveal_type(f8 + b_) # E: {float64}
|
||||
reveal_type(f8 + b) # E: {float64}
|
||||
reveal_type(f8 + c) # E: {complex128}
|
||||
reveal_type(f8 + f) # E: {float64}
|
||||
reveal_type(f8 + i) # E: {float64}
|
||||
reveal_type(f8 + AR_f) # E: Any
|
||||
|
||||
reveal_type(f16 + f8) # E: {float128}
|
||||
reveal_type(f8 + f8) # E: {float64}
|
||||
reveal_type(i8 + f8) # E: {float64}
|
||||
reveal_type(f4 + f8) # E: {float64}
|
||||
reveal_type(i4 + f8) # E: {float64}
|
||||
reveal_type(b_ + f8) # E: {float64}
|
||||
reveal_type(b + f8) # E: {float64}
|
||||
reveal_type(c + f8) # E: {complex128}
|
||||
reveal_type(f + f8) # E: {float64}
|
||||
reveal_type(i + f8) # E: {float64}
|
||||
reveal_type(AR_f + f8) # E: Any
|
||||
|
||||
reveal_type(f4 + f16) # E: {float128}
|
||||
reveal_type(f4 + f8) # E: {float64}
|
||||
reveal_type(f4 + i8) # E: {float64}
|
||||
reveal_type(f4 + f4) # E: {float32}
|
||||
reveal_type(f4 + i4) # E: {float32}
|
||||
reveal_type(f4 + b_) # E: {float32}
|
||||
reveal_type(f4 + b) # E: {float32}
|
||||
reveal_type(f4 + c) # E: {complex128}
|
||||
reveal_type(f4 + f) # E: {float64}
|
||||
reveal_type(f4 + i) # E: floating[{_NBitInt}]
|
||||
reveal_type(f4 + AR_f) # E: Any
|
||||
|
||||
reveal_type(f16 + f4) # E: {float128}
|
||||
reveal_type(f8 + f4) # E: {float64}
|
||||
reveal_type(i8 + f4) # E: {float64}
|
||||
reveal_type(f4 + f4) # E: {float32}
|
||||
reveal_type(i4 + f4) # E: {float32}
|
||||
reveal_type(b_ + f4) # E: {float32}
|
||||
reveal_type(b + f4) # E: {float32}
|
||||
reveal_type(c + f4) # E: {complex128}
|
||||
reveal_type(f + f4) # E: {float64}
|
||||
reveal_type(i + f4) # E: floating[{_NBitInt}]
|
||||
reveal_type(AR_f + f4) # E: Any
|
||||
|
||||
# Int
|
||||
|
||||
reveal_type(i8 + i8) # E: {int64}
|
||||
reveal_type(i8 + u8) # E: Any
|
||||
reveal_type(i8 + i4) # E: {int64}
|
||||
reveal_type(i8 + u4) # E: Any
|
||||
reveal_type(i8 + b_) # E: {int64}
|
||||
reveal_type(i8 + b) # E: {int64}
|
||||
reveal_type(i8 + c) # E: {complex128}
|
||||
reveal_type(i8 + f) # E: {float64}
|
||||
reveal_type(i8 + i) # E: {int64}
|
||||
reveal_type(i8 + AR_f) # E: Any
|
||||
|
||||
reveal_type(u8 + u8) # E: {uint64}
|
||||
reveal_type(u8 + i4) # E: Any
|
||||
reveal_type(u8 + u4) # E: {uint64}
|
||||
reveal_type(u8 + b_) # E: {uint64}
|
||||
reveal_type(u8 + b) # E: {uint64}
|
||||
reveal_type(u8 + c) # E: {complex128}
|
||||
reveal_type(u8 + f) # E: {float64}
|
||||
reveal_type(u8 + i) # E: Any
|
||||
reveal_type(u8 + AR_f) # E: Any
|
||||
|
||||
reveal_type(i8 + i8) # E: {int64}
|
||||
reveal_type(u8 + i8) # E: Any
|
||||
reveal_type(i4 + i8) # E: {int64}
|
||||
reveal_type(u4 + i8) # E: Any
|
||||
reveal_type(b_ + i8) # E: {int64}
|
||||
reveal_type(b + i8) # E: {int64}
|
||||
reveal_type(c + i8) # E: {complex128}
|
||||
reveal_type(f + i8) # E: {float64}
|
||||
reveal_type(i + i8) # E: {int64}
|
||||
reveal_type(AR_f + i8) # E: Any
|
||||
|
||||
reveal_type(u8 + u8) # E: {uint64}
|
||||
reveal_type(i4 + u8) # E: Any
|
||||
reveal_type(u4 + u8) # E: {uint64}
|
||||
reveal_type(b_ + u8) # E: {uint64}
|
||||
reveal_type(b + u8) # E: {uint64}
|
||||
reveal_type(c + u8) # E: {complex128}
|
||||
reveal_type(f + u8) # E: {float64}
|
||||
reveal_type(i + u8) # E: Any
|
||||
reveal_type(AR_f + u8) # E: Any
|
||||
|
||||
reveal_type(i4 + i8) # E: {int64}
|
||||
reveal_type(i4 + i4) # E: {int32}
|
||||
reveal_type(i4 + i) # E: {int_}
|
||||
reveal_type(i4 + b_) # E: {int32}
|
||||
reveal_type(i4 + b) # E: {int32}
|
||||
reveal_type(i4 + AR_f) # E: Any
|
||||
|
||||
reveal_type(u4 + i8) # E: Any
|
||||
reveal_type(u4 + i4) # E: Any
|
||||
reveal_type(u4 + u8) # E: {uint64}
|
||||
reveal_type(u4 + u4) # E: {uint32}
|
||||
reveal_type(u4 + i) # E: Any
|
||||
reveal_type(u4 + b_) # E: {uint32}
|
||||
reveal_type(u4 + b) # E: {uint32}
|
||||
reveal_type(u4 + AR_f) # E: Any
|
||||
|
||||
reveal_type(i8 + i4) # E: {int64}
|
||||
reveal_type(i4 + i4) # E: {int32}
|
||||
reveal_type(i + i4) # E: {int_}
|
||||
reveal_type(b_ + i4) # E: {int32}
|
||||
reveal_type(b + i4) # E: {int32}
|
||||
reveal_type(AR_f + i4) # E: Any
|
||||
|
||||
reveal_type(i8 + u4) # E: Any
|
||||
reveal_type(i4 + u4) # E: Any
|
||||
reveal_type(u8 + u4) # E: {uint64}
|
||||
reveal_type(u4 + u4) # E: {uint32}
|
||||
reveal_type(b_ + u4) # E: {uint32}
|
||||
reveal_type(b + u4) # E: {uint32}
|
||||
reveal_type(i + u4) # E: Any
|
||||
reveal_type(AR_f + u4) # E: Any
|
||||
@@ -0,0 +1,205 @@
|
||||
from typing import Any, TypeVar
|
||||
from pathlib import Path
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
_SCT = TypeVar("_SCT", bound=np.generic, covariant=True)
|
||||
|
||||
class SubClass(np.ndarray[Any, np.dtype[_SCT]]): ...
|
||||
|
||||
i8: np.int64
|
||||
|
||||
A: npt.NDArray[np.float64]
|
||||
B: SubClass[np.float64]
|
||||
C: list[int]
|
||||
|
||||
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
|
||||
|
||||
reveal_type(np.empty_like(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.empty_like(B)) # E: SubClass[{float64}]
|
||||
reveal_type(np.empty_like([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.empty_like(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.empty_like(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.array(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.array(B)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.array(B, subok=True)) # E: SubClass[{float64}]
|
||||
reveal_type(np.array([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.array(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.array(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.array(A, like=A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.zeros([1, 5, 6])) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.zeros([1, 5, 6], dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.zeros([1, 5, 6], dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.empty([1, 5, 6])) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.empty([1, 5, 6], dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.empty([1, 5, 6], dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.concatenate(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.concatenate([A, A])) # E: Any
|
||||
reveal_type(np.concatenate([[1], A])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.concatenate([[1], [1]])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.concatenate((A, A))) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.concatenate(([1], [1]))) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.concatenate([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.concatenate(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.concatenate(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.concatenate([1, 1.0], out=A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.asarray(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.asarray(B)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.asarray([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.asarray(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.asarray(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.asanyarray(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.asanyarray(B)) # E: SubClass[{float64}]
|
||||
reveal_type(np.asanyarray([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.asanyarray(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.asanyarray(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.ascontiguousarray(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.ascontiguousarray(B)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.ascontiguousarray([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.ascontiguousarray(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.ascontiguousarray(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.asfortranarray(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.asfortranarray(B)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.asfortranarray([1, 1.0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.asfortranarray(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.asfortranarray(A, dtype='c16')) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.fromstring("1 1 1", sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromstring(b"1 1 1", sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromstring("1 1 1", dtype=np.int64, sep=" ")) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.fromstring(b"1 1 1", dtype=np.int64, sep=" ")) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.fromstring("1 1 1", dtype="c16", sep=" ")) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.fromstring(b"1 1 1", dtype="c16", sep=" ")) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.fromfile("test.txt", sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromfile("test.txt", dtype=np.int64, sep=" ")) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.fromfile("test.txt", dtype="c16", sep=" ")) # E: ndarray[Any, dtype[Any]]
|
||||
with open("test.txt") as f:
|
||||
reveal_type(np.fromfile(f, sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromfile(b"test.txt", sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromfile(Path("test.txt"), sep=" ")) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.fromiter("12345", np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fromiter("12345", float)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.frombuffer(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.frombuffer(A, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.frombuffer(A, dtype="c16")) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.arange(False, True)) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(np.arange(10)) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(np.arange(0, 10, step=2)) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
reveal_type(np.arange(10.0)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.arange(start=0, stop=10.0)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.arange(np.timedelta64(0))) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(np.arange(0, np.timedelta64(10))) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(np.arange(np.datetime64("0"), np.datetime64("10"))) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(np.arange(10, dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.arange(0, 10, step=2, dtype=np.int16)) # E: ndarray[Any, dtype[{int16}]]
|
||||
reveal_type(np.arange(10, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.arange(0, 10, dtype="f8")) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.require(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.require(B)) # E: SubClass[{float64}]
|
||||
reveal_type(np.require(B, requirements=None)) # E: SubClass[{float64}]
|
||||
reveal_type(np.require(B, dtype=int)) # E: ndarray[Any, Any]
|
||||
reveal_type(np.require(B, requirements="E")) # E: ndarray[Any, Any]
|
||||
reveal_type(np.require(B, requirements=["ENSUREARRAY"])) # E: ndarray[Any, Any]
|
||||
reveal_type(np.require(B, requirements={"F", "E"})) # E: ndarray[Any, Any]
|
||||
reveal_type(np.require(B, requirements=["C", "OWNDATA"])) # E: SubClass[{float64}]
|
||||
reveal_type(np.require(B, requirements="W")) # E: SubClass[{float64}]
|
||||
reveal_type(np.require(B, requirements="A")) # E: SubClass[{float64}]
|
||||
reveal_type(np.require(C)) # E: ndarray[Any, Any]
|
||||
|
||||
reveal_type(np.linspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.linspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(np.linspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.linspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.linspace(0, 10, retstep=True)) # E: Tuple[ndarray[Any, dtype[floating[Any]]], floating[Any]]
|
||||
reveal_type(np.linspace(0j, 10, retstep=True)) # E: Tuple[ndarray[Any, dtype[complexfloating[Any, Any]]], complexfloating[Any, Any]]
|
||||
reveal_type(np.linspace(0, 10, retstep=True, dtype=np.int64)) # E: Tuple[ndarray[Any, dtype[{int64}]], {int64}]
|
||||
reveal_type(np.linspace(0j, 10, retstep=True, dtype=int)) # E: Tuple[ndarray[Any, dtype[Any]], Any]
|
||||
|
||||
reveal_type(np.logspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.logspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(np.logspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.logspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.geomspace(0, 10)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.geomspace(0, 10j)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(np.geomspace(0, 10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.geomspace(0, 10, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.zeros_like(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.zeros_like(C)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.zeros_like(A, dtype=float)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.zeros_like(B)) # E: SubClass[{float64}]
|
||||
reveal_type(np.zeros_like(B, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
|
||||
reveal_type(np.ones_like(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.ones_like(C)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.ones_like(A, dtype=float)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.ones_like(B)) # E: SubClass[{float64}]
|
||||
reveal_type(np.ones_like(B, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
|
||||
reveal_type(np.full_like(A, i8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.full_like(C, i8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.full_like(A, i8, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.full_like(B, i8)) # E: SubClass[{float64}]
|
||||
reveal_type(np.full_like(B, i8, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
|
||||
reveal_type(np.ones(1)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.ones([1, 1, 1])) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.ones(5, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.ones(5, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.full(1, i8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.full([1, 1, 1], i8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.full(1, i8, dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.full(1, i8, dtype=float)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.indices([1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.indices([1, 2, 3], sparse=True)) # E: tuple[ndarray[Any, dtype[{int_}]], ...]
|
||||
|
||||
reveal_type(np.fromfunction(func, (3, 5))) # E: SubClass[{float64}]
|
||||
|
||||
reveal_type(np.identity(10)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.identity(10, dtype=np.int64)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.identity(10, dtype=int)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.atleast_1d(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.atleast_1d(C)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.atleast_1d(A, A)) # E: list[ndarray[Any, dtype[Any]]]
|
||||
reveal_type(np.atleast_1d(A, C)) # E: list[ndarray[Any, dtype[Any]]]
|
||||
reveal_type(np.atleast_1d(C, C)) # E: list[ndarray[Any, dtype[Any]]]
|
||||
|
||||
reveal_type(np.atleast_2d(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.atleast_3d(A)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.vstack([A, A])) # E: ndarray[Any, Any]
|
||||
reveal_type(np.vstack([A, A], dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.vstack([A, C])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.vstack([C, C])) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.hstack([A, A])) # E: ndarray[Any, Any]
|
||||
reveal_type(np.hstack([A, A], dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.stack([A, A])) # E: Any
|
||||
reveal_type(np.stack([A, A], dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.stack([A, C])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.stack([C, C])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.stack([A, A], axis=0)) # E: Any
|
||||
reveal_type(np.stack([A, A], out=B)) # E: SubClass[{float64}]
|
||||
|
||||
reveal_type(np.block([[A, A], [A, A]])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.block(C)) # E: ndarray[Any, dtype[Any]]
|
||||
@@ -0,0 +1,22 @@
|
||||
from collections.abc import Mapping
|
||||
from typing import Any, SupportsIndex
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
def mode_func(
|
||||
ar: npt.NDArray[np.number[Any]],
|
||||
width: tuple[int, int],
|
||||
iaxis: SupportsIndex,
|
||||
kwargs: Mapping[str, Any],
|
||||
) -> None: ...
|
||||
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_LIKE: list[int]
|
||||
|
||||
reveal_type(np.pad(AR_i8, (2, 3), "constant")) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.pad(AR_LIKE, (2, 3), "constant")) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.pad(AR_f8, (2, 3), mode_func)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.pad(AR_f8, (2, 3), mode_func, a=1, b=2)) # E: ndarray[Any, dtype[{float64}]]
|
||||
@@ -0,0 +1,20 @@
|
||||
from collections.abc import Callable
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR: np.ndarray[Any, Any]
|
||||
func_float: Callable[[np.floating[Any]], str]
|
||||
func_int: Callable[[np.integer[Any]], str]
|
||||
|
||||
reveal_type(np.get_printoptions()) # E: TypedDict
|
||||
reveal_type(np.array2string( # E: str
|
||||
AR, formatter={'float_kind': func_float, 'int_kind': func_int}
|
||||
))
|
||||
reveal_type(np.format_float_scientific(1.0)) # E: str
|
||||
reveal_type(np.format_float_positional(1)) # E: str
|
||||
reveal_type(np.array_repr(AR)) # E: str
|
||||
reveal_type(np.array_str(AR)) # E: str
|
||||
|
||||
reveal_type(np.printoptions()) # E: contextlib._GeneratorContextManager
|
||||
with np.printoptions() as dct:
|
||||
reveal_type(dct) # E: TypedDict
|
||||
@@ -0,0 +1,60 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_b: npt.NDArray[np.bool_]
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_M: npt.NDArray[np.datetime64]
|
||||
AR_O: npt.NDArray[np.object_]
|
||||
|
||||
AR_LIKE_f8: list[float]
|
||||
|
||||
reveal_type(np.ediff1d(AR_b)) # E: ndarray[Any, dtype[{int8}]]
|
||||
reveal_type(np.ediff1d(AR_i8, to_end=[1, 2, 3])) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.ediff1d(AR_M)) # E: ndarray[Any, dtype[timedelta64]]
|
||||
reveal_type(np.ediff1d(AR_O)) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.ediff1d(AR_LIKE_f8, to_begin=[1, 1.5])) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.intersect1d(AR_i8, AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.intersect1d(AR_M, AR_M, assume_unique=True)) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(np.intersect1d(AR_f8, AR_i8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.intersect1d(AR_f8, AR_f8, return_indices=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
|
||||
reveal_type(np.setxor1d(AR_i8, AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.setxor1d(AR_M, AR_M, assume_unique=True)) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(np.setxor1d(AR_f8, AR_i8)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.in1d(AR_i8, AR_i8)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.in1d(AR_M, AR_M, assume_unique=True)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.in1d(AR_f8, AR_i8)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.in1d(AR_f8, AR_LIKE_f8, invert=True)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.isin(AR_i8, AR_i8)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.isin(AR_M, AR_M, assume_unique=True)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.isin(AR_f8, AR_i8)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.isin(AR_f8, AR_LIKE_f8, invert=True)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.union1d(AR_i8, AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.union1d(AR_M, AR_M)) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(np.union1d(AR_f8, AR_i8)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.setdiff1d(AR_i8, AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.setdiff1d(AR_M, AR_M, assume_unique=True)) # E: ndarray[Any, dtype[datetime64]]
|
||||
reveal_type(np.setdiff1d(AR_f8, AR_i8)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.unique(AR_f8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, axis=0)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.unique(AR_f8, return_index=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_index=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_inverse=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_inverse=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_counts=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_counts=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_index=True, return_inverse=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_index=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_index=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_inverse=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_inverse=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_f8, return_index=True, return_inverse=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[{float64}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
reveal_type(np.unique(AR_LIKE_f8, return_index=True, return_inverse=True, return_counts=True)) # E: Tuple[ndarray[Any, dtype[Any]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]], ndarray[Any, dtype[{intp}]]]
|
||||
@@ -0,0 +1,24 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_i8: np.ndarray[Any, np.dtype[np.int64]]
|
||||
ar_iter = np.lib.Arrayterator(AR_i8)
|
||||
|
||||
reveal_type(ar_iter.var) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(ar_iter.buf_size) # E: Union[None, builtins.int]
|
||||
reveal_type(ar_iter.start) # E: builtins.list[builtins.int]
|
||||
reveal_type(ar_iter.stop) # E: builtins.list[builtins.int]
|
||||
reveal_type(ar_iter.step) # E: builtins.list[builtins.int]
|
||||
reveal_type(ar_iter.shape) # E: builtins.tuple[builtins.int, ...]
|
||||
reveal_type(ar_iter.flat) # E: typing.Generator[{int64}, None, None]
|
||||
|
||||
reveal_type(ar_iter.__array__()) # E: ndarray[Any, dtype[{int64}]]
|
||||
|
||||
for i in ar_iter:
|
||||
reveal_type(i) # E: ndarray[Any, dtype[{int64}]]
|
||||
|
||||
reveal_type(ar_iter[0]) # E: lib.arrayterator.Arrayterator[Any, dtype[{int64}]]
|
||||
reveal_type(ar_iter[...]) # E: lib.arrayterator.Arrayterator[Any, dtype[{int64}]]
|
||||
reveal_type(ar_iter[:]) # E: lib.arrayterator.Arrayterator[Any, dtype[{int64}]]
|
||||
reveal_type(ar_iter[0, 0, 0]) # E: lib.arrayterator.Arrayterator[Any, dtype[{int64}]]
|
||||
reveal_type(ar_iter[..., 0, :]) # E: lib.arrayterator.Arrayterator[Any, dtype[{int64}]]
|
||||
@@ -0,0 +1,131 @@
|
||||
import numpy as np
|
||||
|
||||
i8 = np.int64(1)
|
||||
u8 = np.uint64(1)
|
||||
|
||||
i4 = np.int32(1)
|
||||
u4 = np.uint32(1)
|
||||
|
||||
b_ = np.bool_(1)
|
||||
|
||||
b = bool(1)
|
||||
i = int(1)
|
||||
|
||||
AR = np.array([0, 1, 2], dtype=np.int32)
|
||||
AR.setflags(write=False)
|
||||
|
||||
|
||||
reveal_type(i8 << i8) # E: {int64}
|
||||
reveal_type(i8 >> i8) # E: {int64}
|
||||
reveal_type(i8 | i8) # E: {int64}
|
||||
reveal_type(i8 ^ i8) # E: {int64}
|
||||
reveal_type(i8 & i8) # E: {int64}
|
||||
|
||||
reveal_type(i8 << AR) # E: Any
|
||||
reveal_type(i8 >> AR) # E: Any
|
||||
reveal_type(i8 | AR) # E: Any
|
||||
reveal_type(i8 ^ AR) # E: Any
|
||||
reveal_type(i8 & AR) # E: Any
|
||||
|
||||
reveal_type(i4 << i4) # E: {int32}
|
||||
reveal_type(i4 >> i4) # E: {int32}
|
||||
reveal_type(i4 | i4) # E: {int32}
|
||||
reveal_type(i4 ^ i4) # E: {int32}
|
||||
reveal_type(i4 & i4) # E: {int32}
|
||||
|
||||
reveal_type(i8 << i4) # E: {int64}
|
||||
reveal_type(i8 >> i4) # E: {int64}
|
||||
reveal_type(i8 | i4) # E: {int64}
|
||||
reveal_type(i8 ^ i4) # E: {int64}
|
||||
reveal_type(i8 & i4) # E: {int64}
|
||||
|
||||
reveal_type(i8 << i) # E: {int64}
|
||||
reveal_type(i8 >> i) # E: {int64}
|
||||
reveal_type(i8 | i) # E: {int64}
|
||||
reveal_type(i8 ^ i) # E: {int64}
|
||||
reveal_type(i8 & i) # E: {int64}
|
||||
|
||||
reveal_type(i8 << b_) # E: {int64}
|
||||
reveal_type(i8 >> b_) # E: {int64}
|
||||
reveal_type(i8 | b_) # E: {int64}
|
||||
reveal_type(i8 ^ b_) # E: {int64}
|
||||
reveal_type(i8 & b_) # E: {int64}
|
||||
|
||||
reveal_type(i8 << b) # E: {int64}
|
||||
reveal_type(i8 >> b) # E: {int64}
|
||||
reveal_type(i8 | b) # E: {int64}
|
||||
reveal_type(i8 ^ b) # E: {int64}
|
||||
reveal_type(i8 & b) # E: {int64}
|
||||
|
||||
reveal_type(u8 << u8) # E: {uint64}
|
||||
reveal_type(u8 >> u8) # E: {uint64}
|
||||
reveal_type(u8 | u8) # E: {uint64}
|
||||
reveal_type(u8 ^ u8) # E: {uint64}
|
||||
reveal_type(u8 & u8) # E: {uint64}
|
||||
|
||||
reveal_type(u8 << AR) # E: Any
|
||||
reveal_type(u8 >> AR) # E: Any
|
||||
reveal_type(u8 | AR) # E: Any
|
||||
reveal_type(u8 ^ AR) # E: Any
|
||||
reveal_type(u8 & AR) # E: Any
|
||||
|
||||
reveal_type(u4 << u4) # E: {uint32}
|
||||
reveal_type(u4 >> u4) # E: {uint32}
|
||||
reveal_type(u4 | u4) # E: {uint32}
|
||||
reveal_type(u4 ^ u4) # E: {uint32}
|
||||
reveal_type(u4 & u4) # E: {uint32}
|
||||
|
||||
reveal_type(u4 << i4) # E: signedinteger[Any]
|
||||
reveal_type(u4 >> i4) # E: signedinteger[Any]
|
||||
reveal_type(u4 | i4) # E: signedinteger[Any]
|
||||
reveal_type(u4 ^ i4) # E: signedinteger[Any]
|
||||
reveal_type(u4 & i4) # E: signedinteger[Any]
|
||||
|
||||
reveal_type(u4 << i) # E: signedinteger[Any]
|
||||
reveal_type(u4 >> i) # E: signedinteger[Any]
|
||||
reveal_type(u4 | i) # E: signedinteger[Any]
|
||||
reveal_type(u4 ^ i) # E: signedinteger[Any]
|
||||
reveal_type(u4 & i) # E: signedinteger[Any]
|
||||
|
||||
reveal_type(u8 << b_) # E: {uint64}
|
||||
reveal_type(u8 >> b_) # E: {uint64}
|
||||
reveal_type(u8 | b_) # E: {uint64}
|
||||
reveal_type(u8 ^ b_) # E: {uint64}
|
||||
reveal_type(u8 & b_) # E: {uint64}
|
||||
|
||||
reveal_type(u8 << b) # E: {uint64}
|
||||
reveal_type(u8 >> b) # E: {uint64}
|
||||
reveal_type(u8 | b) # E: {uint64}
|
||||
reveal_type(u8 ^ b) # E: {uint64}
|
||||
reveal_type(u8 & b) # E: {uint64}
|
||||
|
||||
reveal_type(b_ << b_) # E: {int8}
|
||||
reveal_type(b_ >> b_) # E: {int8}
|
||||
reveal_type(b_ | b_) # E: bool_
|
||||
reveal_type(b_ ^ b_) # E: bool_
|
||||
reveal_type(b_ & b_) # E: bool_
|
||||
|
||||
reveal_type(b_ << AR) # E: Any
|
||||
reveal_type(b_ >> AR) # E: Any
|
||||
reveal_type(b_ | AR) # E: Any
|
||||
reveal_type(b_ ^ AR) # E: Any
|
||||
reveal_type(b_ & AR) # E: Any
|
||||
|
||||
reveal_type(b_ << b) # E: {int8}
|
||||
reveal_type(b_ >> b) # E: {int8}
|
||||
reveal_type(b_ | b) # E: bool_
|
||||
reveal_type(b_ ^ b) # E: bool_
|
||||
reveal_type(b_ & b) # E: bool_
|
||||
|
||||
reveal_type(b_ << i) # E: {int_}
|
||||
reveal_type(b_ >> i) # E: {int_}
|
||||
reveal_type(b_ | i) # E: {int_}
|
||||
reveal_type(b_ ^ i) # E: {int_}
|
||||
reveal_type(b_ & i) # E: {int_}
|
||||
|
||||
reveal_type(~i8) # E: {int64}
|
||||
reveal_type(~i4) # E: {int32}
|
||||
reveal_type(~u8) # E: {uint64}
|
||||
reveal_type(~u4) # E: {uint32}
|
||||
reveal_type(~b_) # E: bool_
|
||||
reveal_type(~AR) # E: Any
|
||||
@@ -0,0 +1,147 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
from collections.abc import Sequence
|
||||
|
||||
AR_U: npt.NDArray[np.str_]
|
||||
AR_S: npt.NDArray[np.bytes_]
|
||||
|
||||
reveal_type(np.char.equal(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.equal(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.not_equal(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.not_equal(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.greater_equal(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.greater_equal(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.less_equal(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.less_equal(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.greater(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.greater(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.less(AR_U, AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.less(AR_S, AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.multiply(AR_U, 5)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.multiply(AR_S, [5, 4, 3])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.mod(AR_U, "test")) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.mod(AR_S, "test")) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.capitalize(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.capitalize(AR_S)) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.center(AR_U, 5)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.center(AR_S, [2, 3, 4], b"a")) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.encode(AR_U)) # E: ndarray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.decode(AR_S)) # E: ndarray[Any, dtype[str_]]
|
||||
|
||||
reveal_type(np.char.expandtabs(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.expandtabs(AR_S, tabsize=4)) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.join(AR_U, "_")) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.join(AR_S, [b"_", b""])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.ljust(AR_U, 5)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.ljust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"])) # E: ndarray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.rjust(AR_U, 5)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.rjust(AR_S, [4, 3, 1], fillchar=[b"a", b"b", b"c"])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.lstrip(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.lstrip(AR_S, chars=b"_")) # E: ndarray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.rstrip(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.rstrip(AR_S, chars=b"_")) # E: ndarray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.strip(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.strip(AR_S, chars=b"_")) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.partition(AR_U, "\n")) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.partition(AR_S, [b"a", b"b", b"c"])) # E: ndarray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.rpartition(AR_U, "\n")) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.rpartition(AR_S, [b"a", b"b", b"c"])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.replace(AR_U, "_", "-")) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.replace(AR_S, [b"_", b""], [b"a", b"b"])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.split(AR_U, "_")) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.char.split(AR_S, maxsplit=[1, 2, 3])) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.char.rsplit(AR_U, "_")) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.char.rsplit(AR_S, maxsplit=[1, 2, 3])) # E: ndarray[Any, dtype[object_]]
|
||||
|
||||
reveal_type(np.char.splitlines(AR_U)) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.char.splitlines(AR_S, keepends=[True, True, False])) # E: ndarray[Any, dtype[object_]]
|
||||
|
||||
reveal_type(np.char.swapcase(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.swapcase(AR_S)) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.title(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.title(AR_S)) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.upper(AR_U)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.upper(AR_S)) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.zfill(AR_U, 5)) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(np.char.zfill(AR_S, [2, 3, 4])) # E: ndarray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(np.char.count(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.count(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(np.char.endswith(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.endswith(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.startswith(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.startswith(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.find(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.find(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.rfind(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.rfind(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(np.char.index(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.index(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.rindex(AR_U, "a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.rindex(AR_S, [b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(np.char.isalpha(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isalpha(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isalnum(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isalnum(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isdecimal(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isdecimal(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isdigit(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isdigit(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.islower(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.islower(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isnumeric(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isnumeric(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isspace(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isspace(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.istitle(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.istitle(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.isupper(AR_U)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.char.isupper(AR_S)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(np.char.str_len(AR_U)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.char.str_len(AR_S)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(np.char.array(AR_U)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(np.char.array(AR_S, order="K")) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.array("bob", copy=True)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(np.char.array(b"bob", itemsize=5)) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.array(1, unicode=False)) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.array(1, unicode=True)) # E: chararray[Any, dtype[str_]]
|
||||
|
||||
reveal_type(np.char.asarray(AR_U)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(np.char.asarray(AR_S, order="K")) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.asarray("bob")) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(np.char.asarray(b"bob", itemsize=5)) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.asarray(1, unicode=False)) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(np.char.asarray(1, unicode=True)) # E: chararray[Any, dtype[str_]]
|
||||
@@ -0,0 +1,132 @@
|
||||
import numpy as np
|
||||
from typing import Any
|
||||
|
||||
AR_U: np.chararray[Any, np.dtype[np.str_]]
|
||||
AR_S: np.chararray[Any, np.dtype[np.bytes_]]
|
||||
|
||||
reveal_type(AR_U == AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S == AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U != AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S != AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U >= AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S >= AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U <= AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S <= AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U > AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S > AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U < AR_U) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S < AR_S) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U * 5) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S * [5]) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U % "test") # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S % b"test") # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.capitalize()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.capitalize()) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.center(5)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.center([2, 3, 4], b"a")) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.encode()) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(AR_S.decode()) # E: chararray[Any, dtype[str_]]
|
||||
|
||||
reveal_type(AR_U.expandtabs()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.expandtabs(tabsize=4)) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.join("_")) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.join([b"_", b""])) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.ljust(5)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.ljust([4, 3, 1], fillchar=[b"a", b"b", b"c"])) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(AR_U.rjust(5)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.rjust([4, 3, 1], fillchar=[b"a", b"b", b"c"])) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.lstrip()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.lstrip(chars=b"_")) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(AR_U.rstrip()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.rstrip(chars=b"_")) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(AR_U.strip()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.strip(chars=b"_")) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.partition("\n")) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.partition([b"a", b"b", b"c"])) # E: chararray[Any, dtype[bytes_]]
|
||||
reveal_type(AR_U.rpartition("\n")) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.rpartition([b"a", b"b", b"c"])) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.replace("_", "-")) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.replace([b"_", b""], [b"a", b"b"])) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.split("_")) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(AR_S.split(maxsplit=[1, 2, 3])) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(AR_U.rsplit("_")) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(AR_S.rsplit(maxsplit=[1, 2, 3])) # E: ndarray[Any, dtype[object_]]
|
||||
|
||||
reveal_type(AR_U.splitlines()) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(AR_S.splitlines(keepends=[True, True, False])) # E: ndarray[Any, dtype[object_]]
|
||||
|
||||
reveal_type(AR_U.swapcase()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.swapcase()) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.title()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.title()) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.upper()) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.upper()) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.zfill(5)) # E: chararray[Any, dtype[str_]]
|
||||
reveal_type(AR_S.zfill([2, 3, 4])) # E: chararray[Any, dtype[bytes_]]
|
||||
|
||||
reveal_type(AR_U.count("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_S.count([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(AR_U.endswith("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.endswith([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_U.startswith("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.startswith([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.find("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_S.find([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_U.rfind("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_S.rfind([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(AR_U.index("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_S.index([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_U.rindex("a", start=[1, 2, 3])) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(AR_S.rindex([b"a", b"b", b"c"], end=9)) # E: ndarray[Any, dtype[{int_}]]
|
||||
|
||||
reveal_type(AR_U.isalpha()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isalpha()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isalnum()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isalnum()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isdecimal()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isdecimal()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isdigit()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isdigit()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.islower()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.islower()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isnumeric()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isnumeric()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isspace()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isspace()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.istitle()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.istitle()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.isupper()) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR_S.isupper()) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(AR_U.__array_finalize__(object())) # E: None
|
||||
reveal_type(AR_S.__array_finalize__(object())) # E: None
|
||||
@@ -0,0 +1,261 @@
|
||||
import numpy as np
|
||||
import fractions
|
||||
import decimal
|
||||
|
||||
c16 = np.complex128()
|
||||
f8 = np.float64()
|
||||
i8 = np.int64()
|
||||
u8 = np.uint64()
|
||||
|
||||
c8 = np.complex64()
|
||||
f4 = np.float32()
|
||||
i4 = np.int32()
|
||||
u4 = np.uint32()
|
||||
|
||||
dt = np.datetime64(0, "D")
|
||||
td = np.timedelta64(0, "D")
|
||||
|
||||
b_ = np.bool_()
|
||||
|
||||
b = bool()
|
||||
c = complex()
|
||||
f = float()
|
||||
i = int()
|
||||
|
||||
AR = np.array([0], dtype=np.int64)
|
||||
AR.setflags(write=False)
|
||||
|
||||
SEQ = (0, 1, 2, 3, 4)
|
||||
|
||||
# object-like comparisons
|
||||
|
||||
reveal_type(i8 > fractions.Fraction(1, 5)) # E: Any
|
||||
reveal_type(i8 > [fractions.Fraction(1, 5)]) # E: Any
|
||||
reveal_type(i8 > decimal.Decimal("1.5")) # E: Any
|
||||
reveal_type(i8 > [decimal.Decimal("1.5")]) # E: Any
|
||||
|
||||
# Time structures
|
||||
|
||||
reveal_type(dt > dt) # E: bool_
|
||||
|
||||
reveal_type(td > td) # E: bool_
|
||||
reveal_type(td > i) # E: bool_
|
||||
reveal_type(td > i4) # E: bool_
|
||||
reveal_type(td > i8) # E: bool_
|
||||
|
||||
reveal_type(td > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(td > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(AR > td) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > td) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
# boolean
|
||||
|
||||
reveal_type(b_ > b) # E: bool_
|
||||
reveal_type(b_ > b_) # E: bool_
|
||||
reveal_type(b_ > i) # E: bool_
|
||||
reveal_type(b_ > i8) # E: bool_
|
||||
reveal_type(b_ > i4) # E: bool_
|
||||
reveal_type(b_ > u8) # E: bool_
|
||||
reveal_type(b_ > u4) # E: bool_
|
||||
reveal_type(b_ > f) # E: bool_
|
||||
reveal_type(b_ > f8) # E: bool_
|
||||
reveal_type(b_ > f4) # E: bool_
|
||||
reveal_type(b_ > c) # E: bool_
|
||||
reveal_type(b_ > c16) # E: bool_
|
||||
reveal_type(b_ > c8) # E: bool_
|
||||
reveal_type(b_ > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(b_ > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
# Complex
|
||||
|
||||
reveal_type(c16 > c16) # E: bool_
|
||||
reveal_type(c16 > f8) # E: bool_
|
||||
reveal_type(c16 > i8) # E: bool_
|
||||
reveal_type(c16 > c8) # E: bool_
|
||||
reveal_type(c16 > f4) # E: bool_
|
||||
reveal_type(c16 > i4) # E: bool_
|
||||
reveal_type(c16 > b_) # E: bool_
|
||||
reveal_type(c16 > b) # E: bool_
|
||||
reveal_type(c16 > c) # E: bool_
|
||||
reveal_type(c16 > f) # E: bool_
|
||||
reveal_type(c16 > i) # E: bool_
|
||||
reveal_type(c16 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(c16 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(c16 > c16) # E: bool_
|
||||
reveal_type(f8 > c16) # E: bool_
|
||||
reveal_type(i8 > c16) # E: bool_
|
||||
reveal_type(c8 > c16) # E: bool_
|
||||
reveal_type(f4 > c16) # E: bool_
|
||||
reveal_type(i4 > c16) # E: bool_
|
||||
reveal_type(b_ > c16) # E: bool_
|
||||
reveal_type(b > c16) # E: bool_
|
||||
reveal_type(c > c16) # E: bool_
|
||||
reveal_type(f > c16) # E: bool_
|
||||
reveal_type(i > c16) # E: bool_
|
||||
reveal_type(AR > c16) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > c16) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(c8 > c16) # E: bool_
|
||||
reveal_type(c8 > f8) # E: bool_
|
||||
reveal_type(c8 > i8) # E: bool_
|
||||
reveal_type(c8 > c8) # E: bool_
|
||||
reveal_type(c8 > f4) # E: bool_
|
||||
reveal_type(c8 > i4) # E: bool_
|
||||
reveal_type(c8 > b_) # E: bool_
|
||||
reveal_type(c8 > b) # E: bool_
|
||||
reveal_type(c8 > c) # E: bool_
|
||||
reveal_type(c8 > f) # E: bool_
|
||||
reveal_type(c8 > i) # E: bool_
|
||||
reveal_type(c8 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(c8 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(c16 > c8) # E: bool_
|
||||
reveal_type(f8 > c8) # E: bool_
|
||||
reveal_type(i8 > c8) # E: bool_
|
||||
reveal_type(c8 > c8) # E: bool_
|
||||
reveal_type(f4 > c8) # E: bool_
|
||||
reveal_type(i4 > c8) # E: bool_
|
||||
reveal_type(b_ > c8) # E: bool_
|
||||
reveal_type(b > c8) # E: bool_
|
||||
reveal_type(c > c8) # E: bool_
|
||||
reveal_type(f > c8) # E: bool_
|
||||
reveal_type(i > c8) # E: bool_
|
||||
reveal_type(AR > c8) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > c8) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
# Float
|
||||
|
||||
reveal_type(f8 > f8) # E: bool_
|
||||
reveal_type(f8 > i8) # E: bool_
|
||||
reveal_type(f8 > f4) # E: bool_
|
||||
reveal_type(f8 > i4) # E: bool_
|
||||
reveal_type(f8 > b_) # E: bool_
|
||||
reveal_type(f8 > b) # E: bool_
|
||||
reveal_type(f8 > c) # E: bool_
|
||||
reveal_type(f8 > f) # E: bool_
|
||||
reveal_type(f8 > i) # E: bool_
|
||||
reveal_type(f8 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(f8 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(f8 > f8) # E: bool_
|
||||
reveal_type(i8 > f8) # E: bool_
|
||||
reveal_type(f4 > f8) # E: bool_
|
||||
reveal_type(i4 > f8) # E: bool_
|
||||
reveal_type(b_ > f8) # E: bool_
|
||||
reveal_type(b > f8) # E: bool_
|
||||
reveal_type(c > f8) # E: bool_
|
||||
reveal_type(f > f8) # E: bool_
|
||||
reveal_type(i > f8) # E: bool_
|
||||
reveal_type(AR > f8) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > f8) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(f4 > f8) # E: bool_
|
||||
reveal_type(f4 > i8) # E: bool_
|
||||
reveal_type(f4 > f4) # E: bool_
|
||||
reveal_type(f4 > i4) # E: bool_
|
||||
reveal_type(f4 > b_) # E: bool_
|
||||
reveal_type(f4 > b) # E: bool_
|
||||
reveal_type(f4 > c) # E: bool_
|
||||
reveal_type(f4 > f) # E: bool_
|
||||
reveal_type(f4 > i) # E: bool_
|
||||
reveal_type(f4 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(f4 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(f8 > f4) # E: bool_
|
||||
reveal_type(i8 > f4) # E: bool_
|
||||
reveal_type(f4 > f4) # E: bool_
|
||||
reveal_type(i4 > f4) # E: bool_
|
||||
reveal_type(b_ > f4) # E: bool_
|
||||
reveal_type(b > f4) # E: bool_
|
||||
reveal_type(c > f4) # E: bool_
|
||||
reveal_type(f > f4) # E: bool_
|
||||
reveal_type(i > f4) # E: bool_
|
||||
reveal_type(AR > f4) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > f4) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
# Int
|
||||
|
||||
reveal_type(i8 > i8) # E: bool_
|
||||
reveal_type(i8 > u8) # E: bool_
|
||||
reveal_type(i8 > i4) # E: bool_
|
||||
reveal_type(i8 > u4) # E: bool_
|
||||
reveal_type(i8 > b_) # E: bool_
|
||||
reveal_type(i8 > b) # E: bool_
|
||||
reveal_type(i8 > c) # E: bool_
|
||||
reveal_type(i8 > f) # E: bool_
|
||||
reveal_type(i8 > i) # E: bool_
|
||||
reveal_type(i8 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(i8 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(u8 > u8) # E: bool_
|
||||
reveal_type(u8 > i4) # E: bool_
|
||||
reveal_type(u8 > u4) # E: bool_
|
||||
reveal_type(u8 > b_) # E: bool_
|
||||
reveal_type(u8 > b) # E: bool_
|
||||
reveal_type(u8 > c) # E: bool_
|
||||
reveal_type(u8 > f) # E: bool_
|
||||
reveal_type(u8 > i) # E: bool_
|
||||
reveal_type(u8 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(u8 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(i8 > i8) # E: bool_
|
||||
reveal_type(u8 > i8) # E: bool_
|
||||
reveal_type(i4 > i8) # E: bool_
|
||||
reveal_type(u4 > i8) # E: bool_
|
||||
reveal_type(b_ > i8) # E: bool_
|
||||
reveal_type(b > i8) # E: bool_
|
||||
reveal_type(c > i8) # E: bool_
|
||||
reveal_type(f > i8) # E: bool_
|
||||
reveal_type(i > i8) # E: bool_
|
||||
reveal_type(AR > i8) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > i8) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(u8 > u8) # E: bool_
|
||||
reveal_type(i4 > u8) # E: bool_
|
||||
reveal_type(u4 > u8) # E: bool_
|
||||
reveal_type(b_ > u8) # E: bool_
|
||||
reveal_type(b > u8) # E: bool_
|
||||
reveal_type(c > u8) # E: bool_
|
||||
reveal_type(f > u8) # E: bool_
|
||||
reveal_type(i > u8) # E: bool_
|
||||
reveal_type(AR > u8) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > u8) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(i4 > i8) # E: bool_
|
||||
reveal_type(i4 > i4) # E: bool_
|
||||
reveal_type(i4 > i) # E: bool_
|
||||
reveal_type(i4 > b_) # E: bool_
|
||||
reveal_type(i4 > b) # E: bool_
|
||||
reveal_type(i4 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(i4 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(u4 > i8) # E: bool_
|
||||
reveal_type(u4 > i4) # E: bool_
|
||||
reveal_type(u4 > u8) # E: bool_
|
||||
reveal_type(u4 > u4) # E: bool_
|
||||
reveal_type(u4 > i) # E: bool_
|
||||
reveal_type(u4 > b_) # E: bool_
|
||||
reveal_type(u4 > b) # E: bool_
|
||||
reveal_type(u4 > AR) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(u4 > SEQ) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(i8 > i4) # E: bool_
|
||||
reveal_type(i4 > i4) # E: bool_
|
||||
reveal_type(i > i4) # E: bool_
|
||||
reveal_type(b_ > i4) # E: bool_
|
||||
reveal_type(b > i4) # E: bool_
|
||||
reveal_type(AR > i4) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > i4) # E: ndarray[Any, dtype[bool_]]
|
||||
|
||||
reveal_type(i8 > u4) # E: bool_
|
||||
reveal_type(i4 > u4) # E: bool_
|
||||
reveal_type(u8 > u4) # E: bool_
|
||||
reveal_type(u4 > u4) # E: bool_
|
||||
reveal_type(b_ > u4) # E: bool_
|
||||
reveal_type(b > u4) # E: bool_
|
||||
reveal_type(i > u4) # E: bool_
|
||||
reveal_type(AR > u4) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(SEQ > u4) # E: ndarray[Any, dtype[bool_]]
|
||||
@@ -0,0 +1,52 @@
|
||||
import numpy as np
|
||||
|
||||
reveal_type(np.Inf) # E: float
|
||||
reveal_type(np.Infinity) # E: float
|
||||
reveal_type(np.NAN) # E: float
|
||||
reveal_type(np.NINF) # E: float
|
||||
reveal_type(np.NZERO) # E: float
|
||||
reveal_type(np.NaN) # E: float
|
||||
reveal_type(np.PINF) # E: float
|
||||
reveal_type(np.PZERO) # E: float
|
||||
reveal_type(np.e) # E: float
|
||||
reveal_type(np.euler_gamma) # E: float
|
||||
reveal_type(np.inf) # E: float
|
||||
reveal_type(np.infty) # E: float
|
||||
reveal_type(np.nan) # E: float
|
||||
reveal_type(np.pi) # E: float
|
||||
|
||||
reveal_type(np.ALLOW_THREADS) # E: int
|
||||
reveal_type(np.BUFSIZE) # E: Literal[8192]
|
||||
reveal_type(np.CLIP) # E: Literal[0]
|
||||
reveal_type(np.ERR_CALL) # E: Literal[3]
|
||||
reveal_type(np.ERR_DEFAULT) # E: Literal[521]
|
||||
reveal_type(np.ERR_IGNORE) # E: Literal[0]
|
||||
reveal_type(np.ERR_LOG) # E: Literal[5]
|
||||
reveal_type(np.ERR_PRINT) # E: Literal[4]
|
||||
reveal_type(np.ERR_RAISE) # E: Literal[2]
|
||||
reveal_type(np.ERR_WARN) # E: Literal[1]
|
||||
reveal_type(np.FLOATING_POINT_SUPPORT) # E: Literal[1]
|
||||
reveal_type(np.FPE_DIVIDEBYZERO) # E: Literal[1]
|
||||
reveal_type(np.FPE_INVALID) # E: Literal[8]
|
||||
reveal_type(np.FPE_OVERFLOW) # E: Literal[2]
|
||||
reveal_type(np.FPE_UNDERFLOW) # E: Literal[4]
|
||||
reveal_type(np.MAXDIMS) # E: Literal[32]
|
||||
reveal_type(np.MAY_SHARE_BOUNDS) # E: Literal[0]
|
||||
reveal_type(np.MAY_SHARE_EXACT) # E: Literal[-1]
|
||||
reveal_type(np.RAISE) # E: Literal[2]
|
||||
reveal_type(np.SHIFT_DIVIDEBYZERO) # E: Literal[0]
|
||||
reveal_type(np.SHIFT_INVALID) # E: Literal[9]
|
||||
reveal_type(np.SHIFT_OVERFLOW) # E: Literal[3]
|
||||
reveal_type(np.SHIFT_UNDERFLOW) # E: Literal[6]
|
||||
reveal_type(np.UFUNC_BUFSIZE_DEFAULT) # E: Literal[8192]
|
||||
reveal_type(np.WRAP) # E: Literal[1]
|
||||
reveal_type(np.tracemalloc_domain) # E: Literal[389047]
|
||||
|
||||
reveal_type(np.little_endian) # E: bool
|
||||
reveal_type(np.True_) # E: bool_
|
||||
reveal_type(np.False_) # E: bool_
|
||||
|
||||
reveal_type(np.UFUNC_PYVALS_NAME) # E: Literal['UFUNC_PYVALS']
|
||||
|
||||
reveal_type(np.sctypeDict) # E: dict
|
||||
reveal_type(np.sctypes) # E: TypedDict
|
||||
@@ -0,0 +1,87 @@
|
||||
import ctypes
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_bool: npt.NDArray[np.bool_]
|
||||
AR_ubyte: npt.NDArray[np.ubyte]
|
||||
AR_ushort: npt.NDArray[np.ushort]
|
||||
AR_uintc: npt.NDArray[np.uintc]
|
||||
AR_uint: npt.NDArray[np.uint]
|
||||
AR_ulonglong: npt.NDArray[np.ulonglong]
|
||||
AR_byte: npt.NDArray[np.byte]
|
||||
AR_short: npt.NDArray[np.short]
|
||||
AR_intc: npt.NDArray[np.intc]
|
||||
AR_int: npt.NDArray[np.int_]
|
||||
AR_longlong: npt.NDArray[np.longlong]
|
||||
AR_single: npt.NDArray[np.single]
|
||||
AR_double: npt.NDArray[np.double]
|
||||
AR_longdouble: npt.NDArray[np.longdouble]
|
||||
AR_void: npt.NDArray[np.void]
|
||||
|
||||
pointer: ctypes._Pointer[Any]
|
||||
|
||||
reveal_type(np.ctypeslib.c_intp()) # E: {c_intp}
|
||||
|
||||
reveal_type(np.ctypeslib.ndpointer()) # E: Type[ctypeslib._ndptr[None]]
|
||||
reveal_type(np.ctypeslib.ndpointer(dtype=np.float64)) # E: Type[ctypeslib._ndptr[dtype[{float64}]]]
|
||||
reveal_type(np.ctypeslib.ndpointer(dtype=float)) # E: Type[ctypeslib._ndptr[dtype[Any]]]
|
||||
reveal_type(np.ctypeslib.ndpointer(shape=(10, 3))) # E: Type[ctypeslib._ndptr[None]]
|
||||
reveal_type(np.ctypeslib.ndpointer(np.int64, shape=(10, 3))) # E: Type[ctypeslib._concrete_ndptr[dtype[{int64}]]]
|
||||
reveal_type(np.ctypeslib.ndpointer(int, shape=(1,))) # E: Type[ctypeslib._concrete_ndptr[dtype[Any]]]
|
||||
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.bool_)) # E: Type[ctypes.c_bool]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.ubyte)) # E: Type[{c_ubyte}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.ushort)) # E: Type[{c_ushort}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.uintc)) # E: Type[{c_uint}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.uint)) # E: Type[{c_ulong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.ulonglong)) # E: Type[{c_ulonglong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.byte)) # E: Type[{c_byte}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.short)) # E: Type[{c_short}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.intc)) # E: Type[{c_int}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.int_)) # E: Type[{c_long}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.longlong)) # E: Type[{c_longlong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.single)) # E: Type[{c_float}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.double)) # E: Type[{c_double}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(np.longdouble)) # E: Type[{c_longdouble}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type(ctypes.c_double)) # E: Type[{c_double}]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type("q")) # E: Type[ctypes.c_longlong]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type([("i8", np.int64), ("f8", np.float64)])) # E: Type[Any]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type("i8")) # E: Type[Any]
|
||||
reveal_type(np.ctypeslib.as_ctypes_type("f8")) # E: Type[Any]
|
||||
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_bool.take(0))) # E: ctypes.c_bool
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ubyte.take(0))) # E: {c_ubyte}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ushort.take(0))) # E: {c_ushort}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_uintc.take(0))) # E: {c_uint}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_uint.take(0))) # E: {c_ulong}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ulonglong.take(0))) # E: {c_ulonglong}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_byte.take(0))) # E: {c_byte}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_short.take(0))) # E: {c_short}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_intc.take(0))) # E: {c_int}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_int.take(0))) # E: {c_long}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_longlong.take(0))) # E: {c_longlong}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_single.take(0))) # E: {c_float}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_double.take(0))) # E: {c_double}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_longdouble.take(0))) # E: {c_longdouble}
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_void.take(0))) # E: Any
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_bool)) # E: ctypes.Array[ctypes.c_bool]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ubyte)) # E: ctypes.Array[{c_ubyte}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ushort)) # E: ctypes.Array[{c_ushort}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_uintc)) # E: ctypes.Array[{c_uint}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_uint)) # E: ctypes.Array[{c_ulong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_ulonglong)) # E: ctypes.Array[{c_ulonglong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_byte)) # E: ctypes.Array[{c_byte}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_short)) # E: ctypes.Array[{c_short}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_intc)) # E: ctypes.Array[{c_int}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_int)) # E: ctypes.Array[{c_long}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_longlong)) # E: ctypes.Array[{c_longlong}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_single)) # E: ctypes.Array[{c_float}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_double)) # E: ctypes.Array[{c_double}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_longdouble)) # E: ctypes.Array[{c_longdouble}]
|
||||
reveal_type(np.ctypeslib.as_ctypes(AR_void)) # E: ctypes.Array[Any]
|
||||
|
||||
reveal_type(np.ctypeslib.as_array(AR_ubyte)) # E: ndarray[Any, dtype[{ubyte}]]
|
||||
reveal_type(np.ctypeslib.as_array(1)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.ctypeslib.as_array(pointer)) # E: ndarray[Any, dtype[Any]]
|
||||
@@ -0,0 +1,21 @@
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
|
||||
path1: Path
|
||||
path2: str
|
||||
|
||||
d1 = np.DataSource(path1)
|
||||
d2 = np.DataSource(path2)
|
||||
d3 = np.DataSource(None)
|
||||
|
||||
reveal_type(d1.abspath("...")) # E: str
|
||||
reveal_type(d2.abspath("...")) # E: str
|
||||
reveal_type(d3.abspath("...")) # E: str
|
||||
|
||||
reveal_type(d1.exists("...")) # E: bool
|
||||
reveal_type(d2.exists("...")) # E: bool
|
||||
reveal_type(d3.exists("...")) # E: bool
|
||||
|
||||
reveal_type(d1.open("...", "r")) # E: IO[Any]
|
||||
reveal_type(d2.open("...", encoding="utf8")) # E: IO[Any]
|
||||
reveal_type(d3.open("...", newline="/n")) # E: IO[Any]
|
||||
@@ -0,0 +1,76 @@
|
||||
import ctypes as ct
|
||||
import numpy as np
|
||||
|
||||
dtype_U: np.dtype[np.str_]
|
||||
dtype_V: np.dtype[np.void]
|
||||
dtype_i8: np.dtype[np.int64]
|
||||
|
||||
reveal_type(np.dtype(np.float64)) # E: dtype[{float64}]
|
||||
reveal_type(np.dtype(np.int64)) # E: dtype[{int64}]
|
||||
|
||||
# String aliases
|
||||
reveal_type(np.dtype("float64")) # E: dtype[{float64}]
|
||||
reveal_type(np.dtype("float32")) # E: dtype[{float32}]
|
||||
reveal_type(np.dtype("int64")) # E: dtype[{int64}]
|
||||
reveal_type(np.dtype("int32")) # E: dtype[{int32}]
|
||||
reveal_type(np.dtype("bool")) # E: dtype[bool_]
|
||||
reveal_type(np.dtype("bytes")) # E: dtype[bytes_]
|
||||
reveal_type(np.dtype("str")) # E: dtype[str_]
|
||||
|
||||
# Python types
|
||||
reveal_type(np.dtype(complex)) # E: dtype[{cdouble}]
|
||||
reveal_type(np.dtype(float)) # E: dtype[{double}]
|
||||
reveal_type(np.dtype(int)) # E: dtype[{int_}]
|
||||
reveal_type(np.dtype(bool)) # E: dtype[bool_]
|
||||
reveal_type(np.dtype(str)) # E: dtype[str_]
|
||||
reveal_type(np.dtype(bytes)) # E: dtype[bytes_]
|
||||
reveal_type(np.dtype(object)) # E: dtype[object_]
|
||||
|
||||
# ctypes
|
||||
reveal_type(np.dtype(ct.c_double)) # E: dtype[{double}]
|
||||
reveal_type(np.dtype(ct.c_longlong)) # E: dtype[{longlong}]
|
||||
reveal_type(np.dtype(ct.c_uint32)) # E: dtype[{uint32}]
|
||||
reveal_type(np.dtype(ct.c_bool)) # E: dtype[bool_]
|
||||
reveal_type(np.dtype(ct.c_char)) # E: dtype[bytes_]
|
||||
reveal_type(np.dtype(ct.py_object)) # E: dtype[object_]
|
||||
|
||||
# Special case for None
|
||||
reveal_type(np.dtype(None)) # E: dtype[{double}]
|
||||
|
||||
# Dtypes of dtypes
|
||||
reveal_type(np.dtype(np.dtype(np.float64))) # E: dtype[{float64}]
|
||||
|
||||
# Parameterized dtypes
|
||||
reveal_type(np.dtype("S8")) # E: dtype
|
||||
|
||||
# Void
|
||||
reveal_type(np.dtype(("U", 10))) # E: dtype[void]
|
||||
|
||||
# Methods and attributes
|
||||
reveal_type(dtype_U.base) # E: dtype[Any]
|
||||
reveal_type(dtype_U.subdtype) # E: Union[None, Tuple[dtype[Any], builtins.tuple[builtins.int, ...]]]
|
||||
reveal_type(dtype_U.newbyteorder()) # E: dtype[str_]
|
||||
reveal_type(dtype_U.type) # E: Type[str_]
|
||||
reveal_type(dtype_U.name) # E: str
|
||||
reveal_type(dtype_U.names) # E: Union[None, builtins.tuple[builtins.str, ...]]
|
||||
|
||||
reveal_type(dtype_U * 0) # E: dtype[str_]
|
||||
reveal_type(dtype_U * 1) # E: dtype[str_]
|
||||
reveal_type(dtype_U * 2) # E: dtype[str_]
|
||||
|
||||
reveal_type(dtype_i8 * 0) # E: dtype[void]
|
||||
reveal_type(dtype_i8 * 1) # E: dtype[{int64}]
|
||||
reveal_type(dtype_i8 * 2) # E: dtype[void]
|
||||
|
||||
reveal_type(0 * dtype_U) # E: dtype[str_]
|
||||
reveal_type(1 * dtype_U) # E: dtype[str_]
|
||||
reveal_type(2 * dtype_U) # E: dtype[str_]
|
||||
|
||||
reveal_type(0 * dtype_i8) # E: dtype[Any]
|
||||
reveal_type(1 * dtype_i8) # E: dtype[Any]
|
||||
reveal_type(2 * dtype_i8) # E: dtype[Any]
|
||||
|
||||
reveal_type(dtype_V["f0"]) # E: dtype[Any]
|
||||
reveal_type(dtype_V[0]) # E: dtype[Any]
|
||||
reveal_type(dtype_V[["f0", "f1"]]) # E: dtype[void]
|
||||
reveal_type(dtype_V[["f0"]]) # E: dtype[void]
|
||||
@@ -0,0 +1,35 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
AR_LIKE_b: list[bool]
|
||||
AR_LIKE_u: list[np.uint32]
|
||||
AR_LIKE_i: list[int]
|
||||
AR_LIKE_f: list[float]
|
||||
AR_LIKE_c: list[complex]
|
||||
AR_LIKE_U: list[str]
|
||||
|
||||
OUT_f: np.ndarray[Any, np.dtype[np.float64]]
|
||||
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_b)) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_u, AR_LIKE_u)) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_i, AR_LIKE_i)) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f)) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_c, AR_LIKE_c)) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_b, AR_LIKE_i)) # E: Any
|
||||
reveal_type(np.einsum("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c)) # E: Any
|
||||
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_c, AR_LIKE_c, out=OUT_f)) # E: ndarray[Any, dtype[{float64}]
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=bool, casting="unsafe", out=OUT_f)) # E: ndarray[Any, dtype[{float64}]
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_f, AR_LIKE_f, dtype="c16")) # E: Any
|
||||
reveal_type(np.einsum("i,i->i", AR_LIKE_U, AR_LIKE_U, dtype=bool, casting="unsafe")) # E: Any
|
||||
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_b)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_u, AR_LIKE_u)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_i, AR_LIKE_i)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_f, AR_LIKE_f)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_c, AR_LIKE_c)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i->i", AR_LIKE_b, AR_LIKE_i)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
reveal_type(np.einsum_path("i,i,i,i->i", AR_LIKE_b, AR_LIKE_u, AR_LIKE_i, AR_LIKE_c)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
|
||||
reveal_type(np.einsum([[1, 1], [1, 1]], AR_LIKE_i, AR_LIKE_i)) # E: Any
|
||||
reveal_type(np.einsum_path([[1, 1], [1, 1]], AR_LIKE_i, AR_LIKE_i)) # E: Tuple[builtins.list[Any], builtins.str]
|
||||
@@ -0,0 +1,52 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_c16: npt.NDArray[np.complex128]
|
||||
f8: np.float64
|
||||
c16: np.complex128
|
||||
|
||||
reveal_type(np.emath.sqrt(f8)) # E: Any
|
||||
reveal_type(np.emath.sqrt(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.sqrt(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.sqrt(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.log(f8)) # E: Any
|
||||
reveal_type(np.emath.log(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.log(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.log(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.log10(f8)) # E: Any
|
||||
reveal_type(np.emath.log10(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.log10(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.log10(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.log2(f8)) # E: Any
|
||||
reveal_type(np.emath.log2(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.log2(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.log2(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.logn(f8, 2)) # E: Any
|
||||
reveal_type(np.emath.logn(AR_f8, 4)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.logn(f8, 1j)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.logn(AR_c16, 1.5)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.power(f8, 2)) # E: Any
|
||||
reveal_type(np.emath.power(AR_f8, 4)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.power(f8, 2j)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.power(AR_c16, 1.5)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.arccos(f8)) # E: Any
|
||||
reveal_type(np.emath.arccos(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.arccos(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.arccos(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.arcsin(f8)) # E: Any
|
||||
reveal_type(np.emath.arcsin(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.arcsin(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.arcsin(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.emath.arctanh(f8)) # E: Any
|
||||
reveal_type(np.emath.arctanh(AR_f8)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.emath.arctanh(c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.emath.arctanh(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
@@ -0,0 +1,10 @@
|
||||
from typing import Any
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_Any: npt.NDArray[Any]
|
||||
|
||||
# Mypy bug where overload ambiguity is ignored for `Any`-parametrized types;
|
||||
# xref numpy/numpy#20099 and python/mypy#11347
|
||||
#
|
||||
# The expected output would be something akin to `ndarray[Any, dtype[Any]]`
|
||||
reveal_type(AR_Any + 2) # E: ndarray[Any, dtype[signedinteger[Any]]]
|
||||
@@ -0,0 +1,35 @@
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
AR_f8: npt.NDArray[np.float64]
|
||||
AR_c16: npt.NDArray[np.complex128]
|
||||
AR_LIKE_f8: list[float]
|
||||
|
||||
reveal_type(np.fft.fftshift(AR_f8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fft.fftshift(AR_LIKE_f8, axes=0)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.fft.ifftshift(AR_f8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fft.ifftshift(AR_LIKE_f8, axes=0)) # E: ndarray[Any, dtype[Any]]
|
||||
|
||||
reveal_type(np.fft.fftfreq(5, AR_f8)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.fft.fftfreq(np.int64(), AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.fft.fftfreq(5, AR_f8)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.fft.fftfreq(np.int64(), AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
|
||||
reveal_type(np.fft.fft(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.ifft(AR_f8, axis=1)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.rfft(AR_f8, n=None)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.irfft(AR_f8, norm="ortho")) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fft.hfft(AR_f8, n=2)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.fft.ihfft(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
|
||||
reveal_type(np.fft.fftn(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.ifftn(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.rfftn(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.irfftn(AR_f8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
|
||||
reveal_type(np.fft.rfft2(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.ifft2(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.fft2(AR_f8)) # E: ndarray[Any, dtype[{complex128}]]
|
||||
reveal_type(np.fft.irfft2(AR_f8)) # E: ndarray[Any, dtype[{float64}]]
|
||||
@@ -0,0 +1,23 @@
|
||||
from typing import Any
|
||||
import numpy as np
|
||||
|
||||
a: np.flatiter[np.ndarray[Any, np.dtype[np.str_]]]
|
||||
|
||||
reveal_type(a.base) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a.copy()) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a.coords) # E: tuple[builtins.int, ...]
|
||||
reveal_type(a.index) # E: int
|
||||
reveal_type(iter(a)) # E: Any
|
||||
reveal_type(next(a)) # E: str_
|
||||
reveal_type(a[0]) # E: str_
|
||||
reveal_type(a[[0, 1, 2]]) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a[...]) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a[:]) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a[(...,)]) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a[(0,)]) # E: str_
|
||||
reveal_type(a.__array__()) # E: ndarray[Any, dtype[str_]]
|
||||
reveal_type(a.__array__(np.dtype(np.float64))) # E: ndarray[Any, dtype[{float64}]]
|
||||
a[0] = "a"
|
||||
a[:5] = "a"
|
||||
a[...] = "a"
|
||||
a[(...,)] = "a"
|
||||
@@ -0,0 +1,297 @@
|
||||
"""Tests for :mod:`core.fromnumeric`."""
|
||||
|
||||
import numpy as np
|
||||
import numpy.typing as npt
|
||||
|
||||
class NDArraySubclass(npt.NDArray[np.complex128]):
|
||||
...
|
||||
|
||||
AR_b: npt.NDArray[np.bool_]
|
||||
AR_f4: npt.NDArray[np.float32]
|
||||
AR_c16: npt.NDArray[np.complex128]
|
||||
AR_u8: npt.NDArray[np.uint64]
|
||||
AR_i8: npt.NDArray[np.int64]
|
||||
AR_O: npt.NDArray[np.object_]
|
||||
AR_subclass: NDArraySubclass
|
||||
|
||||
b: np.bool_
|
||||
f4: np.float32
|
||||
i8: np.int64
|
||||
f: float
|
||||
|
||||
reveal_type(np.take(b, 0)) # E: bool_
|
||||
reveal_type(np.take(f4, 0)) # E: {float32}
|
||||
reveal_type(np.take(f, 0)) # E: Any
|
||||
reveal_type(np.take(AR_b, 0)) # E: bool_
|
||||
reveal_type(np.take(AR_f4, 0)) # E: {float32}
|
||||
reveal_type(np.take(AR_b, [0])) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.take(AR_f4, [0])) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.take([1], [0])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.take(AR_f4, [0], out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.reshape(b, 1)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.reshape(f4, 1)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.reshape(f, 1)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.reshape(AR_b, 1)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.reshape(AR_f4, 1)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.choose(1, [True, True])) # E: Any
|
||||
reveal_type(np.choose([1], [True, True])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.choose([1], AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.choose([1], AR_b, out=AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.repeat(b, 1)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.repeat(f4, 1)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.repeat(f, 1)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.repeat(AR_b, 1)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.repeat(AR_f4, 1)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
# TODO: array_bdd tests for np.put()
|
||||
|
||||
reveal_type(np.swapaxes([[0, 1]], 0, 0)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.swapaxes(AR_b, 0, 0)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.swapaxes(AR_f4, 0, 0)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.transpose(b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.transpose(f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.transpose(f)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.transpose(AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.transpose(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.partition(b, 0, axis=None)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.partition(f4, 0, axis=None)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.partition(f, 0, axis=None)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.partition(AR_b, 0)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.partition(AR_f4, 0)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.argpartition(b, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.argpartition(f4, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.argpartition(f, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.argpartition(AR_b, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.argpartition(AR_f4, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
|
||||
reveal_type(np.sort([2, 1], 0)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.sort(AR_b, 0)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.sort(AR_f4, 0)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.argsort(AR_b, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.argsort(AR_f4, 0)) # E: ndarray[Any, dtype[{intp}]]
|
||||
|
||||
reveal_type(np.argmax(AR_b)) # E: {intp}
|
||||
reveal_type(np.argmax(AR_f4)) # E: {intp}
|
||||
reveal_type(np.argmax(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.argmax(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.argmax(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.argmin(AR_b)) # E: {intp}
|
||||
reveal_type(np.argmin(AR_f4)) # E: {intp}
|
||||
reveal_type(np.argmin(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.argmin(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.argmin(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.searchsorted(AR_b[0], 0)) # E: {intp}
|
||||
reveal_type(np.searchsorted(AR_f4[0], 0)) # E: {intp}
|
||||
reveal_type(np.searchsorted(AR_b[0], [0])) # E: ndarray[Any, dtype[{intp}]]
|
||||
reveal_type(np.searchsorted(AR_f4[0], [0])) # E: ndarray[Any, dtype[{intp}]]
|
||||
|
||||
reveal_type(np.resize(b, (5, 5))) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.resize(f4, (5, 5))) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.resize(f, (5, 5))) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.resize(AR_b, (5, 5))) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.resize(AR_f4, (5, 5))) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.squeeze(b)) # E: bool_
|
||||
reveal_type(np.squeeze(f4)) # E: {float32}
|
||||
reveal_type(np.squeeze(f)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.squeeze(AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.squeeze(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.diagonal(AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.diagonal(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.trace(AR_b)) # E: Any
|
||||
reveal_type(np.trace(AR_f4)) # E: Any
|
||||
reveal_type(np.trace(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.ravel(b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.ravel(f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.ravel(f)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.ravel(AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.ravel(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.nonzero(b)) # E: tuple[ndarray[Any, dtype[{intp}]], ...]
|
||||
reveal_type(np.nonzero(f4)) # E: tuple[ndarray[Any, dtype[{intp}]], ...]
|
||||
reveal_type(np.nonzero(f)) # E: tuple[ndarray[Any, dtype[{intp}]], ...]
|
||||
reveal_type(np.nonzero(AR_b)) # E: tuple[ndarray[Any, dtype[{intp}]], ...]
|
||||
reveal_type(np.nonzero(AR_f4)) # E: tuple[ndarray[Any, dtype[{intp}]], ...]
|
||||
|
||||
reveal_type(np.shape(b)) # E: tuple[builtins.int, ...]
|
||||
reveal_type(np.shape(f4)) # E: tuple[builtins.int, ...]
|
||||
reveal_type(np.shape(f)) # E: tuple[builtins.int, ...]
|
||||
reveal_type(np.shape(AR_b)) # E: tuple[builtins.int, ...]
|
||||
reveal_type(np.shape(AR_f4)) # E: tuple[builtins.int, ...]
|
||||
|
||||
reveal_type(np.compress([True], b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.compress([True], f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.compress([True], f)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.compress([True], AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.compress([True], AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
|
||||
reveal_type(np.clip(b, 0, 1.0)) # E: bool_
|
||||
reveal_type(np.clip(f4, -1, 1)) # E: {float32}
|
||||
reveal_type(np.clip(f, 0, 1)) # E: Any
|
||||
reveal_type(np.clip(AR_b, 0, 1)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.clip(AR_f4, 0, 1)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.clip([0], 0, 1)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.clip(AR_b, 0, 1, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.sum(b)) # E: bool_
|
||||
reveal_type(np.sum(f4)) # E: {float32}
|
||||
reveal_type(np.sum(f)) # E: Any
|
||||
reveal_type(np.sum(AR_b)) # E: bool_
|
||||
reveal_type(np.sum(AR_f4)) # E: {float32}
|
||||
reveal_type(np.sum(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.sum(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.sum(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.all(b)) # E: bool_
|
||||
reveal_type(np.all(f4)) # E: bool_
|
||||
reveal_type(np.all(f)) # E: bool_
|
||||
reveal_type(np.all(AR_b)) # E: bool_
|
||||
reveal_type(np.all(AR_f4)) # E: bool_
|
||||
reveal_type(np.all(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.all(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.all(AR_b, keepdims=True)) # E: Any
|
||||
reveal_type(np.all(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.all(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.any(b)) # E: bool_
|
||||
reveal_type(np.any(f4)) # E: bool_
|
||||
reveal_type(np.any(f)) # E: bool_
|
||||
reveal_type(np.any(AR_b)) # E: bool_
|
||||
reveal_type(np.any(AR_f4)) # E: bool_
|
||||
reveal_type(np.any(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.any(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.any(AR_b, keepdims=True)) # E: Any
|
||||
reveal_type(np.any(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.any(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.cumsum(b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.cumsum(f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.cumsum(f)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.cumsum(AR_b)) # E: ndarray[Any, dtype[bool_]]
|
||||
reveal_type(np.cumsum(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.cumsum(f, dtype=float)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.cumsum(f, dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.cumsum(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.ptp(b)) # E: bool_
|
||||
reveal_type(np.ptp(f4)) # E: {float32}
|
||||
reveal_type(np.ptp(f)) # E: Any
|
||||
reveal_type(np.ptp(AR_b)) # E: bool_
|
||||
reveal_type(np.ptp(AR_f4)) # E: {float32}
|
||||
reveal_type(np.ptp(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.ptp(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.ptp(AR_b, keepdims=True)) # E: Any
|
||||
reveal_type(np.ptp(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.ptp(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.amax(b)) # E: bool_
|
||||
reveal_type(np.amax(f4)) # E: {float32}
|
||||
reveal_type(np.amax(f)) # E: Any
|
||||
reveal_type(np.amax(AR_b)) # E: bool_
|
||||
reveal_type(np.amax(AR_f4)) # E: {float32}
|
||||
reveal_type(np.amax(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.amax(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.amax(AR_b, keepdims=True)) # E: Any
|
||||
reveal_type(np.amax(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.amax(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.amin(b)) # E: bool_
|
||||
reveal_type(np.amin(f4)) # E: {float32}
|
||||
reveal_type(np.amin(f)) # E: Any
|
||||
reveal_type(np.amin(AR_b)) # E: bool_
|
||||
reveal_type(np.amin(AR_f4)) # E: {float32}
|
||||
reveal_type(np.amin(AR_b, axis=0)) # E: Any
|
||||
reveal_type(np.amin(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.amin(AR_b, keepdims=True)) # E: Any
|
||||
reveal_type(np.amin(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.amin(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.prod(AR_b)) # E: {int_}
|
||||
reveal_type(np.prod(AR_u8)) # E: {uint64}
|
||||
reveal_type(np.prod(AR_i8)) # E: {int64}
|
||||
reveal_type(np.prod(AR_f4)) # E: floating[Any]
|
||||
reveal_type(np.prod(AR_c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.prod(AR_O)) # E: Any
|
||||
reveal_type(np.prod(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.prod(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.prod(AR_f4, dtype=np.float64)) # E: {float64}
|
||||
reveal_type(np.prod(AR_f4, dtype=float)) # E: Any
|
||||
reveal_type(np.prod(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.cumprod(AR_b)) # E: ndarray[Any, dtype[{int_}]]
|
||||
reveal_type(np.cumprod(AR_u8)) # E: ndarray[Any, dtype[{uint64}]]
|
||||
reveal_type(np.cumprod(AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.cumprod(AR_f4)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.cumprod(AR_c16)) # E: ndarray[Any, dtype[complexfloating[Any, Any]]]
|
||||
reveal_type(np.cumprod(AR_O)) # E: ndarray[Any, dtype[object_]]
|
||||
reveal_type(np.cumprod(AR_f4, axis=0)) # E: ndarray[Any, dtype[floating[Any]]]
|
||||
reveal_type(np.cumprod(AR_f4, dtype=np.float64)) # E: ndarray[Any, dtype[{float64}]]
|
||||
reveal_type(np.cumprod(AR_f4, dtype=float)) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.cumprod(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.ndim(b)) # E: int
|
||||
reveal_type(np.ndim(f4)) # E: int
|
||||
reveal_type(np.ndim(f)) # E: int
|
||||
reveal_type(np.ndim(AR_b)) # E: int
|
||||
reveal_type(np.ndim(AR_f4)) # E: int
|
||||
|
||||
reveal_type(np.size(b)) # E: int
|
||||
reveal_type(np.size(f4)) # E: int
|
||||
reveal_type(np.size(f)) # E: int
|
||||
reveal_type(np.size(AR_b)) # E: int
|
||||
reveal_type(np.size(AR_f4)) # E: int
|
||||
|
||||
reveal_type(np.around(b)) # E: {float16}
|
||||
reveal_type(np.around(f)) # E: Any
|
||||
reveal_type(np.around(i8)) # E: {int64}
|
||||
reveal_type(np.around(f4)) # E: {float32}
|
||||
reveal_type(np.around(AR_b)) # E: ndarray[Any, dtype[{float16}]]
|
||||
reveal_type(np.around(AR_i8)) # E: ndarray[Any, dtype[{int64}]]
|
||||
reveal_type(np.around(AR_f4)) # E: ndarray[Any, dtype[{float32}]]
|
||||
reveal_type(np.around([1.5])) # E: ndarray[Any, dtype[Any]]
|
||||
reveal_type(np.around(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.mean(AR_b)) # E: floating[Any]
|
||||
reveal_type(np.mean(AR_i8)) # E: floating[Any]
|
||||
reveal_type(np.mean(AR_f4)) # E: floating[Any]
|
||||
reveal_type(np.mean(AR_c16)) # E: complexfloating[Any, Any]
|
||||
reveal_type(np.mean(AR_O)) # E: Any
|
||||
reveal_type(np.mean(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.mean(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.mean(AR_f4, dtype=float)) # E: Any
|
||||
reveal_type(np.mean(AR_f4, dtype=np.float64)) # E: {float64}
|
||||
reveal_type(np.mean(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.std(AR_b)) # E: floating[Any]
|
||||
reveal_type(np.std(AR_i8)) # E: floating[Any]
|
||||
reveal_type(np.std(AR_f4)) # E: floating[Any]
|
||||
reveal_type(np.std(AR_c16)) # E: floating[Any]
|
||||
reveal_type(np.std(AR_O)) # E: Any
|
||||
reveal_type(np.std(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.std(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.std(AR_f4, dtype=float)) # E: Any
|
||||
reveal_type(np.std(AR_f4, dtype=np.float64)) # E: {float64}
|
||||
reveal_type(np.std(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
|
||||
reveal_type(np.var(AR_b)) # E: floating[Any]
|
||||
reveal_type(np.var(AR_i8)) # E: floating[Any]
|
||||
reveal_type(np.var(AR_f4)) # E: floating[Any]
|
||||
reveal_type(np.var(AR_c16)) # E: floating[Any]
|
||||
reveal_type(np.var(AR_O)) # E: Any
|
||||
reveal_type(np.var(AR_f4, axis=0)) # E: Any
|
||||
reveal_type(np.var(AR_f4, keepdims=True)) # E: Any
|
||||
reveal_type(np.var(AR_f4, dtype=float)) # E: Any
|
||||
reveal_type(np.var(AR_f4, dtype=np.float64)) # E: {float64}
|
||||
reveal_type(np.var(AR_f4, out=AR_subclass)) # E: NDArraySubclass
|
||||
@@ -0,0 +1,47 @@
|
||||
import numpy as np
|
||||
f: float
|
||||
f8: np.float64
|
||||
c8: np.complex64
|
||||
|
||||
i: int
|
||||
i8: np.int64
|
||||
u4: np.uint32
|
||||
|
||||
finfo_f8: np.finfo[np.float64]
|
||||
iinfo_i8: np.iinfo[np.int64]
|
||||
|
||||
reveal_type(np.finfo(f)) # E: finfo[{double}]
|
||||
reveal_type(np.finfo(f8)) # E: finfo[{float64}]
|
||||
reveal_type(np.finfo(c8)) # E: finfo[{float32}]
|
||||
reveal_type(np.finfo('f2')) # E: finfo[floating[Any]]
|
||||
|
||||
reveal_type(finfo_f8.dtype) # E: dtype[{float64}]
|
||||
reveal_type(finfo_f8.bits) # E: int
|
||||
reveal_type(finfo_f8.eps) # E: {float64}
|
||||
reveal_type(finfo_f8.epsneg) # E: {float64}
|
||||
reveal_type(finfo_f8.iexp) # E: int
|
||||
reveal_type(finfo_f8.machep) # E: int
|
||||
reveal_type(finfo_f8.max) # E: {float64}
|
||||
reveal_type(finfo_f8.maxexp) # E: int
|
||||
reveal_type(finfo_f8.min) # E: {float64}
|
||||
reveal_type(finfo_f8.minexp) # E: int
|
||||
reveal_type(finfo_f8.negep) # E: int
|
||||
reveal_type(finfo_f8.nexp) # E: int
|
||||
reveal_type(finfo_f8.nmant) # E: int
|
||||
reveal_type(finfo_f8.precision) # E: int
|
||||
reveal_type(finfo_f8.resolution) # E: {float64}
|
||||
reveal_type(finfo_f8.tiny) # E: {float64}
|
||||
reveal_type(finfo_f8.smallest_normal) # E: {float64}
|
||||
reveal_type(finfo_f8.smallest_subnormal) # E: {float64}
|
||||
|
||||
reveal_type(np.iinfo(i)) # E: iinfo[{int_}]
|
||||
reveal_type(np.iinfo(i8)) # E: iinfo[{int64}]
|
||||
reveal_type(np.iinfo(u4)) # E: iinfo[{uint32}]
|
||||
reveal_type(np.iinfo('i2')) # E: iinfo[Any]
|
||||
|
||||
reveal_type(iinfo_i8.dtype) # E: dtype[{int64}]
|
||||
reveal_type(iinfo_i8.kind) # E: str
|
||||
reveal_type(iinfo_i8.bits) # E: int
|
||||
reveal_type(iinfo_i8.key) # E: str
|
||||
reveal_type(iinfo_i8.min) # E: int
|
||||
reveal_type(iinfo_i8.max) # E: int
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user