@@ -48,7 +48,10 @@ def create_segmentation(mean_course, method='gradient'):
4848 else :
4949 strategy = GradientSegmentation ()
5050 segmenter = CourseSegmenter (strategy , params = {
51- 'min_segment_length' : 0.3 , 'straight_curvature_threshold' : 0.05
51+ 'min_segment_length' : 0.3 ,
52+ # Use more permissive thresholds for test geometries
53+ 'straight_curvature_threshold' : 0.1 ,
54+ 'gradient_prominence' : 0.02 , # Lower for synthetic courses
5255 })
5356 return segmenter .segment (mean_course )
5457
@@ -133,8 +136,8 @@ def test_backward_crossing_ignored(self):
133136 x , y , heading , distance = generate_oval_course ()
134137 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
135138
136- # Segment the course using new API
137- segmentation = create_segmentation (mean_course , method = 'threshold ' )
139+ # Segment the course using gradient (works on all geometries)
140+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
138141
139142 if segmentation .num_segments < 2 :
140143 pytest .skip ("Need at least 2 segments" )
@@ -159,7 +162,7 @@ def test_ignore_far_parallel_crossing(self):
159162 x , y , heading , distance = generate_oval_course ()
160163 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
161164
162- segmentation = create_segmentation (mean_course , method = 'threshold ' )
165+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
163166
164167 if segmentation .num_segments < 2 :
165168 pytest .skip ("Need at least two segments" )
@@ -182,7 +185,7 @@ def test_coarse_samples_detect_boundary(self):
182185 # Generate a course with known segments
183186 x , y , heading , distance = generate_figure8_course (radius = 5.0 )
184187 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
185- segmentation = create_segmentation (mean_course , method = 'threshold ' )
188+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
186189
187190 if segmentation .num_segments < 2 :
188191 pytest .skip ("Need at least 2 segments" )
@@ -203,7 +206,7 @@ def test_wraparound_segment_transition(self):
203206 x , y , heading , distance = generate_oval_course ()
204207 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
205208
206- segmentation = create_segmentation (mean_course , method = 'threshold ' )
209+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
207210
208211 if segmentation .num_segments < 2 :
209212 pytest .skip ("Need multiple segments for wraparound test" )
@@ -220,7 +223,7 @@ def test_starting_point_in_middle_segment(self):
220223 x , y , heading , distance = generate_oval_course ()
221224 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
222225
223- segmentation = create_segmentation (mean_course , method = 'threshold ' )
226+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
224227
225228 if segmentation .num_segments < 2 :
226229 pytest .skip ("Need multiple segments for relocated start test" )
@@ -251,7 +254,7 @@ def test_starting_point_already_past_boundary(self):
251254 x , y , heading , distance = generate_oval_course ()
252255 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
253256
254- segmentation = create_segmentation (mean_course , method = 'threshold ' )
257+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
255258
256259 if segmentation .num_segments < 2 :
257260 pytest .skip ("Need multiple segments for wrap test" )
@@ -275,7 +278,7 @@ def test_start_near_boundary_prefers_nearest_segment(self):
275278 x , y , heading , distance = generate_oval_course ()
276279 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
277280
278- segmentation = create_segmentation (mean_course , method = 'threshold ' )
281+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
279282
280283 if segmentation .num_segments < 2 :
281284 pytest .skip ("Need multiple segments for boundary proximity test" )
@@ -296,7 +299,7 @@ def test_relabel_segments_aligns_start(self):
296299 x , y , heading , distance = generate_oval_course ()
297300 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
298301
299- segmentation = create_segmentation (mean_course , method = 'threshold ' )
302+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
300303 if segmentation .num_segments < 2 :
301304 pytest .skip ("Need multiple segments for relabel test" )
302305
@@ -384,7 +387,7 @@ def test_chicane_rapid_transitions(self):
384387 )
385388 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
386389
387- segmentation = create_segmentation (mean_course , method = 'threshold ' )
390+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
388391 assert segmentation .num_segments > 0 , "Should detect segments"
389392
390393 x_path , y_path = simulate_perfect_lap (mean_course )
@@ -414,7 +417,7 @@ def test_non_adjacent_boundary_ignored(self):
414417
415418 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
416419
417- segmentation = create_segmentation (mean_course , method = 'threshold ' )
420+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
418421
419422 if segmentation .num_segments < 3 :
420423 pytest .skip ("Need multiple segments for this test" )
@@ -443,7 +446,7 @@ def test_point_before_boundary_uses_tangent_distance(self):
443446 x , y , heading , distance = generate_figure8_course (radius = 5.0 )
444447 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
445448
446- segmentation = create_segmentation (mean_course , method = 'threshold ' )
449+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
447450
448451 if segmentation .num_segments < 2 :
449452 pytest .skip ("Need at least 2 segments" )
@@ -477,7 +480,7 @@ def test_multilap_offset_path_visits_all_segments(self):
477480 x , y , heading , distance = generate_figure8_course (radius = 5.0 )
478481 mean_course = create_mean_course_from_arrays (x , y , heading , distance )
479482
480- segmentation = create_segmentation (mean_course , method = 'threshold ' )
483+ segmentation = create_segmentation (mean_course , method = 'gradient ' )
481484 num_segs = segmentation .num_segments
482485
483486 if num_segs < 3 :
0 commit comments