How to use numpy in optional typing How to use numpy in optional typing python python

How to use numpy in optional typing


Confusingly, np.array is a function useful for creating numpy arrays. It isn't the actual type of the arrays created.

The type is np.ndarray.

So, replace np.array with np.ndarray. That should fix the problem.