summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAllan Haldane <allan.haldane@gmail.com>2015-06-05 12:10:25 -0400
committerAllan Haldane <allan.haldane@gmail.com>2015-06-19 16:43:31 -0400
commita93b86217e9ff8cc1060aaf362cd682b518cfb7b (patch)
treef189ae6dadc7bd6d38fff815aaf65726c22f605d /doc
parent4027d16f0aa19e551067bf0c93dbe057e0142bb8 (diff)
downloadnumpy-a93b86217e9ff8cc1060aaf362cd682b518cfb7b.tar.gz
BUG: automatically convert recarray dtype to np.record
Viewing an ndarray as a np.recarray now automatically converts the dtype to np.record. This commit also fixes assignment to MaskedArray's dtype attribute, fixes the repr of recarrays with non-structured dtype, and removes recarray.view so that viewing a recarray as a non-structured dtype no longer converts to ndarray type. Fixes #3581
Diffstat (limited to 'doc')
-rw-r--r--doc/release/1.10.0-notes.rst7
-rw-r--r--doc/source/reference/arrays.dtypes.rst18
2 files changed, 17 insertions, 8 deletions
diff --git a/doc/release/1.10.0-notes.rst b/doc/release/1.10.0-notes.rst
index 2318e522e..a7b15dd65 100644
--- a/doc/release/1.10.0-notes.rst
+++ b/doc/release/1.10.0-notes.rst
@@ -85,6 +85,13 @@ Notably, this affect recarrays containing strings with whitespace, as trailing
whitespace is trimmed from chararrays but kept in ndarrays of string type.
Also, the dtype.type of nested structured fields is now inherited.
+recarray views
+~~~~~~~~~~~~~~
+Viewing an ndarray as a recarray now automatically converts the dtype to
+np.record. See new record array documentation. Additionally, viewing a recarray
+with a non-structured dtype no longer converts the result's type to ndarray -
+the result will remain a recarray.
+
'out' keyword argument of ufuncs now accepts tuples of arrays
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When using the 'out' keyword argument of a ufunc, a tuple of arrays, one per
diff --git a/doc/source/reference/arrays.dtypes.rst b/doc/source/reference/arrays.dtypes.rst
index 28e2d4f82..8f14118d6 100644
--- a/doc/source/reference/arrays.dtypes.rst
+++ b/doc/source/reference/arrays.dtypes.rst
@@ -424,16 +424,18 @@ Type strings
``(base_dtype, new_dtype)``
- This usage is discouraged. In NumPy 1.7 and later, it is possible
- to specify struct dtypes with overlapping fields, functioning like
- the 'union' type in C. The union mechanism is preferred.
-
- Both arguments must be convertible to data-type objects in this
- case. The *base_dtype* is the data-type object that the new
- data-type builds on. This is how you could assign named fields to
- any built-in data-type object, as done in
+ In NumPy 1.7 and later, this form allows `base_dtype` to be interpreted as
+ a structured dtype. Arrays created with this dtype will have underlying
+ dtype `base_dtype` but will have fields and flags taken from `new_dtype`.
+ This is useful for creating custom structured dtypes, as done in
:ref:`record arrays <arrays.classes.rec>`.
+ This form also makes it possible to specify struct dtypes with overlapping
+ fields, functioning like the 'union' type in C. This usage is discouraged,
+ however, and the union mechanism is preferred.
+
+ Both arguments must be convertible to data-type objects with the same total
+ size.
.. admonition:: Example
32-bit integer, whose first two bytes are interpreted as an integer