Skip to content
Snippets Groups Projects
Commit 2b5f416b authored by Zineb Aly's avatar Zineb Aly
Browse files

test reading header

parent d2dfab27
No related branches found
No related tags found
1 merge request!10Add header readout for offline files. Closes #13
Pipeline #8011 failed
......@@ -333,9 +333,10 @@ class OfflineReader:
if self._header is None:
fobj = uproot.open(self._file_path)
if b'Head;1' in fobj.keys():
self._header = {}
for n, x in fobj['Head']._map_3c_string_2c_string_3e_.items():
print("{:15s} {}".format(n.decode("utf-8"), x))
self._header = fobj['Head']._map_3c_string_2c_string_3e_
print("{:15s} {}".format(n.decode("utf-8"), x.decode("utf-8")))
self._header[n.decode("utf-8")] = x.decode("utf-8")
if b'Header;1' in fobj.keys():
warnings.warn("Your file header has an unsupported format")
return self._header
......
......@@ -132,6 +132,17 @@ class TestOfflineReader(unittest.TestCase):
# check that there are 10 events
self.assertEqual(Nevents, self.Nevents)
def test_reading_header(self):
# head is the supported format
head = OfflineReader(OFFLINE_NUMUCC).header
self.assertEqual(float(head['DAQ']), 394)
self.assertEqual(float(head['kcut']), 2)
# test the warning for unsupported fheader format
self.assertWarns(UserWarning, self.r.header,
"Your file header has an unsupported format")
class TestOfflineEvents(unittest.TestCase):
def setUp(self):
......
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