Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use reliable int type for mesh size in draw_quad_mesh (#7788) #7791

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

Merged
merged 1 commit into from
Jan 11, 2017

Conversation

AdamWill
Copy link
Contributor

In the agg backend, PyRendererAgg.draw_quad_mesh takes mesh
dimension arguments (mesh_width and mesh_height). When
converting those from Python to C, we were declaring the C
types as size_t, but converting from Python using the 'I'
format specifier, which converts a Python integer to a C
unsigned int. As @QuLogic spotted, this isn't safe, because
size_t is not necessarily the same size as an int. On Fedora
with GCC, for instance, size_t is an alias for long unsigned
int.

On LE arches this usually won't cause a problem, but on a BE
arch where size_t isn't an int type, the mismatch causes
rendering errors (see #7788).

This addresses the problem by just changing the types for these
values to be unsigned int instead.

Along with my other recent PRs, this gets the test suite error count in a Fedora ppc64 build down to 16. Nearly there...

In the agg backend, `PyRendererAgg.draw_quad_mesh` takes mesh
dimension arguments (`mesh_width` and `mesh_height`). When
converting those from Python to C, we were declaring the C
types as `size_t`, but converting from Python using the 'I'
format specifier, which converts a Python integer to a C
unsigned int. As @QuLogic spotted, this isn't safe, because
`size_t` is not necessarily the same size as an int. On Fedora
with GCC, for instance, `size_t` is an alias for long unsigned
int.

On LE arches this usually won't cause a problem, but on a BE
arch where `size_t` isn't an int type, the mismatch causes
rendering errors (see matplotlib#7788).

This addresses the problem by just changing the types for these
values to be `unsigned int` instead.
@codecov-io
Copy link

Current coverage is 62.12% (diff: 100%)

Merging #7791 into master will not change coverage

@@             master      #7791   diff @@
==========================================
  Files           174        174          
  Lines         56028      56028          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          34805      34805          
  Misses        21223      21223          
  Partials          0          0          

Powered by Codecov. Last update 109251f...05eb019

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Jan 11, 2017
@AdamWill
Copy link
Contributor Author

Since people were interested in when these BE issues appeared, in this case, this code was changed in ba40160 , "Remove use of PyCXX in core C++ extensions", which has been around since (I think) 1.5.0. I can't say for 100% sure if the old code would have worked properly on BE, but it looks more likely to have worked, to me. The relevant bit of the old code looked like this:

size_t            mesh_width       = (long)Py::Int(args[2]);
size_t            mesh_height      = (long)Py::Int(args[3]);

@tacaswell
Copy link
Member

@AdamWill Thanks for tracking that down!

The question at hand is we are about to do a 2.0 release, do we want to include all of your cpp work and does it require another rc?

I am leaning towards yes and no. Yes to include, because we are just flat broken on BE machines (and have been for about 2 years apparently) which seems like a high priority to fix. No to requiring another RC because this is all down in the extension layer which is well tested (on LE) and for the most part not user-visible.

@AdamWill
Copy link
Contributor Author

As I'm primarily concerned with Fedora, I don't really have too much of an opinion, as I'm going to backport these changes to the Fedora packages regardless. You're in a better position than I to decide how important and dangerous the changes are.

Note there are still 14 test suite errors I haven't tracked down yet, will file an issue for those shortly, but if you want a quick preview: https://paste.fedoraproject.org/525296/95891148

@tacaswell
Copy link
Member

@sandrotosi it would be interesting to cross reference these against the debian builds.

@sandrotosi
Copy link
Contributor

i gave a quick look at mips (BE) and ppc64 (BE, but not a release architecture for debian) and we dont seem to have the 'arrays are not equal' failures, but on the other side we have a shitload of 'images are not close', likely due to our fancy fonts

FWIW i agree with @tacaswell to include those changes and that they dont require a new rc - downstream distros know how to scream loudly if things break ;)

@efiring
Copy link
Member

efiring commented Jan 11, 2017

I agree with the "include, no rc" strategy for this.

@AdamWill
Copy link
Contributor Author

@sandrotosi the Fedora package has a patch which changes the default value of tol in the image_comparison decorator from 0 to 0.306 (meaning all image comparison tests which don't explicitly specify tol will have that as their tolerance), which is basically there to avoid having hundreds of failures for small font differences caused by using the system freetype. Of course, that means we could be hiding some failures that aren't actually small font differences :/

We also individually patch the tolerances for a few other tests which seem to behave slightly differently on different arches; the package maintainer has filed bugs for some of these, but not all of them. They're mostly stuff like very slightly different color shades, or the 'notches' on an axis (sorry, don't know the technical term) not being drawn in the same place.

If you want to check if Debian is hitting this specific error, look for image comparison failures in the test_colorbar tests. They'll likely have much larger RMS values than you see for little font differences. If you can check the actual image files produced by the build, check if the colorbars don't actually contain any colors.

@AdamWill
Copy link
Contributor Author

Oh, I did file issues for the remaining 14 failures I'm seeing, for the record, but neither of them actually appears to be an endian issue. There's #7797 , and #7798 turned out to be a dupe of #7158 (which the maintainer filed a few months back, after encountering it on aarch64).

@mdboom
Copy link
Member

mdboom commented Jan 11, 2017

👍

@mdboom mdboom merged commit 1c95d94 into matplotlib:master Jan 11, 2017
@mdboom
Copy link
Member

mdboom commented Jan 11, 2017

Backported to v2.x as 248f47a

mdboom added a commit that referenced this pull request Jan 11, 2017
Use reliable int type for mesh size in draw_quad_mesh (#7788)
@dopplershift
Copy link
Contributor

👍 on "include, no rc" as well.

@sandrotosi
Copy link
Contributor

@AdamWill thanks for the reference, i just imported http://pkgs.fedoraproject.org/cgit/rpms/python-matplotlib.git/plain/python-matplotlib-increase-tests-tolerance.patch in the debian packaging, let's see how happy it is now the testsuite :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants