summaryrefslogtreecommitdiff
path: root/numpy/lib/index_tricks.py
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2017-12-11 22:28:35 -0800
committerEric Wieser <wieser.eric@gmail.com>2017-12-11 22:28:35 -0800
commitd4bc1b6795912391473a56f6e757e39bd7b63676 (patch)
tree00c9a6cac7fe9c39886fc6a1a6b120dde45e8033 /numpy/lib/index_tricks.py
parent8032cf4762008155fca610fb61092e6c9ecae98b (diff)
downloadnumpy-d4bc1b6795912391473a56f6e757e39bd7b63676.tar.gz
ENH: Allow np.r_ to accept 0d arrays
Fixes gh-9233
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r--numpy/lib/index_tricks.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 650b37f25..b2c178f10 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -5,7 +5,7 @@ import math
import numpy.core.numeric as _nx
from numpy.core.numeric import (
- asarray, ScalarType, array, alltrue, cumprod, arange
+ asarray, ScalarType, array, alltrue, cumprod, arange, ndim
)
from numpy.core.numerictypes import find_common_type, issubdtype
@@ -312,21 +312,16 @@ class AxisConcatenator(object):
scalar = True
scalartypes.append(newobj.dtype)
else:
- newobj = item
- if ndmin > 1:
- tempobj = array(newobj, copy=False, subok=True)
- newobj = array(newobj, copy=False, subok=True,
- ndmin=ndmin)
- if trans1d != -1 and tempobj.ndim < ndmin:
- k2 = ndmin-tempobj.ndim
- if (trans1d < 0):
- trans1d += k2 + 1
- defaxes = list(range(ndmin))
- k1 = trans1d
- axes = defaxes[:k1] + defaxes[k2:] + \
- defaxes[k1:k2]
- newobj = newobj.transpose(axes)
- del tempobj
+ item_ndim = ndim(item)
+ newobj = array(item, copy=False, subok=True, ndmin=ndmin)
+ if trans1d != -1 and item_ndim < ndmin:
+ k2 = ndmin - item_ndim
+ if (trans1d < 0):
+ trans1d += k2 + 1
+ defaxes = list(range(ndmin))
+ k1 = trans1d
+ axes = defaxes[:k1] + defaxes[k2:] + defaxes[k1:k2]
+ newobj = newobj.transpose(axes)
objs.append(newobj)
if not scalar and isinstance(newobj, _nx.ndarray):
arraytypes.append(newobj.dtype)