def test_tobsr(): data = np.arange(1, 7).repeat(4).reshape((-1, 2, 2)) coords = np.array([[0, 0, 0, 2, 1, 2], [0, 1, 1, 0, 2, 2]]) block_shape = (2, 2) shape = (8, 6) print coords print data #x = BCOO(coords, data=data, shape=shape, block_shape=block_shape, sorted = True, has_duplicates = False) x = BCOO(coords, data=data, shape=shape, block_shape=block_shape, sorted=True, has_duplicates=False) y = x.todense() #print y #print x.coords z = x.tobsr() #print z.data #print z.has_canonical_format #print z.has_sorted_indices x2 = BCOO(coords.copy(), data=data.copy(), shape=shape, block_shape=block_shape, sorted=False, has_duplicates=True) y2 = x2.todense() print y print y2 print x.coords print x2.coords #print y #print x.coords z2 = x2.tobsr() #print z2.data print z.has_canonical_format print z.has_sorted_indices print z2.has_canonical_format print z2.has_sorted_indices #print "z" print z.toarray() #print "z2" print z2.toarray() #assert_eq(z,z2) exit() assert_eq(z, y)
def test_tobsr(): data = np.arange(1, 7).repeat(4).reshape((-1, 2, 2)) coords = np.array([[0, 0, 0, 2, 1, 2], [0, 1, 1, 0, 2, 2]]) block_shape = (2, 2) shape = (8, 6) x = BCOO(coords, data=data, shape=shape, block_shape=block_shape) y = x.todense() z = x.tobsr() assert_eq(z, y)