Esempio n. 1
0
 def test_egine_mixing_nested_2(self):
     """Tests the behaviour of the combine function on a mixture of nested Zipables
     and Productables.
     """
     var1 = Z(2, 3)
     var2 = Z(2, 3)
     var3 = Z(P(10, 11), P(12, 13))
     var4 = P(20, 21)
     var5 = P(22, 23)
     expected = [(2, 2, 10, 20, 22),
                 (2, 2, 11, 20, 22),
                 (2, 2, 10, 20, 23),
                 (2, 2, 11, 20, 23),
                 (2, 2, 10, 21, 22),
                 (2, 2, 11, 21, 22),
                 (2, 2, 10, 21, 23),
                 (2, 2, 11, 21, 23),
                 (3, 3, 12, 20, 22),
                 (3, 3, 13, 20, 22),
                 (3, 3, 12, 20, 23),
                 (3, 3, 13, 20, 23),
                 (3, 3, 12, 21, 22),
                 (3, 3, 13, 21, 22),
                 (3, 3, 12, 21, 23),
                 (3, 3, 13, 21, 23)]
     self.assertEqual(list(combine(var1, var2, var3, var4, var5)),
                      expected)
Esempio n. 2
0
 def test_engine_zipable_zipable(self):
     """Tests the behaviour of the combine function on non nested Zipables.
     """
     var1 = Z(1, 2, 3)
     var2 = Z(4, 5, 6)
     var3 = Z(7, 8, 9)
     var4 = Z(10, 11, 12)
     self.assertEqual(list(combine(var1, var2, var3, var4)),
                      list(grouper(flatten(var1 + var2 + var3 + var4), 4)))
Esempio n. 3
0
 def test_engine_mixing(self):
     """Tests the behaviour of the combine function on a mixture of Zipables and
     Productables.
     """
     var1 = Z(1, 2)
     var2 = Z(3, 4)
     var3 = P(5, 6)
     res = [(1, 3, 5), (1, 3, 6), (2, 4, 5), (2, 4, 6)]
     self.assertEqual(list(combine(var1, var2, var3)), res)
Esempio n. 4
0
 def test_engine_nested_zipable_3(self):
     """Tests the behaviour of the combine function on 3 nested Zipables.
     """
     var1 = Z(Z(1, 2, 3), Z(4, 5, 6))
     var2 = Z(Z(7, 8, 9), Z(10, 11, 12))
     var3 = Z(Z(13, 14, 15), Z(16, 17, 18))
     res = zip([1, 2, 3, 4, 5, 6],
               [7, 8, 9, 10, 11, 12],
               [13, 14, 15, 16, 17, 18])
     self.assertEqual(list(combine(var1, var2, var3)), Z(*res))
Esempio n. 5
0
    def test_zipable_iterator(self):
        '''Behaviour when Zipable combines with tuple or list.
        '''
        var1 = Z(1, 2, 3)
        var2 = (4, 5)
        self.assertEqual(var1 + var2, Z((1, var2), (2, var2), (3, var2)))

        var1 = Z(1, 2, 3)
        var2 = [4, 5]
        self.assertEqual(var1 + var2,
                         P((1, 4), (1, 5), (2, 4), (2, 5), (3, 4), (3, 5)))
Esempio n. 6
0
 def test_engine_nested_zipable(self):
     """Tests the behaviour of the combine function on nested Zipables.
     """
     var1 = Z(Z(1, 2, 3), Z(4, 5, 6))
     var2 = Z(Z(7, 8, 9), Z(10, 11, 12))
     self.assertEqual(list(combine(var1, var2)),
                      Z(*zip([1, 2, 3, 4, 5, 6],
                             [7, 8, 9, 10, 11, 12])))
Esempio n. 7
0
 def test_engine_tuples_mixing(self):
     """Tests the behviour of the combine function with standard tuples
     alongside Zipables and Productables.
     """
     var1 = P(Z(1, 2), P(3, 4))
     var2 = P(Z(5, 6), P(7, 8))
     var3 = ('weirdo!', 5)
     res = [(1, 5, ('weirdo!', 5)),
            (2, 6, ('weirdo!', 5)),
            (1, 7, ('weirdo!', 5)),
            (1, 8, ('weirdo!', 5)),
            (2, 7, ('weirdo!', 5)),
            (2, 8, ('weirdo!', 5)),
            (3, 5, ('weirdo!', 5)),
            (3, 6, ('weirdo!', 5)),
            (4, 5, ('weirdo!', 5)),
            (4, 6, ('weirdo!', 5)),
            (3, 7, ('weirdo!', 5)),
            (3, 8, ('weirdo!', 5)),
            (4, 7, ('weirdo!', 5)),
            (4, 8, ('weirdo!', 5))]
     self.assertEqual(list(combine(var1, var2, var3)), res)
Esempio n. 8
0
 def test_egine_mixing_nested_3(self):
     """Tests the behaviour of the combine function on a mixture of nested Zipables
     and Productables.
     """
     var1 = Z(1, 2, 3)
     var2 = Z(1, 2, 3)
     var3 = P(10, 11, 12)
     var4 = P(13, 14, 15)
     expected = [(1, 1, 10, 13),
                 (1, 1, 10, 14),
                 (1, 1, 10, 15),
                 (1, 1, 11, 13),
                 (1, 1, 11, 14),
                 (1, 1, 11, 15),
                 (1, 1, 12, 13),
                 (1, 1, 12, 14),
                 (1, 1, 12, 15),
                 (2, 2, 10, 13),
                 (2, 2, 10, 14),
                 (2, 2, 10, 15),
                 (2, 2, 11, 13),
                 (2, 2, 11, 14),
                 (2, 2, 11, 15),
                 (2, 2, 12, 13),
                 (2, 2, 12, 14),
                 (2, 2, 12, 15),
                 (3, 3, 10, 13),
                 (3, 3, 10, 14),
                 (3, 3, 10, 15),
                 (3, 3, 11, 13),
                 (3, 3, 11, 14),
                 (3, 3, 11, 15),
                 (3, 3, 12, 13),
                 (3, 3, 12, 14),
                 (3, 3, 12, 15)]
     self.assertEqual(list(combine(var1, var2, var3, var4)),
                      expected)
Esempio n. 9
0
    def test_zipable_standard(self):
        '''Behaviour when Zipable combines with standard types.
        '''
        var1 = Z(1, 2, 3)
        var2 = 1
        self.assertEqual(var1 + var2, Z((1, var2), (2, var2), (3, var2)))

        var1 = Z(1, 2, 3)
        var2 = 1.1
        self.assertEqual(var1 + var2, Z((1, var2), (2, var2), (3, var2)))

        var1 = Z(1, 2, 3)
        var2 = 'aa'
        self.assertEqual(var1 + var2, Z((1, var2), (2, var2), (3, var2)))
Esempio n. 10
0
 def test_mixing(self):
     '''Behaviour when combining Productable and Zipable.
     '''
     var1 = Z(1, 2, 3)
     var2 = P(4, 5, 6)
     self.assertEqual(var1 + var2, P(*var1) + var2)
Esempio n. 11
0
 def test_zipable_zipable(self):
     '''Behaviour when Zipable conbines another Zipable.
     '''
     var1 = Z(1, 2, 3)
     var2 = Z(4, 5, 6)
     self.assertEqual(var1 + var2, Z(*zip(var1, var2)))
Esempio n. 12
0
 def test_check_for_params(self):
     """Tests the nested param check helper."""
     inp = ((((Z(1), 0), P(1)), 0), 0)
     self.assertEqual(sum(check_for_params(inp)), 2)
Esempio n. 13
0
 def test_flatten(self):
     """Tests the behaviour of helper flatten."""
     var1 = P(Z(1, 2, 3), Z(4, 5, 6))
     var2 = P(Z(7, 8, 9), Z(10, 11, 12))
     expanded = list(expand((var1 + var2)[0]))
     self.assertEqual(list(flatten(expanded)), [1, 7, 2, 8, 3, 9])
Esempio n. 14
0
 def test_expand(self):
     """Tests the behaviour of helper expand."""
     var1 = P(Z(1, 2, 3), Z(4, 5, 6))
     var2 = P(Z(7, 8, 9), Z(10, 11, 12))
     expanded = list(expand((var1 + var2)[0]))
     self.assertEqual(expanded, [Z((1, 7), (2, 8), (3, 9))])
Esempio n. 15
0
 def test_engine_mixing_nested(self):
     """Tests the behaviour of the combine function on a mixture of nested Zipables
     and Productables.
     """
     var1 = P(Z(1, 2), P(3, 4))
     var2 = P(Z(5, 6), P(7, 8))
     var3 = P(P(9, 10), P(11, 12))
     res = [(1, 5, 9),
            (1, 5, 10),
            (2, 6, 9),
            (2, 6, 10),
            (1, 5, 11),
            (1, 5, 12),
            (2, 6, 11),
            (2, 6, 12),
            (1, 7, 9),
            (1, 7, 10),
            (1, 8, 9),
            (1, 8, 10),
            (2, 7, 9),
            (2, 7, 10),
            (2, 8, 9),
            (2, 8, 10),
            (1, 7, 11),
            (1, 7, 12),
            (1, 8, 11),
            (1, 8, 12),
            (2, 7, 11),
            (2, 7, 12),
            (2, 8, 11),
            (2, 8, 12),
            (3, 5, 9),
            (3, 5, 10),
            (3, 6, 9),
            (3, 6, 10),
            (4, 5, 9),
            (4, 5, 10),
            (4, 6, 9),
            (4, 6, 10),
            (3, 5, 11),
            (3, 5, 12),
            (3, 6, 11),
            (3, 6, 12),
            (4, 5, 11),
            (4, 5, 12),
            (4, 6, 11),
            (4, 6, 12),
            (3, 7, 9),
            (3, 7, 10),
            (3, 8, 9),
            (3, 8, 10),
            (4, 7, 9),
            (4, 7, 10),
            (4, 8, 9),
            (4, 8, 10),
            (3, 7, 11),
            (3, 7, 12),
            (3, 8, 11),
            (3, 8, 12),
            (4, 7, 11),
            (4, 7, 12),
            (4, 8, 11),
            (4, 8, 12)]
     self.assertEqual(list(combine(var1, var2, var3)), res)