summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-02-01 13:00:35 -0700
committerCharles Harris <charlesr.harris@gmail.com>2016-02-01 13:00:35 -0700
commit5a02591bbaae38c4bd3d8163b10ae86b7faf81ba (patch)
tree80fc034c5156e60fd3e6aa8ddcefcb3bfcff842e /numpy/core/numeric.py
parentd1dada15f60c3de9aa35eb58cc4ed41c3ebf21c4 (diff)
parent7fa6aeaa145d01dd63037d51643218784071805c (diff)
downloadnumpy-5a02591bbaae38c4bd3d8163b10ae86b7faf81ba.tar.gz
Merge pull request #6298 from nbeaver/check-lower-base-limit
Check lower base limit in base_repr.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 0b728f804..a672fdc53 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -2198,7 +2198,7 @@ def base_repr(number, base=2, padding=0):
Parameters
----------
number : int
- The value to convert. Only positive values are handled.
+ The value to convert. Positive and negative values are handled.
base : int, optional
Convert `number` to the `base` number system. The valid range is 2-36,
the default value is 2.
@@ -2232,6 +2232,8 @@ def base_repr(number, base=2, padding=0):
digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
if base > len(digits):
raise ValueError("Bases greater than 36 not handled in base_repr.")
+ elif base < 2:
+ raise ValueError("Bases less than 2 not handled in base_repr.")
num = abs(number)
res = []