codekingpro/portable-devtools
114k
1from typing import Any
2
3import numpy as np
4import numpy.typing as npt
5
6class _Index:
7 def __index__(self) -> int: ...
8
9class _MyArray:
10 def __array__(self) -> np.ndarray[tuple[int], np.dtypes.Float64DType]: ...
11
12_index: _Index
13_my_array: _MyArray
14_something: Any
15_dtype: np.dtype[np.int8]
16
17_a_nd: np.flatiter[npt.NDArray[np.float64]]
18
19###
20
21_a_nd.base = _something # type: ignore[misc]
22_a_nd.coords = _something # type: ignore[misc]
23_a_nd.index = _something # type: ignore[misc]
24
25_a_nd.copy("C") # type: ignore[call-arg]
26_a_nd.copy(order="C") # type: ignore[call-arg]
27
28# NOTE: Contrary to `ndarray.__getitem__` its counterpart in `flatiter`
29# does not accept objects with the `__array__` or `__index__` protocols;
30# boolean indexing is just plain broken (gh-17175)
31_a_nd[np.True_] # type: ignore[call-overload]
32_a_nd[_index] # type: ignore[call-overload]
33_a_nd[_my_array] # type: ignore[call-overload]
34
35# `dtype` and `copy` are no-ops in `flatiter.__array__`
36_a_nd.__array__(_dtype) # type: ignore[arg-type]
37_a_nd.__array__(dtype=_dtype) # type: ignore[call-arg]
38_a_nd.__array__(copy=True) # type: ignore[arg-type]
39 