8000 DOC: numpy.random.sample and numpy.random.random_sample · Issue #10587 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: numpy.random.sample and numpy.random.random_sample #10587

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

Closed
k-kapp opened this issue Feb 14, 2018 · 6 comments · Fixed by #13688
Closed

DOC: numpy.random.sample and numpy.random.random_sample #10587

k-kapp opened this issue Feb 14, 2018 · 6 comments · Fixed by #13688

Comments

@k-kapp
Copy link
Contributor
k-kapp commented Feb 14, 2018

I just noticed in the docs that the page for numpy.random.sample indicates that the function should be called as numpy.random.random_sample. I understand that this may just indicate that the function may be called as either sample or random_sample, but it does come across as a mistake when first viewing the page. Perhaps make it more explicit that random_sample is an alias of sample? Or is this the accepted practice for functions that have aliases?

@eric-wieser
Copy link
Member

This is show this way because:

>>> np.random.random_sample
<function RandomState.random_sample>

>>> np.random.sample
<function RandomState.random_sample>

I think flipping the alias would be reasonable

@rkern
Copy link
Member
rkern commented Feb 15, 2018

sample is just an old backwards-compatibility alias for random_sample, which is the authoritative name.

@godaygo
Copy link
Contributor
godaygo commented Feb 16, 2018

@rkern isn't it better to deprecate random_sample in favor of sample the same way as it is done with random_integers? The random_ prefix seems excessive - they are already live in random module. And this change also allows to achieve greater consistency in the names across random module.

@bashtage
Copy link
Contributor

IMO it is almost never worth it to remove API to achieve consistency since this will break existing code and documentation (e.g., tutorials).

If matching randint was the goal, the name would have to be something like randfloat which isn't very nice. sample and even random_sample are particularly clear that one will get a uniform random number on [0,1). uniform is the probably the clearest, but already taken.

@bashtage
Copy link
Contributor

xref #13163 . This is fixed in the randomgen branch, subject to dropping sample and random and ranf

@bashtage
Copy link
Contributor

Also contains docstring pointers for ranf and sample.

bashtage added a commit to bashtage/numpy that referenced this issue Jun 1, 2019
Expose alias that have correct docstrings

closes numpy#10587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
0