Skip to content

Commit

Permalink
ruff: avoid quadratic list summation
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Nov 27, 2024
1 parent 19a6947 commit 616a02a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions ampel/ztf/view/ZTFT2Tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from ampel.abstract.AbsT2Tabulator import AbsT2Tabulator
from ampel.content.DataPoint import DataPoint
from ampel.types import StockId
from ampel.util.collections import ampel_iter
from ampel.ztf.util.ZTFIdMapper import ZTFIdMapper

ZTF_BANDPASSES = {
Expand Down Expand Up @@ -89,17 +90,10 @@ def get_jd(

def get_stock_id(self, dps: Iterable[DataPoint]) -> set[StockId]:
return set(
sum(
[
list(stockid)
if isinstance(stockid := el["stock"], Sequence)
and not isinstance(stockid, str | bytes)
else [stockid]
for el in dps
if "ZTF" in el["tag"]
],
[],
)
stockid
for el in dps
if "ZTF" in el["tag"]
for stockid in ampel_iter(el["stock"])
)

def get_stock_name(self, dps: Iterable[DataPoint]) -> list[str]:
Expand Down

0 comments on commit 616a02a

Please sign in to comment.