def test_passed_tuple_as_tag(self): with self.assertRaisesRegexp( TypeError, r'Attempting to create a TaggedOutput with non-string tag \(1, 2, 3\)'): TaggedOutput((1, 2, 3), 'value')
def process(self, element, train_size, val_label): """Randomly assigns element to training or validation set.""" if random.random() > train_size: yield TaggedOutput(val_label, element) else: yield element
def mux_input(x): if isinstance(x, int): yield TaggedOutput('numbers', x) else: yield TaggedOutput('letters', x)
def process(self, element): e = json.loads(element) yield TaggedOutput(e.pop('_Dest'), e)