def test_w_and_z_amplitudes(self):
        """Test wavefunction and amplitude calls for W and Z"""

        goal = [ \
            'CALL JWWWXX(W(1,2),W(1,3),W(1,4),MGVX6,wmas,wwid,W(1,1))',
            'CALL JWWWXX(W(1,1),W(1,3),W(1,4),MGVX6,wmas,wwid,W(1,2))',
            'CALL JWWWXX(W(1,1),W(1,2),W(1,4),MGVX6,wmas,wwid,W(1,3))',
            'CALL JWWWXX(W(1,1),W(1,2),W(1,3),MGVX6,wmas,wwid,W(1,4))',
            '# Amplitude(s) for diagram number 1',
            'CALL WWWWXX(W(1,1),W(1,2),W(1,3),W(1,4),MGVX6,AMP(1))',
            'CALL JW3WXX(W(1,2),W(1,3),W(1,4),MGVX8,wmas,wwid,W(1,1))',
            'CALL JW3WXX(W(1,1),W(1,3),W(1,4),MGVX8,wmas,wwid,W(1,2))',
            'CALL JW3WXX(W(1,1),W(1,2),W(1,4),MGVX8,zmas,zwid,W(1,3))',
            'CALL JW3WXX(W(1,1),W(1,2),W(1,3),MGVX8,zmas,zwid,W(1,4))',
            '# Amplitude(s) for diagram number 1',
            'CALL W3W3XX(W(1,1),W(1,2),W(1,3),W(1,4),MGVX8,AMP(1))']

        goal_counter = 0

        myleglist = base_objects.LegList()

        myleglist.append(
            base_objects.Leg({
                'id': 24,
                'number': 1,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': -24,
                'number': 2,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 24,
                'number': 3,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': -24,
                'number': 4,
                'state': False
            }))

        wfs = helas_objects.HelasWavefunctionList(\
            [ helas_objects.HelasWavefunction(leg, 8,
                                              self.mybasemodel) \
              for leg in myleglist ])

        fortran_model = helas_call_writers.FortranHelasCallWriter()

        for wf in wfs:
            mothers = copy.copy(wfs)
            mothers.remove(wf)
            wf.set('mothers', mothers)
            # Not yet implemented special wavefunctions for W/Z
            #self.assertEqual(fortran_model.get_wavefunction_call(wf),
            #                 goal[goal_counter])
            goal_counter = goal_counter + 1

        amplitude = helas_objects.HelasAmplitude({\
            'mothers': wfs,
            'number': 1})
        amplitude.set('interaction_id', 8, self.mybasemodel)
        # Not yet implemented special wavefunctions for W/Z
        #self.assertEqual(fortran_model.get_amplitude_call(amplitude),
        #                 goal[goal_counter])
        goal_counter = goal_counter + 1

        myleglist = base_objects.LegList()

        myleglist.append(
            base_objects.Leg({
                'id': 24,
                'number': 1,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': -24,
                'number': 2,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 23,
                'number': 3,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 23,
                'number': 4,
                'state': False
            }))

        wfs = helas_objects.HelasWavefunctionList(\
            [ helas_objects.HelasWavefunction(leg, 9,
                                              self.mybasemodel) \
              for leg in myleglist ])

        fortran_model = helas_call_writers.FortranHelasCallWriter()

        for wf in wfs:
            mothers = copy.copy(wfs)
            mothers.remove(wf)
            wf.set('mothers', mothers)
            # Not yet implemented special wavefunctions for W/Z
            # self.assertEqual(fortran_model.get_wavefunction_call(wf),
            #                 goal[goal_counter])
            goal_counter = goal_counter + 1


        amplitude = helas_objects.HelasAmplitude({\
            'mothers': wfs,
            'number': 1})
        amplitude.set('interaction_id', 9, self.mybasemodel)
        # Not yet implemented special wavefunctions for W/Z
        #self.assertEqual(fortran_model.get_amplitude_call(amplitude),
        #                 goal[goal_counter])
        goal_counter = goal_counter + 1
    def test_generate_wavefunctions_and_amplitudes(self):
        """Test automatic generation of wavefunction and amplitude calls"""

        goal = [ \
            'CALL IXXXXX(P(0,1),me,NHEL(1),+1*IC(1),W(1,1))',
            'CALL OXXXXX(P(0,2),me,NHEL(2),-1*IC(2),W(1,2))',
            'CALL VXXXXX(P(0,3),zero,NHEL(3),-1*IC(3),W(1,3))',
            'CALL FVOXXX(W(1,2),W(1,3),MGVX12,me,zero,W(1,1))',
            'CALL FVIXXX(W(1,1),W(1,3),MGVX12,me,zero,W(1,2))',
            'CALL JIOXXX(W(1,1),W(1,2),MGVX12,zero,zero,W(1,3))',
            'CALL IOVXXX(W(1,1),W(1,2),W(1,3),MGVX12,AMP(1))',
            'CALL VXXXXX(P(0,1),zero,NHEL(1),-1*IC(1),W(1,1))',
            'CALL VXXXXX(P(0,2),zero,NHEL(2),-1*IC(2),W(1,2))',
            'CALL TXXXXX(P(0,3),zero,NHEL(3),-1*IC(3),W(1,3))',
            'CALL JVTAXX(W(1,2),W(1,3),MGVX2,zero,zero,W(1,1))',
            'CALL JVTAXX(W(1,1),W(1,3),MGVX2,zero,zero,W(1,2))',
            'CALL UVVAXX(W(1,1),W(1,2),MGVX2,zero,zero,zero,W(1,3))',
            'CALL VVTAXX(W(1,1),W(1,2),W(1,3),MGVX2,zero,AMP(2))',
            'CALL VXXXXX(P(0,1),zero,NHEL(1),-1*IC(1),W(1,1))',
            'CALL VXXXXX(P(0,2),zero,NHEL(2),-1*IC(2),W(1,2))',
            'CALL SXXXXX(P(0,3),-1*IC(3),W(1,3))',
            'CALL SXXXXX(P(0,4),-1*IC(4),W(1,4))',
            'CALL JVSSXX(W(1,2),W(1,3),W(1,4),MGVX89,zero,zero,W(1,1))',
            'CALL JVSSXX(W(1,1),W(1,3),W(1,4),MGVX89,zero,zero,W(1,2))',
            'CALL HVVSXX(W(1,2),W(1,1),W(1,4),MGVX89,Musq2,Wusq2,W(1,3))',
            'CALL HVVSXX(W(1,2),W(1,1),W(1,3),MGVX89,Musq2,Wusq2,W(1,4))',
            'CALL VVSSXX(W(1,2),W(1,1),W(1,3),W(1,4),MGVX89,AMP(1))']

        myleglist = base_objects.LegList()

        myleglist.append(
            base_objects.Leg({
                'id': 11,
                'number': 1,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': -11,
                'number': 2,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 22,
                'number': 3,
                'state': False
            }))

        wfs = helas_objects.HelasWavefunctionList(\
            [ helas_objects.HelasWavefunction(leg, 7,
                                              self.mybasemodel) \
              for leg in myleglist ])

        fortran_model = helas_call_writers.FortranHelasCallWriter()

        goal_counter = 0

        for wf in wfs:
            self.assertEqual(fortran_model.get_wavefunction_call(wf),
                             goal[goal_counter])
            goal_counter = goal_counter + 1

        for wf in wfs:
            mothers = copy.copy(wfs)
            mothers.remove(wf)
            wf.set('mothers', mothers)
            if not wf.get('self_antipart'):
                wf.flip_part_antipart()
            self.assertEqual(fortran_model.get_wavefunction_call(wf),
                             goal[goal_counter])
            if not wf.get('self_antipart'):
                wf.flip_part_antipart()
            goal_counter = goal_counter + 1

        amplitude = helas_objects.HelasAmplitude({\
            'mothers': wfs,
            'number': 1})
        amplitude.set('interaction_id', 7, self.mybasemodel)

        self.assertEqual(fortran_model.get_amplitude_call(amplitude),
                         goal[goal_counter])
        goal_counter = goal_counter + 1

        myleglist = base_objects.LegList()

        myleglist.append(
            base_objects.Leg({
                'id': 21,
                'number': 1,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 21,
                'number': 2,
                'state': False
            }))
        myleglist.append(
            base_objects.Leg({
                'id': 8000002,
                'number': 3,
                'state': False
            }))

        wfs = helas_objects.HelasWavefunctionList(\
            [ helas_objects.HelasWavefunction(leg, 5,
                                              self.mybasemodel) \
              for leg in myleglist ])

        fortran_model = helas_call_writers.FortranHelasCallWriter()

        for wf in wfs:
            self.assertEqual(fortran_model.get_wavefunction_call(wf),
                             goal[goal_counter])
            goal_counter = goal_counter + 1

        for wf in wfs:
            mothers = copy.copy(wfs)
            mothers.remove(wf)
            wf.set('mothers', mothers)
            self.assertEqual(fortran_model.get_wavefunction_call(wf),
                             goal[goal_counter])
            goal_counter = goal_counter + 1

        amplitude = helas_objects.HelasAmplitude({\
            'mothers': wfs,
            'number': 2})
        amplitude.set('interaction_id', 5, self.mybasemodel)
        self.assertEqual(fortran_model.get_amplitude_call(amplitude),
                         goal[goal_counter])
        goal_counter = goal_counter + 1