diff options
author | Ralf Gommers <ralf.gommers@gmail.com> | 2016-11-06 17:56:06 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-06 17:56:06 +1300 |
commit | e287741d60205bb920dea15d4e70178453db2788 (patch) | |
tree | 126c74deebdb141ce355319d60ac5f18e4c3ebc0 /numpy/lib/tests/test_function_base.py | |
parent | 9aff656065f2749b83abf127472cafc28e235222 (diff) | |
parent | ecf11a6710a354db52dfb5fe073ee1ce6e15bd3e (diff) | |
download | numpy-e287741d60205bb920dea15d4e70178453db2788.tar.gz |
Merge pull request #5302 from idfah/master
Fixed meshgrid to return arrays with same dtype as arguments.
Diffstat (limited to 'numpy/lib/tests/test_function_base.py')
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 6327aaf7c..f396e036b 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -2211,6 +2211,7 @@ class TestMeshgrid(TestCase): def test_no_input(self): args = [] assert_array_equal([], meshgrid(*args)) + assert_array_equal([], meshgrid(*args, copy=False)) def test_indexing(self): x = [1, 2, 3] @@ -2244,6 +2245,30 @@ class TestMeshgrid(TestCase): assert_raises(TypeError, meshgrid, [1, 2, 3], [4, 5, 6, 7], indices='ij') + def test_return_type(self): + # Test for appropriate dtype in returned arrays. + # Regression test for issue #5297 + # https://github.com/numpy/numpy/issues/5297 + x = np.arange(0, 10, dtype=np.float32) + y = np.arange(10, 20, dtype=np.float64) + + X, Y = np.meshgrid(x,y) + + assert_(X.dtype == x.dtype) + assert_(Y.dtype == y.dtype) + + # copy + X, Y = np.meshgrid(x,y, copy=True) + + assert_(X.dtype == x.dtype) + assert_(Y.dtype == y.dtype) + + # sparse + X, Y = np.meshgrid(x,y, sparse=True) + + assert_(X.dtype == x.dtype) + assert_(Y.dtype == y.dtype) + class TestPiecewise(TestCase): |