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_ampgen_style_names(name, pid):
particle = Particle.from_string(name)
assert int(particle) == pid
assert particle.pdgid == pid
assert particle == pid
def test_string():
pi = Particle.from_string("pi+")
assert pi.pdgid == 211
with pytest.raises(ParticleNotFound):
Particle.from_string("unknown")
def test_fuzzy_string():
"""
The input name is not specific enough, in which case the search is done
by pdg_name after failing a match by name.
"""
p = Particle.from_string("a(0)(980)") # all 3 charge stages match
assert p.pdgid == 9000111
def test_string():
pi = Particle.from_string("pi+")
assert pi.pdgid == 211
with pytest.raises(ParticleNotFound):
Particle.from_string("unknown")