File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed
hypothesis-python/src/hypothesis Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,17 @@ def next_down(value, width=64):
102102 return - next_up (- value , width )
103103
104104
105+ def next_down_normal (value , width , allow_subnormal ):
106+ value = next_down (value , width )
107+ if (not allow_subnormal ) and 0 < abs (value ) < width_smallest_normals [width ]:
108+ return 0.0 if value > 0 else - width_smallest_normals [width ]
109+ return value
110+
111+
112+ def next_up_normal (value , width , allow_subnormal ):
113+ return - next_down_normal (- value , width , allow_subnormal )
114+
115+
105116# Smallest positive non-zero numbers that is fully representable by an
106117# IEEE-754 float, calculated with the width's associated minimum exponent.
107118# Values from https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats
Original file line number Diff line number Diff line change 3131 float_to_int ,
3232 int_to_float ,
3333 is_negative ,
34- next_down ,
34+ next_down_normal ,
3535 next_up ,
36+ next_up_normal ,
3637 width_smallest_normals ,
3738)
3839from hypothesis .internal .validation import (
@@ -279,17 +280,6 @@ def do_draw(self, data):
279280 return f
280281
281282
282- def next_down_normal (value , width , allow_subnormal ):
283- value = next_down (value , width )
284- if (not allow_subnormal ) and 0 < abs (value ) < width_smallest_normals [width ]:
285- return 0.0 if value > 0 else - width_smallest_normals [width ]
286- return value
287-
288-
289- def next_up_normal (value , width , allow_subnormal ):
290- return - next_down_normal (- value , width , allow_subnormal )
291-
292-
293283@cacheable
294284@defines_strategy (force_reusable_values = True )
295285def floats (
You can’t perform that action at this time.
0 commit comments