Skip to content

Commit

Permalink
fch5: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristosT committed Nov 12, 2024
1 parent ab11ca4 commit a4968ce
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions tests/imageseries/test_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def setUp(self):
self.fcfile = os.path.join(self.tmpdir, 'frame-cache.npz')
self.fmt = 'frame-cache'
self.thresh = 0.5
self.style = 'npz'
self.cache_file='frame-cache.npz'
_, self.is_a = make_array_ims()

Expand All @@ -93,9 +94,9 @@ def tearDown(self):

def test_fmtfc(self):
"""save/load frame-cache format"""
imageseries.write(self.is_a, self.fcfile, self.fmt,
imageseries.write(self.is_a, self.fcfile, self.fmt, style=self.style,
threshold=self.thresh, cache_file=self.cache_file)
is_fc = imageseries.open(self.fcfile, self.fmt)
is_fc = imageseries.open(self.fcfile, self.fmt, style=self.style)
diff = compare(self.is_a, is_fc)
self.assertAlmostEqual(diff, 0., "frame-cache reconstruction failed")
self.assertTrue(compare_meta(self.is_a, is_fc))
Expand All @@ -104,9 +105,9 @@ def test_fmtfc_nocache_file(self):
"""save/load frame-cache format with no cache_file arg"""
imageseries.write(
self.is_a, self.fcfile, self.fmt,
threshold=self.thresh
threshold=self.thresh, style=self.style
)
is_fc = imageseries.open(self.fcfile, self.fmt)
is_fc = imageseries.open(self.fcfile, self.fmt, style=self.style)
diff = compare(self.is_a, is_fc)
self.assertAlmostEqual(diff, 0., "frame-cache reconstruction failed")
self.assertTrue(compare_meta(self.is_a, is_fc))
Expand All @@ -117,11 +118,22 @@ def test_fmtfc_nparray(self):
npa = np.array([0,2.0,1.3])
self.is_a.metadata[key] = npa

imageseries.write(self.is_a, self.fcfile, self.fmt,
imageseries.write(self.is_a, self.fcfile, self.fmt, style=self.style,
threshold=self.thresh, cache_file=self.cache_file
)
is_fc = imageseries.open(self.fcfile, self.fmt)
is_fc = imageseries.open(self.fcfile, self.fmt, style=self.style)
meta = is_fc.metadata
diff = np.linalg.norm(meta[key] - npa)
self.assertAlmostEqual(diff, 0.,
"frame-cache numpy array metadata failed")


class TestFormatFrameCache_FCH5(TestFormatFrameCache):

def setUp(self):
self.fcfile = os.path.join(self.tmpdir, 'frame-cache.fch5')
self.fmt = 'frame-cache'
self.style = 'fch5'
self.thresh = 0.5
self.cache_file = 'frame-cache.fch5'
_, self.is_a = make_array_ims()

0 comments on commit a4968ce

Please sign in to comment.