diff options
author | Bertrand <bertrand.l3f@gmail.com> | 2015-07-08 22:45:05 -0400 |
---|---|---|
committer | Bertrand <bertrand.l3f@gmail.com> | 2015-07-08 22:45:05 -0400 |
commit | 43d4aa5de8a991fa40c9976280cef5b4b080a806 (patch) | |
tree | b7f158f124e7f8b2916fe2d80a4102da8222b9f7 /numpy/core/function_base.py | |
parent | e9a75342099995b07c4d326fb6c0f47ce3edb002 (diff) | |
download | numpy-43d4aa5de8a991fa40c9976280cef5b4b080a806.tar.gz |
EHN: raise error for negative 'num' in linspace.
Closing #5937
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r-- | numpy/core/function_base.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index e50e1a505..532ef2950 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -25,7 +25,7 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): evenly spaced samples, so that `stop` is excluded. Note that the step size changes when `endpoint` is False. num : int, optional - Number of samples to generate. Default is 50. + Number of samples to generate. Default is 50. Must be non-negative. endpoint : bool, optional If True, `stop` is the last sample. Otherwise, it is not included. Default is True. @@ -82,6 +82,8 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): """ num = int(num) + if num < 0: + raise ValueError("Number of samples, %s, must be non-negative." % num) div = (num - 1) if endpoint else num # Convert float/complex array scalars to float, gh-3504 |