Skip to content

Commit

Permalink
optional icetray dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Aske-Rosted committed Sep 27, 2023
1 parent 5c4260f commit 83cce2a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/graphnet/data/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
from abc import abstractmethod
from graphnet.utilities.logging import Logger
from typing import List
from icecube import icetray

from graphnet.utilities.imports import has_icecube_package

if has_icecube_package():
from icecube import icetray


class I3Filter(Logger):
"""A generic filter for I3-frames."""

@abstractmethod
def _pass_frame(self, frame: icetray.I3Frame) -> bool:
def _pass_frame(self, frame: "icetray.I3Frame") -> bool:
"""Return True if the frame passes the filter, False otherwise.
Args:
Expand All @@ -21,7 +25,7 @@ def _pass_frame(self, frame: icetray.I3Frame) -> bool:
"""
raise NotImplementedError

def __call__(self, frame: icetray.I3Frame) -> bool:
def __call__(self, frame: "icetray.I3Frame") -> bool:
"""Return True if the frame passes the filter, False otherwise.
Args:
Expand All @@ -44,7 +48,7 @@ def __call__(self, frame: icetray.I3Frame) -> bool:
class NullSplitI3Filter(I3Filter):
"""A filter that skips all null-split frames."""

def _keep_frame(self, frame: icetray.I3Frame) -> bool:
def _keep_frame(self, frame: "icetray.I3Frame") -> bool:
"""Check that frame is not a null-split frame.
returns False if the frame is a null-split frame, True otherwise.
Expand Down Expand Up @@ -76,7 +80,7 @@ def __init__(self, filter_names: List[str], filter_any: bool = True):
self._filter_names = filter_names
self._filter_any = filter_any

def _keep_frame(self, frame: icetray.I3Frame) -> bool:
def _keep_frame(self, frame: "icetray.I3Frame") -> bool:
"""Check if current frame should be kept.
Args:
Expand Down

0 comments on commit 83cce2a

Please sign in to comment.