-
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 strategy fails with timedelta64 dtype #2351
Comments
|
I think what must be happening is that the array and the scalar value have different units with no consistent conversion factor (e.g years to days, or days to months).
|
|
IMO we should either change our code so that this is not an error, or so that the error message explains what's happening and gives enough information to reproduce the problem. |
|
Thanks for your input, I think for now I'll just exclude any timedelta scalar types from the strategy. I agree, it would be nice if the extras strategy worked for all dtypes in |
|
The The problematic hypothesis/hypothesis-python/src/hypothesis/extra/numpy.py Lines 90 to 95 in f781f78
and I think the second branch should actually be an error, and explain that dtypes without a time unit can't be resolved to a strategy. We don't have to hurt usability much if we then get |
|
Ah fantastic, I should have read the entire docs page before deciding I needed to implement one myself. Thanks for the tip!
Yes if I understand you correctly that seems like a nice solution that covers every case. |
I'm getting an error I can't make sense of when generating a numpy array with
dtype=np.dtype("m8"), which corresponds todtype=timedelta64, andshape=(1,1).The trace is given below.
Any help would be greatly appreciated!
If it's useful to know, the context is that I'm trying to write a strategy which will generate an arbitrary numpy array of any valid type and shape, within reasonable memory constraints.
The text was updated successfully, but these errors were encountered: