@@ -49,7 +49,7 @@ def mock_int_dtype(n: int, dtype: DataType) -> int:
49
49
def isclose (
50
50
a : float ,
51
51
b : float ,
52
- M : float ,
52
+ maximum : float ,
53
53
* ,
54
54
rel_tol : float = 0.25 ,
55
55
abs_tol : float = 1 ,
@@ -62,35 +62,30 @@ def isclose(
62
62
if math .isnan (a ) or math .isnan (b ):
63
63
raise ValueError (f"{ a = } and { b = } , but input must be non-NaN" )
64
64
if math .isinf (a ):
65
- return math .isinf (b ) or abs (b ) > math .log (M )
65
+ return math .isinf (b ) or abs (b ) > math .log (maximum )
66
66
elif math .isinf (b ):
67
- return math .isinf (a ) or abs (a ) > math .log (M )
67
+ return math .isinf (a ) or abs (a ) > math .log (maximum )
68
68
return math .isclose (a , b , rel_tol = rel_tol , abs_tol = abs_tol )
69
69
70
70
71
71
def isclose_complex (
72
72
a : complex ,
73
73
b : complex ,
74
- M : float ,
74
+ maximum : float ,
75
75
* ,
76
76
rel_tol : float = 0.25 ,
77
77
abs_tol : float = 1 ,
78
78
) -> bool :
79
- """Wraps math.isclose with very generous defaults.
80
-
81
- This is useful for many floating-point operations where the spec does not
82
- make accuracy requirements.
83
- """
79
+ """Like isclose() but specifically for complex values."""
84
80
if cmath .isnan (a ) or cmath .isnan (b ):
85
81
raise ValueError (f"{ a = } and { b = } , but input must be non-NaN" )
86
82
if cmath .isinf (a ):
87
- return cmath .isinf (b ) or abs (b ) > cmath .log (M )
83
+ return cmath .isinf (b ) or abs (b ) > cmath .log (maximum )
88
84
elif cmath .isinf (b ):
89
- return cmath .isinf (a ) or abs (a ) > cmath .log (M )
85
+ return cmath .isinf (a ) or abs (a ) > cmath .log (maximum )
90
86
return cmath .isclose (a , b , rel_tol = rel_tol , abs_tol = abs_tol )
91
87
92
88
93
-
94
89
def default_filter (s : Scalar ) -> bool :
95
90
"""Returns False when s is a non-finite or a signed zero.
96
91
0 commit comments