Skip to content
Snippets Groups Projects
Verified Commit 7a457b14 authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Add length to SummarysliceReader

parent 231c97d3
No related branches found
No related tags found
1 merge request!68Rewrite the online module
Pipeline #25149 passed
......@@ -60,6 +60,9 @@ class SummarysliceReader:
def __next__(self):
return next(self._summaryslices)
def __len__(self):
return int(np.ceil(len(self._branch) / self._step_size))
@nb.vectorize(
[nb.int32(nb.int8), nb.int32(nb.int16), nb.int32(nb.int32), nb.int32(nb.int64)]
......
......@@ -739,6 +739,14 @@ class TestSummarysliceReader(unittest.TestCase):
def test_init(self):
sr = SummarysliceReader(data_path("online/km3net_online.root"))
def test_length(self):
sr = SummarysliceReader(data_path("online/km3net_online.root"))
assert 1 == len(sr)
sr = SummarysliceReader(data_path("online/km3net_online.root"), step_size=2)
assert 2 == len(sr)
sr = SummarysliceReader(data_path("online/km3net_online.root"), step_size=3)
assert 1 == len(sr)
def test_iterate_with_step_size_one(self):
sr = SummarysliceReader(data_path("online/km3net_online.root"), step_size=1)
i = 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment