-
Notifications
You must be signed in to change notification settings - Fork 82
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
re-usable spectral subset dropdown component with color indicator #1156
re-usable spectral subset dropdown component with color indicator #1156
Conversation
747f759
to
f009c3d
Compare
* changed from list of strings to list of dicts, the original list of strings is now accessed through the spectral_subset_labels computed property
* will need to eventually be refactored into its own mixin and may currently be subject to random order-of-operation
* with yet another mixin
* remove spectral bounds from collapse and moment maps in favor of a warning text when the selected subset contains subregions
2910898
to
889b9f0
Compare
jdaviz/core/template_mixin.py
Outdated
def selected_min(self, cube): | ||
if self.selected == "Entire Spectrum": | ||
return np.nanmin(cube.spectral_axis.value) | ||
else: | ||
return self.selected_obj.lower.value | ||
|
||
def selected_max(self, cube): | ||
if self.selected == "Entire Spectrum": | ||
return np.nanmax(cube.spectral_axis.value) | ||
else: | ||
return self.selected_obj.upper.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.
might be able to turn these into cached properties once we create another component for the data entry and have them talk to each other (so that the underlying data entry can be cached and accessed directly instead of needing to pass it to the method).
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 caching here really save anything? By the time this gets called, the whole cube is there. I think it is better to catch where you can prevent the cube from being recreated in the first place (most logically using its data label) but then you face the problem of cache invalidation. 🤷
Also, do selected_min
and selected_max
need to be two different methods? Will there be a case where you only need one but not the other? Is it better to have a selected_minmax
or selected_cube_limits
(or whatever you want to call it) that returns both at once?
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.
In this case, it probably wouldn't be a significant savings to cache, unless the cube is really large. But ease-of-caching is one thing we gain by this refactor, so I think we should use it when possible to keep ahead of optimization efforts.
I'm guessing this will get removed entirely if/when we support subsets with subregions in collapse/moment maps. Since those are the only two cases that currently use it, I have no objection to switching to a single method.
28f03bf
to
d047370
Compare
@@ -66,6 +66,8 @@ Other Changes and Additions | |||
- Redshifts imported with a custom line list are now ignored. Redshift must be set app-wide via | |||
viz.set_redshift or the line list plugin. [#1134] | |||
|
|||
- Subset selection dropdowns in plugins now show synced color indicators. [#1156] |
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 this is more of a "new feature"?
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 don't have a strong feeling either way, it just feels like too small of a change (for the user) to qualify as a "feature", but have no problem moving it if you think it belongs there?
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.
"New feature" is more visible to the user if you think users are going to be super excited about this. I'll leave it to your good judgement.
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.
Maybe we should remove :no-inheritance-diagram:
from .. automodapi:: jdaviz.core.template_mixin
because at this point, the diagram might be useful.
Is it enough for future development work to only have docstrings? Do we need more docs under https://jdaviz.readthedocs.io/en/latest/dev/index.html ? For instance, if we decide to extend this to Imviz or non-spectral subset, will someone be able to figure it out from existing doc?
I would also like Brian C. to have a look as well, in case this somehow affects MAST.
Maybe squash the commits before final review, unless you want commits like "trying to make RTD happy" to be in the history. Or we can use that "Squash and Merge" button. Up to you. 😉
jdaviz/core/template_mixin.py
Outdated
|
||
class BasePluginComponent(HubListener): | ||
""" | ||
This Base class handles attaching traitlets from the plugin itself to logic |
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 Base class handles attaching traitlets from the plugin itself to logic | |
This base class handles attaching traitlets from the plugin itself to logic |
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.
If this is eventually going to be the base class for all plugin components, it needs to be better documented.
I almost want to suggest abstract/meta class but maybe that is overengineering.
Thanks for the review/suggestions!
Probably would be useful for devs, but unlikely for users - should I include that in this PR or should we handle that separately?
Good points, I'm not sure. I think using the existing component is pretty straightforward and covered by the docstrings and existing examples. But writing other components might be a little more difficult... I just have no idea the best place/way to document that.
I see no reason that this should affect MAST, its just internal code refactoring and shouldn't touch any embedding/css, but always welcome extra reviews!
I always prefer the "squash and merge" so the individual commit history can live in the PR, but since someone else might beat me to it without squashing, I'll see if I can clean up the history to just a few commits. |
Co-authored-by: P. L. Lim <2090236+pllim@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## main #1156 +/- ##
==========================================
+ Coverage 76.17% 76.36% +0.19%
==========================================
Files 87 87
Lines 6685 6716 +31
==========================================
+ Hits 5092 5129 +37
+ Misses 1593 1587 -6
Continue to review full report at Codecov.
|
Let's remove |
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.
Overall, this works as advertised. My comments about dev docs or combining methods are suggestions and do not block merge, so I am approving. Not sure about your comment about finalizing icon, is that a Jenn question?
Thanks. Great work!
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 like the idea of using the mixins to remove some duplicated code, and I think the UI looks great! My only question would be is there anyway to cover more lines by tests? Otherwise, this is good to go! I'll leave it un-merged until after the tag-up in case anyone wants to take a look at it before it goes in.
Thanks @javerbukh - I'd like to address as many of @pllim's remaining documentation suggestions that I can first and then squash/merge if no one has other comments/suggestions by then (I also reached out to Jenn about the icon, but that can always be iterated on down the road as well). |
Sounds good to me. |
This reverts commit 5c3382e.
* and rename cube->spectrum1d to be applicable across other configs
Description
This pull request implements a color indicator in all plugin spectral subset dropdowns. In order to do so, it creates a new
SpectralSubsetSelectMxn
which applies the logic on the python side to the plugins, as well as aplugin-subset-select
vue component. If needing customization outside the defaults of the mixin (as is the case with the line analysis plugin which needs two separate subset select instances), we can create traitlets manually and attach to the plugin withself.continuum = SpectralSubsetSelect(self, 'spectral_subset_items', 'spectral_subset_selected')
. This allows us to isolate all logic for subset selection to a single place for self-consistent across plugins and minimizing code duplication. In the future, we should consider doing this for all re-used components/code in plugins as we edit them.Screen.Recording.2022-03-09.at.3.18.16.PM.mov
This also removes the spectral bounds from the moment map and collapse plugins. In its place is a warning that will show when the selected subset contains subregions that the plugin will take the full range of the region (at least until we update that behavior).
Screen.Recording.2022-03-14.at.10.18.00.AM.mov
🐱
TODO:
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
?