def test_kron_large(self): n = 2**16 a = construct.eye(1, n, n - 1) b = construct.eye(n, 1, 1 - n) construct.kron(a, a) construct.kron(b, b)
def test_eye_one(self): assert_equal(construct.eye(1).toarray(), [[1]]) assert_equal(construct.eye(2).toarray(), [[1, 0], [0, 1]]) I = construct.eye(3, dtype='int8', format='dia') assert_equal(I.dtype, np.dtype('int8')) assert_equal(I.format, 'dia') for fmt in sparse_formats: I = construct.eye(3, format=fmt) assert_equal(I.format, fmt) assert_equal(I.toarray(), [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
def test_eye(self): assert_equal(construct.eye(1, 1).toarray(), [[1]]) assert_equal(construct.eye(2, 3).toarray(), [[1, 0, 0], [0, 1, 0]]) assert_equal(construct.eye(3, 2).toarray(), [[1, 0], [0, 1], [0, 0]]) assert_equal( construct.eye(3, 3).toarray(), [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) assert_equal( construct.eye(3, 3, dtype='int16').dtype, np.dtype('int16')) for m in [3, 5]: for n in [3, 5]: for k in range(-5, 6): assert_equal( construct.eye(m, n, k=k).toarray(), np.eye(m, n, k=k)) if m == n: assert_equal( construct.eye(m, k=k).toarray(), np.eye(m, n, k=k))