diff options
author | Andras Deak <deak.andris@gmail.com> | 2020-01-06 01:13:07 +0100 |
---|---|---|
committer | Andras Deak <deak.andris@gmail.com> | 2020-01-06 01:38:39 +0100 |
commit | a66ebb1a97efbb22940adee1c4d721f07d967265 (patch) | |
tree | 3077d794cea12826dac48e6e50f40ce3cf62870b /numpy | |
parent | b5739e8a81c71174b75cf4c8f9de4eccaa7eca2c (diff) | |
download | numpy-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.py | 13 |
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 -------- |