[GENIE] Add support for genie-icetray. #200
14 errors, 1 fail, 93 pass in 2m 8s
Annotations
Check warning on line 0 in tests.test_genie_weighter.TestGenieWeighter
github-actions / Test Results
All 4 runs failed: test_genie (tests.test_genie_weighter.TestGenieWeighter)
test-results-macos-13-3.12.junit.xml [took 0s]
test-results-ubuntu-22.04-3.10.junit.xml [took 0s]
test-results-ubuntu-22.04-3.11.junit.xml [took 0s]
test-results-ubuntu-22.04-3.12.junit.xml [took 0s]
Raw output
RuntimeError: GenieWeighter received an nfiles=10, but `<NONE>` was produced with genie-reader instead of genie-icetray. We expect to read the number of files from the number of observed S-frames in the file, so this is unnecessary. Do not pass in a value for nfiles for genie-reader files.
self = <test_genie_weighter.TestGenieWeighter testMethod=test_genie>
def test_genie(self):
nevents = 10000
coszen = 0.7
pdgid = 12
c1 = simweights.CircleInjector(300, 0, 1)
p1 = simweights.PowerLaw(0, 1e3, 1e4)
for event_weight in [1e-6, 1e-3, 1]:
for nfiles in [1, 5, 50]:
for include_volscale in [True, False]:
result_dtype = [("neu", np.int32), ("pzv", np.float64), ("Ev", np.float64), ("wght", np.float64)]
if include_volscale:
result_dtype.append(("volscale", np.float64))
weight = np.zeros(nevents, dtype=result_dtype)
weight["neu"] = pdgid
weight["pzv"] = coszen
weight["Ev"] = p1.ppf(np.linspace(0, 1, nevents))
weight["wght"] = event_weight
if include_volscale:
weight["volscale"] = 1
rows = nfiles * [
(
pdgid,
nevents,
1,
c1.radius,
np.arccos(c1.cos_zen_max),
np.arccos(c1.cos_zen_min),
p1.a,
p1.b,
p1.g,
),
]
info = np.array(rows, dtype=info_dtype)
d = {"I3GenieResult": weight, "I3GenieInfo": info}
for flux in [0.1, 1, 10]:
wobj = simweights.GenieWeighter(d)
w = wobj.get_weights(flux)
np.testing.assert_allclose(
w.sum(),
flux * event_weight * c1.etendue * p1.integral / nfiles,
)
E = d["I3GenieResult"]["Ev"]
y, x = np.histogram(E, weights=w, bins=51, range=[p1.a, p1.b])
Ewidth = np.ediff1d(x)
np.testing.assert_allclose(y, flux * event_weight * Ewidth * c1.etendue / nfiles, 5e-3)
with self.assertRaises(TypeError):
> simweights.GenieWeighter(d, nfiles=10)
tests/test_genie_weighter.py:81:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
# pylint: disable=invalid-name
"""Weighter for GENIE simulation.
Reads ``I3GenieInfo`` from S-Frames and ``I3GenieResult`` from Q-Frames for genie-reader files
and ``I3MCWeightDict`` and "I3GENIEResultDict" from Q-Frames for older legacy genie-icetray files.
"""
if has_table(file_obj, "I3GenieInfo"):
# Branch for newer genie-reader files
if nfiles is not None:
msg = (
f"GenieWeighter received an nfiles={nfiles}, but `{getattr(file_obj, 'filename', '<NONE>')}` "
"was produced with genie-reader instead of genie-icetray. We expect to read the number of "
"files from the number of observed S-frames in the file, so this is unnecessary. Do not pass "
"in a value for nfiles for genie-reader files."
)
> raise RuntimeError(msg)
E RuntimeError: GenieWeighter received an nfiles=10, but `<NONE>` was produced with genie-reader instead of genie-icetray. We expect to read the number of files from the number of observed S-frames in the file, so this is unnecessary. Do not pass in a value for nfiles for genie-reader files.
/opt/hostedtoolcache/Python/3.12.6/x64/lib/python3.12/site-packages/simweights/_genie_weighter.py:99: RuntimeError
github-actions / Test Results
All 2 runs with error: tests.test_corsika_datasets
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_corsika_datasets.py:18: in <module>
from simweights import CorsikaWeighter, GaisserH4a
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_corsika_weighter
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_corsika_weighter.py:12: in <module>
import simweights
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_fluxes
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_fluxes.py:14: in <module>
import simweights
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_generation_surface
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_generation_surface.py:13: in <module>
from simweights import GenerationSurface, NaturalRateCylinder, PDGCode, PowerLaw, generation_surface
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_genie_datasets
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_genie_datasets.py:18: in <module>
from simweights import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_genie_weighter
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_genie_weighter.py:11: in <module>
import simweights
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_icetop_datasets
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_icetop_datasets.py:18: in <module>
from simweights import IceTopWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_icetop_weighter
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_icetop_weighter.py:11: in <module>
import simweights
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_nugen_datasets
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_nugen_datasets.py:18: in <module>
from simweights import NuGenWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_nugen_weighter
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_nugen_weighter.py:12: in <module>
from simweights import CircleInjector, NaturalRateCylinder, NuGenWeighter, PowerLaw
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_powerlaw
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_powerlaw.py:13: in <module>
from simweights import PowerLaw
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_spatial
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_spatial.py:11: in <module>
from simweights import (
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_util
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_util.py:15: in <module>
from simweights import Hoerandel
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'
github-actions / Test Results
All 2 runs with error: tests.test_weighter
test-results-ubuntu-22.04-3.8.junit.xml [took 0s]
test-results-ubuntu-22.04-3.9.junit.xml [took 0s]
Raw output
collection failure
tests/test_weighter.py:12: in <module>
from simweights import TIG1996, NaturalRateCylinder, PowerLaw, Weighter, generation_surface
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/__init__.py:67: in <module>
from ._genie_weighter import GenieWeighter
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/simweights/_genie_weighter.py:83: in <module>
def GenieWeighter(file_obj: Any, nfiles: float | None = None) -> Weighter: # noqa: N802
E TypeError: unsupported operand type(s) for |: 'type' and 'NoneType'