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

Re-enable exporting cubeviz spectrum viewer #2825

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Apr 23, 2024

Description

This pull request re-enables support for exporting the cubeviz spectrum viewer (to png or svg) by temporarily "cleaning" any unicode from the marks (which currently exist for the slice indicator).

The cleaning/restoring part of this PR could be reverted if support for unicode is fixed upstream (likely in bqplot).

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

@kecnry kecnry added this to the 3.9.2 milestone Apr 23, 2024
@github-actions github-actions bot added the plugin Label for plugins common to multiple configurations label Apr 23, 2024
@kecnry kecnry force-pushed the export-cubeviz-spectrum-viewer branch from c5ddd8c to 68895ff Compare April 23, 2024 13:43
@kecnry kecnry added bug Something isn't working cubeviz 💤 backport-v3.9.x on-merge: backport to v3.9.x labels Apr 23, 2024
@kecnry kecnry marked this pull request as ready for review April 23, 2024 14:06
by removing any unicode characters and restoring after export
@kecnry kecnry force-pushed the export-cubeviz-spectrum-viewer branch from 68895ff to efd9240 Compare April 23, 2024 14:30
Copy link

codecov bot commented Apr 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.91%. Comparing base (a39a0fe) to head (929ec1e).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2825      +/-   ##
==========================================
+ Coverage   88.88%   88.91%   +0.03%     
==========================================
  Files         111      111              
  Lines       16983    16985       +2     
==========================================
+ Hits        15096    15103       +7     
+ Misses       1887     1882       -5     

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

@rosteen
Copy link
Collaborator

rosteen commented Apr 23, 2024

Looking at the resulting PNG: "oh, it's that space that was causing problems!?"

if len(getattr(mark, 'labels', [])):
restore['labels'] = mark.labels[:]
mark.labels = [lbl.strip() for lbl in mark.labels]
restores.append(restore)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we also have restore_marks and only populate the two lists if restore isn't empty, to avoid looping over things we don't need to update in the zip later?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I follow - do you mean store a copy of the original mark? I'm trying to store/restore as little as possible to minimize memory impacts. I tried to avoid the append, but there can be some copying-referencing issues if we're not careful then.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
restores.append(restore)
if restore != {}:
restores.append(restore)
restore_marks.append(mark)

Would restore_mark have a copy of the object or a reference to the original in this case? I can never keep track of when python does which, but this would avoid looping over things that don't need to be restored. If memory is an issues it can stay as-is, I honestly don't think this is going to be impactful either way here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I suspect this would be more expensive than looping over the empty dictionary, but I'm not sure. We could also track indices, but I'm not sure its worth it either 🤷‍♂️

Copy link
Collaborator

Choose a reason for hiding this comment

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

As I said, I don't feel strongly about it, I'll just approve.

Copy link
Contributor

@haticekaratay haticekaratay left a comment

Choose a reason for hiding this comment

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

Export works great! It feels the gap of unsupported Unicode in bqplot. Thanks!

@kecnry kecnry merged commit b3e32ca into spacetelescope:main Apr 24, 2024
20 checks passed
@kecnry kecnry deleted the export-cubeviz-spectrum-viewer branch April 24, 2024 14:25
meeseeksmachine pushed a commit to meeseeksmachine/jdaviz that referenced this pull request Apr 24, 2024
kecnry added a commit that referenced this pull request Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cubeviz plugin Label for plugins common to multiple configurations Ready for final review 💤 backport-v3.9.x on-merge: backport to v3.9.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants