Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_class_string_representations():
pid = PDGID(11)
assert pid == 11
assert pid.__str__() == ""
pid = PDGID(-99999999)
assert pid.__str__() == ""
def test_to_pdgid():
gid = Geant3ID(8)
assert gid.to_pdgid() == 211
assert gid.to_pdgid() == PDGID(211)
def test_class_operations(PDGIDs):
id_electron = PDGID(PDGIDs.Electron)
id_positron = PDGID(PDGIDs.Positron)
assert PDGIDs.Electron == id_electron
assert id_positron == -id_electron
assert PDGIDs.Positron == -id_electron
def test_class_inversion():
assert -PDGID(311) == ~PDGID(311)
def test_pdg_convert():
p = Particle.from_pdgid(211)
assert isinstance(p.pdgid, PDGID)
assert int(p) == 211
assert PDGID(p) == 211
def test_class_return_type():
assert isinstance(-PDGID(311), PDGID)
assert isinstance(~PDGID(311), PDGID)
is_SUSY False
is_baryon False
is_diquark False
is_dyon False
is_hadron False
is_lepton False
is_meson False
is_nucleus False
is_pentaquark False
is_valid True
j_spin 3
l_spin None
s_spin None
three_charge 0
"""
assert PDGID(22).info() == __info
def test_nonphysical_pdgids():
# The negative PDGID of a self-conjugate meson makes no sense
assert (
PDGID(-111).is_meson == False
) # the "anti-pi0" with opposite PDGID of a pi0 does not exist
assert (
PDGID(-443).is_meson == False
) # the "anti-J/psi" with opposite PDGID of a J/psi does not exist
def test_decorated_class_methods(PDGIDs):
"""
Check that all particle.pdgid functions decorated in the PDGID class
work as expected for all kinds of PDGIDs.
"""
for m in _fnames:
for pid in PDGIDs:
assert getattr(PDGID(pid), m) == getattr(_functions, m)(pid)