Skip to content

Commit

Permalink
add flavio_all method
Browse files Browse the repository at this point in the history
  • Loading branch information
peterstangl committed Aug 1, 2020
1 parent 0582522 commit 2b8e496
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions flavio/parameters.py
Expand Up @@ -94,13 +94,15 @@ def write_file(filename, constraints):
class FlavioParticle(Particle):
"""This class extends the `particle.Particle` class.
Additional class method
-----------------------
Additional class methods
------------------------
- from_flavio_name(flavio_name)
returns a class instance for a given `flavio_name`
- flavio_all()
returns a set of all class instances used in flavio
Additional properties
--------------------
---------------------
- flavio_name
the particle name as used in flavio if defined, otherwise `None`
- latex_name_simplified
Expand Down Expand Up @@ -170,6 +172,10 @@ class FlavioParticle(Particle):
def from_flavio_name(cls, flavio_name):
return cls.from_pdgid(cls.PDG_PARTICLES[flavio_name])

@classmethod
def flavio_all(cls):
return {particle for particle in cls.all() if particle.flavio_name}

@property
def flavio_name(self):
return self._pdg_particles_inv.get(self.pdgid, None)
Expand Down Expand Up @@ -224,8 +230,7 @@ def flavio_tau(self):
def read_pdg(year, constraints):
"""Read particle masses and widths from the PDG data file of a given year."""
FlavioParticle.load_table(p_data.open_text(p_data, "particle{}.csv".format(year)))
for flavio_name in FlavioParticle.PDG_PARTICLES.keys():
particle = FlavioParticle.from_flavio_name(flavio_name)
for particle in FlavioParticle.flavio_all():
for data in (particle.flavio_m, particle.flavio_tau):
if data is None:
continue
Expand Down

0 comments on commit 2b8e496

Please sign in to comment.