def test_vector_validation(self): feature_type = Vector([Number(), Label(['a', 'b'])]) for a in ((1, 'a'), (3, 'b'), (17, 'a')): with self.subTest(a=a): self.assertEqual(feature_type.validate(a), a) for a in ((1, ), (1, 'a', 2), ('a', 1), (1, 1)): with self.subTest(a=a), \ self.assertRaises((TypeError, ValueError)): feature_type.validate(a)
def test_number_validation(self): feature_type = Number() for n in (0, 1, 3.141592, -17): with self.subTest(n=n): self.assertEqual(feature_type.validate(n), n) for a, b in (("1", 1), ): with self.subTest(a=a): self.assertEqual(feature_type.validate(a), b) for n in (1j, float("nan"), float("inf"), -float("inf"), "a"): with self.subTest(n=n), \ self.assertRaises((TypeError, ValueError)): feature_type.validate(n)
class Input: a = Number()
class Output: b = Vector([ Number(), Vector([Number(), Label(['a', 'b'])]), Number() ])
class Input: sepal_length_cm = Number() sepal_width_cm = Number() petal_length_cm = Number() petal_width_cm = Number()
class Output: output = Number()
class Input: input_ = Number()
class Output: b = Tag() c = Number()
class Output: c = Number() d = Number() e = Label(['a', 'b']) f = Complex() g = Number()
class Output: c = Number()
class Input: a = Number() b = Tag()
class Output: b = Number()
class Output: number_a = Number() number_b = Number()
class Input: number = Number() label = Label(['a', 'b', 'c'])