BUG: Fix segfault in random.permutation(x)
when x is a string.
#14330
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #14241.
Reference #14238
I made the assumption that anyone who passes a string
x
to the functionnp.random.permutation(x)
most likely intend to shuffle the string in question. I suggest that if this isn't the desired behaviour, then I can flag an error instead of the segfault.fixing segfault error in np.random.permutation(x) where x is str
removed whitespace
changing error type to ValueError
changing error type to ValueError
changing error type to ValueError
tests
changed error to IndexError for backward compatibility with numpy 1.16
fixes numpy.randomstate.permutation segfault too
Rolled back to ValueError for Generator.permutation() for all 0-dimensional
fixes refuige erro and rolls backs to AxisError