Skip to content
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

BUG: diagflat could overflow on windows or 32-bit platforms #18455

Merged
merged 1 commit into from Feb 21, 2021

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Feb 21, 2021

Closes #18449.

For particularly large input arrays the np.diagflat function could yield non-zero diagonal elements due to integer overflow,
the latter facilitated by the default np.arange integer-dtype being np.int32 on windows.

This PR fixes aforementioned issue by explicitly setting the dtype to np.intp.

@BvB93 BvB93 added the 00 - Bug label Feb 21, 2021
@mattip mattip merged commit b126821 into numpy:master Feb 21, 2021
@mattip
Copy link
Member

mattip commented Feb 21, 2021

Thanks @BvB93

@seberg seberg added the 09 - Backport-Candidate PRs tagged should be backported label Feb 21, 2021
@BvB93 BvB93 deleted the diagflat branch February 21, 2021 17:51
@charris charris changed the title BUG: Fixed an issue where diagflat could overflow on windows or 32-bit platforms BUG: Fixed an issue where diagflat could overflow on windows or 32-bit platforms Feb 21, 2021
@charris charris changed the title BUG: Fixed an issue where diagflat could overflow on windows or 32-bit platforms BUG: diagflat could overflow on windows or 32-bit platforms Feb 21, 2021
@charris charris added component: numpy.lib and removed 09 - Backport-Candidate PRs tagged should be backported labels Feb 21, 2021
@charris charris removed this from the 1.20.2 release milestone Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

diagflat() yields incorrect results for large vectors on Windows10
5 participants