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-35621: Add matched-to-reference table plots and metrics #17
Conversation
0778ec5
to
5379f8d
Compare
5379f8d
to
23be579
Compare
02fceff
to
8fdd630
Compare
d46b7d5
to
4624524
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this mostly looks good, but I have some concerns in places.
|
||
class ScatterPlotStatsAction(KeyedDataAction): | ||
vectorKey = Field[str](doc="Vector on which to compute statistics") | ||
highSNSelector = ConfigurableActionField[VectorAction]( | ||
highSNSelector = ConfigurableActionField[SnSelector]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do this, it means no other actions (that are not subclasses of SnSelector) could ever be assigned to this field, I am not sure we are ready to declare that that is an interface vs an implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I'm also a bit on the fence between worrying that leaving it as a VectorAction
is a trap (and it being named SNSelector
implies that it was intended as an interface), and acknowledging that someone may implement an alternative to SNSelector
. But they could just change the typing in the latter case, no?
doc="Selector used to determine high SN Objects", default=SnSelector(threshold=2700) | ||
) | ||
lowSNSelector = ConfigurableActionField[VectorAction]( | ||
lowSNSelector = ConfigurableActionField[SnSelector]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same, but I am happy to have a discussion on it.
@@ -125,25 +82,35 @@ def getOutputSchema(self) -> KeyedDataSchema: | |||
|
|||
def __call__(self, data: KeyedData, **kwargs) -> KeyedData: | |||
results = {} | |||
highMaskKey = f'{self.identity or ""}HighSNMask' | |||
highMaskKey = f'{self.identity.lower() or ""}HighSNMask' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you add this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually added it in DM-35818 (the ticket I split off with various fixes, mainly for scatter plot). Without it, my tasks fail with ValueError: Task needs keys {'galaxiesHighSNMask', 'galaxiesLowSNMask', 'starsHighSNMask', 'starsLowSNMask'} but they were not found in input
. So presumably self.identity is capitalized but the keys are not.
("range_minimum", Scalar), | ||
) | ||
|
||
@cached_property |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you want a cached_property
as these fields are configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. It works as is, because these are meant to be frozen configs, no? Although I suppose that's not enforced as it is elsewhere with Tasks, etc.
class CalcBinnedStatsAction(KeyedDataAction): | ||
name_prefix = Field[str](doc="Field name to append stat names to", default="") | ||
name_suffix = Field[str](doc="Field name to append to stat names", default="") | ||
rangeSelector = ConfigurableActionField[RangeSelector](doc="Range selector") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to highlight, this will restrict this field to only work with RangeSelector or a subclass there of
@@ -61,6 +61,16 @@ def __call__(self, data: KeyedData, **kwargs) -> Scalar: | |||
) | |||
|
|||
|
|||
class ConstantAction(ScalarAction): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just for tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding more doc string would be useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it just so there was a scalar equivalent to the vector one, but I don't actually use it, no. I can just remove it.
@@ -145,6 +144,18 @@ def __call__(self, data: KeyedData, **kwargs) -> Vector: | |||
return np.array(cast(Vector, result)) | |||
|
|||
|
|||
class ConstantValue(VectorAction): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is easy to get confused with the Scalar one. Additionally, do we need it? Or would it be better to defer to a Vector action that can run generic Scalar ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do need it, yes, but if you think it can be replaced with a generic scalar-to-vector action, that's fine by me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In KeyedDataActions
we have KeyedScalars
that does something similar. I think in the spirit of analysis tools where composition is prime focus, maybe a generic VectorAction
that turns a ScalarAction
into a vector would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, well I'm open to adding that if there's at least one more use case, but since I didn't use the ConstantAction
and decided to get rid of it entirely, I'd rather wait until there's a more pressing need to introduce that kind of generic scalar-to-vector action.
|
||
names = ("stars", "galaxies", "all") | ||
types = ("unresolved", "resolved", "all") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this things a getInputSchema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort of? It also returns values that are units, not just the keys, and takes mandatory args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 . That said, even though it will not break now, it is supposed to have a getInputSchema method, perhaps you can make one deffer to the other in some way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you suggested offline, there is a default getInputSchema and it seems to work fine in the new unit tests, so there's no need to override it (yet).
|
||
class MatchedRefCoaddPositionPlot(MatchedRefCoaddCModelPlot, MatchedRefCoaddDiffPositionTool): | ||
def matchedRefDiffContext(self): | ||
super(MatchedRefCoaddPositionPlot, self).matchedRefDiffContext() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you using parameterized version of super?
class DiffMatchedAnalysisConnections( | ||
AnalysisBaseConnections, | ||
dimensions=("skymap", "tract"), | ||
defaultTemplates={"inputName": "diff_matched_truth_summary_objectTable_tract"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did InputName get changed to something else while I have been sitting on this ticket review?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... I don't think so? I'm not sure what you mean.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7dd41ae
to
6e8c091
Compare
58dad02
to
3b35222
Compare
59ada8b
to
7aec3bf
Compare
7aec3bf
to
81277b6
Compare
No description provided.