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

Add test that triggers handle_display_units bug #2910

Merged
merged 17 commits into from
Jun 18, 2024

Conversation

javerbukh
Copy link
Contributor

Description

This pull request is to address a bug that exists on main but was made more apparent by #2873 . Currently there is just a couple lines in the unit conversion test that triggers this in CI, but the traceback can also be seen by running the following lines in the cubeviz example notebook after data has been loaded:

uc = cubeviz.plugins['Unit Conversion']._obj
la = cubeviz.plugins['Line Analysis']
la.open_in_tray()
uc.show_translator = True
uc.flux_or_sb.selected = 'Flux'

and in a new cell after the Line Analysis plugin has opened and the continuum is visible:
la.get_results()

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

@github-actions github-actions bot added specviz plugin Label for plugins common to multiple configurations labels Jun 5, 2024
@javerbukh javerbukh added this to the 4.0 milestone Jun 5, 2024
@javerbukh javerbukh marked this pull request as draft June 5, 2024 14:02
@javerbukh javerbukh marked this pull request as draft June 5, 2024 14:02
Copy link

codecov bot commented Jun 5, 2024

Codecov Report

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

Project coverage is 88.77%. Comparing base (1733f43) to head (87b1a8a).
Report is 7 commits behind head on main.

Files Patch % Lines
jdaviz/core/helpers.py 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2910      +/-   ##
==========================================
+ Coverage   88.76%   88.77%   +0.01%     
==========================================
  Files         111      111              
  Lines       17178    17194      +16     
==========================================
+ Hits        15248    15264      +16     
  Misses       1930     1930              

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

@javerbukh javerbukh marked this pull request as ready for review June 11, 2024 14:43
Copy link
Contributor

@gibsongreen gibsongreen left a comment

Choose a reason for hiding this comment

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

This looks good to me, will be very nice to have the changes at the helper level. Great work!

@@ -109,72 +109,76 @@ def to_unit(self, data, cid, values, original_units, target_units):
spec = data.get_object(cls=Spectrum1D)

except RuntimeError:
eqv = []
data = data.get_object(cls=NDDataArray)
spec = Spectrum1D(flux=data.data * u.Unit(original_units))
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we pass along the attributes for spectral axis, meta, or WCS, too? There are places within the methods below that call Spectrum1D's spectral_axis and meta, so we might need to make sure those get passed in here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What value should I pass for the spectral_axis parameter? Otherwise yes that makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good question. We could pull it out of the wcs by getting out the spectral component of the coordinates, and evaluate it on the integer pixel grid.

Copy link
Contributor

Choose a reason for hiding this comment

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

BUT I'm pretty sure if you give Spectrum1D the WCS without separately specifying spectral axis, it will do that parsing for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding the wcs did not work for me, would you be ok with me creating a follow-up ticket for roundtripping all relevant information? I would like to get this in soon so I can finish with #2873 and have this available for the aperture photometry work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure thing 💯

jdaviz/app.py Outdated Show resolved Hide resolved
jdaviz/app.py Outdated Show resolved Hide resolved
jdaviz/app.py Outdated Show resolved Hide resolved
Comment on lines +347 to +355
# TODO: Failing because of dev version of upstream dependency, figure
# out which one
# assert mm.calculate_moment()

# TODO: This test should pass once continuum subtraction works with
# flux to surface brightness conversion
# mm.continuum.selected = 'Surrounding'
#
# assert mm.calculate_moment()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests will need to be uncommented when we make the unit conversion translator available to users. Otherwise, this PR is ready for a re-review @bmorris3 .

Copy link
Contributor

@bmorris3 bmorris3 left a comment

Choose a reason for hiding this comment

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

This looks great. Please add a changelog entry and you're good to go.

@javerbukh javerbukh merged commit a1d9682 into spacetelescope:main Jun 18, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Label for plugins common to multiple configurations specviz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants