NumPy has dtypes (as I am sure everyone knows), but also DType classes. I.e that is the:
import numpy as np
float64_dtype = np.dtype("float64")
type(float64_dtype)
The is the DType class. Besides being referred to in some errors, the classes are not particularly interesting in most code, since we are used to np.dtype("float64")
, etc. although StringDType(10)
could e.g. be used to do np.dtype("S10")
.
However, these classes are sensible objects and allow things like isinstance
checks. It has also always been a plan to implement abstract DType classes. For example we would have a FloatingDType
to represent any floating point number (float16, float32, float64, …), potentially even allowing arr.astype(FloatingDType)
(doesn’t actually exist yet).
There is enough use for this, that I would like to finally resolve where to put them and create the names. I have always rejected the main namespace, because it already has the scalar np.int64
, etc. and this is just not very common.
So, lets lets try if a poll can help give enough insight here to help make a decision.
np.<name>
-
np.types.<name>
(might be used for more types) np.dtype_classes.<name>
np.lib.types.<name>
np.lib.dtype_classes.<name>
- There must be a better way/place! (please comment)
0 voters
Please don’t hesitate to add a comment!
More options (would prefer no double voting, since this wasn’t multiple choice ;).
np.dtypes.<name>
np.lib.dtypes.<name>
0 voters