Removing more indirections via .entries

Sun, 28 Apr 2013 21:20:55 +0200

author
Andy Buckley <andy@insectnation.org>
date
Sun, 28 Apr 2013 21:20:55 +0200
changeset 201
3ac555efdbba
parent 200
651b0fac2163
child 202
d3d069f4549a

Removing more indirections via .entries

pyslha.py file | annotate | diff | comparison | revisions
     1.1 --- a/pyslha.py	Sun Apr 28 21:16:12 2013 +0200
     1.2 +++ b/pyslha.py	Sun Apr 28 21:20:55 2013 +0200
     1.3 @@ -131,7 +131,7 @@
     1.4  
     1.5      def keys(self):
     1.6          """Access the block item keys."""
     1.7 -        return self.entries.iteritems()
     1.8 +        return self.entries.keys()
     1.9  
    1.10      def items(self, key=None):
    1.11          """Access the block items as (key,value) tuples.
    1.12 @@ -150,6 +150,9 @@
    1.13      def __getitem__(self, key):
    1.14          return self.entries[key]
    1.15  
    1.16 +    def __setitem__(self, key, value):
    1.17 +        self.entries[key] = value
    1.18 +
    1.19      def __cmp__(self, other):
    1.20          return cmp(self.name, other.name) and cmp(self.entries, other.entries)
    1.21  
    1.22 @@ -304,9 +307,9 @@
    1.23      ## Try to populate Particle masses from the MASS block
    1.24      # print blocks.keys()
    1.25      try:
    1.26 -        for pid in blocks["MASS"].entries.keys():
    1.27 +        for pid in blocks["MASS"].keys():
    1.28              if decays.has_key(pid):
    1.29 -                decays[pid].mass = blocks["MASS"].entries[pid]
    1.30 +                decays[pid].mass = blocks["MASS"][pid]
    1.31      except:
    1.32          raise ParseError("No MASS block found: cannot populate particle masses")
    1.33  
    1.34 @@ -333,7 +336,7 @@
    1.35              namestr += (" Q= " + fmte) % float(b.q)
    1.36          blockstr = "BLOCK %s\n" % namestr
    1.37          entrystrs = []
    1.38 -        for k, v in b.entries.iteritems():
    1.39 +        for k, v in b.items():
    1.40              entrystr = ""
    1.41              if type(k) == tuple:
    1.42                  entrystr += sep.join(_autostr(i) for i in k)
    1.43 @@ -639,7 +642,7 @@
    1.44      blocks["MINPAR"] = Block("MINPAR")
    1.45      blocks["MINPAR"].add_entry((3, TANB))
    1.46      blocks["ALPHA"] = Block("ALPHA")
    1.47 -    blocks["ALPHA"].entries = ALPHAH
    1.48 +    blocks["ALPHA"].add_entry((ALPHAH,))
    1.49      #
    1.50      ## Neutralino mixing matrix
    1.51      blocks["NMIX"] = Block("NMIX")
    1.52 @@ -710,7 +713,7 @@
    1.53      """
    1.54      fmte = "%." + str(precision) + "e"
    1.55  
    1.56 -    masses = blocks["MASS"].entries
    1.57 +    masses = blocks["MASS"]
    1.58  
    1.59      ## Init output string
    1.60      out = ""
    1.61 @@ -762,7 +765,7 @@
    1.62      """
    1.63      fmte = "%." + str(precision) + "e"
    1.64  
    1.65 -    masses = blocks["MASS"].entries
    1.66 +    masses = blocks["MASS"]
    1.67  
    1.68      ## Init output string
    1.69      out = ""
    1.70 @@ -986,7 +989,7 @@
    1.71                                                              blocks["AD"][3,3],
    1.72                                                              blocks["AE"][3,3])
    1.73      ## MUSS == sign(mu)
    1.74 -    out += "%f\n" % blocks["MINPAR"].entries[4]
    1.75 +    out += "%f\n" % blocks["MINPAR"][4]
    1.76  
    1.77      ## RPV SUSY
    1.78      isRPV = False
    1.79 @@ -1081,7 +1084,7 @@
    1.80  
    1.81          print blocks.keys()
    1.82  
    1.83 -        print blocks["MASS"].entries[25]
    1.84 +        print blocks["MASS"][25]
    1.85          print
    1.86  
    1.87          for p in sorted(decays.values()):

mercurial