| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Any chance this fixes, or you understand it enough to fix, #7491? |
Sorry, something went wrong.
|
Apparently we do need to squash the angles in both code paths. |
Sorry, something went wrong.
|
I adjusted the tests and squashed this down to one commit. |
Sorry, something went wrong.
|
On closer inspection, this test is not testing what I thought it was. Will work up a new test (and rebase). |
Sorry, something went wrong.
|
This is ready for review again and very different that the original version. The new test should be more understandable as well. I am still not sure that the threshold for switching to the "big path" logic is right, but it is possible I am confused about how it should work. |
Sorry, something went wrong.
|
https://github.com/matplotlib/matplotlib/blob/ce9bade034cc09e3fb49d7d12fc83aa36c557cdb/lib/matplotlib/patches.py is I think the reference to look at when trying to understand this code. |
Sorry, something went wrong.
|
If I force it to always run through the "small" code path this is how the new test fails: so it is doing something, but I could not find a regime where it is visually different. |
Sorry, something went wrong.
|
Looking at the paper, for a 4-spline, it said:
and since 8-spline is 1e-6 (or 1000 times smaller), it makes sense that we need a circle of such a large radius in order to see something with only about a pixel difference. |
Sorry, something went wrong.
There was a problem hiding this comment.
Not 100% on the tests, but the change seems right, individually.
Sorry, something went wrong.
| ax2.set_xlim(-25000, 18000) | ||
| ax2.set_ylim(-20000, 6600) |
There was a problem hiding this comment.
Is this still the right trigger?
Sorry, something went wrong.
There was a problem hiding this comment.
The second axis is trying to hit the "small" path which this does. These numbers could be made much smaller now that we have fixed the quadratic growth issue.
Sorry, something went wrong.
The draw method of mpatches.Arc has two paths: - if the arc is "small" compared to its size in the rendered image then render the whole arc and let clipping do it's thing - if the arc is "big" compared to its size on the screen then sort out where the circle intersects the axes boundary and only draw that part of it This makes several changes to the Arc draw method: - make sure that we keep angles in [0, 360) range - only go through the angle stretching code if we need to (to avoid numerical instability of angles not round-tripping with scale=1) - compute length, not offset from origin of width / height and use the correct transform. Previously we were effectively squaring the height and width Tests: - Adjusted an existing test image to use this failing case and to exercise both code paths. - Added a test function of ensuring we can draw a big arc in each quadrant
The previous commit removed a quadratic scaling when deciding which path we should go through. The quadratic scaling made us kick into the high-resolution code path too soon. We now no longer go through the high-resolution code path in this test which changes the curves slightly due to using different control points.
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
| # if we need to stretch the angles because we are distorted | ||
| width != height | ||
| # and we are not doing a full circle | ||
| and not (theta1 != theta2 and theta1 % 360 == theta2 % 360) |
There was a problem hiding this comment.
probably needs a comment, IIRC you do this because theta1 and theta2 may not match anymore after stretching? (i.e. why can't you just always stretch)
Sorry, something went wrong.
There was a problem hiding this comment.
can you instead first take everything mod 360 and then always stretch?
Sorry, something went wrong.
There was a problem hiding this comment.
I tried that and it did not work, as 0%360 == 360%360. I guess we could keep track of if theta1 == theta2 up front and then add back 360 if they were? I don't think we want to special case theta1 == theta2 as input to mean "full circle" not "no arc".
Sorry, something went wrong.
|
why did arc_angles.png change? |
Sorry, something went wrong.
|
Because this fixes a bug where we triggered the "big arc" path too soon in many cases (we were checking if r**2 > thresh not r > thresh) so that test is now all in the "small arc" regime. |
Sorry, something went wrong.
|
Is that really r**2 vs r? I don't see where in the code... |
Sorry, something went wrong.
|
get_transform scaled (1,1) to (width/2, height/2), so inputting (width, height) scales to (width**2/2, height**2/2), hence the switch to get_data_transform 'unsquares' the threshold. |
Sorry, something went wrong.
|
@QuLogic beat me to posting, but link to where the transform is set up: matplotlib/lib/matplotlib/patches.py Lines 1398 to 1414 in 7f298e1 |
Sorry, something went wrong.
|
I'm going to make an executive decision and self-merge this with one review.
|
Sorry, something went wrong.
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
$ git checkout v3.2.x $ git pull
$ git cherry-pick -m1 31e26cc73918ff20c44af8cb1d59256e67df996d
$ git commit -am 'Backport PR #17564: FIX: correctly handle large arcs'
git push YOURFORK v3.2.x:auto-backport-of-pr-17564-on-v3.2.x
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
Sorry, something went wrong.
Merge pull request matplotlib#17564 from tacaswell/fix_big_arc FIX: big arc code path Conflicts: lib/matplotlib/patches.py - implicitly backport a change from matplotlib#15356 (from `- trans ` -> `+ trans.inverted()`)
There was a problem hiding this comment.
Retrospectively approving :)
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
The draw method of mpatches.Arc has two paths:
then render the whole arc and let clipping do it's thing
out where the circle intersects the axes boundary and only draw
that part of it
This makes several changes to the Arc draw method:
in the "big" case via transforms
Adjusted the test image to use this failing case and to exercise both
code paths, but could be convinced to split it out into its own file.
closes #17547
PR Checklist