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)
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)]
def test_to_pdgid(): pythiaid = PythiaID(10331) assert pythiaid.to_pdgid() == 10221 assert pythiaid.to_pdgid() == PDGID(10221)
def test_class_inversion(): assert -PythiaID(311) == ~PythiaID(311)
def test_class_return_type(): assert isinstance(-PythiaID(211), PythiaID) assert isinstance(~PythiaID(211), PythiaID)
def test_class_string_representations(): pid = PythiaID(211) assert pid == 211 assert pid.__str__() == "<PythiaID: 211>"