Exemplo n.º 1
0
 def test_ignoring_metadata_warning(self):
     filename = os.path.join(self.tempdir, 'image0005')
     save_image(filename, self.holo)
     warn_msg = "Metadata detected but ignored. Use hp.load to read it."
     with self.assertWarns(UserWarning) as cm:
         load_image(filename + '.tif')
     self.assertTrue(str(cm.warning) == warn_msg)
Exemplo n.º 2
0
 def test_auto_scaling(self):
     filename = os.path.join(self.tempdir, 'image0001.tif')
     save_image(filename, self.holo, depth='float')
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         l = load_image(filename,
                        name=self.holo.name,
                        spacing=get_spacing(self.holo))
     # skip checking full DataArray attrs because it is akward to keep
     # them through arithmetic. Ideally we would figure out a way to
     # preserve them and switch back to testing fully
     assert_allclose(l, (self.holo - self.holo.min()) /
                     (self.holo.max() - self.holo.min()))
Exemplo n.º 3
0
 def test_image_io(self):
     filename = os.path.join(self.tempdir, 'image0001.tif')
     save_image(filename, self.holo, scaling=None)
     l = self.load_image_with_metadata(filename)
     assert_obj_close(l, self.holo)
Exemplo n.º 4
0
 def test_load_func_from_save_image_func_with_scaling(self):
     filename = os.path.join(self.tempdir, 'image0006')
     save_image(filename, self.holo, scaling='auto')
     loaded = load(filename + '.tif')
     assert_obj_close(np.around(loaded), self.holo)
Exemplo n.º 5
0
 def test_load_func_from_save_image_func(self):
     filename = os.path.join(self.tempdir, 'image0006')
     save_image(filename, self.holo, scaling=None)
     loaded = load(filename + '.tif')
     assert_obj_close(loaded, self.holo)
Exemplo n.º 6
0
 def test_saving_16_bit(self):
     filename = os.path.join(self.tempdir, 'image0003')
     save_image(filename, self.holo, scaling=None, depth=16)
     l = self.load_image_with_metadata(filename + '.tif')
     assert_obj_close(l, self.holo)