Closed
Description
Per #7370 (comment), we could specify dtype as part of ndarray types (including type inference) by using NumPy's scalar types, e.g., np.ndarray[Any, np.float64]
or np.ndarray[np.float64, Any]
(where Any
indicates the shape).
Is this a good way to indicate dtypes? How would we handle dtypes that don't have a well specified scalar type? For example:
datetime64
andtimedelta64
do not have precision as part of the typenp.void
is used for all arbitrary structured dtypes, but doesn't indicate the field names or subtypes (side note:np.struct
would be a much better name)- string dtypes have their size as part of the type
One simple answer is to not worry about more detailed type information for now, and worry about more precise specification for scalar types later, when support in the typing module becomes available (e.g., for integer types or custom struct-like data structures like TypedDict
).