Pre-processing decorator that adapt frames to match input_blocksize
and input_stepsize of the decorated analyzer
>>> from timeside.analyzer.preprocessors import frames_adapter
>>> @frames_adapter
... def process(analyzer,frames,eod):
... analyzer.frames.append(frames)
... return frames, eod
...
>>> class Fake_Analyzer(object):
... def __init__(self):
... self.input_blocksize = 4
... self.input_stepsize = 3
... self.frames = []
>>> import numpy as np
>>> analyzer = Fake_Analyzer()
>>> frames = np.asarray(range(0,12))
>>> eod = False
>>> frames_, eod_ = process(analyzer,frames,eod)
Inside the process the frames have been adapted to match
input_blocksize and input_stepsize
>>> analyzer.frames
[array([0, 1, 2, 3]), array([3, 4, 5, 6]), array([6, 7, 8, 9])]
Outside the process, the original frames and eod are preserved:
>>> frames_
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
>>> eod_
False
Releasing the process with eod=True will zeropad the last frame if
necessary
>>> frames = np.asarray(range(12,14))
>>> eod = True
>>> frames_, eod_ = process(analyzer,frames,eod)
>>> analyzer.frames
[array([0, 1, 2, 3]), array([3, 4, 5, 6]), array([6, 7, 8, 9]), array([ 9, 10, 11, 12]), array([12, 13, 0, 0])]
|