Skip to content

BUG: random: Use correct length when axis is given to shuffle. - #14662

Merged
mattip merged 1 commit into
numpy:masterfrom
WarrenWeckesser:shufflebug
Oct 10, 2019
Merged

mattip merged 1 commit into
numpy:masterfrom
WarrenWeckesser:shufflebug

Conversation

@WarrenWeckesser

Copy link
Copy Markdown
Member

When an axis argument was given, shuffle was using the original length of
the array instead of the length of the given axis. This meant that, for
example, if an array with shape (2, 10) was shuffled with axis=1, only the
first two columns were shuffled.

When an axis argument was given, shuffle was using the original length of
the array instead of the length of the given axis.  This meant that, for
example, if an array with shape (2, 10) was shuffled with axis=1, only the
first two columns were shuffled.
def shuffle(self, object x, axis=0):
"""
shuffle(x)
shuffle(x, axis=0)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm surprised these are needed at all - does cython not work with inspect.signature?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I haven't looked into it. I only noticed that the axis was missing when I used rng.shuffle? in ipython. It shows only the docstring, with no separate line for the signature.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps I'll take a look at this at some point

@seberg seberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Feel free and just merge yourself Warren, I was thinking if we should reorganize the n definition for a second, but I guess it does not really matter.

@mattip
mattip merged commit 9451d6f into numpy:master Oct 10, 2019
@WarrenWeckesser
WarrenWeckesser deleted the shufflebug branch October 12, 2019 01:41
@WarrenWeckesser WarrenWeckesser added this to the 1.18.0 release milestone Oct 18, 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.

4 participants