~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/madevent/combine_grid.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:
1
1
from __future__ import division
 
2
from __future__ import absolute_import
2
3
import collections
3
4
import math
4
5
import os
 
6
from six.moves import range
5
7
try:
6
8
    import madgraph
7
9
except ImportError:
60
62
        elif isinstance(path, file):
61
63
            finput=path
62
64
        else:
63
 
            raise Exception, "path should be a path or a file descriptor"
 
65
            raise Exception("path should be a path or a file descriptor")
64
66
        
65
67
        line = finput.readline()
66
68
        if self.nonzero == 0:
79
81
                self.oneFail = True
80
82
                return
81
83
            elif len(info) !=3:
82
 
                raise Exception, "wrong formatting of %s"% finput.name
 
84
                raise Exception("wrong formatting of %s"% finput.name)
83
85
            
84
86
            nonzero, ng, maxinvar = info
85
87
            self.nonzero+=nonzero
153
155
            finput=path
154
156
            fname = finput.name
155
157
        else:
156
 
            raise Exception, "path should be a path or a file descriptor"
 
158
            raise Exception("path should be a path or a file descriptor")
157
159
         
158
160
        
159
161
        return self.results.add_results(fname,finput)
253
255
        th_maxwgt = [R.th_maxwgt for R in self.results]
254
256
        th_nunwgt = [R.th_nunwgt for R in self.results]
255
257
        nb_data = len(th_nunwgt)
256
 
        total_sum = sum(th_maxwgt[i] * th_nunwgt[i] for i in xrange(nb_data))
257
 
        info = sorted([ (th_maxwgt[i], th_nunwgt[i]) for i in xrange(nb_data) 
 
258
        total_sum = sum(th_maxwgt[i] * th_nunwgt[i] for i in range(nb_data))
 
259
        info = sorted([ (th_maxwgt[i], th_nunwgt[i]) for i in range(nb_data) 
258
260
                                                          if th_nunwgt[i] > 0],
259
261
                      reverse=True)
260
262
 
547
549
            
548
550
        while 1:
549
551
            try:
550
 
                line = fsock.next()
 
552
                line = next(fsock)
551
553
            except StopIteration:
552
554
                break
553
555
            line = line.lower()
580
582
  
581
583
        
582
584
        def next_line(fsock):
583
 
            line = fsock.next()
 
585
            line = next(fsock)
584
586
            if '#' in line:
585
587
                line = line.split('#',1)[0]
586
588
            line = line.strip()