File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -75,13 +75,28 @@ def test_fillpos_precision(dtype):
75
75
rand = np .random .default_rng ()
76
76
# Permit 1 epsilon per value
77
77
w2_thresh = 3 * - np .finfo (dtype ).eps
78
+
79
+ pos_error = neg_error = False
78
80
for _ in range (50 ):
79
81
xyz = rand .uniform (size = (3 ,)).astype (dtype )
80
82
# Normalize to unit vector up to type precision
81
83
xyz /= np .sqrt (xyz @ xyz )
82
84
wxyz = nq .fillpositive (xyz , w2_thresh )
83
85
assert wxyz [0 ] == 0.0
84
86
87
+ # Verify that we exercise the threshold
88
+ magnitude = xyz @ xyz
89
+ if magnitude < 1 :
90
+ pos_error = True
91
+ elif magnitude > 1 :
92
+ neg_error = True
93
+
94
+ if pos_error and neg_error :
95
+ break
96
+
97
+ assert pos_error , 'Did not encounter a case where 1 - |xyz| > 0'
98
+ assert neg_error , 'Did not encounter a case where 1 - |xyz| < 0'
99
+
85
100
86
101
def test_conjugate ():
87
102
# Takes sequence
You can’t perform that action at this time.
0 commit comments