Exemplo n.º 1
0
def test_load_matrix_flexible(tmpdir):
    tiff_file = str(tmpdir.join("test.tiff"))
    tif_file = str(tmpdir.join("test.tif"))
    npy_file = str(tmpdir.join("test.npy"))
    txt_file = str(tmpdir.join("test.txt"))
    matrix = np.zeros([3, 3])
    mod.write_tiff(tiff_file, matrix)
    mod.write_tiff(tif_file, matrix)
    np.save(npy_file, matrix)
    np.savetxt(txt_file, matrix)
    for f in [tiff_file, tif_file, npy_file, txt_file]:
        matrix1 = mod.load_matrix_flexible(f)
        assert np.array_equal(matrix1, matrix)
Exemplo n.º 2
0
def test_load_matrix_flexible_error():
    with pytest.raises(ValueError):
        mod.load_matrix_flexible("test.jpg")
Exemplo n.º 3
0
 def user_mask(self):
     mask_file = self.get("ANALYSIS", "user_mask", fallback="")
     if not mask_file:
         return None
     return io.load_matrix_flexible(mask_file)
Exemplo n.º 4
0
 def user_mask(self) -> tp.Union[None, np.ndarray]:
     """The mask given by the user. Default None."""
     mask_file = self._section.get(self._mask_file, fallback=None)
     if mask_file:
         return io.load_matrix_flexible(mask_file)
     return None