How to use hepunits - 10 common examples

To help you get started, we’ve selected a few hepunits examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-hep / scikit-hep / tests / math / test_kinematics.py View on Github external
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)
github scikit-hep / scikit-hep / tests / math / test_kinematics.py View on Github external
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)
github scikit-hep / particle / tests / particle / test_kinematics.py View on Github external
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
github scikit-hep / particle / tests / particle / test_kinematics.py View on Github external
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
github scikit-hep / scikit-hep / tests / math / test_kinematics.py View on Github external
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)
github scikit-hep / particle / tests / particle / test_kinematics.py View on Github external
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
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
filter_fn=lambda p: p.pdgid.is_meson
        and p.pdgid.has_strange
        and p.ctau > 1 * meter,
        exclusive_fields=["pdgid", "name"],
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
    assert 2212 in Particle.findall(lifetime=lambda x: x > 1 * second)
github scikit-hep / particle / src / particle / particle / kinematics.py View on Github external
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)
github scikit-hep / scikit-hep / skhep / math / kinematics.py View on Github external
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)

hepunits

Units and constants in the HEP system of units

BSD-3-Clause
Latest version published 3 months ago

Package Health Score

67 / 100
Full package analysis

Similar packages