예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 class Input:
     a = Number()
예제 #4
0
 class Output:
     b = Vector([
         Number(),
         Vector([Number(), Label(['a', 'b'])]),
         Number()
     ])
예제 #5
0
 class Input:
     sepal_length_cm = Number()
     sepal_width_cm = Number()
     petal_length_cm = Number()
     petal_width_cm = Number()
예제 #6
0
 class Output:
     output = Number()
예제 #7
0
 class Input:
     input_ = Number()
예제 #8
0
 class Output:
     b = Tag()
     c = Number()
예제 #9
0
 class Output:
     c = Number()
     d = Number()
     e = Label(['a', 'b'])
     f = Complex()
     g = Number()
예제 #10
0
 class Output:
     c = Number()
예제 #11
0
 class Input:
     a = Number()
     b = Tag()
예제 #12
0
 class Output:
     b = Number()
예제 #13
0
 class Output:
     number_a = Number()
     number_b = Number()
예제 #14
0
 class Input:
     number = Number()
     label = Label(['a', 'b', 'c'])