Skip to content

Commit

Permalink
refactor group to series
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 19, 2017
1 parent 8bb88e6 commit dceb568
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
24 changes: 12 additions & 12 deletions qpformat/file_formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
import os.path as op

from .dataset import DataSet
# from .group_hdf5_qpimage import GroupHdf5Qpimage
from .group_zip_tif_phasics import GroupZipTifPhasics
from .single_hdf5_qimage import SingleHdf5Qpimage
# from .series_hdf5_qpimage import SeriesHdf5Qpimage
from .series_zip_tif_phasics import SeriesZipTifPhasics
from .single_hdf5_qpimage import SingleHdf5Qpimage
from .single_tif_phasics import SingleTifPhasics


class GroupFolder(DataSet):
class SeriesFolder(DataSet):
def __init__(self, *args, **kwargs):
super(GroupFolder, self).__init__(*args, **kwargs)
super(SeriesFolder, self).__init__(*args, **kwargs)
self._files = None
self._formats = None
self._dataset = None
Expand All @@ -32,7 +32,7 @@ def _search_files(path):
theformats = [ff[1] for ff in fifo]
formset = set(theformats)
if len(formset) > 1:
fmts_qpimage = ["SingleHdf5Qpimage", "GroupHdf5Qpimage"]
fmts_qpimage = ["SingleHdf5Qpimage", "SeriesHdf5Qpimage"]
fifo = [ff for ff in fifo if ff[1] not in fmts_qpimage]
# sort the lists
fifo = sorted(fifo)
Expand All @@ -49,14 +49,14 @@ def _get_dataset(self, idx):
# TODO:
# - add enumeration within files
# - required for `self.get_*` functions
msg = "Multiple qpimages per GroupFolder file not supported yet!"
msg = "Multiple qpimages per SeriesFolder file not supported yet!"
raise NotImplementedError(msg)
return self._dataset[idx]

@property
def files(self):
if self._files is None:
fifo = GroupFolder._search_files(self.path)
fifo = SeriesFolder._search_files(self.path)
self._files = [ff[0] for ff in fifo]
self._formats = [ff[1] for ff in fifo]
return self._files
Expand All @@ -77,7 +77,7 @@ def verify(path):
The folder file format is only valid when
- there is only one file format present
"""
fifo = GroupFolder._search_files(path)
fifo = SeriesFolder._search_files(path)
fifmts = [ff[1] for ff in fifo]
return len(set(fifmts)) == 1

Expand All @@ -87,9 +87,9 @@ class UnknownFileFormatError(BaseException):


# the order is important for
formats = [GroupFolder,
GroupZipTifPhasics,
# GroupHdf5Qpimage,
formats = [SeriesFolder,
SeriesZipTifPhasics,
# SeriesHdf5Qpimage,
SingleHdf5Qpimage,
SingleTifPhasics,
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dataset import DataSet


class GroupHdf5Qpimage(DataSet):
class SeriesHdf5Qpimage(DataSet):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from .single_tif_phasics import SingleTifPhasics


class GroupZipTifPhasics(DataSet):
class SeriesZipTifPhasics(DataSet):
def __init__(self, *args, **kwargs):
super(GroupZipTifPhasics, self).__init__(*args, **kwargs)
super(SeriesZipTifPhasics, self).__init__(*args, **kwargs)
self._files = None
self._dataset = None

Expand Down Expand Up @@ -47,7 +47,7 @@ def _index_files(path):
@property
def files(self):
if self._files is None:
self._files = GroupZipTifPhasics._index_files(self.path)
self._files = SeriesZipTifPhasics._index_files(self.path)
return self._files

def get_qpimage_raw(self, idx=0):
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_group_folder.py → tests/test_series_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_load_data():
assert ds.get_time(0) == 0
# format should be right
assert ds.verify(ds.path)
assert ds.__class__.__name__ == "GroupFolder"
assert ds.__class__.__name__ == "SeriesFolder"
shutil.rmtree(path, ignore_errors=True)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
The test file "group_phasics.zip" was created from an original
The test file "series_phasics.zip" was created from an original
Phasics zip file. The "ConfigStack.txt" was adapted to reflect
only three measured images. All data files that are not relevant
for qpformat are included as empty files to reflect the original
Expand All @@ -17,14 +17,14 @@


def test_load_data():
path = join(dirname(abspath(__file__)), "data/group_phasics.zip")
path = join(dirname(abspath(__file__)), "data/series_phasics.zip")
ds = qpformat.load_data(path)
assert ds.path == path
assert "GroupZipTifPhasics" in ds.__repr__()
assert "SeriesZipTifPhasics" in ds.__repr__()


def test_data_content():
path = join(dirname(abspath(__file__)), "data/group_phasics.zip")
path = join(dirname(abspath(__file__)), "data/series_phasics.zip")
ds = qpformat.load_data(path)
assert len(ds) == 3
assert ds.get_time(0) == 1461949418.29027
Expand Down

0 comments on commit dceb568

Please sign in to comment.