Skip to content

Commit d0d3bee

Browse files
committed
Use per-plotAction key/suffix in StructPlotAction
1 parent 1b10d8f commit d0d3bee

2 files changed

Lines changed: 12 additions & 8 deletions

File tree

python/lsst/analysis/tools/atools/genericPlotAction.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ def getInputSchema(self) -> KeyedDataSchema:
3939
for action in self.actions:
4040
yield from action.getInputSchema()
4141

42+
def getPlotType(self) -> str:
43+
return ""
44+
4245
def getOutputNames(self, config: Config | None = None) -> Iterable[str]:
43-
names = []
4446
for key, action in self.actions.items():
4547
names_action = action.getOutputNames(config=config)
4648
if not names_action:
4749
names_action = [key]
48-
names.extend(names_action)
49-
return tuple(names)
50+
for name in names_action:
51+
yield f"{name}_{action.getPlotType()}"
5052

5153
def __call__(self, data: KeyedData, **kwargs) -> PlotResultType:
5254
results = {}
5355
for key, action in self.actions.items():
54-
result = action(data=data, **kwargs)
55-
results[key] = result
56+
results[f"{key}_{action.getPlotType()}"] = action(data=data, **kwargs)
5657
return results

python/lsst/analysis/tools/interfaces/_analysisTools.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,22 @@ def _process_single_results(
215215
results: Mapping[str, PlotTypes] | PlotTypes | Mapping[str, Measurement] | Measurement | JointResults,
216216
) -> KeyedResults:
217217
accumulation = {}
218-
suffix = self._getPlotType()
219218
predicate = f"{self.identity}" if self.identity else ""
220219
match results:
221220
case Mapping():
221+
suffix = self._getPlotType()
222222
for key, value in results.items():
223223
match value:
224-
case PlotTypes():
225-
iterable = (predicate, key, suffix)
226224
case Measurement():
227225
iterable = (predicate, key)
226+
case PlotTypes():
227+
iterable = (predicate, key, suffix)
228+
case _:
229+
raise RuntimeError(f"Unexpected {key=}, {value=} from:\n{self=}")
228230
refKey = "_".join(x for x in iterable if x)
229231
accumulation[refKey] = value
230232
case PlotTypes():
233+
suffix = self._getPlotType()
231234
refKey = "_".join(x for x in (predicate, suffix) if x)
232235
accumulation[refKey] = results
233236
case Measurement():

0 commit comments

Comments
 (0)