Skip to content

Commit

Permalink
Remove the handling of unnecessary overloads from python
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jun 5, 2024
1 parent 4c07994 commit c25cd89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
11 changes: 2 additions & 9 deletions python/podio/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ def getName(self, token):
"""Get the name of the collection from the Frame
Args:
token (podio.CollectionBase | int | podio.ObjectID | podio generated
datatype): Something that that can be used to get the name of a
collection. Can either be the collection itself, a collectionID
or an object ID of an element of a collection
token (podio.CollectionBase | int): A collection or its ID
Returns:
str: The name of the collection inside the frame
Expand All @@ -130,11 +127,7 @@ def getName(self, token):
def _get_id(tok):
if isinstance(tok, int):
return f"{tok:0>8x}"
if _is_collection_base(token):
return _get_id(tok.getID())
if isinstance(tok, podio.ObjectID):
return f"({tok.collectionID:0>8x}: {tok.index})"
return _get_id(tok.id())
return _get_id(tok.getID())

raise KeyError(f"No collection name can be found in Frame for {_get_id(token)}")

Expand Down
6 changes: 0 additions & 6 deletions python/podio/test_Frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@ def test_frame_get_name_invalid_token(self):
coll = ExampleHitCollection()
_ = frame.getName(coll)

with self.assertRaises(KeyError):
coll = ExampleHitCollection()
hit = coll.create()
_ = frame.getName(hit)

def test_frame_put_collection(self):
"""Check that putting a collection works as expected"""
frame = Frame()
Expand Down Expand Up @@ -217,4 +212,3 @@ def test_frame_get_name(self):
mc_particles = self.event.get("mcparticles")
self.assertEqual(self.event.getName(mc_particles), "mcparticles")
self.assertEqual(self.event.getName(mc_particles.getID()), "mcparticles")
self.assertEqual(self.event.getName(mc_particles[0]), "mcparticles")

0 comments on commit c25cd89

Please sign in to comment.