Skip to content

Commit 5b19397

Browse files
committed
make test_process statistical
1 parent 186cba8 commit 5b19397

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

openpiv/test/test_process.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313

1414

15-
THRESHOLD = 0.3
15+
THRESHOLD = 0.25
1616

1717
# define "PIV" shift, i.e. creating u,v values that we want to get
1818
# -5.5 pixels to the left and 3.2 pixels upwards
@@ -102,18 +102,22 @@ def test_extended_search_area_overlap():
102102

103103
def test_extended_search_area_sig2noise():
104104
""" test of the extended area PIV with sig2peak """
105-
frame_a, frame_b = create_pair(image_size=64, u=SHIFT_U, v=SHIFT_V)
106-
u, v, _ = piv(
107-
frame_a,
108-
frame_b,
109-
window_size=16,
110-
search_area_size=32,
111-
sig2noise_method="peak2peak",
112-
subpixel_method="gaussian"
113-
)
114-
115-
assert np.allclose(u, SHIFT_U, atol=THRESHOLD)
116-
assert np.allclose(v, SHIFT_V, atol=THRESHOLD)
105+
success_count = 0
106+
num_trials = 10
107+
for _ in range(num_trials):
108+
frame_a, frame_b = create_pair(image_size=64, u=SHIFT_U, v=SHIFT_V)
109+
u, v, _ = piv(
110+
frame_a,
111+
frame_b,
112+
window_size=16,
113+
search_area_size=32,
114+
sig2noise_method="peak2peak",
115+
subpixel_method="gaussian"
116+
)
117+
if np.allclose(u, SHIFT_U, atol=THRESHOLD) and np.allclose(v, SHIFT_V, atol=THRESHOLD):
118+
success_count += 1
119+
120+
assert success_count >= 7, f"Test failed: {success_count} out of {num_trials} trials were successful"
117121

118122

119123
def test_process_extended_search_area():

0 commit comments

Comments
 (0)