@@ -210,3 +210,37 @@ def test_tabulizer_summary_table():
210
210
assert df ['lower_ci' ].tolist () == [3 , 8 , 13 ]
211
211
assert df ['upper_ci' ].tolist () == [7 , 12 , 17 ]
212
212
assert df ['deviation' ].tolist () == [0.1 , 0.2 , 0.3 ]
213
+
214
+
215
+ @pytest .mark .parametrize ('lst, exp, look_ahead' , [
216
+ ([None , None , 0.8 , 0.4 , 0.3 ], 4 , 0 ), # Normal case
217
+ ([0.4 , 0.3 , 0.2 , 0.1 ], 1 , 0 ), # No None values
218
+ ([0.8 , 0.9 , 0.8 , 0.7 ], None , 0 ), # No values below threshold
219
+ ([None , None , None , None ], None , 0 ), # No values
220
+ ([], None , 0 ), # Empty list
221
+ ([None , None , 0.8 , 0.8 , 0.3 , 0.3 , 0.3 ], None , 3 ), # Not full lookahead
222
+ ([None , None , 0.8 , 0.8 , 0.3 , 0.3 , 0.3 , 0.3 ], 5 , 3 ) # Meets lookahead
223
+ ])
224
+ def test_find_position (lst , exp , look_ahead ):
225
+ """
226
+ Test the find_position() method from ReplicationsAlgorithm.
227
+
228
+ Arguments:
229
+ lst (list)
230
+ List of values to input to find_position().
231
+ exp (float)
232
+ Expected result from find_position().
233
+ look_ahead (int)
234
+ Number of extra positions to check that they also fall under the
235
+ threshold.
236
+ """
237
+ # Set threshold to 0.5, with provided look_ahead
238
+ alg = ReplicationsAlgorithm (half_width_precision = 0.5 ,
239
+ look_ahead = look_ahead )
240
+
241
+ # Get result from algorithm and compare to expected
242
+ result = alg .find_position (lst )
243
+ assert result == exp , (
244
+ f'Ran find_position on: { lst } (threshold 0.5, look-ahead ' +
245
+ f'{ look_ahead } ). Expected { exp } , but got { result } .'
246
+ )
0 commit comments