summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_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/tests/test_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/tests/test_index_tricks.py')
-rw-r--r--numpy/lib/tests/test_index_tricks.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index 028bba37d..e687e2f54 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -292,11 +292,16 @@ class TestIndexExpression(object):
class TestIx_(object):
def test_regression_1(self):
- # Test empty inputs create outputs of indexing type, gh-5804
- # Test both lists and arrays
- for func in (range, np.arange):
- a, = np.ix_(func(0))
- assert_equal(a.dtype, np.intp)
+ # Test empty untyped inputs create outputs of indexing type, gh-5804
+ a, = np.ix_(range(0))
+ assert_equal(a.dtype, np.intp)
+
+ a, = np.ix_([])
+ assert_equal(a.dtype, np.intp)
+
+ # but if the type is specified, don't change it
+ a, = np.ix_(np.array([], dtype=np.float32))
+ assert_equal(a.dtype, np.float32)
def test_shape_and_dtype(self):
sizes = (4, 5, 3, 2)