def test_set_zero(): s = BDOK((1, ), block_shape=(1, ), dtype=np.uint8) s[0] = 1 s[0] = 0 assert s[0] == 0 assert s.nnz == 0
def test_convert_from_numpy(): x = np.random.rand(2, 4, 4) s = BDOK(x, (2, 2, 2)) #x = np.array([[1,-1,0,0],[1,-1,0,0],[2,2,3,3],[2,2,3,3]]) #s = BDOK(x, (2, 2)) assert_eq(x, s)
def test_int_dtype(): data = { 1: np.uint8(1), 2: np.uint16(2), } s = BDOK((5, ), block_shape=(1, ), data=data) assert s.dtype == np.uint16
def test_default_dtype(): s = BDOK((5, ), block_shape=(1, )) assert s.dtype == np.float64
def test_convert_from_coo(): s1 = sparse.brandom((6, 6, 12), (2, 2, 3), 0.5, format='bcoo') s2 = BDOK(s1) assert_eq(s1, s2)