-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use contourpy for quad contour calculations #22567
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
Conversation
I would suggest starting with sticking to the mpl2014 algorithm for now so that we don't have to update the images? Actually switching the algorithm (perhaps configurable globally via an rcParam?) could be done as a second step? |
ae08ddf
to
313dd2a
Compare
Do you know what happened to patheffect2? The change isn't a huge deal, but the old "18" label position seems better? |
I do, and it is most unfortunate. The Mpl's label positioning algorithm evidently uses the number of points in a line to work out where to put the label, so it can be different now. If the contour lines weren't going exactly through the grid points there would be no difference. |
The minimum versions CI test is failing because in contourpy I have pinned a minimum numpy version of 1.20 whereas it is 1.19 in mpl. It doesn't really need to be 1.20 so I can put it back to 1.19, but that will need a new release of contourpy. |
I am not sure about the idea of using a new rcParam. In the long run we will use the new |
We probably need to agree a strategy going forward here. Do we run with this as it is (current algorithm) for one mpl release and then switch to the new algorithm for the next mpl release to spread the risk, or do we do both changes in one go? |
As discussed on the call:
From my quick look I think this still needs docs, a change note, and the new kwarg if you are planning to offer it. |
I wish you had given me some notice that you were going to talk about this on the call so that I could attend and give an informed opinion. The algorithms already have names (https://contourpy.readthedocs.io/en/v1.0.1/user_guide/name.html) and the names in question here are I still need some clarity here. Sticking with |
@ianthomas23 Sorry about that, will you be able to make the call next week? The analogy we had was the interpolation kwarg on If there are 4 algorithms I would go with something like https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/tests/baseline_images/test_image/imshow_masked_interpolation.png to make sure they all run and leave a majority of our test images using |
Yes, I can make this week's call. Thanks for the clarification, it makes more sense now. Getting this all done for 3.6 should be fine. To do list (mostly for my own benefit):
Once this is in 3.6 and we have confirmed everything is OK, a future PR will:
After that, there is the possibility of taking advantage of the improvements in
I am keen on doing item 1. Item 2 might be driven by user requests for such. |
Updates following yesterday's call:
|
https://bugzilla.redhat.com/show_bug.cgi?id=2073692; no issues with tests on other architectures. |
dff7b08
to
3fcf814
Compare
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.
Seems good to me, but maybe a few more things need to be mentioned in the changes notes?
@@ -607,10 +607,11 @@ | |||
## * CONTOUR PLOTS * | |||
## *************************************************************************** | |||
#contour.negative_linestyle: dashed # string or on-off ink sequence | |||
#contour.corner_mask: True # {True, False, legacy} |
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.
This probably needs to be in the API change as well?
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.
Support for corner_mask='legacy'
was deprecated in mpl 1.5 (doc/api/prev_api_changes/api_changes_1.5.0.rst) and the code removed in mpl 2.2 (doc/api/prev_api_changes/api_changes_2.2.0.rst
). This evidently missed the code removal.
adjacent (x, y) points that are identical; previously the duplicate points | ||
were removed, now they are kept. Contours affected by this will produce the | ||
same visual output, but there will be a greater number of points in the | ||
contours. |
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.
Do the differences in clabel need to be mentioned here or are those usually small enough not to matter?
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.
Yes, I will mention it here.
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.
Looks good to me. Did you want to keep all the commits, or should this be squashed?
I'd squash it. |
7dd6b6d
to
20c5af3
Compare
Commits squashed. |
@QuLogic pinging you to review and merge if you are OK with this. I think this was all as discussed, but you may have packaging insights, if any. Thanks! |
@ianthomas23 I squashed and merged your latest changes. Thanks for doing this - hopefully this is a smooth transition! |
Closes #22529.
This PR replaces the C++ contouring code shipped with Matplotlib with a new external dependency
contourpy
. Details are listed in the linked issue.Nearly all of the test image changes are too small for the human eye to identify and are caused by a change in the start point of calculated and rendered polygons. Other test image changes are visible and are all movements of contour labels, code that has not changed in this PR but evidently the change in order of the lines/polygons returned affects the
clabel
positions.I have added
contourpy
as a dependency insetup.py
andenvironment.yml
. I don't think there are any other files featuring dependencies that need to be changed here, but I am not 100% sure.