Skip to content

Commit

Permalink
Added some more tests just in case.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Jan 29, 2024
1 parent f1ba4f6 commit c3ce4f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
16 changes: 15 additions & 1 deletion tests/test_delayed_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_delayed_array_low_block_size_F_contiguous():
########################################################


def test_delayed_array_sparse():
def test_delayed_array_sparse_csc():
x = scipy.sparse.random(1000, 200, 0.1).tocsc()
y = da.wrap(x) * 10

Expand All @@ -127,3 +127,17 @@ def test_delayed_array_sparse():
assert isinstance(roundtrip, dm.ReloadedArray)
assert isinstance(roundtrip.seed.seed, filebackedarray.Hdf5CompressedSparseMatrixSeed)
assert (numpy.array(roundtrip) == x.toarray() * 10).all()


def test_delayed_array_sparse_csr():
x = scipy.sparse.random(1000, 200, 0.1).tocsr()
y = da.wrap(x) * 10

dir = os.path.join(mkdtemp(), "foobar")
dl.save_object(y, dir, compressed_sparse_matrix_buffer_size=8*10000)
roundtrip = dl.read_object(dir)
assert roundtrip.shape == y.shape
assert roundtrip.dtype == y.dtype
assert isinstance(roundtrip, dm.ReloadedArray)
assert isinstance(roundtrip.seed.seed, filebackedarray.Hdf5CompressedSparseMatrixSeed)
assert (numpy.array(roundtrip) == x.toarray() * 10).all()
12 changes: 6 additions & 6 deletions tests/test_optimize_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ def test_optimize_integer_storage_scipy():
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_integer_storage(y.tocsc())
opt = optim.optimize_integer_storage(y.tocsc(), buffer_size = 10)
assert opt.type == "i2"
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_integer_storage(y.tocsr())
opt = optim.optimize_integer_storage(y.tocsr(), buffer_size = 20)
assert opt.type == "i2"
assert opt.placeholder is None
assert opt.non_zero == 5
Expand Down Expand Up @@ -450,12 +450,12 @@ def test_optimize_float_storage_scipy():
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_float_storage(y.tocsc())
opt = optim.optimize_float_storage(y.tocsc(), buffer_size = 10)
assert opt.type == "i2"
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_float_storage(y.tocsr())
opt = optim.optimize_float_storage(y.tocsr(), buffer_size = 20)
assert opt.type == "i2"
assert opt.placeholder is None
assert opt.non_zero == 5
Expand Down Expand Up @@ -629,12 +629,12 @@ def test_optimize_boolean_storage_scipy():
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_boolean_storage(y.tocsc())
opt = optim.optimize_boolean_storage(y.tocsc(), buffer_size = 2)
assert opt.type == "i1"
assert opt.placeholder is None
assert opt.non_zero == 5

opt = optim.optimize_boolean_storage(y.tocsr())
opt = optim.optimize_boolean_storage(y.tocsr(), buffer_size = 5)
assert opt.type == "i1"
assert opt.placeholder is None
assert opt.non_zero == 5
Expand Down

0 comments on commit c3ce4f4

Please sign in to comment.