class Pooled(Node): def __init__(self, op=None, axis=None, needs=None): super(Pooled, self).__init__(needs=needs) self._timeslices = VariableRateTimeSeries(()) self._timeseries = None self._op = op self._axis = axis def _enqueue(self, data, pusher): if isinstance(data, ArrayWithUnits): try: self._timeseries = self._timeseries.concatenate(data) except AttributeError: self._timeseries = data else: self._timeslices = self._timeslices.concat(data) def _dequeue(self): if not self._finalized: raise NotEnoughData() return self._timeslices, self._timeseries def _process(self, data): slices, series = data slices = slices.slices examples = [(ts, self._op(series[ts], axis=self._axis)) for ts in slices] yield VariableRateTimeSeries(examples)
def _process(self, data): td = data.dimensions[0] frequency = td.frequency indices = self._onset_indices(data) timestamps = self._pos + (indices * frequency) self._pos += len(data) * frequency timestamps = [self._leftover_timestamp] + list(timestamps) self._leftover_timestamp = timestamps[-1] time_slices = TimeSlice.slices(timestamps) vrts = VariableRateTimeSeries([(ts, np.zeros(0)) for ts in time_slices]) yield vrts
def _last_chunk(self): yield VariableRateTimeSeries( ((TimeSlice(start=self._leftover_timestamp, duration=self._pos - self._leftover_timestamp), np.zeros(0)), ))
def _process(self, data): slices, series = data slices = slices.slices examples = [(ts, self._op(series[ts], axis=self._axis)) for ts in slices] yield VariableRateTimeSeries(examples)
def __init__(self, op=None, axis=None, needs=None): super(Pooled, self).__init__(needs=needs) self._timeslices = VariableRateTimeSeries(()) self._timeseries = None self._op = op self._axis = axis