Commit e574baeb authored by David GEISSBUHLER's avatar David GEISSBUHLER
Browse files

cleaning

parent 7c46f511
......@@ -91,6 +91,12 @@ assert(stream_sl.shape == data_sl.shape)
assert(stream_sl.ndim == data_sl.ndim)
assert(np.array_equal(stream_sl.load(), data_sl))
stream_sl = stream_a[:,:,1:2:3,4:5:6]
data_sl = data_a[:,:,1:2:3,4:5:6]
assert(stream_sl.shape == data_sl.shape)
assert(stream_sl.ndim == data_sl.ndim)
assert(np.array_equal(stream_sl.load(), data_sl))
###########
#fo = StreamFile('api_test.h5', 'w')
......
......@@ -20,13 +20,14 @@ class Stream:
self.parent = parent
self.reset()
# reset stream
def reset(self):
self.__loaded = None
self.__data = None
self.__bounding_box = StreamArray(self)
self.__image_points = StreamArray(self)
# source
# source property
@property
def source(self):
if isinstance(self.parent, StreamFile) or self.parent is None:
......@@ -34,6 +35,11 @@ class Stream:
else:
return self.parent.source
@source.setter
def source(self, src):
self.set_source(src)
# set source recursively
def set_source(self, src):
if isinstance(self.parent, StreamFile) or self.parent is None:
self.parent = src
......@@ -138,25 +144,11 @@ class Stream:
else:
raise Exception("index can only be int, slice or tuple")
# case 2 & 3: return stream_view
print('__getitem__', view_indices)
return self.view(view_indices=view_indices)
def __setitem__(self, index, data):
raise Exception("not yet implemented")
# load one or several frames
def load(self, index=None):
indices = self.get_frame_indices(index)
# return buffered data OR load from file OR process data
if self.__loaded == indices and self.__data is not None:
# print('loaded', self.name)
pass
else:
self.__data = self.parent.load_stream_data(self.name, indices)
# buffer and return data
self.__loaded = indices
return self.__data
# get list of frame indices
def get_frame_indices(self, index):
# None index is equivalent to [:] i.e. slice(None, None, None)
......@@ -203,6 +195,19 @@ class Stream:
raise Exception("index can only be None, int, slice or list")
return indices
# load one or several frames
def load(self, index=None):
indices = self.get_frame_indices(index)
# return buffered data OR load from file OR process data
if self.__loaded == indices and self.__data is not None:
# print('loaded', self.name)
pass
else:
self.__data = self.parent.load_stream_data(self.name, indices)
# buffer and return data
self.__loaded = indices
return self.__data
# get size of a given (sliced) axis
def get_axis_size(self, axis, _slice=None):
if _slice is None:
......@@ -385,7 +390,6 @@ class StreamView(StreamFilter):
# should be int or slice
__bulk_view_full[d] = self.bulk_view[d]
self.__bulk_view_full = tuple(__bulk_view_full)
print('self.__bulk_view_full', self.__bulk_view_full)
return super().process(data, indices)
def process_frame(self, data, data_index, stream_index):
......
Supports Markdown
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