Example #1
0
def test_describe():
    # Test print-out of symmetric lifetime errors
    __description = u'Lifetime = 26.033 ± 0.005 ns'
    if sys.version_info < (3, 0):
        __description = __description.replace(u'±', u'+/-')
    pi = Particle.from_pdgid(211)
    assert __description in pi.describe()

    # Test print-out of asymmetric lifetime errors
    __description = 'Lifetime = 1.12e+09 + 1.7e+08 - 1.6e+08 ns'
    Omega_b_minus = Particle.from_pdgid(5332)
    assert __description in Omega_b_minus.describe()

    # Test print-out of symmetric width errors
    __description = u'Width = 2495.2 ± 2.3 MeV'
    if sys.version_info < (3, 0):
        __description = __description.replace(u'±', u'+/-')
    H0 = Particle.from_pdgid(23)
    assert __description in H0.describe()

    # Test print-out of asymmetric width errors
    __description = 'Width = 1.89 + 0.09 - 0.18 MeV'
    Sigma_c_pp = Particle.from_pdgid(4222)
    assert __description in Sigma_c_pp.describe()

    # Test print-out of zero width values
    __description = r"""Name: gamma          ID: 22           Latex: $\gamma$
Mass  = 0.0 MeV
Width = 0.0 MeV
Q (charge)        = 0       J (total angular) = 1.0      P (space parity) = -
C (charge parity) = -       I (isospin)       = <2       G (G-parity)     = ?
    SpinType: SpinType.Vector
    Antiparticle name: gamma (antiparticle status: Same)"""
    photon = Particle.from_pdgid(22)
    assert photon.describe() == __description
Example #2
0
def test_is_unflavoured_meson(PDGIDs):
    _unflavoured_mesons = (
        PDGIDs.Pi0,
        PDGIDs.PiPlus,
        PDGIDs.eta,
        PDGIDs.eta_prime,
        PDGIDs.a_0_1450_plus,
        PDGIDs.rho_770_minus,
        PDGIDs.phi,
        PDGIDs.omega,
        PDGIDs.rho_1700_0,
        PDGIDs.a2_1320_minus,
        PDGIDs.omega_3_1670,
        PDGIDs.f_4_2300,
        PDGIDs.jpsi,
        PDGIDs.psi_2S,
        PDGIDs.Upsilon_1S,
        PDGIDs.Upsilon_4S,
    )
    _non_unflavoured_mesons = [
        pid for pid in PDGIDs if pid not in _unflavoured_mesons
    ]
    for pid in _unflavoured_mesons:
        try:
            assert Particle.from_pdgid(pid).is_unflavoured_meson == True
        except (ParticleNotFound, InvalidParticle):
            pass
    for pid in _non_unflavoured_mesons:
        try:
            assert Particle.from_pdgid(pid).is_unflavoured_meson == False
        except (ParticleNotFound, InvalidParticle):
            pass
Example #3
0
def test_int_compare():
    assert Particle.from_pdgid(211) > 0
    assert Particle.from_pdgid(-211) < 0
    assert Particle.from_pdgid(211) >= 0
    assert Particle.from_pdgid(-211) <= 0

    assert 0 < Particle.from_pdgid(211)
    assert 0 > Particle.from_pdgid(-211)
    assert 0 <= Particle.from_pdgid(211)
    assert 0 >= Particle.from_pdgid(-211)
Example #4
0
def test_describe():
    __description = u'Lifetime = 26.033 ± 0.005 ns'
    if sys.version_info < (3, 0):
        __description = __description.replace(u'±', u'+/-')
    pi = Particle.from_pdgid(211)
    assert __description in pi.describe()

    __description = r"""PDG name: gamma      ID: 22           Name: gamma          Latex: $\gamma$
Mass  = 0.0 MeV
Width = 0.0 MeV
I (isospin)       = <2     G (parity)        = ?      Q (charge)       = 0
J (total angular) = 1.0    C (charge parity) = -      P (space parity) = -
    SpinType: SpinType.Vector
    Antiparticle status: Same (antiparticle name: gamma)"""
    photon = Particle.from_pdgid(22)
    assert photon.describe() == __description

    __description = 'Width = 1.89 + 0.09 - 0.18 MeV'
    Sigma_c_pp = Particle.from_pdgid(4222)
    assert __description in Sigma_c_pp.describe()
def test_P_consistency_baryons():
    """
    The parity quantum number is stored in the (curated) data CSV files.
    For baryons the (intrinsic) parity flips sign for the antiparticle.
    """
    pdgid = lambda p: p.pdgid

    pdgids_baryons = [
        pdgid(b) for b in Particle.findall(
            lambda p: p.P != Parity.u and p.pdgid.is_baryon and p.pdgid > 0)
    ]
    pdgids_antibaryons = [
        pdgid(b) for b in Particle.findall(
            lambda p: p.P != Parity.u and p.pdgid.is_baryon and p.pdgid < 0)
    ]

    for pdgid in pdgids_baryons:
        # Only consider checks on existing baryon-antibaryon pairs in the "DB"
        if not (-pdgid in pdgids_antibaryons):
            continue

        assert Particle.from_pdgid(pdgid).P == -Particle.from_pdgid(-pdgid).P
Example #6
0
def test_P_consistency_baryons():
    """
    The parity quantum number is stored in the (curated) data CSV files.
    For baryons the (intrinsic) parity flips sign for the antiparticle.
    As for baryons with undefined parity, that of the antibaryon
    is equally undefined, of course.
    """
    pdgid = lambda p: p.pdgid

    pdgids_baryons_defined_P = [
        pdgid(b) for b in Particle.findall(
            lambda p: p.P != Parity.u and p.pdgid.is_baryon and p.pdgid > 0)
    ]

    pdgids_baryons_undefined_P = [
        pdgid(b) for b in Particle.findall(
            lambda p: p.P == Parity.u and p.pdgid.is_baryon and p.pdgid > 0)
    ]

    for pdgid in pdgids_baryons_defined_P:
        assert Particle.from_pdgid(pdgid).P == -Particle.from_pdgid(-pdgid).P

    for pdgid in pdgids_baryons_undefined_P:
        assert Particle.from_pdgid(pdgid).P == Particle.from_pdgid(-pdgid).P
Example #7
0
def test_sorting():
    assert Particle.from_pdgid(211) < Particle.from_pdgid(311)
    assert Particle.from_pdgid(211) < Particle.from_pdgid(-311)
Example #8
0
def test_pdg_convert():
    p = Particle.from_pdgid(211)
    assert isinstance(p.pdgid, PDGID)
    assert int(p) == 211
    assert PDGID(p) == 211
Example #9
0
def test_isospin(pid, isospin):
    particle = Particle.from_pdgid(pid)

    assert particle.I == isospin
Example #10
0
def test_basic_props():
    pi = Particle.from_pdgid(211)
    assert pi.pdgname == 'pi'
    assert pi.pdgid == 211
    assert pi.three_charge == Charge.p
Example #11
0
def test_html_name(pid, html_name):
    particle = Particle.from_pdgid(pid)

    assert particle.html_name == html_name
Example #12
0
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")
Example #13
0
def test_describe(pid, description):
    particle = Particle.from_pdgid(pid)
    assert description in particle.describe()
Example #14
0
def test_basic_props():
    pi = Particle.from_pdgid(211)
    assert pi.pdg_name == "pi"
    assert pi.pdgid == 211
    assert pi.three_charge == Charge.p
    assert pi.charge == 1
Example #15
0
def test_default_table_loading():
    Particle.table()
    p = Particle.from_pdgid(211)
    assert p.table_loaded() is True
    assert p.table_names() == ('particle2018.csv', )
Example #16
0
def test_str():
    pi = Particle.from_pdgid(211)
    assert str(pi) == 'pi+'
Example #17
0
def test_rep():
    pi = Particle.from_pdgid(211)
    assert "pdgid=211" in repr(pi)
    assert "name='pi+'" in repr(pi)
    assert "mass=139.57" in repr(pi)
Example #18
0
def test_is_self_conjugate(pid, is_self_conjugate):
    particle = Particle.from_pdgid(pid)

    assert particle.is_self_conjugate == is_self_conjugate
Example #19
0
def test_lifetime_props():
    pi = Particle.from_pdgid(211)
    assert pi.lifetime == approx(26.0327460625985)  # in nanoseconds
    assert pi.ctau == approx(7804.4209306)  # in millimeters
Example #20
0
def test_is_name_barred(pid, has_bar):
    particle = Particle.from_pdgid(pid)

    assert particle.is_name_barred == has_bar
Example #21
0
def test_pdg():
    assert Particle.from_pdgid(211).pdgid == 211
    with pytest.raises(InvalidParticle):
        Particle.from_pdgid(0)
Example #22
0
def test_spin_type(pid, stype):
    particle = Particle.from_pdgid(pid)

    assert particle.spin_type == stype