Skip to content

Commit

Permalink
add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
leoschwarz committed Oct 23, 2024
1 parent 0e553b1 commit 46d7198
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/integration/imzml_parser/test_ome_tiff_roundtrip.py
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)

0 comments on commit 46d7198

Please sign in to comment.