summaryrefslogtreecommitdiff
path: root/numpy/lib/index_tricks.py
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-04-29 10:37:01 -0700
committerGitHub <noreply@github.com>2019-04-29 10:37:01 -0700
commitc23bd98de665733dd090636f38b6aacf9f99450b (patch)
treec83c325eb493f0d5c79c61cd9ed25adcedae30dc /numpy/lib/index_tricks.py
parentff99a67e13ca1b07d7399b0586e8c265ed0a5f76 (diff)
parent7f4579279a6a6aa07df664b901afa36ab3fc5ce0 (diff)
downloadnumpy-c23bd98de665733dd090636f38b6aacf9f99450b.tar.gz
Merge pull request #8641 from eric-wieser/ix_-preserve-type
BUG: Preserve types of empty arrays in ix_ when known
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r--numpy/lib/index_tricks.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index 40c1cda05..04384854c 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -94,12 +94,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))