diff options
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r-- | numpy/core/function_base.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index 21ca1af01..750fbe838 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -1,10 +1,24 @@ from __future__ import division, absolute_import, print_function +import warnings +import operator + __all__ = ['logspace', 'linspace'] from . import numeric as _nx from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError +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(start, stop, num=50, endpoint=True, retstep=False, dtype=None): """ @@ -81,7 +95,8 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): >>> plt.show() """ - num = int(num) + # 2016-02-25, 1.12 + num = _index_deprecate(num) if num < 0: raise ValueError("Number of samples, %s, must be non-negative." % num) div = (num - 1) if endpoint else num |