diff options
author | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2019-03-04 17:25:22 -0500 |
---|---|---|
committer | Marten van Kerkwijk <mhvk@astro.utoronto.ca> | 2019-03-04 17:25:22 -0500 |
commit | b3fdef08b5c586fff50fdabb0967e53ccaaab3c4 (patch) | |
tree | 6cc7da15bbd04367f281d7a67cbb1299e2aa383f /numpy/core/function_base.py | |
parent | d08b733e6612690bd35680019216e2aa4e3321ab (diff) | |
download | numpy-b3fdef08b5c586fff50fdabb0967e53ccaaab3c4.tar.gz |
BUG: ensure linspace works on object input.
As it was, the difference between stop and start was calculated and
it was assumed that that would be a numpy scalar or array. This is
not true for object input.
Diffstat (limited to 'numpy/core/function_base.py')
-rw-r--r-- | numpy/core/function_base.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/core/function_base.py b/numpy/core/function_base.py index f8800b83e..296213823 100644 --- a/numpy/core/function_base.py +++ b/numpy/core/function_base.py @@ -6,7 +6,7 @@ import operator from . import numeric as _nx from .numeric import (result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, - TooHardError, asanyarray) + TooHardError, asanyarray, ndim) from numpy.core.multiarray import add_docstring from numpy.core import overrides @@ -140,7 +140,7 @@ def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, dtype = dt delta = stop - start - y = _nx.arange(0, num, dtype=dt).reshape((-1,) + (1,) * delta.ndim) + y = _nx.arange(0, num, dtype=dt).reshape((-1,) + (1,) * ndim(delta)) # In-place multiplication y *= delta/div is faster, but prevents the multiplicant # from overriding what class is produced, and thus prevents, e.g. use of Quantities, # see gh-7142. Hence, we multiply in place only for standard scalar types. |