Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test full chain in multiple chunks and clean up input tests #184

Merged
merged 6 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/test_FullChain.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


class TestFullChain(unittest.TestCase):
__test__ = True

@classmethod
def setUpClass(cls):
cls.temp_dir = tempfile.TemporaryDirectory()
Expand Down Expand Up @@ -87,5 +89,14 @@ def test_PMTResponseAndDAQ(self):
self.test_context.make(self.run_number, "raw_records")


class TestChunkedFullChain(TestFullChain):
__test__ = True

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.test_context.set_config({"n_interactions_per_chunk": 2})


if __name__ == "__main__":
unittest.main()
56 changes: 18 additions & 38 deletions tests/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def test_load_all(self):
)
g4_loaded = test_context.get_array(self.run_number, "geant4_interactions")
loaded_event_count = len(np.unique(g4_loaded["evtid"]))
assert loaded_event_count == 52, f"Expecting 52 events, but got {loaded_event_count} events"
self.assertTrue(
loaded_event_count == 52, f"Expecting 52 events, but got {loaded_event_count} events"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="LoadHalf timed out")
def test_load_half(self):
Expand All @@ -59,7 +61,9 @@ def test_load_half(self):
g4_loaded = test_context.get_array(self.run_number, "geant4_interactions")
loaded_event_count = len(np.unique(g4_loaded["evtid"]))

assert loaded_event_count == 26, f"Expecting 26 events, but got {loaded_event_count} events"
self.assertTrue(
loaded_event_count == 26, f"Expecting 26 events, but got {loaded_event_count} events"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="LoadEventIDAll timed out")
def test_load_eventid_all(self):
Expand All @@ -69,7 +73,9 @@ def test_load_eventid_all(self):
)
g4_loaded = test_context.get_array(self.run_number, "geant4_interactions")
loaded_event_count = len(np.unique(g4_loaded["evtid"]))
assert loaded_event_count == 52, f"Expecting 52 events, but got {loaded_event_count} events"
self.assertTrue(
loaded_event_count == 52, f"Expecting 52 events, but got {loaded_event_count} events"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="LoadEventIDHalf timed out")
def test_load_eventid_half(self):
Expand All @@ -85,7 +91,9 @@ def test_load_eventid_half(self):
)
g4_loaded = test_context.get_array(self.run_number, "geant4_interactions")
loaded_event_count = len(np.unique(g4_loaded["evtid"]))
assert loaded_event_count == 23, f"Expecting 23 events, but got {loaded_event_count} events"
self.assertTrue(
loaded_event_count == 23, f"Expecting 23 events, but got {loaded_event_count} events"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs0 timed out")
def test_invalid_args_0(self):
Expand All @@ -99,11 +107,8 @@ def test_invalid_args_0(self):
"entry_stop": 15,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError("entry_start >= entry_stop does not raise an exception!")

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs1 timed out")
def test_invalid_args_1(self):
Expand All @@ -117,13 +122,8 @@ def test_invalid_args_1(self):
"entry_stop": 91,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError(
"An out-of-range entry_start without cut_by_eventid does not raise an exception!"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs2 timed out")
def test_invalid_args_2(self):
Expand All @@ -137,13 +137,8 @@ def test_invalid_args_2(self):
"entry_stop": -1,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError(
"An out-of-range entry_stop without cut_by_eventid does not raise an exception!"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs3 timed out")
def test_invalid_args_3(self):
Expand All @@ -157,13 +152,8 @@ def test_invalid_args_3(self):
"entry_stop": -1,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError(
"An out-of-range entry_stop with cut_by_eventid does not raise an exception!"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs4 timed out")
def test_invalid_args_4(self):
Expand All @@ -177,13 +167,8 @@ def test_invalid_args_4(self):
"entry_stop": 103,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError(
"An out-of-range entry_start with cut_by_eventid does not raise an exception!"
)

@timeout_decorator.timeout(TIMEOUT, exception_message="InvalidArgs5 timed out")
def test_invalid_args_5(self):
Expand All @@ -197,13 +182,8 @@ def test_invalid_args_5(self):
"entry_stop": 11,
}
)
try:
with self.assertRaises(ValueError):
test_context.make(self.run_number, "geant4_interactions")
except ValueError:
return
raise RuntimeError(
"Selecting an empty eventid range with cut_by_eventid does not raise an exception!"
)


if __name__ == "__main__":
Expand Down