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

Exclude subsets from WCS-only layer filter #3097

Merged

Conversation

bmorris3
Copy link
Contributor

Description

If you create a subset in Imviz while WCS-linked, the subset appears in the Orientation plugin's "orientation in viewer" dropdown. It does not appear in the data dropdown. This is an artifact of the way that WCS-only layers are filtered in LayerSelect. I've tweaked the filter to be sure to exclude subsets.

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

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.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)? 🐱

@bmorris3 bmorris3 added this to the 3.10.3 milestone Jul 17, 2024
@bmorris3 bmorris3 force-pushed the exclude-subsets-orientation-dropdown branch from 8511b66 to 8120ebc Compare July 17, 2024 16:37
@bmorris3 bmorris3 marked this pull request as ready for review July 17, 2024 16:56
Copy link

codecov bot commented Jul 17, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.74%. Comparing base (23b3edd) to head (b13c3bc).

Files Patch % Lines
jdaviz/utils.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3097      +/-   ##
==========================================
+ Coverage   88.73%   88.74%   +0.01%     
==========================================
  Files         111      111              
  Lines       17262    17257       -5     
==========================================
- Hits        15317    15315       -2     
+ Misses       1945     1942       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jdaviz/utils.py Outdated
Comment on lines 256 to 251
return (
# WCS-only layers have a metadata label:
getattr(state, 'meta', {}).get(_wcs_only_label, False) and

# the above logic doesn't exclude 100% of subsets, so here we
# ensure that no subsets make it through the filter:
not is_subset
)
Copy link
Member

Choose a reason for hiding this comment

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

wait, so subset.state.meta['_WCS_ONLY'] is sometimes set and True? 🤔

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 tried to simplify this whole function, but there were corner cases that got messy. The layers that get passed through LayerSelect can have the following attributes: data, layer, or meta:

jdaviz/jdaviz/utils.py

Lines 244 to 252 in 23b3edd

# exclude WCS-only layers from the layer choices:
if hasattr(layer, 'layer'):
state = layer.layer
elif hasattr(layer, 'data'):
state = layer.data
elif hasattr(layer, 'meta'):
state = layer
else:
raise NotImplementedError

In the case where the layer is a subset, layer.data corresponds to the subset's parent Data, which itself may have a meta['_WCS_ONLY']. That's where the second check is necessary.

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'm experimenting right now to see if this works without the second elif. 🤞🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Phew, much simplified in b13c3bc.

@bmorris3 bmorris3 force-pushed the exclude-subsets-orientation-dropdown branch from 8120ebc to b13c3bc Compare July 17, 2024 17:47
@bmorris3 bmorris3 merged commit 4fe79a9 into spacetelescope:main Jul 17, 2024
17 of 19 checks passed
@bmorris3
Copy link
Contributor Author

Sorry, I merged this before two approvals without first labeling as trivial. If anyone disagrees, I can revert or follow up with another PR.

bmorris3 added a commit to bmorris3/jdaviz that referenced this pull request Jul 18, 2024
bmorris3 added a commit to bmorris3/jdaviz that referenced this pull request Jul 18, 2024
@pllim pllim added backport-v3.10.x on-merge: backport to v3.10.x bug Something isn't working and removed Still Needs Manual Backport labels Jul 18, 2024
bmorris3 added a commit that referenced this pull request Jul 19, 2024
Backport PR #3097: Exclude subsets from WCS-only layer filter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v3.10.x on-merge: backport to v3.10.x bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants