diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2019-08-19 19:20:52 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-19 19:20:52 -0500 |
commit | e1c42bb77fa727f0b214f3433207e20261acb57f (patch) | |
tree | cf4da7cd17f747fe707c7dfc7d55fbd25503e2b9 /numpy/core/numeric.py | |
parent | 98bdde643af6443d68a8c6233807b75bd3f0ed80 (diff) | |
parent | dd9051c78476be2bc2cbf03ab895e8dde5ca14ca (diff) | |
download | numpy-e1c42bb77fa727f0b214f3433207e20261acb57f.tar.gz |
Merge pull request #14295 from WarrenWeckesser/binary-repr-arg
BUG: core: Handle large negative np.int64 args in binary_repr.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index ff8c58867..bbcd58abb 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1935,6 +1935,10 @@ def binary_repr(num, width=None): "will raise an error in the future.", DeprecationWarning, stacklevel=3) + # Ensure that num is a Python integer to avoid overflow or unwanted + # casts to floating point. + num = operator.index(num) + if num == 0: return '0' * (width or 1) |