More cleaning up with use of the updated Block API, and adding a keys() method

Sun, 28 Apr 2013 21:16:12 +0200

author
Andy Buckley <andy@insectnation.org>
date
Sun, 28 Apr 2013 21:16:12 +0200
changeset 200
651b0fac2163
parent 199
80d4b063103a
child 201
3ac555efdbba

More cleaning up with use of the updated Block API, and adding a keys() method

pyslha.py file | annotate | diff | comparison | revisions
     1.1 --- a/pyslha.py	Sun Apr 28 21:13:25 2013 +0200
     1.2 +++ b/pyslha.py	Sun Apr 28 21:16:12 2013 +0200
     1.3 @@ -129,6 +129,10 @@
     1.4              raise AccessError("Tried to access unique value of multi-value block")
     1.5          return self.entries[key]
     1.6  
     1.7 +    def keys(self):
     1.8 +        """Access the block item keys."""
     1.9 +        return self.entries.iteritems()
    1.10 +
    1.11      def items(self, key=None):
    1.12          """Access the block items as (key,value) tuples.
    1.13  
    1.14 @@ -289,11 +293,7 @@
    1.15                  if len(items) < 1:
    1.16                      continue
    1.17                  if currentblock != "DECAY":
    1.18 -                    if len(items) > 1:
    1.19 -                        blocks[currentblock].add_entry(items)
    1.20 -                    else:
    1.21 -                        ## The ALPHA block in particular only has one, non-indexed value
    1.22 -                        blocks[currentblock].entries[None] = _autotype(items[0])
    1.23 +                    blocks[currentblock].add_entry(items)
    1.24                  else:
    1.25                      br = float(items[0]) if items[0].upper() != "NAN" else None
    1.26                      nda = int(items[1])
    1.27 @@ -968,23 +968,23 @@
    1.28      ## TANB, ALPHAH:
    1.29      out += (fmte + " " + fmte + "\n") % (blocks["MINPAR"].value(3), blocks["ALPHA"].value())
    1.30      ## Neutralino mixing matrix
    1.31 -    nmix = blocks["NMIX"].entries
    1.32 +    nmix = blocks["NMIX"]
    1.33      for i in xrange(1, 5):
    1.34          out += (fmte + " " + fmte + " " + fmte + " " + fmte + "\n") % (nmix[i,1], nmix[i,2], nmix[i,3], nmix[i,4])
    1.35      ## Chargino mixing matrices V and U
    1.36 -    vmix = blocks["VMIX"].entries
    1.37 +    vmix = blocks["VMIX"]
    1.38      out += (fmte + " " + fmte + " " + fmte + " " + fmte + "\n") % (vmix[1,1], vmix[1,2], vmix[2,1], vmix[2,2])
    1.39 -    umix = blocks["UMIX"].entries
    1.40 +    umix = blocks["UMIX"]
    1.41      out += (fmte + " " + fmte + " " + fmte + " " + fmte + "\n") % (umix[1,1], umix[1,2], umix[2,1], umix[2,2])
    1.42      ## THETAT,THETAB,THETAL
    1.43      import math
    1.44 -    out += (fmte + " " + fmte + " " + fmte + " " + "\n") % (math.acos(blocks["STOPMIX"].entries[1,1]),
    1.45 -                                                            math.acos(blocks["SBOTMIX"].entries[1,1]),
    1.46 -                                                            math.acos(blocks["STAUMIX"].entries[1,1]))
    1.47 +    out += (fmte + " " + fmte + " " + fmte + " " + "\n") % (math.acos(blocks["STOPMIX"][1,1]),
    1.48 +                                                            math.acos(blocks["SBOTMIX"][1,1]),
    1.49 +                                                            math.acos(blocks["STAUMIX"][1,1]))
    1.50      ## ATSS,ABSS,ALSS
    1.51 -    out += (fmte + " " + fmte + " " + fmte + " " + "\n") % (blocks["AU"].entries[3,3],
    1.52 -                                                            blocks["AD"].entries[3,3],
    1.53 -                                                            blocks["AE"].entries[3,3])
    1.54 +    out += (fmte + " " + fmte + " " + fmte + " " + "\n") % (blocks["AU"][3,3],
    1.55 +                                                            blocks["AD"][3,3],
    1.56 +                                                            blocks["AE"][3,3])
    1.57      ## MUSS == sign(mu)
    1.58      out += "%f\n" % blocks["MINPAR"].entries[4]
    1.59  

mercurial