Skip to content

Commit 13e21ac

Browse files
committed
TYP: add type-tests for mixed-integer shape-types in array constructors
1 parent bf9bad2 commit 13e21ac

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

numpy/typing/tests/data/reveal/array_constructors.pyi

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import Any, Literal as L, TypeVar
2+
from typing import Any, TypeVar
33
from pathlib import Path
44
from collections import deque
55

@@ -19,6 +19,8 @@ B: SubClass[np.float64]
1919
C: list[int]
2020
D: SubClass[np.float64 | np.int64]
2121

22+
mixed_shape: tuple[int, np.int64]
23+
2224
def func(i: int, j: int, **kwargs: Any) -> SubClass[np.float64]: ...
2325

2426
assert_type(np.empty_like(A), npt.NDArray[np.float64])
@@ -43,10 +45,12 @@ assert_type(np.array(D), npt.NDArray[np.float64 | np.int64])
4345
assert_type(np.zeros([1, 5, 6]), npt.NDArray[np.float64])
4446
assert_type(np.zeros([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])
4547
assert_type(np.zeros([1, 5, 6], dtype='c16'), npt.NDArray[Any])
48+
assert_type(np.zeros(mixed_shape), npt.NDArray[np.float64])
4649

4750
assert_type(np.empty([1, 5, 6]), npt.NDArray[np.float64])
4851
assert_type(np.empty([1, 5, 6], dtype=np.int64), npt.NDArray[np.int64])
4952
assert_type(np.empty([1, 5, 6], dtype='c16'), npt.NDArray[Any])
53+
assert_type(np.empty(mixed_shape), npt.NDArray[np.float64])
5054

5155
assert_type(np.concatenate(A), npt.NDArray[np.float64])
5256
assert_type(np.concatenate([A, A]), npt.NDArray[Any])
@@ -182,6 +186,7 @@ assert_type(np.ones(_shape_1d, dtype=np.int64), np.ndarray[tuple[int], np.dtype[
182186
assert_type(np.ones(_shape_like), npt.NDArray[np.float64])
183187
assert_type(np.ones(_shape_like, dtype=np.dtypes.Int64DType()), np.ndarray[Any, np.dtypes.Int64DType])
184188
assert_type(np.ones(_shape_like, dtype=int), npt.NDArray[Any])
189+
assert_type(np.ones(mixed_shape), npt.NDArray[np.float64])
185190

186191
assert_type(np.full(_size, i8), np.ndarray[tuple[int], np.dtype[np.int64]])
187192
assert_type(np.full(_shape_2d, i8), np.ndarray[tuple[int, int], np.dtype[np.int64]])

0 commit comments

Comments
 (0)