diff --git a/km3io/gseagen.py b/km3io/gseagen.py index 5d4188feae932eaa353f7147470ea86a1bbb8433..d14502d6e1400f0b800164e2241b34badef4bb71 100644 --- a/km3io/gseagen.py +++ b/km3io/gseagen.py @@ -10,6 +10,7 @@ from .tools import cached_property class GSGReader(EventReader): """reader for gSeaGen ROOT files""" + event_path = "Events" skip_keys = ["Header"] diff --git a/km3io/rootio.py b/km3io/rootio.py index c05b459338416fc1dae61e6cb0541b5ef90543ff..5c4e4de0bede7f414b336aeea6ee5551123e1c5f 100644 --- a/km3io/rootio.py +++ b/km3io/rootio.py @@ -10,6 +10,7 @@ import logging log = logging.getLogger("km3io.rootio") + class EventReader: """reader for offline ROOT files""" @@ -129,7 +130,9 @@ class EventReader: # indexing # TODO: maybe just propagate everything to awkward and let it deal # with the type? - if isinstance(key, (slice, int, np.int32, np.int64, list, np.ndarray, ak.Array)): + if isinstance( + key, (slice, int, np.int32, np.int64, list, np.ndarray, ak.Array) + ): if isinstance(key, (int, np.int32, np.int64)): key = int(key) return self.__class__( @@ -239,7 +242,11 @@ class EventReader: return 1 else: # ignore the usual index magic and access `id` directly - return len(unfold_indices(self._fobj[self.event_path]["id"].array(), self._index_chain)) + return len( + unfold_indices( + self._fobj[self.event_path]["id"].array(), self._index_chain + ) + ) def __actual_len__(self): """The raw number of events without any indexing/slicing magic""" diff --git a/tests/test_offline.py b/tests/test_offline.py index 197105d17c380fbf3eb8eab8f07ce1ce9ee1f9fb..8e9e52e0a4d11ab0ed96922ad0e1507e77617c18 100644 --- a/tests/test_offline.py +++ b/tests/test_offline.py @@ -439,6 +439,7 @@ class TestBranchIndexingMagic(unittest.TestCase): # test selecting with a list self.assertEqual(3, len(self.events[ak.Array([0, 2, 3])])) + class TestUsr(unittest.TestCase): def setUp(self): self.f = OFFLINE_USR