~maddevelopers/mg5amcnlo/3.0.2-pineappl

« back to all changes in this revision

Viewing changes to tests/unit_tests/various/test_usermod.py

  • Committer: marco zaro
  • Date: 2020-09-18 11:00:14 UTC
  • mfrom: (956.1.11 3.0.4)
  • Revision ID: marcozaro@pcteor1.mi.infn.it-20200918110014-5jc20pkwceijqspw
merged with 3.0.4 rev967

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
"""Unit test Library for importing and restricting model"""
16
16
from __future__ import division
17
17
 
 
18
from __future__ import absolute_import
18
19
import copy
19
20
import os
20
21
import sys
30
31
import models as ufomodels
31
32
import models.model_reader as model_reader
32
33
import madgraph.iolibs.export_v4 as export_v4
 
34
import madgraph.various.misc as misc
 
35
import six
 
36
from six.moves import range
 
37
from six.moves import zip
33
38
 
34
39
_file_path = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
35
40
pjoin = os.path.join
157
162
        if self.selfconjugate:
158
163
            raise Exception('%s has no anti particle.' % self.name) 
159
164
        outdic = {}
160
 
        for k,v in self.__dict__.iteritems():
 
165
        for k,v in six.iteritems(self.__dict__):
161
166
            if k not in self.require_args_all:                
162
167
                outdic[k] = -v
163
168
        if self.color in [1,8]:
324
329
 
325
330
 
326
331
    def setUp(self):
327
 
        
328
 
        self.path = tempfile.mkdtemp(prefix='unitest_usermod') 
 
332
        self.debug=False
 
333
        if self.debug:
 
334
            self.path = "/tmp/"
 
335
        else:   
 
336
            self.path = tempfile.mkdtemp(prefix='unitest_usermod') 
329
337
 
330
338
        #Read the full SM
331
339
        self.sm_path = import_ufo.find_ufo_path('sm')
333
341
        
334
342
    def tearDown(self):
335
343
        
336
 
        shutil.rmtree(self.path)
337
 
 
 
344
        if not self.debug:
 
345
            shutil.rmtree(self.path)
 
346
        self.assertFalse(self.debug)
338
347
 
339
348
    def test_write_model(self):
340
349
        """ Check that we can write all the require UFO files """
450
459
        target = [l for l in target if not '.anti()' in l or duplicate.append(l.split('=')[0].strip())] 
451
460
        
452
461
        text = text.replace('.0,',',')
 
462
        text = text.replace('1/3,','0.333333333333,')
 
463
        text = text.replace('2/3,','0.666666666667,')
 
464
        text = text.replace('0.6666666666666666', '0.666666666667')
 
465
        text = text.replace('0.3333333333333333', '0.333333333333')
453
466
        text = text.split('\n')        
454
467
        text = [l.strip() for l in text
455
468
                  if l.strip() and not l.strip().startswith('#') and 
456
469
                  not l.split('=')[0].strip() in ['line', 'propagating', 'goldstoneboson', 'GoldstoneBoson','selfconjugate']]
 
470
 
457
471
        
458
472
        keep = True      
459
473
        new_text = []  
468
482
            else:
469
483
                new_text.append(line)
470
484
        text=new_text
471
 
                
 
485
        
472
486
        for line1, line2 in zip(target, text):
473
 
            try:
474
 
                self.assertEqual(line1.replace(',',')'), line2.replace(',',')'))
475
 
            except Exception:
476
 
                self.assertEqual(target, text)
 
487
            self.assertEqual(line1.replace(',',')'), line2.replace(',',')'))
 
488
 
 
489
                
477
490
    def test_write_vertices(self):
478
491
        """Check that the content of the file is valid"""
479
492