Skip to content

Commit

Permalink
decrease diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
ric-evans committed Oct 28, 2024
1 parent 695019e commit 2407c9d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 21 deletions.
15 changes: 8 additions & 7 deletions skymap_scanner/recos/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# mypy: ignore-errors
# fmt: off

from abc import ABC, abstractmethod
import importlib
import pkgutil
from abc import ABC, abstractmethod
from typing import Any, List, TYPE_CHECKING, Tuple, Union
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union

if TYPE_CHECKING: # https://stackoverflow.com/a/65265627
from ..utils.pixel_classes import RecoPixelVariation
Expand All @@ -17,8 +17,8 @@
try: # these are only used for typehints, so mock imports are fine
from icecube.dataclasses import I3Position # type: ignore[import]
from icecube.icetray import I3Frame # type: ignore[import]
from icecube import astro # type: ignore[import]
except ImportError: # type: ignore[import]
from icecube import astro # type: ignore[import]
except ImportError: # type: ignore[import]
I3Position = Any
I3Frame = Any

Expand Down Expand Up @@ -88,7 +88,7 @@ def traysegment(self, tray, name, logger, **kwargs: Any) -> None:
@staticmethod
@abstractmethod
def to_recopixelvariation(
frame: I3Frame, geometry: I3Frame
frame: I3Frame, geometry: I3Frame
) -> "RecoPixelVariation":
raise NotImplementedError()

Expand Down Expand Up @@ -123,9 +123,10 @@ def get_reco_spline_requirements(name: str) -> List[str]:
raise UnsupportedRecoAlgoException(name) from e
raise # something when wrong AFTER accessing sub-module


def set_pointing_ra_dec(
particle_name_possibilities: Union[List[str], None],
p_frame: I3Frame
particle_name_possibilities: Union[List[str], None],
p_frame: I3Frame
) -> Union[Tuple[float, float], None]:
"""Retrieves the direction for a pointed scan"""
pointing_ra_dec = None
Expand Down
7 changes: 5 additions & 2 deletions skymap_scanner/recos/crash_dummy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""IceTray segment for a dummy reco (will crash w/in a given probability)."""

import os
import random
import time
from typing import Final
Expand All @@ -21,9 +22,11 @@ def traysegment(tray, name, logger, **kwargs):

def crash(frame):
rand = random.random()
logger.debug(f"crash probability: {ENV.SKYSCAN_CRASH_DUMMY_PROBABILITY=}")
logger.debug(
f"crash probability: {os.getenv('SKYSCAN_CRASH_DUMMY_PROBABILITY')}"
)

if rand < ENV.SKYSCAN_CRASH_DUMMY_PROBABILITY:
if rand < float(os.getenv("SKYSCAN_CRASH_DUMMY_PROBABILITY")):
logger.debug(f"crash! {rand=}")

# now, pick what to fail with
Expand Down
36 changes: 27 additions & 9 deletions skymap_scanner/recos/splinempe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,40 @@
# fmt: off

import datetime
from typing import Final

import numpy as np
from typing import Final, List


from icecube.icetray import I3Units # type: ignore[import]

# NOTE: icecube module imports are required to make IceTray modules and services available.
from icecube import (dataclasses) # type: ignore[import] # noqa: F401
from icecube.STTools.seededRT.configuration_services import \
I3DOMLinkSeededRTConfigurationService # type: ignore[import]
from icecube import ( # type: ignore[import] # noqa: F401
dataclasses,
DomTools,
frame_object_diff,
gulliver,
gulliver_modules,
icetray,
lilliput,
mue,
spline_reco,
photonics_service,
recclasses,
simclasses,
STTools,
VHESelfVeto,
)

# Class bindings directly accessed by the python code are imported explicitly.
from icecube.icetray import I3Frame, I3Units, traysegment # type: ignore[import]; type: ignore[import]
from icecube.lilliput import i3minuit, scipymin # type: ignore[import]
from icecube.icetray import I3Frame, traysegment # type: ignore[import]
from icecube.lilliput import scipymin, i3minuit # type: ignore[import]
from icecube.photonics_service import I3PhotoSplineService # type: ignore[import]
from icecube.STTools.seededRT.configuration_services import I3DOMLinkSeededRTConfigurationService # type: ignore[import]

from . import RecoInterface, VertexGenerator
from .common.pulse_proc import mask_deepcore
from .. import config as cfg
from ..utils.pixel_classes import RecoPixelVariation
from . import RecoInterface, VertexGenerator
from .common.pulse_proc import mask_deepcore


class SplineMPE(RecoInterface):
Expand Down
4 changes: 2 additions & 2 deletions skymap_scanner/recos/splinempe_pointed.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

from typing import Final

from . import RecoInterface, splinempe

from . import splinempe
from . import RecoInterface

class SplineMPEPointed(splinempe.SplineMPE):

Expand Down
3 changes: 2 additions & 1 deletion skymap_scanner/utils/pixel_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import time
from typing import Any, Dict, Tuple

from .. import config as cfg, recos
from .. import config as cfg
from .. import recos

try: # these are only used for typehints, so mock imports are fine
from icecube.dataclasses import I3Position # type: ignore[import]
Expand Down

0 comments on commit 2407c9d

Please sign in to comment.