summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorAndras Deak <deak.andris@gmail.com>2020-01-06 01:13:07 +0100
committerAndras Deak <deak.andris@gmail.com>2020-01-06 01:38:39 +0100
commita66ebb1a97efbb22940adee1c4d721f07d967265 (patch)
tree3077d794cea12826dac48e6e50f40ce3cf62870b /numpy
parentb5739e8a81c71174b75cf4c8f9de4eccaa7eca2c (diff)
downloadnumpy-a66ebb1a97efbb22940adee1c4d721f07d967265.tar.gz
DOC: Clarify the effect of None parameters passed to ndarray.view
Make it clear that explicitly passing None for dtype or type will behave differently than omitting these parameters. See also #14875
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/_add_newdocs.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
index 36fc9d7d6..5ff12a2c7 100644
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -4129,14 +4129,14 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
Parameters
----------
dtype : data-type or ndarray sub-class, optional
- Data-type descriptor of the returned view, e.g., float32 or int16. The
- default, None, results in the view having the same data-type as `a`.
+ Data-type descriptor of the returned view, e.g., float32 or int16.
+ Omitting it results in the view having the same data-type as `a`.
This argument can also be specified as an ndarray sub-class, which
then specifies the type of the returned object (this is equivalent to
setting the ``type`` parameter).
type : Python type, optional
- Type of the returned view, e.g., ndarray or matrix. Again, the
- default None results in type preservation.
+ Type of the returned view, e.g., ndarray or matrix. Again, omission
+ of the parameter results in type preservation.
Notes
-----
@@ -4160,6 +4160,11 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('view',
defined as a slice or transpose, etc., the view may give different
results.
+ Passing None explicitly for ``dtype`` is different from omitting the
+ parameter, since the former invokes ``dtype(None)`` which is an alias for
+ ``dtype('float_')``. Similarly, explicitly passing None for ``type``
+ is an error.
+
Examples
--------