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

FIX: round instead of truncate Agg canvas size #8265

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tacaswell
Copy link
Member

As suggested by @njsmith in #8253 round, rather than truncate the size in pixels of the Agg canvas. This fails two tests for me locally

  • test_boxarrow[0-boxarrow_test_image-png]
  • test_bbox_inches_tight_suptile_legend[0-bbox_inches_tight_suptile_legend-png]

iirc the second one is also unstable on travis. Do not have time to investigate further tonight, but regenerating two images seems like a small price to pay for making it more reliable to get renders of a fixed pixel size.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Mar 11, 2017
@@ -243,7 +243,7 @@ def get_renderer(self, cleared=None):
# Mirrors super.get_renderer, but caches the old one
# so that we can do things such as produce a diff image
# in get_diff_image
_, _, w, h = self.figure.bbox.bounds
_, _, w, h = np.round(self.figure.bbox.bounds).astype(int)
w, h = int(w), int(h)
Copy link
Member

Choose a reason for hiding this comment

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

This conversion to python int is not done in the other two backends, so presumably it is not needed here. (I see that numpy.int64 and int instances both hash to the corresponding python int.)

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.0.1 (next bug fix release) Mar 11, 2017
@tacaswell
Copy link
Member Author

I get one failure locally now:

bbox_inches_tight_suptile_legend-failed-diff

which is due to some text shifting vertically, not really sure what is going on here. The logic inside of bbox_tight is a bit confusing and hacks at the inneards of the transform stack in interesting ways.

@ngoldbaum
Copy link
Contributor

FWIW, this doesn't fix the floating point round-off issues in the animation framework that #8253 resolves. I will try to make a simple test script to attach to that issue.

@efiring
Copy link
Member

efiring commented Mar 15, 2017

@ngoldbaum, is it possible that using rounding consistently--here and in #8253, in place of int with the nextafter adjustment--would solve the problem?

@ngoldbaum
Copy link
Contributor

I don't know - all I tried was running my test yt script with this PR applied in my working copy. It failed, but it's possible there needs to be other code changes in the animation module.

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Aug 29, 2017
@jklymak
Copy link
Member

jklymak commented Jul 25, 2019

Thanks for the PR. This hasn't seen action for a long time so marking stale. Note that PRs sometimes fall through the cracks, so if this is important, please ping for more reviews.

This avoids marking the figure as stale un-necessarily.

Also remove a local variable which is immediately replaced below.
The change to rounding made these images one pixel wider
When rasterizing the figure, the allowed sizes are discrete due to a
finite dpi.  When getting the renderer (at which point we have
committed to rasterizing the figure at this dpi) feedback the actual
size.
@tacaswell
Copy link
Member Author

self.window.ClientToWindowSize(wx.Size(\nRuntimeError: wrapped C/C++ object of type FigureFrameWx has been deleted

This still needs some work and I think tweak around the short-circuit on the resize is not working quite right either.

@github-actions
Copy link

github-actions bot commented Apr 9, 2023

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@efiring
Copy link
Member

efiring commented Jun 5, 2023

It seems past time for something like this to get in; let's keep it alive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: agg status: inactive Marked by the “Stale” Github Action status: needs rebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants