Currying numpy's ndarray type

Viewed 99

Numpy just released support for typing in 1.22.0. The ndarray class accepts two params: shape and data type. I would like to wrap the ndarray and only require the data type to specified. Is there a way to do this?

from typing import Generic, TypeVar, Any
import numpy as np


T = TypeVar('T')
class NDArrayAnyShape(np.ndarray[Any, Generic[T]]):
    ...

NDArrayAnyShapeIntDtype = NDArrayAnyShape[int]

This throws

TypeError: Too few arguments for NDArrayAnyShape
0 Answers
Related