-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[BUG] Prevent under the hood downcasting of values #25832
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
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. 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.
Reopened to trigger waiting tests. |
Thank you for working on this. I would describe this is more forcing an up-conversion that preventing a down conversion (as it looks like Could you add a simple test that passing in a list of ints does not raise? |
Sure thing, I will add the test case today. Thanks for the review! |
@tacaswel I wrote the test, but in one of the CI tests, it compares against the original main and fails. Am I missing something trivial here? For your reference, the permalink of the error is reproduced below: |
I am very confused why this is only happening on windows, but this looks like a real warning from numpy and our tests are set to fail on any warning. Given that we are looking for "does this fail", what is the simplest (smallest) input data we can get away with using? |
Alternative would be to upcast to float sooner which would likely elide the precision warning (though may still have slight imprecision due to inexact float calcs). e.g. correls = np.correlate(x, y, mode="full").astype(float) (And then keep the |
This may be due to the system default long in Windows vs Linux. So, trying explicit |
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.
modulo squashing or squash-merge.
Looks good @abcnishant007 ! Are you comfortable squashing your commits (see https://matplotlib.org/stable/devel/development_workflow.html#rewriting-commit-history)? |
Thanks for the review @tacaswell. I targeted two commits- 1 for the change and 1 for the test. I did the cleaning and squashing using rebase, but while changing the commit message of the first commit, there was a dummy merge. Now, GitHub won't let me squash that merge commit anymore. If this is unacceptable, I can create a new pull request with exactly two commits and the same changes as this one. What do you think? |
It looks like you fell into the trap of: https://matplotlib.org/devdocs/devel/development_workflow.html#pushing-with-force You are probably [these are destructive commands, understand them before you run them!]
away from getting rid of the merge (and duplicate) commits. |
Thanks for the guidance! Yes, that was the trap. Finally, I managed to fix it by:
Now, we have a clean commit history of two commits, one for the fix, other for the test. |
tried to re-trigger CI to pick up a fix on main for the mypy error. |
I think the |
…832-on-v3.7.x Backport PR #25832 on branch v3.7.x ([BUG] Prevent under the hood downcasting of values)
I think this behaviour was not intended. Spotted the issue due to a question posted on Stackoverflow https://stackoverflow.com/questions/76195580/when-plotting-autocorrelation-function-plot-getting-ufunctypeerror
When using a list of integers in the
xcorr
function, the following lines:matplotlib/lib/matplotlib/axes/_axes.py
Lines 2118 to 2119 in 4bdae2e
result in an under-the-hood downcasting to int, and as a result, the following error is thrown:
The obvious fix is to remove in-place update and use standard assignment.
PR summary
PR checklist