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_width_lifetime_conversions():
assert lifetime_to_width(1.5*ps)/GeV == approx(4.388079676311604e-13)
assert 1.5*ps * lifetime_to_width(1.5*ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
#
with pytest.raises(ValueError):
lifetime_to_width(-1)
with pytest.raises(ValueError):
width_to_lifetime(-1)
def test_width_lifetime_conversions():
assert lifetime_to_width(1.5*ps)/GeV == approx(4.388079676311604e-13)
assert 1.5*ps * lifetime_to_width(1.5*ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
#
with pytest.raises(ValueError):
lifetime_to_width(-1)
with pytest.raises(ValueError):
width_to_lifetime(-1)
def test_valid_width_lifetime_conversions():
assert lifetime_to_width(1.5 * ps) / GeV == approx(4.388079676311604e-13)
assert 1.5 * ps * lifetime_to_width(1.5 * ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
def test_valid_width_lifetime_conversions():
assert lifetime_to_width(1.5 * ps) / GeV == approx(4.388079676311604e-13)
assert 1.5 * ps * lifetime_to_width(1.5 * ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
def test_width_lifetime_conversions():
assert lifetime_to_width(1.5*ps)/GeV == approx(4.388079676311604e-13)
assert 1.5*ps * lifetime_to_width(1.5*ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
#
with pytest.raises(ValueError):
lifetime_to_width(-1)
with pytest.raises(ValueError):
width_to_lifetime(-1)
def test_valid_width_lifetime_conversions():
assert lifetime_to_width(1.5 * ps) / GeV == approx(4.388079676311604e-13)
assert 1.5 * ps * lifetime_to_width(1.5 * ps) == hbar
assert width_to_lifetime(hbar) == 1 * MeV
filter_fn=lambda p: p.pdgid.is_meson
and p.pdgid.has_strange
and p.ctau > 1 * meter,
exclusive_fields=["pdgid", "name"],
assert 2212 in Particle.findall(lifetime=lambda x: x > 1 * second)
4.33e-10
>>>
>>> lifetime_to_width(1.520119980246514*ps) # result again returned in MeV
4.33e-10
>>>
>>> lifetime_to_width(1.520119980246514*ps)/eV # result converted to eV
0.000433
"""
if tau < 0:
raise ValueError("Input provided, {0} <= 0!".format(tau))
elif tau == 0:
return float("inf")
# Just need to first make sure that the lifetime is in the standard unit ns
return hbar / float(tau / ns)
Parameters
----------
Gamma : float > 0
Particle decay width, typically in MeV (any HEP energy unit is OK).
Returns
-------
Particle lifetime, in the HEP standard time unit ns.
"""
if Gamma <= 0.:
raise ValueError( 'Input provided, %s <= 0!'.format(Gamma) )
# Just need to first make sure that the width is in the standard unit MeV
return hbar / float(Gamma / MeV)