Skip to content
Snippets Groups Projects
Commit 2eb6c757 authored by Johannes Schumann's avatar Johannes Schumann
Browse files

Update gSeaGen handling for uproot4

parent c3b7d044
No related branches found
No related tags found
1 merge request!47Resolve "uproot4 integration"
Pipeline #16307 failed
......@@ -26,7 +26,7 @@ class GSGReader(EventReader):
v = v.decode("utf-8")
except UnicodeDecodeError:
pass
header[k.decode("utf-8")] = v
header[k] = v
return header
else:
warnings.warn("Your file header has an unsupported format")
import os
import re
import unittest
import inspect
import awkward as ak
from km3net_testdata import data_path
......@@ -8,21 +10,23 @@ from km3io.gseagen import GSGReader
GSG_READER = GSGReader(data_path("gseagen/gseagen.root"))
AWKWARD_STR_CLASSES = [
s[1] for s in inspect.getmembers(ak.behaviors.string, inspect.isclass)
]
class TestGSGHeader(unittest.TestCase):
# def setUp(self):
# self.header = GSG_READER.header
def setUp(self):
self.header = GSG_READER.header
@unittest.skip
def test_str_byte_type(self):
assert isinstance(self.header["gSeaGenVer"], str)
assert isinstance(self.header["GenieVer"], str)
assert isinstance(self.header["gSeaGenVer"], str)
assert isinstance(self.header["InpXSecFile"], str)
assert isinstance(self.header["Flux1"], str)
assert isinstance(self.header["Flux2"], str)
assert type(self.header["gSeaGenVer"]) in AWKWARD_STR_CLASSES
assert type(self.header["GenieVer"]) in AWKWARD_STR_CLASSES
assert type(self.header["gSeaGenVer"]) in AWKWARD_STR_CLASSES
assert type(self.header["InpXSecFile"]) in AWKWARD_STR_CLASSES
assert type(self.header["Flux1"]) in AWKWARD_STR_CLASSES
assert type(self.header["Flux2"]) in AWKWARD_STR_CLASSES
@unittest.skip
def test_values(self):
assert self.header["RunNu"] == 1
assert self.header["RanSeed"] == 3662074
......@@ -112,14 +116,12 @@ class TestGSGEvents(unittest.TestCase):
self.assertListEqual(event.Id_tr.tolist(), [4, 5, 10, 11, 12])
self.assertListEqual(event.Pdg_tr.tolist(), [22, -13, 2112, -211, 111])
[
self.assertAlmostEqual(x, y)
for x, y in zip(
event.E_tr, [0.00618, 4.88912206, 2.33667201, 1.0022909, 1.17186997]
)
self.assertAlmostEqual(x, y) for x, y in zip(
event.E_tr,
[0.00618, 4.88912206, 2.33667201, 1.0022909, 1.17186997])
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Vx_tr,
[
-337.67895799,
......@@ -131,8 +133,7 @@ class TestGSGEvents(unittest.TestCase):
)
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Vy_tr,
[
-203.90999969,
......@@ -144,31 +145,36 @@ class TestGSGEvents(unittest.TestCase):
)
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Vz_tr,
[416.08845294, 416.08845294, 416.08845294, 416.08845294, 416.08845294],
[
416.08845294, 416.08845294, 416.08845294, 416.08845294,
416.08845294
],
)
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Dx_tr,
[0.06766196, -0.63563065, -0.70627586, -0.76364544, -0.80562216],
[
0.06766196, -0.63563065, -0.70627586, -0.76364544,
-0.80562216
],
)
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Dy_tr,
[0.33938809, -0.4846643, 0.50569058, -0.04136113, 0.10913917],
)
]
[
self.assertAlmostEqual(x, y)
for x, y in zip(
self.assertAlmostEqual(x, y) for x, y in zip(
event.Dz_tr,
[-0.93820978, -0.6008945, -0.49543056, -0.64430963, -0.58228994],
[
-0.93820978, -0.6008945, -0.49543056, -0.64430963,
-0.58228994
],
)
]
[self.assertAlmostEqual(x, y) for x, y in zip(event.T_tr, 5 * [0.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