Example #1
0
def test_nonphysical_pdgids():
    # The negative PDGID of a self-conjugate meson makes no sense
    assert PDGID(
        -111
    ).is_meson == False  # the "anti-pi0" with opposite PDGID of a pi0 does not exist
    assert PDGID(
        -443
    ).is_meson == False  # the "anti-J/psi" with opposite PDGID of a J/psi does not exist
Example #2
0
def test_from_pdgid():
    assert PythiaID.from_pdgid(9010221) == 10221

    assert PythiaID.from_pdgid(PDGID(9010221)) == 10221
    assert PythiaID.from_pdgid(PDGID(9010221)) == PythiaID(10221)

    with pytest.raises(MatchingIDNotFound):
        pdgid = PythiaID.from_pdgid(9000221)
Example #3
0
def test_info():
    __info = """A              None
C              None
J              1.0
L              None
P              None
S              None
Z              None
abspid         22
charge         0.0
has_bottom     False
has_charm      False
has_down       False
has_fundamental_anti False
has_strange    False
has_top        False
has_up         False
is_Qball       False
is_Rhadron     False
is_SUSY        False
is_baryon      False
is_diquark     False
is_dyon        False
is_hadron      False
is_lepton      False
is_meson       False
is_nucleus     False
is_pentaquark  False
is_valid       True
j_spin         3
l_spin         None
s_spin         None
three_charge   0
"""
    assert PDGID(22).info() == __info
Example #4
0
def test_decorated_class_methods(PDGIDs):
    """
    Check that all particle.pdgid functions decorated in the PDGID class
    work as expected for all kinds of PDGIDs.
    """
    for m in _fnames:
        for pid in PDGIDs:
            assert getattr(PDGID(pid), m) == getattr(_functions, m)(pid)
Example #5
0
def test_BiMap():
    bimap = BiMap(PDGID, PythiaID)

    assert len(bimap) == 538
    assert "BiMap(PDGID-PythiaID)" in str(bimap)

    with pytest.raises(MatchingIDNotFound):
        pyid = bimap[PDGID(9000221)]
Example #6
0
def test_DirectionalMaps():
    filename = data.open_text(data, "pdgid_to_pythiaid.csv")
    PDG2PyIDMap, Py2PDGIDMap = DirectionalMaps(
        "PDGID", "PythiaID", filename=filename, converters=(int, int)
    )

    assert len(PDG2PyIDMap) == 538
    assert len(Py2PDGIDMap) == 538

    assert "DirectionalMap(PDGID->PYTHIAID)" in str(PDG2PyIDMap)
    assert "DirectionalMap(PYTHIAID->PDGID)" in str(Py2PDGIDMap)

    with pytest.raises(MatchingIDNotFound):
        pyid = PDG2PyIDMap[PDGID(9000221)]
    with pytest.raises(MatchingIDNotFound):
        pdgid = Py2PDGIDMap[PythiaID(9000221)]
Example #7
0
def test_info():
    __info = """A              None
J              1.0
L              None
S              None
Z              None
abspid         22
charge         0.0
has_bottom     False
has_charm      False
has_down       False
has_fundamental_anti False
has_strange    False
has_top        False
has_up         False
is_Qball       False
is_Rhadron     False
is_SUSY        False
is_baryon      False
is_composite_quark_or_lepton False
is_diquark     False
is_dyon        False
is_gauge_boson_or_higgs True
is_generator_specific False
is_hadron      False
is_lepton      False
is_meson       False
is_nucleus     False
is_pentaquark  False
is_quark       False
is_sm_gauge_boson_or_higgs True
is_special_particle False
is_technicolor False
is_valid       True
j_spin         3
l_spin         None
s_spin         None
three_charge   0
"""
    assert PDGID(22).info() == __info
Example #8
0
def test_class_string_representations():
    pid = PDGID(11)
    assert pid == 11
    assert pid.__str__() == '<PDGID: 11>'
    pid = PDGID(-99999999)
    assert pid.__str__() == '<PDGID: -99999999 (is_valid==False)>'
Example #9
0
def test_class_inversion():
    assert -PDGID(311) == ~PDGID(311)
Example #10
0
def test_class_return_type():
    assert isinstance(-PDGID(311), PDGID)
    assert isinstance(~PDGID(311), PDGID)
Example #11
0
def test_class_operations(PDGIDs):
    id_electron = PDGID(PDGIDs.Electron)
    id_positron = PDGID(PDGIDs.Positron)
    assert PDGIDs.Electron == id_electron
    assert id_positron == -id_electron
    assert PDGIDs.Positron == -id_electron
Example #12
0
def test_to_pdgid():
    pythiaid = PythiaID(10331)
    assert pythiaid.to_pdgid() == 10221
    assert pythiaid.to_pdgid() == PDGID(10221)
Example #13
0
def test_pdg_convert():
    p = Particle.from_pdgid(211)
    assert isinstance(p.pdgid, PDGID)
    assert int(p) == 211
    assert PDGID(p) == 211
Example #14
0
def test_to_pdgid():
    gid = Geant3ID(8)
    assert gid.to_pdgid() == 211
    assert gid.to_pdgid() == PDGID(211)
Example #15
0
def test_from_pdgid():
    assert Geant3ID.from_pdgid(211) == 8

    assert Geant3ID.from_pdgid(PDGID(211)) == 8
    assert Geant3ID.from_pdgid(PDGID(211)) == Geant3ID(8)