diff options
| -rw-r--r-- | numpy/typing/_generic_alias.py | 3 | ||||
| -rw-r--r-- | numpy/typing/tests/test_generic_alias.py | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/numpy/typing/_generic_alias.py b/numpy/typing/_generic_alias.py index f98fca62e..d83979aaf 100644 --- a/numpy/typing/_generic_alias.py +++ b/numpy/typing/_generic_alias.py @@ -63,7 +63,8 @@ def _reconstruct_alias(alias: _T, parameters: Iterator[TypeVar]) -> _T: elif isinstance(i, _GenericAlias): value = _reconstruct_alias(i, parameters) elif hasattr(i, "__parameters__"): - value = i[next(parameters)] + prm_tup = tuple(next(parameters) for _ in i.__parameters__) + value = i[prm_tup] else: value = i args.append(value) diff --git a/numpy/typing/tests/test_generic_alias.py b/numpy/typing/tests/test_generic_alias.py index 13072051a..5f86c4001 100644 --- a/numpy/typing/tests/test_generic_alias.py +++ b/numpy/typing/tests/test_generic_alias.py @@ -11,6 +11,8 @@ import numpy as np from numpy.typing._generic_alias import _GenericAlias ScalarType = TypeVar("ScalarType", bound=np.generic) +T1 = TypeVar("T1") +T2 = TypeVar("T2") DType = _GenericAlias(np.dtype, (ScalarType,)) NDArray = _GenericAlias(np.ndarray, (Any, DType)) @@ -50,6 +52,7 @@ class TestGenericAlias: ("__getitem__", lambda n: n[np.float64]), ("__getitem__", lambda n: n[ScalarType][np.float64]), ("__getitem__", lambda n: n[Union[np.int64, ScalarType]][np.float64]), + ("__getitem__", lambda n: n[Union[T1, T2]][np.float32, np.float64]), ("__eq__", lambda n: n == n), ("__ne__", lambda n: n != np.ndarray), ("__dir__", lambda n: dir(n)), |
