File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
hypothesis-python/src/hypothesis/internal/conjecture/shrinking Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 9
9
# obtain one at https://mozilla.org/MPL/2.0/.
10
10
11
11
import math
12
- import struct
13
12
import sys
14
13
15
14
from hypothesis .internal .conjecture .floats import float_to_lex
16
15
from hypothesis .internal .conjecture .shrinking .common import Shrinker
17
16
from hypothesis .internal .conjecture .shrinking .integer import Integer
18
- from hypothesis .internal .floats import MAX_PRECISE_INTEGER
17
+ from hypothesis .internal .floats import MAX_PRECISE_INTEGER , float_to_int
19
18
20
19
21
20
class Float (Shrinker ):
@@ -25,9 +24,8 @@ def setup(self):
25
24
def make_canonical (self , f ):
26
25
if math .isnan (f ):
27
26
# Distinguish different NaN bit patterns, while making each equal to itself.
28
- # Returning bytes instead of integer (float_to_int) avoids accidental
29
- # equality with valid large floats.
30
- return struct .pack ("d" , f )
27
+ # Wrap in tuple to avoid potential collision with (huge) finite floats.
28
+ return ("nan" , float_to_int (f ))
31
29
return f
32
30
33
31
def check_invariants (self , value ):
You can’t perform that action at this time.
0 commit comments