diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2020-04-15 14:50:31 +0100 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2020-04-15 14:50:31 +0100 |
commit | 3ec9d675a40fb8a7dc8f361870e3710b940553de (patch) | |
tree | 42d33f40849798a36d86bb09730c8301eede6d24 /numpy/core/function_base.py | |
parent | 9ccb42d02f7b3fb2b47854bbd4ab418676e6be42 (diff) | |
download | numpy-3ec9d675a40fb8a7dc8f361870e3710b940553de.tar.gz |
BUG: Avoid duplication in stack trace of `linspace(a, b, num=1.5)`
Before this commit, the stack trace was:
```
Traceback (most recent call last):
File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 114, in linspace
num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-13-802b8c6e85f6>", line 1, in <module>
np.linspace(1, 2, 1.5)
File "<__array_function__ internals>", line 5, in linspace
File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 116, in linspace
raise TypeError(
TypeError: object of type <class 'float'> cannot be safely interpreted as an integer.
```
Now it is
```
Traceback (most recent call last):
File "C:\Users\wiese\Repos\numeric-python\numpy\build\testenv\Lib\site-packages\numpy\core\function_base.py", line 114, in linspace
num = operator.index(num)
TypeError: 'float' object cannot be interpreted as an integer
```
This noisy traceback was introduced in f4dfe833e3e037bb69113f7250fad3699f918cfc.
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r-- | numpy/core/function_base.py | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index 6d49b9055..9e46f0ea5 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -110,13 +110,7 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, >>> plt.show() """ - try: - num = operator.index(num) - except TypeError: - raise TypeError( - "object of type {} cannot be safely interpreted as an integer." - .format(type(num))) - + num = operator.index(num) if num < 0: raise ValueError("Number of samples, %s, must be non-negative." % num) div = (num - 1) if endpoint else num |