Allow many distributions to have a scale of 0.#5822
Conversation
numpy/random/mtrand/mtrand.pyx
Outdated
There was a problem hiding this comment.
This is calling rk_standard_gamma with shape = 0. If you go to the source code of that function in distributions.c, you will find that, with shape = 0, you are computing things like X = pow(U, 1./shape)). I think we should handle that particular case directly there, not rely on the behavior of pow for corner cases.
|
Please, double check what the Another thing to consider is whether we want to handle the |
|
Arguably the right way to handle a lot of those cases is to fix the rk_*
|
|
|
|
There are to sources of unease for me here:
I don't know the answer to 1, but for 2, if you take a look at where Now if which I am guessing will return a big fat From a quick look it seems that |
374ab22 to
c4ff5f6
Compare
|
I apologize for The case of negative zero is more interesting; as it is at least some of the generators ( |
|
I think treating negative zero like zero would be better? In general they Regarding special value handling in general: NumPy certainly requires
|
|
Everything in Most of the changes we made to |
Heh. |
|
Actually -0.+-0. = -0. but that' not the point there :-) I can certainly switch the checks to "normalize -0. to +0.", I don't care much. |
|
I would like to see this going into 1.10. Kindly bumping the issue, now that 1.10 is being branched out. I know that Pillow is starting to use Appveyor for Windows testing, perhaps that could be useful for numpy too? |
|
☔ The latest upstream changes (presumably #6831) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@anntzer Oops, needs rebase after spelling fix went in... |
|
Any news as to testing on Windows (which is all that blocks this issue)? Even though I gave in and finally installed MSVC for other purposes, I still can't manage to build numpy (this fails with an unresolved external symbol, |
(in which case a stream of 0's is usually returned (or 1's)). See numpy#5818.
26f0e39 to
5bc4624
Compare
|
Kindly bumping the issue. The remaining blocker was the lack of tests on Windows (wrt. MSVC compliance with the annex F of the C standard), but now we can check that the tests pass on Appveyor. |
numpy/random/tests/test_random.py
Outdated
There was a problem hiding this comment.
Real nitpick, but for completeness might as well test for the exception being raise on -0. here as well.
This does look all OK otherwise.
At least the gamma generator doesn't support it.
5bc4624 to
0319d0c
Compare
|
Sorry for how long this has been sitting, and thanks for being stubborn about pinging. Indeed the windows tests seem to be passing, I don't see any complaints, and from a quick read through the changes it LGTM, so merging! |
(in which case a stream of 0's is usually returned (or 1's)).
See #5818.