def execute(self, batch: FrameBatch): predictions = batch.get_outcomes_for(self.predicate.name) required_frame_ids = [] for i, prediction in enumerate(predictions): if self.predicate(prediction): required_frame_ids.append(i) return batch[required_frame_ids]
def test_get_outcome_from_non_existing_udf_name_returns_empty_list(self): batch = FrameBatch(frames=[Frame(1, np.ones((1, 1)), None)], info=None) self.assertEqual([], batch.get_outcomes_for('test'))
def test_set_outcomes_method_should_set_the_predictions_with_udf_name( self): batch = FrameBatch(frames=[Frame(1, np.ones((1, 1)), None)], info=None) batch.set_outcomes('test', [None]) self.assertEqual([None], batch.get_outcomes_for('test'))