summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-02-07 11:33:45 -0800
committerSebastian Berg <sebastian@sipsolutions.net>2020-02-07 13:47:19 -0800
commitcefd3523a63cfd5ede693d53d3821e37fa8ca158 (patch)
tree627bd350cef3c2dbf81b6efa51b58c5d108475ed /doc/source
parent1a1611a33cfb5ea50d16d20affa5c6fa03e148d7 (diff)
downloadnumpy-cefd3523a63cfd5ede693d53d3821e37fa8ca158.tar.gz
Fixup: Do not deprecate generic python types
Add a comment that we can think about only allowing it for `dtype=...` though...
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/reference/arrays.dtypes.rst16
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/source/reference/arrays.dtypes.rst b/doc/source/reference/arrays.dtypes.rst
index 231707b11..71c2fa5a4 100644
--- a/doc/source/reference/arrays.dtypes.rst
+++ b/doc/source/reference/arrays.dtypes.rst
@@ -156,6 +156,14 @@ Array-scalar types
Generic types
+ .. deprecated NumPy 1.19::
+
+ The use of generic types is deprecated. This is because it can be
+ unexpected in a context such as ``arr.astype(dtype=np.floating)``.
+ ``arr.astype(dtype=np.floating)`` which casts an array of ``float32``
+ to an array of ``float64``, even though ``float32`` is a subdtype of
+ ``np.floating``.
+
The generic hierarchical type objects convert to corresponding
type objects according to the associations:
@@ -179,8 +187,7 @@ Built-in Python types
:class:`float` :class:`float\_`
:class:`complex` :class:`cfloat`
:class:`bytes` :class:`bytes\_`
- :class:`str` :class:`bytes\_` (Python2) or :class:`unicode\_` (Python3)
- :class:`unicode` :class:`unicode\_`
+ :class:`str` :class:`str\_`
:class:`buffer` :class:`void`
(all others) :class:`object_`
================ ===============
@@ -196,6 +203,11 @@ Built-in Python types
>>> dt = np.dtype(int) # Python-compatible integer
>>> dt = np.dtype(object) # Python object
+ .. note::
+
+ All other types map to ``object_`` for convenience. Code should expect
+ that such types may map to a specific (new) dtype in future the future.
+
Types with ``.dtype``
Any type object with a ``dtype`` attribute: The attribute will be