[Numpy-discussion] np.{bool,float,int} deprecation

Juan Nunez-Iglesias jni at fastmail.com
Sun Dec 13 03:00:05 EST 2020



> On 13 Dec 2020, at 6:25 am, Sebastian Berg <sebastian at sipsolutions.net> wrote:
> 
> But "default" in NumPy really doesn't mean a whole lot?  I can think of
> three places where "defaults" exists:

Huh? There are platform-specific defaults for literally every array creation function in NumPy?

In [1]: np.array([4, 9]).dtype
Out[1]: dtype('int64')

In [2]: np.array([3., 0.]).dtype
Out[2]: dtype('float64')

In [3]: np.arange(5).dtype
Out[3]: dtype('int64')

In [4]: np.arange(5.).dtype
Out[4]: dtype('float64')

In [5]: np.empty(5).dtype
Out[5]: dtype('float64')

In [6]: np.zeros(5).dtype
Out[6]: dtype('float64')

In [7]: np.full(5, 5).dtype
Out[7]: dtype('int64')

In [8]: np.full(5, 5.).dtype
Out[8]: dtype('float64’)

The list goes on…

And, indeed, mixing types can cause implicit casting, and thus both slowness and unexpected type promotion, which brings with it its own bugs… Again, I think it is valuable to have syntax to express `np.zeros(…, dtype=<whatever-dtype-np.array(…)-would-give-for-my-data>)`.

Juan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20201213/e58df761/attachment.html>


More information about the NumPy-Discussion mailing list