-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
prevent spectral lines from converting y-range #3242
prevent spectral lines from converting y-range #3242
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3242 +/- ##
=======================================
Coverage 88.63% 88.63%
=======================================
Files 125 125
Lines 18779 18782 +3
=======================================
+ Hits 16644 16647 +3
Misses 2135 2135 ☔ View full report in Codecov by Sentry. |
jdaviz/core/marks.py
Outdated
@@ -244,6 +244,11 @@ def set_x_unit(self, unit=None): | |||
super().set_x_unit(unit=unit) | |||
self._rest_value = (self._rest_value * prev_unit).to_value(unit, u.spectral()) | |||
|
|||
def set_y_unit(self, unit=None): | |||
# prevent spectral lines from entering unit conversion machinery so they maintain | |||
# their position in the viewer at the rest + redshifted spectral value |
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 a regression test possible? I guess you can check marker values? 🤷♀️
Does this need a bug fix change log?
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.
For a regression test, the y-value range of the mark for the line will always be [0, 1]
with this change so I don't think it is possible here.
There was a mention of backporting in tagup for this PR, I think it would be for v4.0.x but wasn't certain. I will add it 4.0.1 change log now.
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 you think it would be possible for PluginMark._on_global_display_unit_changed
to check for LinearScale(0, 1)
and skip the call to getattr(self, f'set_{axis}_unit')(msg.unit)
if so? That way this can be applied in general across all marks (it looks now like the slice indicator handles this manually by overriding _on_global_display_unit_changed
- maybe that could be removed as well then).
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.
Functionality was maintained with this change and the update to no longer override for the slice indicator also works!
jdaviz/core/marks.py
Outdated
# Updating the value is handled by the plugin itself, need to update unit string. | ||
if msg.axis in ["spectral", "x"]: | ||
self.xunit = msg.unit | ||
self._update_label() |
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.
the _update_label
may still be necessary to change the units in the label, but the rest probably can now be replaced with super()._on_global_display_unit_changed(msg)
. Sorry for missing that!
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'll double check this now
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'm seeing that the values for LinearScale and the slice indicator are not (0, 1). I can alter it to just test for LinearScale but I will need to check if there are an adverse affects from this.
If I do alter this and include this change, the label value updates but the unit does not on the slice indicator (which should be feasible to update but is proving to be a bit tricky).
A note that if the _global_display_unit_changed
is not altered for SliceIndicator
, there is no need for the LinearScale in this comment and everything functions as expected.
…rScale(0,1), remove slice override to also use it
ea224d9
to
e7190ae
Compare
Description
This pull request is to address line lists and unit conversion compatibility. On main, line marks go through conversion machinery and can cause lines to vanish from the spectrum-viewer depending on the original unit and target unit (are not visible even at updated y-range for line after conversion). This PR prevents SpectralLines from y-converting so they maintain their position in the viewer at the rest + redshifted spectral value.
Change log entry
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, maintainershould 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.
trivial
label.