summaryrefslogtreecommitdiff
path: root/numpy/core/function_base.py
diff options
context:
space:
mode:
authorSeth Troisi <sethtroisi@google.com>2019-10-01 03:16:53 -0700
committerSeth Troisi <sethtroisi@google.com>2019-10-01 03:29:41 -0700
commitf4dfe833e3e037bb69113f7250fad3699f918cfc (patch)
treed59d2e551426a5c6b79e1f5cce8aaf8aeb2fb741 /numpy/core/function_base.py
parent8fa7b6e73380d4b73251d8226d90f327996baa19 (diff)
downloadnumpy-f4dfe833e3e037bb69113f7250fad3699f918cfc.tar.gz
Dep: Deprecation of float index in linespace
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r--numpy/core/function_base.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py
index d83af9911..42604ec3f 100644
--- a/numpy/core/function_base.py
+++ b/numpy/core/function_base.py
@@ -18,18 +18,6 @@ array_function_dispatch = functools.partial(
overrides.array_function_dispatch, module='numpy')
-def _index_deprecate(i, stacklevel=2):
- try:
- i = operator.index(i)
- except TypeError:
- msg = ("object of type {} cannot be safely interpreted as "
- "an integer.".format(type(i)))
- i = int(i)
- stacklevel += 1
- warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel)
- return i
-
-
def _linspace_dispatcher(start, stop, num=None, endpoint=None, retstep=None,
dtype=None, axis=None):
return (start, stop)
@@ -125,8 +113,13 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None,
>>> plt.show()
"""
- # 2016-02-25, 1.12
- num = _index_deprecate(num)
+ try:
+ num = operator.index(num)
+ except TypeError:
+ raise TypeError(
+ "object of type {} cannot be safely interpreted as an integer."
+ .format(type(num)))
+
if num < 0:
raise ValueError("Number of samples, %s, must be non-negative." % num)
div = (num - 1) if endpoint else num