How to use the particle.particle.Particle.all function in particle

To help you get started, we’ve selected a few particle 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 / particle / tests / particle / test_particle.py View on Github external
def test_C_consistency():
    """
    The charge conjugation parity is stored in the (curated) data CSV files.
    For unflavoured mesons it can be calculated as C = (-1)^(L+S),
    and this relation can be checked against the CSV data.

    Note: mesons with PDGIDs of the kind 9XXXXXX (N=9) are not experimentally
    well-known particles and C is undefined.
    """
    for p in Particle.all():
        if not p.is_unflavoured_meson:
            continue
        elif _digit(p.pdgid, Location.N) == 9:
            continue
        elif p.pdgid == 22:  # Special case of the photon
            assert p.C == -1
        elif p.pdgid in [130, 310]:  # Special case of the KS and KL
            assert p.C == Parity.u
        else:
            assert p.C == (-1) ** (p.L + p.S)
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_P_consistency():
    """
    The parity quantum number is stored in the (curated) data CSV files.
    For unflavoured mesons it can be calculated as P = (-1)^(L+1),
    and this relation can be checked against the CSV data.

    Note: mesons with PDGIDs of the kind 9XXXXXX (N=9) are not experimentally
    well-known particles and P is undefined.
    """
    for p in Particle.all():
        if not p.is_unflavoured_meson:
            continue
        elif _digit(p.pdgid, Location.N) == 9:
            continue
        elif p.pdgid == 22:  # Special case of the photon
            assert p.P == -1
        else:
            assert p.P == (-1) ** (p.L + 1)
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_default_table_loading_bis():
    Particle.all()
    p = Particle.from_pdgid(211)
    assert p.table_loaded() is True
    assert p.table_names() == ("particle2019.csv", "nuclei2020.csv")
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_self_conjugation_consistenty():
    """
    The logic implemented in ``Particle.invert()`` and ``Particle.is_self_conjugate``
    should be consistent. In other words, the inverse of
    ``self.anti_flag == Inv.ChargeInv and self.three_charge != Charge.o``
    in ``Particle.invert()`` should match ``Particle.is_self_conjugate``.
    """
    n_inconsistencies = 0

    for p in Particle.all():
        if (
            p.anti_flag == Inv.ChargeInv and p.three_charge == Charge.o
        ) and not p.is_self_conjugate:
            n_inconsistencies += 1

    assert n_inconsistencies == 0
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_explicit_table_loading():
    Particle.load_table(data.open_text(data, "particle2019.csv"))
    assert Particle.table_loaded() == True
    assert len(Particle.table_names()) == 1
    assert Particle.all() is not None
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_charge_consistency():
    """
    The charge of a particle is presently stored in the CSV files
    (see Particle.charge for the motivation), but it can also be retrieved
    from the particle's PDG ID, *if* the latter is valid.
    This test makes sure both numbers are consistent for all particles in the PDG table.
    """
    for p in Particle.all():
        assert p.three_charge == p.pdgid.three_charge