Commit e673e094 authored by payno's avatar payno

[dataset] Add documentation for unit test and updated since take file_pattern...

[dataset] Add documentation for unit test and updated since take file_pattern in parameter and rename `_data_files` by `_data_files_pattern`
parent 8e818d4c
......@@ -39,12 +39,17 @@ import os
class Dataset(object):
"""
Class used to define a dataset
:param str or None data_files_pattern: pattern to the data files
data_0000.edf for example
:param list or tuple or None dark_files: list of the dark files
:param list or tuple or None ff_files: list of the flat field files
"""
def __init__(self, data_files=None, dark_files=None, ff_files=None):
assert isinstance(data_files, (type(None), list, str, set))
assert isinstance(dark_files, (type(None), list, str, set))
assert isinstance(ff_files, (type(None), list, str, set))
self._data_files = [] if data_files is None else data_files
def __init__(self, data_files_pattern=None, dark_files=None, ff_files=None):
assert isinstance(data_files_pattern, (type(None), str, set))
assert isinstance(dark_files, (type(None), list, set))
assert isinstance(ff_files, (type(None), list, set))
self._data_files_pattern = data_files_pattern
"""data files"""
self._data = None
"""data"""
......@@ -52,7 +57,7 @@ class Dataset(object):
"""dark files"""
self._ff_files = [] if ff_files is None else ff_files
"""flat field files"""
self.__data_has_changed = data_files is not None
self.__data_has_changed = data_files_pattern is not None
"""Flag to avoid loading data from files every time"""
self.__dark_has_changed = dark_files is not None
"""Flag to avoid loading darks from files every time"""
......@@ -66,15 +71,11 @@ class Dataset(object):
@property
def data_files_pattern(self):
return self._data_files
return self._data_files_pattern
@data_files_pattern.setter
def data_files_pattern(self, data_files):
self._data_files = data_files
self.__data_has_changed = True
def addDataFile(self, data_file):
self._data_files.append(data_file)
self._data_files_pattern = data_files
self.__data_has_changed = True
@property
......@@ -108,7 +109,7 @@ class Dataset(object):
raise NotImplementedError('')
def is_valid(self):
return len(self._data_files) > 0 or self._data is not None
return len(self._data_files_pattern) > 0 or self._data is not None
def __eq__(self, other):
if isinstance(other, Dataset) is False:
......
......@@ -91,7 +91,7 @@ class TestExperiement(unittest.TestCase):
_dir = '/nobackup/linazimov/payno/dev/esrf/ID06/dataset/for_mapping'
files = []
[files.append(os.path.join(_dir, _file)) for _file in os.listdir(_dir)]
dataset = Dataset(data_files=files)
dataset = Dataset(data_files_pattern=files)
geometry = TwoThetaGeometry(
twotheta=0.03, # for now those are defined in degree but should
# be defined in radians
......
......@@ -86,7 +86,7 @@ class DatasetSelection(qt.QTabWidget):
:return: dataset defined on the GUI
:rtype: :class:`Dataset`
"""
return Dataset(data_files=self.getDataFilesPattern(),
return Dataset(data_files_pattern=self.getDataFilesPattern(),
dark_files=self.getDarkFiles(),
ff_files=self.getFlatFieldFiles())
......
......@@ -105,7 +105,8 @@ def createDataset(pattern, background, dx=0, dy=0, dz=0, nb_data_files=10,
data_file = os.path.join(_dir, 'data_file%04i.edf' % index)
image = fabio.edfimage.EdfImage(data=pattern+background)
image.write(data_file)
dataset.addDataFile(data_file)
if nb_data_files > 0:
dataset.data_files_pattern = os.path.join(_dir, 'data_file%04i.edf' % 0)
for index in range(nb_flat_field_files):
ff_file = os.path.join(_dir, 'flat_field_file%04i.edf' % index)
......
......@@ -109,7 +109,7 @@ class TestTrueData(OrangeWorflowTest):
dir_ff = "/users/payno/datasets/id06/strain_scan/bg_ff_5s_1x1/"
[ff_files.append(os.path.join(dir_data, _file)) for _file in os.listdir(dir_ff)]
return Dataset(data_files=data_files, ff_files=ff_files)
return Dataset(data_files_pattern=data_files, ff_files=ff_files)
def _moveToNextStep(self):
app.processEvents()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment