summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2020-03-06 00:23:43 +0200
committerGitHub <noreply@github.com>2020-03-06 00:23:43 +0200
commitff4cfe7ecd46ee15fd88297964f6a5cb5423c291 (patch)
treeab318ae312db68d4329e23ade0457a9f026dbb4c /doc
parent901211eddd5e17c8c7c85bc5f791679559d4efb5 (diff)
parenta5a653d25e7329b9366be6f44b052d41bf297b0f (diff)
downloadnumpy-ff4cfe7ecd46ee15fd88297964f6a5cb5423c291.tar.gz
Merge pull request #15534 from seberg/deprecate-abstract-scalar-types
DEP: Do not allow "abstract" dtype conversion/creation
Diffstat (limited to 'doc')
-rw-r--r--doc/release/upcoming_changes/15534.deprecation.rst11
-rw-r--r--doc/source/reference/arrays.dtypes.rst16
2 files changed, 25 insertions, 2 deletions
diff --git a/doc/release/upcoming_changes/15534.deprecation.rst b/doc/release/upcoming_changes/15534.deprecation.rst
new file mode 100644
index 000000000..243e224ba
--- /dev/null
+++ b/doc/release/upcoming_changes/15534.deprecation.rst
@@ -0,0 +1,11 @@
+Converting certain types to dtypes is Deprecated
+------------------------------------------------
+The super classes of scalar types, such as ``np.integer``, ``np.generic``,
+or ``np.inexact`` will now give a deprecation warning when converted
+to a dtype (or used in a dtype keyword argument).
+The reason for this is that `np.integer` is converted to ``np.int_``,
+while it would be expected to represent *any* integer (e.g. also
+``int8``, ``int16``, etc.
+For example, ``dtype=np.floating`` is currently identical to
+``dtype=np.float64``, even though also ``np.float32`` is a subclass of
+``np.floating``.
diff --git a/doc/source/reference/arrays.dtypes.rst b/doc/source/reference/arrays.dtypes.rst
index e97ee3c3a..f8d40b13c 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