hypothesis
hypothesis copied to clipboard
Generating non-IEEE `floats` - such as `bfloat16`, `bfloat32`, or various `float8_*` types
Thank you for hypothesis! It's a wonderful library that I use frequently.
While investigating a bug report from one of the users of my extension library: https://github.com/qthequartermasterman/hypothesis-torch/issues/20, I realized that there is no obvious way (at least to me) in hypothesis to build a strategy that can generate only floats of width other than 16, 32, or 64, such as bfloat16
or bfloat32
.
Is there a straightforward way to construct such a strategy?
There is a mention of a desire to support these types after the float overhaul, but I cannot find any other references to such work ever being done.
I looked into the internals of how floats
handles width
currently, and it looks like floats_of
could be extended using a similar technique of stuct packing/unpacking. Before I implement that however, I was hoping to see if there is a more straightforward way.
Is there a straightforward way to generate only bfloat16
-valid floats using hypothesis?