summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2020-07-28 18:54:56 +0200
committerBas van Beek <43369155+BvB93@users.noreply.github.com>2021-10-13 20:26:38 +0200
commit34ba7d7db0a43060f430e84d072f114faad80993 (patch)
tree715fcf29b8f9a73a8f8b9de398d95b9ba276591b /numpy/lib
parent42c5512e2dbcccf1821ad8995841eb67dff4336f (diff)
downloadnumpy-34ba7d7db0a43060f430e84d072f114faad80993.tar.gz
TST: Update the `np.mgrid` tests
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/tests/test_index_tricks.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py
index c21aefd1a..8529beebf 100644
--- a/numpy/lib/tests/test_index_tricks.py
+++ b/numpy/lib/tests/test_index_tricks.py
@@ -255,6 +255,28 @@ class TestGrid:
assert_(grid32.dtype == np.float64)
assert_array_almost_equal(grid64, grid32)
+ def test_accepts_longdouble(self):
+ # regression tests for #16945
+ grid64 = mgrid[0.1:0.33:0.1, ]
+ grid128 = mgrid[
+ np.longdouble(0.1):np.longdouble(0.33):np.longdouble(0.1),
+ ]
+ assert_(grid128.dtype == np.longdouble)
+ assert_array_almost_equal(grid64, grid128)
+
+ grid128c_a = mgrid[0:np.longdouble(1):3.4j]
+ grid128c_b = mgrid[0:np.longdouble(1):3.4j, ]
+ assert_(grid128c_a.dtype == grid128c_b.dtype == np.longdouble)
+ assert_array_equal(grid128c_a, grid128c_b[0])
+
+ # different code path for single slice
+ grid64 = mgrid[0.1:0.33:0.1]
+ grid128 = mgrid[
+ np.longdouble(0.1):np.longdouble(0.33):np.longdouble(0.1)
+ ]
+ assert_(grid128.dtype == np.longdouble)
+ assert_array_almost_equal(grid64, grid128)
+
def test_accepts_npcomplexfloating(self):
# Related to #16466
assert_array_almost_equal(
@@ -266,6 +288,18 @@ class TestGrid:
mgrid[0.1:0.3:3j], mgrid[0.1:0.3:np.complex64(3j)]
)
+ # Related to #16945
+ grid64_a = mgrid[0.1:0.3:3.3j]
+ grid64_b = mgrid[0.1:0.3:3.3j, ][0]
+ assert_(grid64_a.dtype == grid64_b.dtype == np.float64)
+ assert_array_equal(grid64_a, grid64_b)
+
+ grid128_a = mgrid[0.1:0.3:np.clongdouble(3.3j)]
+ grid128_b = mgrid[0.1:0.3:np.clongdouble(3.3j), ][0]
+ assert_(grid128_a.dtype == grid128_b.dtype == np.longdouble)
+ assert_array_equal(grid64_a, grid64_b)
+
+
class TestConcatenator:
def test_1d(self):
assert_array_equal(r_[1, 2, 3, 4, 5, 6], np.array([1, 2, 3, 4, 5, 6]))