summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_index_tricks.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_index_tricks.py')
-rw-r--r--numpy/lib/tests/test_index_tricks.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index 905165a99..843e27cef 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -249,6 +249,29 @@ class TestGrid:
assert_equal(grid.size, expected[0])
assert_equal(grid_small.size, expected[1])
+ def test_accepts_npfloating(self):
+ # regression test for #16466
+ grid64 = mgrid[0.1:0.33:0.1, ]
+ grid32 = mgrid[np.float32(0.1):np.float32(0.33):np.float32(0.1), ]
+ assert_(grid32.dtype == np.float64)
+ assert_array_almost_equal(grid64, grid32)
+
+ # different code path for single slice
+ grid64 = mgrid[0.1:0.33:0.1]
+ grid32 = mgrid[np.float32(0.1):np.float32(0.33):np.float32(0.1)]
+ assert_(grid32.dtype == np.float64)
+ assert_array_almost_equal(grid64, grid32)
+
+ def test_accepts_npcomplexfloating(self):
+ # Related to #16466
+ assert_array_almost_equal(
+ mgrid[0.1:0.3:3j, ], mgrid[0.1:0.3:np.complex64(3j), ]
+ )
+
+ # different code path for single slice
+ assert_array_almost_equal(
+ mgrid[0.1:0.3:3j], mgrid[0.1:0.3:np.complex64(3j)]
+ )
class TestConcatenator:
def test_1d(self):
@@ -270,6 +293,10 @@ class TestConcatenator:
g = r_[0:36:100j]
assert_(g.shape == (100,))
+ # Related to #16466
+ g = r_[0:36:np.complex64(100j)]
+ assert_(g.shape == (100,))
+
def test_2d(self):
b = np.random.rand(5, 5)
c = np.random.rand(5, 5)