[pypy-commit] pypy numpy-identity: Made tests look nicer
jterrace
noreply at buildbot.pypy.org
Tue Dec 13 23:41:34 CET 2011
Author: Jeff Terrace <jterrace at gmail.com>
Branch: numpy-identity
Changeset: r50483:506329de8bc3
Date: 2011-12-13 17:41 -0500
http://bitbucket.org/pypy/pypy/changeset/506329de8bc3/
Log: Made tests look nicer
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -724,34 +724,23 @@
def test_identity(self):
from numpypy import identity, array
- from numpypy import int32, float64
+ from numpypy import int32, float64, dtype
a = identity(0)
assert len(a) == 0
- assert repr(a.dtype) == "dtype('float64')"
+ assert a.dtype == dtype('float64')
assert a.shape == (0,0)
b = identity(1, dtype=int32)
assert len(b) == 1
assert b[0][0] == 1
assert b.shape == (1,1)
- assert repr(b.dtype) == "dtype('int32')"
+ assert b.dtype == dtype('int32')
c = identity(2)
assert c.shape == (2,2)
- assert c[0][0] == 1.0
- assert c[0][1] == 0.0
- assert c[1][0] == 0.0
- assert c[1][1] == 1.0
+ assert (c == [[1,0],[0,1]]).all()
d = identity(3, dtype='int32')
assert d.shape == (3,3)
- assert repr(d.dtype) == "dtype('int32')"
- assert d[0][0] == 1.0
- assert d[0][1] == 0.0
- assert d[0][2] == 0.0
- assert d[1][0] == 0.0
- assert d[1][1] == 1.0
- assert d[1][2] == 0.0
- assert d[2][0] == 0.0
- assert d[2][1] == 0.0
- assert d[2][2] == 1.0
+ assert d.dtype == dtype('int32')
+ assert (d == [[1,0,0],[0,1,0],[0,0,1]]).all()
def test_prod(self):
from numpypy import array
More information about the pypy-commit
mailing list