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: have geometric() raise ValueError on p=0 #11613

Merged
merged 1 commit into from
Oct 12, 2018
Merged

Conversation

moshelooks
Copy link

Currently np.random.geometric(0) => -9223372036854775808

Currently `np.random.geometric(0) => -9223372036854775808`
Copy link
Contributor

@tylerjereddy tylerjereddy left a comment

Choose a reason for hiding this comment

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

Reviewers with more domain expertise may want to comment on whether this fix is needed & consistent with the RNG NEP--bug fixes still ok in this regard?

If fix is suitable, may also be appropriate to add a Raises section to the docstring?

if fp < 0.0:
raise ValueError("p < 0.0")
if fp <= 0.0:
raise ValueError("p <= 0.0")
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be suitable to add a unit test for both scalar and array p values of 0 (that failed before and pass now)--ensuring that ValueError is appropriately raised.

@moshelooks
Copy link
Author

moshelooks commented Jul 27, 2018 via email

@rkern
Copy link
Member

rkern commented Jul 27, 2018

In the RNG NEP, I didn't specifically state what would happen between formal acceptance and when the new subsystem lands and the new "don't fix bugs in RandomState distributions" policy will definitely be in effect. I just didn't think about it. I lean towards just turning this into a warning, to more align with the pending policy, but I won't object if people would really like this to strictly raise an error in these situations until the new subsystem lands.

@mattip mattip merged commit 0a113ed into numpy:master Oct 12, 2018
@mattip
Copy link
Member

mattip commented Oct 12, 2018

This fix seems like an improvement as

  • it does not seem the new subsytem will be in place for 1.16
  • the current code returns an incorrect value

@mattip
Copy link
Member

mattip commented Oct 12, 2018

Thanks @moshelooks

bashtage added a commit to bashtage/randomgen that referenced this pull request Nov 5, 2018
mattip pushed a commit to mattip/numpy that referenced this pull request Mar 20, 2019
mattip pushed a commit to mattip/numpy that referenced this pull request May 20, 2019
Sync upstream changes in numpy#11613, numpy#11771, and
numpy#12089
Update to NumPy 1.12 as the minimum version
Fix documentation
Add information about Lemire generator
Update change log
Fix docstring for randint
Refactor benchmark with more options
Clean code for PEP8 violations
Improve performance testing
mattip pushed a commit to mattip/numpy that referenced this pull request May 20, 2019
Sync upstream changes in numpy#11613, numpy#11771, and
numpy#12089
Update to NumPy 1.12 as the minimum version
Fix documentation
Add information about Lemire generator
Update change log
Fix docstring for randint
Refactor benchmark with more options
Clean code for PEP8 violations
Improve performance testing
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.

None yet

4 participants