def test_shape(self): # tests taken from numpy/core/fromnumeric.py docstring from numpypy import identity, shape assert shape(identity(3)) == (3, 3) assert shape([[1, 2]]) == (1, 2) assert shape([0]) == (1,) assert shape(0) == ()
def test_shape(self): # tests taken from numpy/core/fromnumeric.py docstring from numpypy import array, identity, shape assert shape(identity(3)) == (3, 3) assert shape([[1, 2]]) == (1, 2) assert shape([0]) == (1,) assert shape(0) == ()
def test_identity(self): from numpypy import array, int32, float64, dtype, identity a = identity(0) assert len(a) == 0 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 b.dtype == dtype('int32') c = identity(2) assert c.shape == (2, 2) assert (c == [[1, 0], [0, 1]]).all() d = identity(3, dtype='int32') assert d.shape == (3, 3) assert d.dtype == dtype('int32') assert (d == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]).all()