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

Skip to content

fixed gouraud error in pcolormesh #26320

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wyojustin
Copy link

@wyojustin wyojustin commented Jul 15, 2023

PR summary

closes #8422

fixed unlikely exception when pcolormesh is called with cell boundaries instead of cell centers by
checking for this specific condition pcolormesh code.

If boundaries are passed, average them to compute the center points and continue on.

                if (Nx, Ny) == (ncols + 1, nrows + 1):
                    X = (X[1:, 1:] + X[:1, :-1]) / 2
                    Y = (Y[1:, :-1] + Y[:-1, :-1]) / 2
                else:
                    raise TypeError('Dimensions of C %s are incompatible with'
                                    ' X (%d) and/or Y (%d); see help(%s)' % (
                                        C.shape, Nx, Ny, funcname))

PR checklist

@QuLogic QuLogic added the mentored: sprint Issues intended and suitable for sprints label Jul 15, 2023
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@jklymak
Copy link
Member

jklymak commented Jul 15, 2023

I don't think we should change data without at least warning. If users want to avoid a warning they can pass centred coords.

Comment on lines +5824 to +5825
X = (X[1:, 1:] + X[:1, :-1]) / 2
Y = (Y[1:, :-1] + Y[:-1, :-1]) / 2
Copy link
Member

Choose a reason for hiding this comment

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

I haven't looked at these shapes in detail, but shouldn't these be consistent?

Suggested change
X = (X[1:, 1:] + X[:1, :-1]) / 2
Y = (Y[1:, :-1] + Y[:-1, :-1]) / 2
X = (X[1:, 1:] + X[:-1, :-1]) / 2
Y = (Y[1:, 1:] + Y[:-1, :-1]) / 2

Copy link
Author

Choose a reason for hiding this comment

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

Might work, but I thought is made more since to change the X and Y boundary points independently.

@wyojustin
Copy link
Author

I don't think we should change data without at least warning. If users want to avoid a warning they can pass centred coords.

We do not change the user copy of the data. I don't think that the X/Y boundary arguments make since in regard to the gouraud shading, so this is the most obvious behavior.

@jklymak
Copy link
Member

jklymak commented Jul 16, 2023

Right, but users often don't know this about Gouraud shading and they should before they try to interpret their data. Before we errored - I'm fine with a warning, but I don't think we should just silently regrid.

@wyojustin
Copy link
Author

Right, but users often don't know this about Gouraud shading and they should before they try to interpret their data. Before we errored - I'm fine with a warning, but I don't think we should just silently regrid.

Perhaps we should just include a note in the doc-string. I think a warning would be an annoyance here and maybe a bit of an overkill.

@jklymak
Copy link
Member

jklymak commented Jul 16, 2023

We just got pcolormesh to stop dropping rows and columns silently. I'm 👎 on more silent behaviour. But others can chime in if they want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mentored: sprint Issues intended and suitable for sprints status: needs rebase
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

plt.pcolormesh shape mismatch when shading='gouraud'
3 participants