Skip to content

BUG: random: Revert gh-14458 and refix gh-14557. #14490

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 2 commits into from
Sep 12, 2019

Conversation

WarrenWeckesser
Copy link
Member

Reverts gh-14458 and instead fixes the actual incorrect code.

This fixes a regression in 1.17 and does not result in a change in behavior of the legacy random code.

@@ -3517,7 +3517,7 @@ cdef class RandomState:
# Convert to int64, if necessary, to use int64 infrastructure
ongood = ongood.astype(np.int64)
onbad = onbad.astype(np.int64)
onbad = onbad.astype(np.int64)
onsample = onsample.astype(np.int64)
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch

onsample = <np.ndarray>np.PyArray_FROM_OTF(nsample, np.NPY_INT64, np.NPY_ALIGNED)
ongood = <np.ndarray>np.PyArray_FROM_OTF(ngood, np.NPY_LONG, np.NPY_ALIGNED)
onbad = <np.ndarray>np.PyArray_FROM_OTF(nbad, np.NPY_LONG, np.NPY_ALIGNED)
onsample = <np.ndarray>np.PyArray_FROM_OTF(nsample, np.NPY_LONG, np.NPY_ALIGNED)
Copy link
Member

Choose a reason for hiding this comment

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

Can you remind me why we're using long here instead of int64?

Copy link
Member Author

Choose a reason for hiding this comment

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

Legacy. The original random code was written using C long integers. This code is supposed to preserve the old behavior.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Sep 12, 2019
@charris charris added this to the 1.17.3 release milestone Sep 12, 2019
@charris charris merged commit 6584a7d into numpy:master Sep 12, 2019
@charris
Copy link
Member

charris commented Sep 12, 2019

Thanks Warren.

@WarrenWeckesser WarrenWeckesser deleted the bug-14457 branch September 12, 2019 20:34
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Sep 13, 2019
@charris charris removed this from the 1.17.3 release milestone Sep 13, 2019
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.

3 participants