summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_function_base.py
diff options
context:
space:
mode:
authorElliott M Forney <elliott.forney@gmail.com>2014-11-20 15:09:35 -0700
committerElliott M Forney <elliott.forney@gmail.com>2014-11-20 15:09:35 -0700
commit3811083eee8d61548587f0d52286a08a7744d88f (patch)
treece3d5b46cd958ef2807a4e4b7837d408e244f043 /numpy/lib/tests/test_function_base.py
parent31b94e85a99db998bd6156d2b800386973fef3e1 (diff)
downloadnumpy-3811083eee8d61548587f0d52286a08a7744d88f.tar.gz
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.py25
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 80faf85a6..cdc4285e8 100644
--- a/numpy/lib/tests/test_function_base.py
+++ b/numpy/lib/tests/test_function_base.py
@@ -1462,6 +1462,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]
@@ -1495,6 +1496,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):
def test_simple(self):