~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/core/color_amp.py

  • Committer: olivier-mattelaer
  • Date: 2020-08-21 09:16:56 UTC
  • mfrom: (284.2.24 python3)
  • Revision ID: olivier-mattelaer-20200821091656-iizux2mj94tkssuo
pass to 2.8.0 (and move to python3 branch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
for a diagram and build a color basis, and to square a QCD color string for
18
18
squared diagrams and interference terms."""
19
19
 
 
20
from __future__ import absolute_import
20
21
import copy
21
22
import fractions
22
23
import operator
26
27
import madgraph.core.color_algebra as color_algebra
27
28
import madgraph.core.diagram_generation as diagram_generation
28
29
import madgraph.core.base_objects as base_objects
 
30
from six.moves import range
 
31
from functools import reduce
29
32
 
30
33
#===============================================================================
31
34
# ColorBasis
413
416
        # If more than one string at leading N...
414
417
        if len(res_cs) > 1 and any([not cs.near_equivalent(res_cs[0]) \
415
418
                                    for cs in res_cs]):
416
 
            raise ColorBasis.ColorBasisError, \
417
 
             "More than one color string with leading N coeff: %s" % str(res_cs)
 
419
            raise ColorBasis.ColorBasisError("More than one color string with leading N coeff: %s" % str(res_cs))
418
420
 
419
421
        res_cs = res_cs[0]
420
422
 
423
425
        for col_obj in res_cs:
424
426
            if not isinstance(col_obj, color_algebra.T) and \
425
427
                   not col_obj.__class__.__name__.startswith('Epsilon'):
426
 
                raise ColorBasis.ColorBasisError, \
427
 
                  "Color flow decomposition %s contains non T/Epsilon elements" % \
428
 
                                                                    str(res_cs)
 
428
                raise ColorBasis.ColorBasisError("Color flow decomposition %s contains non T/Epsilon elements" % \
 
429
                                                                    str(res_cs))
429
430
            if isinstance(col_obj, color_algebra.T) and len(col_obj) != 2:
430
 
                raise ColorBasis.ColorBasisError, \
431
 
                  "Color flow decomposition %s contains T's w/o 2 indices" % \
432
 
                                                                    str(res_cs)
 
431
                raise ColorBasis.ColorBasisError("Color flow decomposition %s contains T's w/o 2 indices" % \
 
432
                                                                    str(res_cs))
433
433
 
434
434
        return res_cs
435
435
 
463
463
 
464
464
                # Raise an error if external legs contain non supported repr
465
465
                if abs(leg_repr) not in [1, 3, 6, 8]:
466
 
                    raise ColorBasis.ColorBasisError, \
467
 
        "Particle ID=%i has an unsupported color representation" % leg_repr
 
466
                    raise ColorBasis.ColorBasisError("Particle ID=%i has an unsupported color representation" % leg_repr)
468
467
 
469
468
                # Build the fake indices replacements for octets
470
469
                if abs(leg_repr) == 8:
614
613
                if is_symmetric:
615
614
                    self.col_matrix_fixed_Nc[(i2, i1)] = result_fixed_Nc
616
615
                # and update the inverted dict
617
 
                if result_fixed_Nc in self.inverted_col_matrix.keys():
 
616
                if result_fixed_Nc in list(self.inverted_col_matrix.keys()):
618
617
                    self.inverted_col_matrix[result_fixed_Nc].append((i1,
619
618
                                                                      i2))
620
619
                    if is_symmetric: