-
Notifications
You must be signed in to change notification settings - Fork 76
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
generalize subset select component to handle spatial and spectral #1175
generalize subset select component to handle spatial and spectral #1175
Conversation
c70540c
to
1f31e99
Compare
1f31e99
to
76d0ba4
Compare
jdaviz/core/template_mixin.py
Outdated
subset_type="spectral").get(self.selected) | ||
subset_type = self.selected_item['type'] | ||
for viewer_id in self.app.get_viewer_ids(): | ||
match = self.app.get_subsets_from_viewer(viewer_id, |
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.
Okay, I remember now. I did what I did to aperture photometry because of this:
97d459a
to
2b9995a
Compare
Codecov Report
@@ Coverage Diff @@
## main #1175 +/- ##
==========================================
+ Coverage 77.44% 77.83% +0.39%
==========================================
Files 90 90
Lines 7079 7147 +68
==========================================
+ Hits 5482 5563 +81
+ Misses 1597 1584 -13
Continue to review full report at Codecov.
|
if subset.label not in self.labels: | ||
# NOTE: this logic will need to be revisited if generic renaming of subsets is added | ||
# see https://github.com/spacetelescope/jdaviz/pull/1175#discussion_r829372470 | ||
if subset.label.startswith('Subset'): |
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.
@@ -230,32 +302,50 @@ def _update_has_subregions(self): | |||
def labels(self): | |||
return [s['label'] for s in self.items if 'label' in s.keys()] | |||
|
|||
@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.
Do we need a way to invalidate cache if we start to allow people to rename stuff?
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.
Yes, I left a note in line ~273 that we would need to catch those events, refresh the items
list, and clear the cache (the ability to clear cache already exists, we just need to trigger it in occasions that are necessary).
# that. For imviz, this will mean we won't be able to loop through each of the viewers, | ||
# but the original viewer should have access to all the subsets. | ||
for viewer_ref in self.viewer_refs: | ||
match = self.app.get_subsets_from_viewer(viewer_ref, |
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.
Will this break for Imviz, if say, Subset 1 is "hidden" (or not shown) in imviz-0
but it is shown in imviz-1
and people are working on the latter? I remember this is a problem for get_data_from_viewer
and that is why I had to do #1096
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.
Aperture photometry still uses your logic to actually extract the object (although in the future I think it would be nice to migrate to use the logic in the new component), and the dropdown is populated by messages, not looping over layers. If you can find a reproducible case that shows an issue, let me know (although I'd argue that we should fix get_data_from_viewer
if it is failing to show items outside viewer limits or something like that... but we definitely want to avoid re-introducing broken behavior in this PR).
9164880
to
84062a7
Compare
84062a7
to
feadd75
Compare
* so that initializing a plugin after subset creation will populate the original choices and then begin listening to messages
* aperture photometry tests used to handle gracefully ignoring invalid subset names, whereas the component now raises an error * bg_subset_items is now a dictionary, the old list can be accessed with bg_subset.labels
* component will consider all viewers unless viewer_refs is passed * spectral subset mixin passes spectrum-viewer by default * will ignore programmatically created imviz viewers which are not assigned a reference, but the subsets should be available from the original viewer.
Co-authored-by: P. L. Lim <[email protected]>
feadd75
to
2610402
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 only tested the plugins touched here, and the spectral ones only on Cubeviz. Basic usage on example notebooks seem to work fine. I didn't try very hard to break them. I think this is good to go in. We can always fine tune it as needed in follow-up PRs. Very nice UI/UX improvement for spatial subsets. Thanks!
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.
Wow, that was a lot of code; kudos on ripping all that out! I tested the plugins across the viz tools and everything seems to be intact! I have a few nitpicks about a few exception wordings, but overall looks great! Happy to approve once we resolve those.
I'll also note I confirmed I can still enter a manual value to the background in the aperture photometry section (as per #1175 (comment))
Co-authored-by: Duy Tuong Nguyen <[email protected]>
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.
Thanks for applying the suggestions! I'll merge when all the tests pass
@property | ||
def viewers(self): | ||
return [self.app.get_viewer(ref) for ref in self.viewer_refs] |
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 likely the cause of #1217 - when _subset_to_dict
loops through the viewers by ref in imviz, only the original viewer has a reference. The subset still exists in the original viewer, so it is able to get the label and type, but the color must not be set when the message is received.
# NOTE: we use reference names here instead of IDs since get_subsets_from_viewer requires | ||
# that. For imviz, this will mean we won't be able to loop through each of the viewers, | ||
# but the original viewer should have access to all the subsets. | ||
for viewer_ref in self.viewer_refs: |
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.
will also need to be updated when fixing #1217
Description
This pull request extends upon #1156 to support both spatial and spectral subsets (including in the same dropdown, although we don't have any uses for that, yet). Most of this is just a generalization of logic, with a new Mixin for
SpatialSubsetSelectMixin
.For the aperture photometry plugin, the dropdowns now look like:
Although not actually in use, a mixed dropdown would look like:
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
trivial
label.CHANGES.rst
?