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

initialize zoom center even when viewer not shown #3222

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Oct 16, 2024

Description

This pull request sets the zoom center/radius traitlets as soon as the viewer is assigned back to the state to ensure they are initialized immediately rather than waiting for a zoom event when the viewer is shown on the screen. @duytnguyendtn - can you confirm if this fixes the case that you were running into?

Fixes #3217

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 4.0 milestone Oct 16, 2024
@kecnry kecnry added the no-changelog-entry-needed changelog bot directive label Oct 16, 2024
Copy link

codecov bot commented Oct 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.56%. Comparing base (7b8aeba) to head (b6de9b5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3222   +/-   ##
=======================================
  Coverage   88.56%   88.56%           
=======================================
  Files         125      125           
  Lines       18751    18754    +3     
=======================================
+ Hits        16606    16609    +3     
  Misses       2145     2145           

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

@pllim
Copy link
Contributor

pllim commented Oct 16, 2024

Thanks! Maybe turn Duy's example code into a regression test? 🤔

@kecnry
Copy link
Member Author

kecnry commented Oct 16, 2024

yep - wanted to make sure this works on top of #2872 first and see whether tests there will cover this case or whether we want a dedicated test just for this

@kecnry
Copy link
Member Author

kecnry commented Oct 16, 2024

on second thought, this can be tested on an even simpler case (confirmed to fail on main). @duytnguyendtn - if you think this will later get duplicated coverage in #2872, feel free to remove the test there when you rebase.

Comment on lines +104 to +106
assert imviz_helper.default_viewer._obj.state.zoom_center_x > 0
assert imviz_helper.default_viewer._obj.state.zoom_center_y > 0
assert imviz_helper.default_viewer._obj.state.zoom_radius > 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we be a little more specific? Maybe allclose check instead of just non-zero check?

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 intentionally left this flexible so if the zoom behavior changes this does not break except for the regression (where the values were left uninitialized at their default values). Other tests handle specific zoom-tool behavior already. But if you'd still prefer to enforce the current values, I can easily make that change.

Copy link
Collaborator

@duytnguyendtn duytnguyendtn left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix! I tested this on top of #2872 and that fixed one of the two failures that happened, but digging into it last night it seems like the two failures are two separate cases. But at least the one that was failing due to the uninitialized zoom center is now passing. Thanks!

@duytnguyendtn
Copy link
Collaborator

on second thought, this can be tested on an even simpler case (confirmed to fail on main). @duytnguyendtn - if you think this will later get duplicated coverage in #2872, feel free to remove the test there when you rebase.

While technically true the test_autocenter_coords does cover this initialization case, I would say it's incidental rather than intended. I could see value in having this test as a standalone to be clear what's failing, in the event something causes this to break. Ultimately I'll leave that to y'all about whether the extra runtime is worth it for testing clarity

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

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

Thanks!

@rosteen rosteen merged commit 2170624 into spacetelescope:main Oct 17, 2024
19 checks passed
@kecnry kecnry deleted the fix-initialize-zoom-center branch October 18, 2024 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Viewer states zoom_center_x/y do not update
4 participants