def create(): dt235 = datetime.utcfromtimestamp(235) dt255 = datetime.utcfromtimestamp(255) return xs.pipe( ops.take_until_with_time(dt255), ops.take_until_with_time(dt235), )
def recursive_predict(self): if self.is_prediction_mode: self.processor.add_data_batch(self.data_to_predict) # X = self.processor.pca(self.processor.processed_data.reshape(1, -1)) self.trainer.predict(self.data_to_predict) self.connector.data.pipe(take_until_with_time(1)).subscribe( observer=self.loop_data, on_error=print, on_completed=self.recursive_predict)
def record(self, path='./processor_data', recording_length=10): if not self.is_recording: self._save_path = os.path.realpath(path) self.recorded_data = [] self.is_recording = True self.data.pipe(take_until_with_time(recording_length)).subscribe( observer=lambda values: self.recorded_data.append(values), on_error=lambda e: print(e), on_completed=self._save) else: print('Already recording...')
def __init__(self, poll: PollModel): """ Initializes the class. If there is no duration for the poll or is inactive, it only will initialize with the poll attribute Attributes: poll(PollModel): Object with the poll """ # TODO check if is active self.poll = poll if self.poll.duration == -1: return # Use for avoid waiting to edit message # https://stackoverflow.com/questions/53722398/how-to-send-a-message-with-discord-py-from-outside-the-event-loop-i-e-from-pyt self._loop = asyncio.get_event_loop() self.sub = rx.interval(REFRESH_RATE).pipe( # Seconds that the poll will last op.take_until_with_time(self.poll.duration)) self.subscribe()
def create(): dt = datetime.utcfromtimestamp(250) return xs.pipe(ops.take_until_with_time(dt))
def create(): return xs.pipe(ops.take_until_with_time(datetime.utcfromtimestamp(0)))