Skip to content

Commit

Permalink
ruff: prune & sort imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Jan 26, 2024
1 parent e975909 commit db790d1
Show file tree
Hide file tree
Showing 58 changed files with 249 additions and 205 deletions.
5 changes: 3 additions & 2 deletions ampel/template/ZTFLegacyChannelTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
# Last Modified By: valery brinnel <[email protected]>

from typing import Any, ClassVar
from ampel.log.AmpelLogger import AmpelLogger

from ampel.config.builder.FirstPassConfig import FirstPassConfig
from ampel.template.AbsEasyChannelTemplate import AbsEasyChannelTemplate
from ampel.log.AmpelLogger import AmpelLogger
from ampel.model.ingest.T2Compute import T2Compute
from ampel.template.AbsEasyChannelTemplate import AbsEasyChannelTemplate
from ampel.ztf.ingest.ZiCompilerOptions import ZiCompilerOptions


Expand Down
2 changes: 1 addition & 1 deletion ampel/template/ZTFPeriodicSummaryT3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from collections.abc import Sequence

from ampel.template.PeriodicSummaryT3 import PeriodicSummaryT3, LoaderDirective
from ampel.template.PeriodicSummaryT3 import LoaderDirective, PeriodicSummaryT3


class ZTFPeriodicSummaryT3(PeriodicSummaryT3):
Expand Down
9 changes: 5 additions & 4 deletions ampel/template/ZTFProcessLocalAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
# Last Modified By: valery brinnel <[email protected]>

from typing import Any, Literal
from ampel.types import ChannelId

from ampel.abstract.AbsConfigMorpher import AbsConfigMorpher
from ampel.log.AmpelLogger import AmpelLogger
from ampel.model.UnitModel import UnitModel
from ampel.model.job.JobTaskModel import JobTaskModel
from ampel.model.ingest.T2Compute import T2Compute
from ampel.abstract.AbsConfigMorpher import AbsConfigMorpher
from ampel.model.job.JobTaskModel import JobTaskModel
from ampel.model.UnitModel import UnitModel
from ampel.template.AbsEasyChannelTemplate import AbsEasyChannelTemplate
from ampel.types import ChannelId


# Inheritance orders matters in this case
Expand Down
8 changes: 4 additions & 4 deletions ampel/util/Observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
# Last Modified Date: 20.08.2018
# Last Modified By: [email protected]

import logging
import time
import numpy as np

import astropy.units as u
import numpy as np
from astropy.coordinates import AltAz, EarthLocation, SkyCoord, get_moon, get_sun
from astropy.time import Time
from astropy.coordinates import SkyCoord, AltAz, EarthLocation, get_sun, get_moon

import logging

logging.basicConfig(level=logging.INFO)

Expand Down
5 changes: 2 additions & 3 deletions ampel/ztf/alert/HealpixPathSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
import healpy as hp
import numpy as np
import requests
from ampel.log import AmpelLogger
from ampel.ztf.alert.load.ZTFHealpixAlertLoader import HealpixSource
from ampel.ztf.alert.ZiHealpixAlertSupplier import ZiHealpixAlertSupplier

from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.ztf.alert.ZiHealpixAlertSupplier import ZiHealpixAlertSupplier


class HealpixPathSupplier(ZiHealpixAlertSupplier):
Expand Down
12 changes: 7 additions & 5 deletions ampel/ztf/alert/PhotoAlertPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
# Last Modified Date: 13.06.2018
# Last Modified By: mg <[email protected]>

import gzip, io, os
import numpy as np
import gzip
import io
import logging
import os

import matplotlib.dates as mdates
import matplotlib.pyplot as plt
import numpy as np
from astropy.io import fits
from astropy.time import Time
from matplotlib.colors import Normalize
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol


import logging
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol

logger = None

Expand Down
15 changes: 6 additions & 9 deletions ampel/ztf/alert/ZTFFPbotForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,26 @@

import gc
import os
import re
import sys
from hashlib import blake2b
from os.path import basename
from typing import Any, Literal, Optional, Union

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

# from appdirs import user_cache_dir
from astropy.time import Time
from bson import encode
from scipy.stats import median_abs_deviation

from ampel.alert.AmpelAlert import AmpelAlert
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.model.PlotProperties import PlotProperties
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.types import Tag
from ampel.view.ReadOnlyDict import ReadOnlyDict
from ampel.ztf.util.ZTFIdMapper import ZTFIdMapper
from ampel.ztf.util.ZTFNoisifiedIdMapper import ZTFNoisifiedIdMapper

# from appdirs import user_cache_dir
from astropy.time import Time
from bson import encode
from scipy.stats import median_abs_deviation

# Only works directly on filenames
# from bts_phot.calibrate_fps import get_baseline # type: ignore[import]

Expand Down
3 changes: 2 additions & 1 deletion ampel/ztf/alert/ZTFForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
from os.path import basename
from typing import Literal

from bson import encode

from ampel.alert.AmpelAlert import AmpelAlert
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.view.ReadOnlyDict import ReadOnlyDict
from ampel.ztf.util.ZTFIdMapper import to_ampel_id
from bson import encode

dcast = {
"sigma": float,
Expand Down
7 changes: 4 additions & 3 deletions ampel/ztf/alert/ZTFGeneralActiveAlertRegister.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
# Last Modified Date: 27.06.2022
# Last Modified By: valery brinnel <[email protected]>

from struct import pack
from typing import ClassVar, BinaryIO, Any
from collections.abc import Sequence
from struct import pack
from typing import Any, BinaryIO, ClassVar

from ampel.log.AmpelLogger import AmpelLogger
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.ztf.alert.ZTFGeneralAlertRegister import ZTFGeneralAlertRegister
from ampel.log.AmpelLogger import AmpelLogger


class ZTFGeneralActiveAlertRegister(ZTFGeneralAlertRegister):
Expand Down
7 changes: 4 additions & 3 deletions ampel/ztf/alert/ZTFGeneralAlertRegister.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
# Last Modified Date: 24.11.2021
# Last Modified By: valery brinnel <[email protected]>

from struct import pack
from typing import ClassVar, Literal, BinaryIO
from collections.abc import Generator
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from struct import pack
from typing import BinaryIO, ClassVar, Literal

from ampel.alert.reject.BaseAlertRegister import BaseAlertRegister
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.util.register import reg_iter


Expand Down
15 changes: 8 additions & 7 deletions ampel/ztf/alert/ZTFIPACForcedPhotometryAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
# Last Modified By: valery brinnel <[email protected]>

import sys
import pandas as pd
import matplotlib.pyplot as plt
from hashlib import blake2b
from os.path import basename

import matplotlib.pyplot as plt
import pandas as pd
from bson import encode
from hashlib import blake2b
from bts_phot.calibrate_fps import get_baseline # type: ignore[import]

from ampel.ztf.util.ZTFIdMapper import to_ampel_id
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.view.ReadOnlyDict import ReadOnlyDict
from ampel.alert.AmpelAlert import AmpelAlert
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.model.PlotProperties import PlotProperties, FormatModel
from ampel.model.PlotProperties import FormatModel, PlotProperties
from ampel.plot.create import create_plot_record
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.view.ReadOnlyDict import ReadOnlyDict
from ampel.ztf.util.ZTFIdMapper import to_ampel_id

dcast = {
"field": int,
Expand Down
9 changes: 5 additions & 4 deletions ampel/ztf/alert/ZiAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
# Last Modified Date: 24.11.2021
# Last Modified By: valery brinnel <[email protected]>

from typing import Literal, Any
from typing import Any, Literal

from ampel.alert.AmpelAlert import AmpelAlert
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.types import Tag
from ampel.ztf.util.ZTFIdMapper import to_ampel_id
from ampel.view.ReadOnlyDict import ReadOnlyDict
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.alert.AmpelAlert import AmpelAlert
from ampel.ztf.util.ZTFIdMapper import to_ampel_id


class ZiAlertSupplier(BaseAlertSupplier):
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/ZiHealpixAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.ztf.alert.ZiAlertSupplier import ZiAlertSupplier
from ampel.ztf.alert.load.ZTFHealpixAlertLoader import HealpixSource
from ampel.ztf.alert.ZiAlertSupplier import ZiAlertSupplier


class ZiHealpixAlertSupplier(BaseAlertSupplier):
Expand Down
2 changes: 1 addition & 1 deletion ampel/ztf/alert/ZiTaggedAlertSupplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from typing import Literal

from ampel.abstract.AbsAlertLoader import AbsAlertLoader
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.alert.BaseAlertSupplier import BaseAlertSupplier
from ampel.alert.load.DirFileNamesLoader import DirFileNamesLoader
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.ztf.alert.ZiAlertSupplier import ZiAlertSupplier


Expand Down
7 changes: 3 additions & 4 deletions ampel/ztf/alert/load/ZTFHealpixAlertLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

import backoff
import requests
from astropy.time import Time

from ampel.abstract.AbsAlertLoader import AbsAlertLoader
from ampel.base.AmpelBaseModel import AmpelBaseModel
from ampel.log.AmpelLogger import AmpelLogger
from ampel.ztf.base.ArchiveUnit import BearerAuth, BaseUrlSession
from ampel.secret.NamedSecret import NamedSecret

from astropy.time import Time
from ampel.ztf.base.ArchiveUnit import BaseUrlSession, BearerAuth


class HealpixSource(AmpelBaseModel):
Expand Down
10 changes: 5 additions & 5 deletions ampel/ztf/base/CatalogMatchFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
# Last Modified Date: 24.11.2021
# Last Modified By: Jakob van Santen <[email protected]>

from typing import Literal, Any, cast
from typing import Any, Literal, cast

from ampel.abstract.AbsAlertFilter import AbsAlertFilter
from ampel.ztf.base.CatalogMatchUnit import CatalogMatchUnit, ConeSearchRequest
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.model.operator.AnyOf import AnyOf
from ampel.model.operator.AllOf import AllOf
from ampel.base.AmpelBaseModel import AmpelBaseModel
from ampel.model.operator.AllOf import AllOf
from ampel.model.operator.AnyOf import AnyOf
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from ampel.ztf.base.CatalogMatchUnit import CatalogMatchUnit, ConeSearchRequest


class BaseCatalogMatchRequest(AmpelBaseModel):
Expand Down
6 changes: 1 addition & 5 deletions ampel/ztf/base/CatalogMatchUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@

from functools import cached_property
from typing import (
Sequence,
Dict,
Any,
Literal,
Sequence,
TypedDict,
Optional,
List,
Union,
overload,
)

Expand Down
8 changes: 7 additions & 1 deletion ampel/ztf/dev/DevAlertConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
# Last Modified By: valery brinnel <[email protected]>


import logging, time, sys, fastavro, tarfile # type: ignore[import]
import logging # type: ignore[import]
import sys
import tarfile
import time
from typing import Any

import fastavro

from ampel.alert.AmpelAlert import AmpelAlert


Expand Down
5 changes: 3 additions & 2 deletions ampel/ztf/dev/DevSkyPortalClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
import gzip
import io
from collections import defaultdict
from collections.abc import Generator, Sequence
from datetime import datetime
from typing import Any
from collections.abc import Sequence, Generator

import numpy as np
import requests
from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol
from astropy.io import fits
from astropy.time import Time
from matplotlib.colors import Normalize
from matplotlib.figure import Figure

from ampel.protocol.AmpelAlertProtocol import AmpelAlertProtocol


def render_thumbnail(cutout_data: bytes) -> bytes:
"""
Expand Down
14 changes: 8 additions & 6 deletions ampel/ztf/dev/ZTFAlert.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@
# Last Modified Date: 31.07.2020
# Last Modified By: valery brinnel <[email protected]>

import random, fastavro
from typing import Any
import random
from collections.abc import Sequence
from typing import Any

import fastavro

from ampel.alert.AmpelAlert import AmpelAlert
from ampel.content.DataPoint import DataPoint
from ampel.content.T2Document import T2Document
from ampel.model.UnitModel import UnitModel
from ampel.view.T2DocView import T2DocView
from ampel.view.LightCurve import LightCurve
from ampel.view.T2DocView import T2DocView
from ampel.view.TransientView import TransientView
from ampel.content.DataPoint import DataPoint
from ampel.content.T2Document import T2Document
from ampel.alert.AmpelAlert import AmpelAlert
from ampel.ztf.alert.ZiAlertSupplier import ZiAlertSupplier
from ampel.ztf.ingest.ZiDataPointShaper import ZiDataPointShaperBase

Expand Down
11 changes: 5 additions & 6 deletions ampel/ztf/ingest/ZiArchiveMuxer.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from functools import cached_property
from typing import Any
from collections.abc import Sequence
from typing import Any

import backoff, requests # type: ignore
from requests_toolbelt.sessions import BaseUrlSession
import backoff # type: ignore
import requests

from ampel.types import StockId
from ampel.abstract.AbsT0Muxer import AbsT0Muxer
from ampel.abstract.AbsT0Unit import AbsT0Unit
from ampel.content.DataPoint import DataPoint
from ampel.secret.NamedSecret import NamedSecret
from ampel.model.UnitModel import UnitModel
from ampel.secret.NamedSecret import NamedSecret
from ampel.types import StockId
from ampel.ztf.alert.ZiAlertSupplier import ZiAlertSupplier
from ampel.ztf.base.ArchiveUnit import ArchiveUnit
from ampel.ztf.util.ZTFIdMapper import to_ztf_id
Expand Down
1 change: 1 addition & 0 deletions ampel/ztf/ingest/ZiCompilerOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Last Modified By: valery brinnel <[email protected]>

from typing import Any

from ampel.model.ingest.CompilerOptions import CompilerOptions


Expand Down
Loading

0 comments on commit db790d1

Please sign in to comment.