Esempio n. 1
0
 def check_simple_skew_symmetric_float(self):
     a = array([[1,2],[-2.0,4]],'f')
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','real','skew-symmetric'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 2
0
 def check_simple_hermitian(self):
     a = [[1,2+3j],[2-3j,4]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','complex','hermitian'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 3
0
 def check_simple_skew_symmetric(self):
     a = [[1,2],[-2,4]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','integer','skew-symmetric'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 4
0
 def check_simple_complex(self):
     a = [[1,2],[3,4j]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,2,4,'array','complex','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 5
0
 def check_simple_rectangular_real(self):
     a = [[1,2],[3.5,4],[5,6]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(3,2,6,'array','real','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 6
0
 def check_simple_rectangular(self):
     a = [[1,2,3],[4,5,6]]
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(2,3,6,'array','integer','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 7
0
 def check_random_rect_real(self):
     sz = (20,15)
     a = rand(*sz)
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(20,15,300,'array','real','general'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 8
0
 def check_random_symmetric_real(self):
     sz = (20,20)
     a = rand(*sz)
     a = a + transpose(a)
     fn = mktemp()
     mmwrite(fn,a)
     assert_equal(mminfo(fn),(20,20,400,'array','real','symmetric'))
     b = mmread(fn)
     assert_array_almost_equal(a,b)
Esempio n. 9
0
    def check_simple_write_read(self):
        I = array([0, 0, 1, 2, 3, 3, 3, 4])
        J = array([0, 3, 1, 2, 1, 3, 4, 4])
        V = array([  1.0,   6.0,   10.5, 0.015,   250.5,  -280.0, 33.32, 12.0 ])
        
        b = scipy.sparse.coo_matrix((V,(I,J)),dims=(5,5))

        fn = mktemp()
        mmwrite(fn,b)
        
        assert_equal(mminfo(fn),(5,5,8,'coordinate','real','general'))
        a = [[1,    0,      0,       6,      0],
             [0,   10.5,    0,       0,      0],
             [0,    0,    .015,      0,      0],
             [0,  250.5,    0,     -280,    33.32],
             [0,    0,      0,       0,     12]]
        b = mmread(fn).todense()
        assert_array_almost_equal(a,b)