Skip to content

Commit

Permalink
Store df input data since creating at runtime is not stable
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinchai committed Nov 7, 2024
1 parent 65926d1 commit 66d8fec
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Binary file added tests/data/df_input.zip
Binary file not shown.
20 changes: 13 additions & 7 deletions tests/data/generate_trusted_result.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import glob
import os
import tempfile
import zipfile

import test_df
import test_lsm
import zarr

import test_df
import test_lsm
from linc_convert.modalities.df import multi_slice
from linc_convert.modalities.lsm import mosaic

if __name__ == "__main__":
with tempfile.TemporaryDirectory() as tmp_dir:
test_lsm._write_test_data(tmp_dir)
output_zarr = os.path.join(tmp_dir, "output.zarr")
mosaic.convert(tmp_dir, output_zarr)
zarr.copy_all(zarr.open(output_zarr), zarr.open("data/lsm.zarr.zip", "w"))

with tempfile.TemporaryDirectory() as tmp_dir:
test_df._write_test_data(tmp_dir)
output_zarr = os.path.join(tmp_dir, "output.zarr")
files = glob.glob(os.path.join(tmp_dir, "*.jp2"))
with zipfile.ZipFile("data/df_input.zip", "w") as z:
for file in files:
z.write(file, os.path.basename(file))
multi_slice.convert(files, output_zarr)
zarr.copy_all(zarr.open(output_zarr), zarr.open("data/df.zarr.zip", "w"))

with tempfile.TemporaryDirectory() as tmp_dir:
test_lsm._write_test_data(tmp_dir)
output_zarr = os.path.join(tmp_dir, "output.zarr")
mosaic.convert(tmp_dir, output_zarr)
zarr.copy_all(zarr.open(output_zarr), zarr.open("data/lsm.zarr.zip", "w"))
2 changes: 0 additions & 2 deletions tests/helper.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
""" """

import numpy as np
import zarr

Expand Down
10 changes: 6 additions & 4 deletions tests/test_df.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@

import glob
import os
import zipfile

import glymur
import numpy as np
from helper import _cmp_zarr_archives

from helper import _cmp_zarr_archives
from linc_convert.modalities.df import multi_slice


def _write_test_data(directory: str) -> None:
for level in range(5):
image = np.zeros((1024, 768, 3), dtype=np.uint8) + level * 10
jp2 = glymur.Jp2k(f"{directory}/{level}.jp2", data=image)
glymur.Jp2k(f"{directory}/{level}.jp2", data=image, )


def test_df(tmp_path):
_write_test_data(tmp_path)
# _write_test_data(tmp_path)
with zipfile.ZipFile("data/df_input.zip", "r") as z:
z.extractall(tmp_path)
output_zarr = tmp_path / "output.zarr"
files = glob.glob(os.path.join(tmp_path, "*.jp2"))
multi_slice.convert(files, str(output_zarr))
Expand Down

0 comments on commit 66d8fec

Please sign in to comment.