-
Notifications
You must be signed in to change notification settings - Fork 586
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
Numpy arrays strategy generates infinities with elements=floats(allow_infinity=False) #1385
Comments
|
Huh. I think what's happening here is that the I'm not sure what the right thing to do here is. I don't think this behaviour can/will change, but maybe this is a use case for adding a specific strategy for 32-bit floats that could be used instead? |
|
Strictly speaking, this is not a bug - it's just what happens when you put large values of dtype f32_max = (2. - 2**-23) * 2**127
finite_f32 = st.floats(-f32_max, f32_max, allow_nan=False, allow_infinity=False)Nonetheless, I think Hypothesis can do better. Proposals:
Providing a native float32 strategy would be a real pain for Hypothesis in Python - on the order of duplicating |
The solution I mostly had in mind was to implement the native 32-bit floats as something not too far off |
|
Thanks @Zac-HD , your solution fixes. (I had tried previously to filter on I hadn't realised that coercing floats to lower precision can result in inf! |
I have tried to explicitly as
hypothesis.extra.numpy.arraysto not produce any infinities, by providing a strategy for both fill and elements. However, this doesn't seem to be working.MWE:
Am I doing something wrong? Thanks for any help
The text was updated successfully, but these errors were encountered: