-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e553b1
commit 46d7198
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import numpy as np | ||
import pytest | ||
import xarray | ||
from xarray import DataArray | ||
|
||
from depiction.persistence.format_ome_tiff import OmeTiff | ||
from depiction.persistence.pixel_size import PixelSize | ||
|
||
|
||
@pytest.fixture | ||
def sample_data() -> DataArray: | ||
sizes = (2, 3, 4) | ||
return DataArray( | ||
np.arange(np.prod(sizes), dtype=float).reshape(sizes), | ||
dims=["c", "y", "x"], | ||
attrs={"pixel_size": PixelSize(10.0, 20.0, "micrometer")}, | ||
coords={"c": ["a", "b"]}, | ||
) | ||
|
||
|
||
def test_round_trip(sample_data, tmp_path): | ||
out_path = tmp_path / "test.ome.tiff" | ||
|
||
# write the file | ||
OmeTiff.write(sample_data, out_path) | ||
assert out_path.stat().st_size > 0 | ||
|
||
# read the file | ||
read_data = OmeTiff.read(out_path) | ||
|
||
# check the data | ||
xarray.testing.assert_identical(read_data, sample_data) |