[Numpy-svn] r5402 - trunk/numpy/core/tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Sun Jul 13 17:43:01 EDT 2008
Author: alan.mcintyre
Date: 2008-07-13 16:42:52 -0500 (Sun, 13 Jul 2008)
New Revision: 5402
Modified:
trunk/numpy/core/tests/test_multiarray.py
trunk/numpy/core/tests/test_numeric.py
Log:
Add tests to improve coverage.
Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py 2008-07-13 19:22:26 UTC (rev 5401)
+++ trunk/numpy/core/tests/test_multiarray.py 2008-07-13 21:42:52 UTC (rev 5402)
@@ -892,5 +892,26 @@
assert res.info == dat.info
+class TestSummarization(TestCase):
+ def test_1d(self):
+ A = np.arange(1001)
+ strA = '[ 0 1 2 ..., 998 999 1000]'
+ assert str(A) == strA
+
+ reprA = 'array([ 0, 1, 2, ..., 998, 999, 1000])'
+ assert repr(A) == reprA
+
+ def test_2d(self):
+ A = np.arange(1002).reshape(2,501)
+ strA = '[[ 0 1 2 ..., 498 499 500]\n' \
+ ' [ 501 502 503 ..., 999 1000 1001]]'
+ assert str(A) == strA
+
+ reprA = 'array([[ 0, 1, 2, ..., 498, 499, 500],\n' \
+ ' [ 501, 502, 503, ..., 999, 1000, 1001]])'
+ assert repr(A) == reprA
+
+
+
if __name__ == "__main__":
run_module_suite()
Modified: trunk/numpy/core/tests/test_numeric.py
===================================================================
--- trunk/numpy/core/tests/test_numeric.py 2008-07-13 19:22:26 UTC (rev 5401)
+++ trunk/numpy/core/tests/test_numeric.py 2008-07-13 21:42:52 UTC (rev 5402)
@@ -817,6 +817,28 @@
assert_almost_equal(std(A)**2,real_var)
+class TestLikeFuncs(TestCase):
+ '''Test zeros_like and empty_like'''
+
+ def setUp(self):
+ self.data = [(array([[1,2,3],[4,5,6]],dtype=int32), (2,3), int32),
+ (array([[1,2,3],[4,5,6]],dtype=float32), (2,3), float32),
+ ]
+
+ def test_zeros_like(self):
+ for d, dshape, dtype in self.data:
+ dz = zeros_like(d)
+ assert dz.shape == dshape
+ assert dz.dtype.type == dtype
+ assert all(abs(dz) == 0)
+
+ def test_empty_like(self):
+ for d, dshape, dtype in self.data:
+ dz = zeros_like(d)
+ assert dz.shape == dshape
+ assert dz.dtype.type == dtype
+
+
if __name__ == "__main__":
run_module_suite()
More information about the Numpy-svn
mailing list