diff options
author | Alan McIntyre <alan.mcintyre@local> | 2008-07-13 21:42:52 +0000 |
---|---|---|
committer | Alan McIntyre <alan.mcintyre@local> | 2008-07-13 21:42:52 +0000 |
commit | 5f1b347d807b713292a5771b5bf086265848faf0 (patch) | |
tree | 36e2098c70eca4468064f622b036002f999e479c /numpy | |
parent | 207e37a2eb9f2004c390c7b41cbdea4cc79afe59 (diff) | |
download | numpy-5f1b347d807b713292a5771b5bf086265848faf0.tar.gz |
Add tests to improve coverage.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 21 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 22 |
2 files changed, 43 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 2bfd7df41..663dff294 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -892,5 +892,26 @@ class TestStats(TestCase): 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() diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 24334dacd..da8378784 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -817,6 +817,28 @@ class TestStdVarComplex(TestCase): 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() |