Skip to content

Commit

Permalink
don't run icectray tests unless icetray env
Browse files Browse the repository at this point in the history
also utils test
  • Loading branch information
kjmeagher committed Jan 14, 2025
1 parent e6910da commit 555ba94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_corsika_weighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def test_old_corsika_i3file(oversampling, flux):
@pytest.mark.parametrize("oversampling", (1, 10, 100, 1000))
@pytest.mark.parametrize("n_events", (1, 10, 100))
@pytest.mark.parametrize("flux", (0.1, 1, 10))
@pytest.mark.skipif("icetray" not in globals(), reason="Not in an IceTray environment")
def test_sframe_corsika_i3files(oversampling, n_events, flux):
c1 = simweights.NaturalRateCylinder(1200, 600, 0, 1)
p1 = simweights.PowerLaw(0, 1e3, 1e4)
Expand Down Expand Up @@ -275,6 +276,7 @@ def test_sframe_corsika_i3files(oversampling, n_events, flux):
@pytest.mark.parametrize("event_weight", (1e-6, 1e-3, 1))
@pytest.mark.parametrize("nevents", (1, 5, 50))
@pytest.mark.parametrize("flux", (0.1, 1, 10))
@pytest.mark.skipif("icetray" not in globals(), reason="Not in an IceTray environment")
def test_triggered_corsika_i3file(event_weight, nevents, flux):
c1 = simweights.NaturalRateCylinder(1200, 600, 0, 1)
p1 = simweights.PowerLaw(0, 1e3, 1e4)
Expand Down
10 changes: 10 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def test_table_and_column(self):
f1 = SimpleNamespace(root=SimpleNamespace(x=t1))
t2 = {"a": np.full(10, 7), "b": np.arange(10)}
f2 = {"x": t2}
p1 = SimpleNamespace(energy=1e5, dir=SimpleNamespace(zenith=1.57))
w1 = SimpleNamespace(primary=p1)

self.assertEqual(has_table(f1, "x"), True)
self.assertEqual(has_table(f1, "y"), False)
Expand All @@ -48,8 +50,16 @@ def test_table_and_column(self):
self.assertEqual(has_column(t1, "a"), True)
self.assertEqual(has_column(t1, "b"), True)
self.assertEqual(has_column(t1, "c"), False)
self.assertEqual(has_column(p1, "energy"), True)
self.assertEqual(has_column(p1, "zenith"), True)
self.assertEqual(has_column(w1, "energy"), True)
self.assertEqual(has_column(w1, "zenith"), True)
assert_array_equal(get_column(t1, "a"), 10 * [3])
assert_array_equal(get_column(t1, "b"), 5 * [3] + 5 * [4])
assert_array_equal(get_column(p1, "energy"), [1e5])
assert_array_equal(get_column(p1, "zenith"), [1.57])
assert_array_equal(get_column(w1, "energy"), [1e5])
assert_array_equal(get_column(w1, "zenith"), [1.57])
with self.assertRaises(AttributeError):
get_column(t1, "c")

Expand Down

0 comments on commit 555ba94

Please sign in to comment.