jdaviz
jdaviz copied to clipboard
feat: allow exporting of figures in a custom resolution
Description
This will clone a viewer and display it (invisibly) at a custom resolution.
I am opening this as a draft, because it still requires a few fixes:
- [ ] A UI to change the resolution
- [x] A working _clone_viewer
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 toCHANGES.rstbefore merge. If no, maintainer should add ano-changelog-entry-neededlabel.
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
triviallabel. - [ ] 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)?
@astrofrog or @kecnry Do you know a good way to clone a viewer, I was expecting this to work, but it does not, maybe you know why?
import glue_jupyter as gj
points = gj.example_data_xyz(loc=60, scale=30, N=10*1000)
app = gj.jglue(points=points)
s = app.scatter2d(x='x', y='y')
def _clone_viewer(self):
new_viewer = type(self)(session=app.session)
d = self.state.as_dict()
new_viewer.state.update_from_dict(d)
for this_layer_state, new_layer_state in zip(self.state.layers, new_viewer.state.layers):
new_layer_state.update_from_dict(this_layer_state.as_dict())
return new_viewer
s_clone = _clone_viewer(s)
s_clone.figure
Codecov Report
Attention: Patch coverage is 28.81356% with 42 lines in your changes missing coverage. Please review.
Project coverage is 87.68%. Comparing base (
cf27560) to head (67c9339). Report is 12 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| jdaviz/configs/default/plugins/export/export.py | 32.65% | 33 Missing :warning: |
| jdaviz/configs/default/plugins/viewers.py | 10.00% | 9 Missing :warning: |
:x: Your patch check has failed because the patch coverage (28.81%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.
Additional details and impacted files
@@ Coverage Diff @@
## main #3478 +/- ##
==========================================
- Coverage 87.81% 87.68% -0.14%
==========================================
Files 152 156 +4
Lines 20742 20949 +207
==========================================
+ Hits 18215 18369 +154
- Misses 2527 2580 +53
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
calling layer.update was needed for cloning of the viewer.
I see this output in the console log, but no file actually seems to get saved to disk:
Html(children=[Html(children=[Figure(axes=[Axis(grid_lines='none', label='Offset1', scale=LinearScale(allow_pa…
I think that happens when the callback isn't successful, I used to see that but then fixed a bug and don't anymore. Can you try adding some debug statements to see if the callback is running and, if not, where its failing?
Could it be because you never actually call get_png in _show_hidden on the hidden figure widget?
Actually I see that's in on_figure_displayed, still slightly suspicious of the logic 🤔
Edit: I checked the snackbar messages, I do see a success message [8:43:17]: Exported to /Users/rosteen/flux-viewer-test.png