def test_BR3_g3_h1_1(self):
        g3_h1_1a = [(['c_{3}', 'c_{7}'], ['v_{1}', 'v_{3}'], ['m_{4}']),
                    (['c_{3}', 'c_{7}'], ['c_{3}'], ['v_{1}', 'v_{3}']),
                    (['c_{3}', 'c_{7}'], ['m_{4}'], ['v_{1}', 'v_{2}']),
                    (['c_{3}', 'c_{7}'], ['v_{2}', 'v_{3}'], ['c_{3}'])]

        anti_g3_h1_1a = chain_integrate(g3_h1_1a, self.BR_C)

        self.assertIsNotNone(anti_g3_h1_1a)

        d_anti_g3_h1_1a = [dX for dXs in derivative(anti_g3_h1_1a, self.BR_C) for dX in expand_tuple_list(dXs)]
        d_anti_g3_h1_1a = list_mod(d_anti_g3_h1_1a)
        g3_h1_1a_exp = [x for xs in g3_h1_1a for x in expand_tuple_list(xs)]
        g3_h1_1a_exp = list_mod(g3_h1_1a_exp)
        self.assertSetEqual(set(d_anti_g3_h1_1a), set(g3_h1_1a_exp))
    def test_chain_derivative1(self):

        chain = ['m_{4}', 'm_{11}']

        d_chain = derivative(chain, self.BR3)
        self.assertEqual(d_chain, ['v_{2}', 'v_{1}', 'v_{2}', 'v_{1}'])

        d_chain = list_mod(d_chain)
        self.assertFalse(d_chain)
    def test_chain_derivative2(self):

        chain = [('v_{1}', 'm_{4}'), ('v_{2}', 'm_{4}'),
                 ('v_{1}', 'm_{11}'), ('v_{2}', 'm_{11}')]

        d_chain = derivative(chain, self.BR3)
        self.assertEqual(d_chain, [([], 'm_{4}'), ('v_{1}', ['v_{2}', 'v_{1}']), ([], 'm_{4}'), ('v_{2}', ['v_{2}', 'v_{1}']),
                                   ([], 'm_{11}'), ('v_{1}', ['v_{2}', 'v_{1}']), ([], 'm_{11}'), ('v_{2}', ['v_{2}', 'v_{1}'])])

        d_chain = [tp for c in d_chain for tp in expand_tuple_list(c)]

        self.assertEqual(d_chain, [('v_{1}', 'v_{2}'), ('v_{1}', 'v_{1}'), ('v_{2}', 'v_{2}'), ('v_{2}', 'v_{1}'),
                                   ('v_{1}', 'v_{2}'), ('v_{1}', 'v_{1}'), ('v_{2}', 'v_{2}'), ('v_{2}', 'v_{1}')])

        d_chain = list_mod(d_chain)
        self.assertFalse(d_chain)