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

simple filters...

parent 1c40396f
......@@ -117,10 +117,14 @@ for t in tests:
assert(sd.ndim == dd.ndim)
assert(np.array_equal(sd.load(), dd))
# test put method
# test put method & simple filters
stream = Stream('test')
outlet = stream.filter()
def test(data):
assert(np.array_equal(data, data_a[0]))
stream0 = Stream('test')
stream1 = stream0.filter(process_frame = lambda data: data)
stream2 = stream1.filter(process_frame = test)
stream.put(data_a[0])
......
......@@ -223,19 +223,22 @@ def stream_filter(name):
################################################################################
# Stream Filters
### Filter general class ###
### Filter general class & simple filter ###
@stream_filter('filter')
class StreamFilter(Stream):
def __init__(self, name, parent):
def __init__(self, name, parent, process_frame=None):
self.__process_frame = process_frame
super().__init__(name=name, parent=parent)
pass
def process(self, data, indices):
assert isinstance(indices, list)
return np.stack([self.process_frame(data[i], i, indices[i]) for i in range(data.shape[0])])
def process_frame(self, data, data_index, stream_index):
return data
if self.__process_frame is not None:
return self.__process_frame(data)
else:
return data
# load one or several frames
def load(self, index=None):
......
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