diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-02-19 13:12:30 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-02-19 14:16:05 +0000 |
commit | 24960daf3e326591047eb099af840da6e95d0910 (patch) | |
tree | 4a6e14b265578e6e7c182ea6b3912b912bf125ca /numpy/lib/index_tricks.py | |
parent | aba10bb5829caee63a20251a226d8cb716ec1125 (diff) | |
download | numpy-24960daf3e326591047eb099af840da6e95d0910.tar.gz |
BUG: Preserve types of empty arrays when known
Fixes regression in #5805
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r-- | numpy/lib/index_tricks.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 84c161b2e..23f9a8c25 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -85,12 +85,13 @@ def ix_(*args): out = [] nd = len(args) for k, new in enumerate(args): - new = asarray(new) + if not isinstance(new, _nx.ndarray): + new = asarray(new) + if new.size == 0: + # Explicitly type empty arrays to avoid float default + new = new.astype(_nx.intp) if new.ndim != 1: raise ValueError("Cross index must be 1 dimensional") - if new.size == 0: - # Explicitly type empty arrays to avoid float default - new = new.astype(_nx.intp) if issubdtype(new.dtype, _nx.bool_): new, = new.nonzero() new = new.reshape((1,)*k + (new.size,) + (1,)*(nd-k-1)) |