diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2022-06-09 12:34:35 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 12:34:35 -0600 |
| commit | 09dc8bcb8b729deb19e40fe9e9361690dc0113ec (patch) | |
| tree | 34ead172fb598b43167d6596d0e503b1e5b282ae /numpy/lib/tests | |
| parent | 5447192c8dc5d43d837b93ed5c5d47457e367669 (diff) | |
| parent | 34ba7d7db0a43060f430e84d072f114faad80993 (diff) | |
| download | numpy-09dc8bcb8b729deb19e40fe9e9361690dc0113ec.tar.gz | |
Merge pull request #16971 from BvB93/nd_grid
BUG: Fix three `complex`- & `float128`-related issues with `nd_grid`
Diffstat (limited to 'numpy/lib/tests')
| -rw-r--r-- | numpy/lib/tests/test_index_tricks.py | 34 |
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 26a34be7e..b599cb345 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -254,6 +254,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( @@ -265,6 +287,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])) |
