suppose I want the default data type to be np.uint8
, in such a way that when I call:
a = 2
print(type(a))
I get in output numpy.uint8
.
Is it possible to obtain this?
suppose I want the default data type to be np.uint8
, in such a way that when I call:
a = 2
print(type(a))
I get in output numpy.uint8
.
Is it possible to obtain this?
It's not possible, at least not with little effort, and it was discouraged when it was discussed on Numpy's issue tracker as 'unlikely to add', for good reason.
The easiest thing to do is to either use a function that takes the input and casts it to the desired data type or to check out this post on to 'overload' your numpy
functions to always use eg. dtype=uint8
.