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/tests/test_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/tests/test_index_tricks.py')
-rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 15 |
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 d9fa1f43e..e645114ab 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -198,11 +198,16 @@ class TestIndexExpression(TestCase): class TestIx_(TestCase): def test_regression_1(self): - # Test empty inputs create ouputs 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 ouputs 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) |