Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-41049: Add matched color difference plots/metrics #156

Merged
merged 13 commits into from Apr 10, 2024
Merged

Conversation

taranu
Copy link
Contributor

@taranu taranu commented Oct 13, 2023

No description provided.

Copy link
Contributor

@natelust natelust left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are lots of random little comments, but I am happy for you to use your judgement on most of this. The only real place I would like changes, or at least explanation is where you are introducing the dict types that need changes in pex_config. I think there are other ways of doing that as I mentioned and I would rather see them done that way instead of changing pex_config.

color1_flux2 = ConfigurableActionField[VectorAction](doc="Action providing first color's second flux")
color2_flux1 = ConfigurableActionField[VectorAction](doc="Action providing second color's first flux")
color2_flux2 = ConfigurableActionField[VectorAction](doc="Action providing second color's second flux")
returnMillimags = Field[bool](doc="Use millimags or not?", default=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doc string is weirdly worded as part statement part question

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's copypasta from MagDiff which dates back to analysis_drp, but sure, now is as good a time as any to fix them.


flux_err1 = ConfigurableActionField[VectorAction](doc="Action providing error for first flux")
flux_err2 = ConfigurableActionField[VectorAction](doc="Action providing error for second flux")
returnMillimags = Field[bool](doc="Use millimags or not?", default=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

@@ -30,6 +32,11 @@
class MagnitudeScatterPlot(MagnitudeXTool):
"""A scatter plot with a magnitude on the x-axis."""

suffixes_y_finalize = ListField[str](
doc="Suffixes for y-axis keys to finalize summary stats for",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc seems to trail off

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's it... but I'll re-word it.

# ... but ScatterPlotStatsAction uses self.identity for names
# And then ScatterPlotWithTwoHists relies on self.identity
# being Stars/Galaxies
setattr(self.process.calculateActions, plural, statAction)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arn’t you going to be overwriting whatever plural is each time through the loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops... good point.

from .genericProduce import MagnitudeScatterPlot


class MatchedRefCoaddToolBase(MagnitudeXTool, ExtendednessTool):
class DictMetricAction(MetricAction):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don’t understand why you need a dictionary to store actions here, especially as it means you need to modify pex_config. Why not use ConfigurableActionStructFields? Those don’t required exact types, and they also give you the name associated with whatever the user assigned the action to. You can use .fieldNames to get the names for each Action in the struct, or use items if you want to iterate over the (name, action) pairs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general do you even need this class at all?

else:
y_any = np.concatenate([data[f"y{self._datatypes[key].suffix_xy}"] for key in self.plotTypes])
y_any = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as with X


def getInputSchema(self) -> KeyedDataSchema:
# Something is wrong with the typing for DictField key iteration
schema = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason you wanted to store a list and extend vs. yield from ? It's not wrong, you don't need to change it, I was just curious if you chose it for a reason.

actions = ConfigDictField[str, PlotAction](doc="Named plot actions")

def getInputSchema(self) -> KeyedDataSchema:
schema = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here if you choose to change

),
),

class MatchedRefCoaddDiffColorTool(MatchedRefCoaddDiffTool, MagnitudeScatterPlot):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is multiple inheritance here much better than construction with composition?

default={"u": "g", "g": "r", "r": "i", "i": "z", "z": "y"},
)

def finalize(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When finalize functions start getting this extensive, I wonder if it is not better to just define your own process or produce actions, with their own __call__ and assign those.

@taranu taranu force-pushed the tickets/DM-41049 branch 3 times, most recently from ef99026 to 56fa142 Compare April 5, 2024 03:24
@taranu taranu merged commit ebfcfad into main Apr 10, 2024
8 checks passed
@taranu taranu deleted the tickets/DM-41049 branch April 10, 2024 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants