コード例 #1
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)
コード例 #2
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)]
コード例 #3
0
def test_to_pdgid():
    pythiaid = PythiaID(10331)
    assert pythiaid.to_pdgid() == 10221
    assert pythiaid.to_pdgid() == PDGID(10221)
コード例 #4
0
def test_class_inversion():
    assert -PythiaID(311) == ~PythiaID(311)
コード例 #5
0
def test_class_return_type():
    assert isinstance(-PythiaID(211), PythiaID)
    assert isinstance(~PythiaID(211), PythiaID)
コード例 #6
0
def test_class_string_representations():
    pid = PythiaID(211)
    assert pid == 211
    assert pid.__str__() == "<PythiaID: 211>"