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-35621: Add matched-to-reference table plots and metrics #17

Merged
merged 5 commits into from Oct 28, 2022

Conversation

taranu
Copy link
Contributor

@taranu taranu commented Jul 22, 2022

No description provided.

@taranu taranu force-pushed the tickets/DM-35621 branch 6 times, most recently from 0778ec5 to 5379f8d Compare July 28, 2022 16:32
@taranu taranu force-pushed the tickets/DM-35621 branch 3 times, most recently from 02fceff to 8fdd630 Compare August 17, 2022 17:55
@taranu taranu force-pushed the tickets/DM-35621 branch 7 times, most recently from d46b7d5 to 4624524 Compare September 26, 2022 17:23
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.

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](
Copy link
Contributor

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.

Copy link
Contributor Author

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](
Copy link
Contributor

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'
Copy link
Contributor

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?

Copy link
Contributor Author

@taranu taranu Oct 5, 2022

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
Copy link
Contributor

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

Copy link
Contributor Author

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")
Copy link
Contributor

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):
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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):
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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")

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 things a getInputSchema

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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()
Copy link
Contributor

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"},
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@taranu taranu force-pushed the tickets/DM-35621 branch 2 times, most recently from 7dd41ae to 6e8c091 Compare October 6, 2022 18:14
@taranu taranu force-pushed the tickets/DM-35621 branch 3 times, most recently from 58dad02 to 3b35222 Compare October 17, 2022 15:11
@taranu taranu force-pushed the tickets/DM-35621 branch 3 times, most recently from 59ada8b to 7aec3bf Compare October 27, 2022 03:04
@taranu taranu merged commit 0fae88a into main Oct 28, 2022
@taranu taranu deleted the tickets/DM-35621 branch October 28, 2022 15:34
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