Skip to content

Commit

Permalink
Add test for reading/writing Pint quantities
Browse files Browse the repository at this point in the history
  • Loading branch information
mruffalo committed Apr 24, 2024
1 parent 7b51bfa commit 7a51205
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/anndata/tests/test_readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,3 +821,17 @@ def test_io_dtype(tmp_path, diskfmt, dtype):
curr = read(pth)

assert curr.X.dtype == dtype


def test_readwrite_units(read, write, name, tmp_path):
X_arr = np.array(X_list)
adata = ad.AnnData(
X=X_arr,
uns={"size": 100 * ad.units["um"]},
obsm={"X_spatial": X_arr * ad.units.mm},
)
write(tmp_path / name, adata)
ad_read = read(tmp_path / name)

assert adata.uns["spot_size"] == ad_read.uns["spot_size"]
assert (adata.obsm["X_spatial_units"] == ad_read.obsm["X_spatial_units"]).all()

0 comments on commit 7a51205

Please sign in to comment.