[Numpy-discussion] Py-API: Deprecate `np.dtype(np.floating)` and similar dtype creation

Nathan nathan.goldbaum at gmail.com
Fri Feb 14 16:39:21 EST 2020


For what it's worth, github search only finds two instances of this usage:

https://github.com/search?q=%22np.dtype%28np.floating%29%22&type=Code

On Fri, Feb 14, 2020 at 2:28 PM Sebastian Berg <sebastian at sipsolutions.net>
wrote:

> Hi all,
>
> In https://github.com/numpy/numpy/pull/15534 I would like to start
> deprecating creating dtypes from "abstract" scalar classes, such as:
>
> np.dtype(np.floating) is np.dtype(np.float64)
>
> While, at the same time, `isinstance(np.float32, np.floating)` is true.
>
> Right now `arr.astype(np.floating, copy=False)` and, more obviously,
> `arr.astype(np.dtype(np.floating), copy=False)` will cast a float32
> array to float64.
>
> I think we should deprecate this, to consistently enable that in the
> future `dtype=np.floating` may choose to not cast a float32 array. Of
> course for the `astype` call the DeprecationWarning would be changed to
> a FutureWarning before we change the result value.
>
> A slight (but hopefully rare) annoyance is that `np.integer` might be
> used since it reads fairly well compared to `np.int_`. The large
> upstream packages such as SciPy or astropy seem to be clean in this
> regard, though (at least almost clean).
>
> Does anyone think this is a bad idea? To me these deprecations seem
> fairly straight forward, possibly flush out bugs/unintended behaviour,
> and necessary for consistent future behaviour. (More similar ones may
> have to follow).
>
> If there is some, but not much, hesitation, I can also add this to the
> NEP 41 draft. Although I currently feel it is the right thing to do
> even if we never had any new dtypes.
>
> - Sebastian
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20200214/d57d4145/attachment-0001.html>


More information about the NumPy-Discussion mailing list