diff options
author | Emilien Kofman <emilien.kofman@gmail.com> | 2016-02-24 14:56:59 +0100 |
---|---|---|
committer | Emilien Kofman <emilien.kofman@gmail.com> | 2016-03-08 19:34:59 +0100 |
commit | 04df564cc6a107ceb9b8d54faf516dc408f96cbb (patch) | |
tree | 4bd390f745289253a5a68cd537e4ae3f791b1a3b /numpy/core/function_base.py | |
parent | b92cc76afad2e74cbbf6f5b9f5b68050f7c8642a (diff) | |
download | numpy-04df564cc6a107ceb9b8d54faf516dc408f96cbb.tar.gz |
DEP: Deprecated using a float index in linspace
DEP: Deprecated using a float index in linspace
DEP: Deprecated using a float index in linspace
DEP: Deprecated using a float index in linspace
DEP: Deprecated using a float index in linspace
DEP: Deprecated using a float index in linspace
DEP: Release notes for PR#7328
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..cb5d253e5 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))) + stacklevel += 1 + warnings.warn(msg, DeprecationWarning, stacklevel=stacklevel) + i = int(i) + 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 |