-
Notifications
You must be signed in to change notification settings - Fork 75
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
Imviz: Add zoom and zoom_level API #744
Conversation
912923b
to
ced8ee0
Compare
ced8ee0
to
a39b66a
Compare
Codecov Report
@@ Coverage Diff @@
## main #744 +/- ##
==========================================
+ Coverage 63.00% 63.09% +0.08%
==========================================
Files 65 65
Lines 4290 4319 +29
==========================================
+ Hits 2703 2725 +22
- Misses 1587 1594 +7
Continue to review full report at Codecov.
|
fa852b0
to
d3c7f37
Compare
|
||
# NOTE: Not sure why X/Y min/max not exactly the same as aspect ratio 1 | ||
self.imviz.zoom_level = 1 | ||
self.assert_zoom_results(1, -46, 54, -45.5, 54.5, dpix) |
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.
Does seem weird some x/y min/max not matching exactly for square data and display at aspect ratio one, but that adjustment is deep within glue core and I don't feel like digging no more. If @astrofrog has ideas, then great. Otherwise, I'll just leave it be.
# in the unit test when off-center. Works in notebook though. | ||
if not is_offcenter: | ||
self.imviz.zoom_level = 'fit' | ||
self.assert_zoom_results(10, -0.5, 9.5, -0.5, 9.5, 0) |
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 the off-center case, local testing showed that y_min
and y_max
was -5. , 5.
instead of -0.5, 9.5
like X. Something not triggering here in the way I set up or hack around the viewer for unit testing. I swear to you it works properly in a notebook. If @astrofrog has ideas, then great. If not, I'll just leave this untested for the off-center case.
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.
Made one change request, although I haven't been part of the astrowidgets API discussion so maybe there was a reason for not making zoom
have the input option I suggested there. Other than that I think this looks good - I don't have any insight into why your test cases are weird for Y, but it seems to be working as I would expect in the notebook.
""" | ||
if not isinstance(val, (int, float)): | ||
raise ValueError(f"zoom only accepts int or float but got '{val}'") | ||
self.zoom_level = self.zoom_level * val |
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 simply a method to set the zoom_level
, it would would be nice to accept "fit" as input here as well as when setting zoom_level
directly. That was one of the first things I tried and I was surprised that it didn't 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.
That would go against the current astrowidgets
API upstream though...
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.
zoom()
was supposed to be relative zoom, so "fit" does not really fit (pun?) in that paradigm.
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.
Ah I see, that's the context I was missing, I guess. I didn't fully appreciate that zoom_level
is setting the absolute zoom relative to the image, whereas zoom
is setting the zoom relative to the current display.
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 can't blame you. I didn't either until astropy/astrowidgets#144
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.
Approving this as "successfully implements the current Astrowidgets API". I can take any gripes with how that API works to astrowidgets directly...
Re: gripes -- Will be happy to get your feedback over at astropy/astrowidgets#142 ❗ |
I didn't hear any crying or objections during sprint review. Does that mean we can merge this? |
I think I consider a live demo with general approval as a second thumbs up. Merging. |
Fix #715
TODO
viewer.shape