|
1 | 1 | from _typeshed import Unused |
2 | 2 | from collections.abc import Callable, Iterable |
3 | | -from typing import Any, Final, Generic, TypeVar |
| 3 | +from typing import Any, Final |
4 | 4 |
|
5 | 5 | import numpy as np |
6 | 6 | import optype.numpy as onp |
7 | 7 |
|
8 | | -_ScalarT = TypeVar("_ScalarT", bound=np.generic) |
9 | | -_ShapeT = TypeVar("_ShapeT", bound=tuple[int, ...]) |
| 8 | +class _FakeMatrix[ScalarT: np.generic, ShapeT: tuple[int, ...]]: # undocumented |
| 9 | + _data: onp.ArrayND[ScalarT, ShapeT] |
10 | 10 |
|
11 | | -class _FakeMatrix(Generic[_ScalarT, _ShapeT]): # undocumented |
12 | | - _data: onp.ArrayND[_ScalarT, _ShapeT] |
13 | | - |
14 | | - def __init__(self, /, data: onp.ArrayND[_ScalarT, _ShapeT]) -> None: ... |
| 11 | + def __init__(self, /, data: onp.ArrayND[ScalarT, ShapeT]) -> None: ... |
15 | 12 | __array_interface__: Final[Callable[[], dict[str, Any]]] = ... |
16 | 13 |
|
17 | 14 | @property |
18 | | - def shape(self) -> _ShapeT: ... |
| 15 | + def shape(self) -> ShapeT: ... |
19 | 16 |
|
20 | | -class _FakeMatrix2(Generic[_ScalarT, _ShapeT]): # undocumented |
21 | | - _data: onp.ArrayND[_ScalarT, _ShapeT] |
22 | | - def __init__(self, /, data: onp.ArrayND[_ScalarT, _ShapeT]) -> None: ... |
23 | | - def __array__(self, /, dtype: np.dtype[Any] | None = None, copy: bool | None = None) -> onp.ArrayND[_ScalarT, _ShapeT]: ... |
| 17 | +class _FakeMatrix2[ScalarT: np.generic, ShapeT: tuple[int, ...]]: # undocumented |
| 18 | + _data: onp.ArrayND[ScalarT, ShapeT] |
| 19 | + def __init__(self, /, data: onp.ArrayND[ScalarT, ShapeT]) -> None: ... |
| 20 | + def __array__(self, /, dtype: np.dtype[Any] | None = None, copy: bool | None = None) -> onp.ArrayND[ScalarT, ShapeT]: ... |
24 | 21 | @property |
25 | | - def shape(self) -> _ShapeT: ... |
| 22 | + def shape(self) -> ShapeT: ... |
26 | 23 |
|
27 | | -def _get_array(shape: _ShapeT, dtype: type[_ScalarT]) -> onp.ArrayND[_ScalarT, _ShapeT]: ... # undocumented |
| 24 | +def _get_array[ScalarT: np.generic, ShapeT: tuple[int, ...]]( |
| 25 | + shape: ShapeT, dtype: type[ScalarT] |
| 26 | +) -> onp.ArrayND[ScalarT, ShapeT]: ... # undocumented |
28 | 27 | def _id[T](x: T) -> T: ... # undocumented |
29 | 28 |
|
30 | 29 | # |
|
0 commit comments