summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorPetre-Flaviu Gostin <37553536+flaviu-gostin@users.noreply.github.com>2020-04-30 12:03:43 +0100
committerGitHub <noreply@github.com>2020-04-30 14:03:43 +0300
commit6f8d7fd467b69229c0a7ed3662966573e8b3d85c (patch)
tree7fa12c33014ff3c8e29da2f7bee05cf6a0b0de81 /numpy
parent92bda60074d0afcc3d29a0131037f11b350a99d7 (diff)
downloadnumpy-6f8d7fd467b69229c0a7ed3662966573e8b3d85c.tar.gz
DOC: add note on type casting to numpy.left_shift(). (#16081)
* DOC: add note on type casting to numpy.left_shift(). Co-Authored-By: Ross Barnowski <rossbar@berkeley.edu>
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/code_generators/ufunc_docstrings.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/core/code_generators/ufunc_docstrings.py b/numpy/core/code_generators/ufunc_docstrings.py
index 129516658..82cd6fb27 100644
--- a/numpy/core/code_generators/ufunc_docstrings.py
+++ b/numpy/core/code_generators/ufunc_docstrings.py
@@ -1835,6 +1835,17 @@ add_newdoc('numpy.core.umath', 'left_shift',
>>> np.left_shift(5, [1,2,3])
array([10, 20, 40])
+ Note that the dtype of the second argument may change the dtype of the
+ result and can lead to unexpected results in some cases (see
+ :ref:`Casting Rules <ufuncs.casting>`):
+
+ >>> a = np.left_shift(np.uint8(255), 1) # Expect 254
+ >>> print(a, type(a)) # Unexpected result due to upcasting
+ 510 <class 'numpy.int64'>
+ >>> b = np.left_shift(np.uint8(255), np.uint8(1))
+ >>> print(b, type(b))
+ 254 <class 'numpy.uint8'>
+
""")
add_newdoc('numpy.core.umath', 'less',