Skip to content

Commit 0fbf5a5

Browse files
committed
ruff reformat
1 parent 00e9968 commit 0fbf5a5

1 file changed

Lines changed: 125 additions & 89 deletions

File tree

tests/unit/test_models.py

Lines changed: 125 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,13 @@ def test_valid_ink_trajectory(
244244

245245
def test_uniform_motion() -> None:
246246
"""Test with points moving at constant velocity."""
247-
points = pd.DataFrame({
248-
"x": [0, 1, 2, 3],
249-
"y": [0, 0, 0, 0],
250-
"seconds": [0, 1, 2, 3],
251-
})
247+
points = pd.DataFrame(
248+
{
249+
"x": [0, 1, 2, 3],
250+
"y": [0, 0, 0, 0],
251+
"seconds": [0, 1, 2, 3],
252+
}
253+
)
252254
segment = models.LineSegment(
253255
start_label="1",
254256
end_label="2",
@@ -269,11 +271,13 @@ def test_uniform_motion() -> None:
269271

270272
def test_accelerating_motion() -> None:
271273
"""Test with motion accelerating over time."""
272-
points = pd.DataFrame({
273-
"x": [0, 1, 4, 9],
274-
"y": [0, 0, 0, 0],
275-
"seconds": [0, 1, 2, 3],
276-
})
274+
points = pd.DataFrame(
275+
{
276+
"x": [0, 1, 4, 9],
277+
"y": [0, 0, 0, 0],
278+
"seconds": [0, 1, 2, 3],
279+
}
280+
)
277281
segment = models.LineSegment(
278282
start_label="1",
279283
end_label="2",
@@ -294,11 +298,13 @@ def test_accelerating_motion() -> None:
294298

295299
def test_velocity_two_points_only() -> None:
296300
"""Test velocity calculation with only two points."""
297-
points = pd.DataFrame({
298-
"x": [0, 3],
299-
"y": [0, 4],
300-
"seconds": [0, 2],
301-
})
301+
points = pd.DataFrame(
302+
{
303+
"x": [0, 3],
304+
"y": [0, 4],
305+
"seconds": [0, 2],
306+
}
307+
)
302308
segment = models.LineSegment(
303309
start_label="1",
304310
end_label="2",
@@ -319,11 +325,13 @@ def test_velocity_two_points_only() -> None:
319325

320326
def test_decelerating_motion() -> None:
321327
"""Test with decelerating motion (negative acceleration)."""
322-
points = pd.DataFrame({
323-
"x": [0, 4, 7, 9],
324-
"y": [0, 0, 0, 0],
325-
"seconds": [0, 1, 2, 3],
326-
})
328+
points = pd.DataFrame(
329+
{
330+
"x": [0, 4, 7, 9],
331+
"y": [0, 0, 0, 0],
332+
"seconds": [0, 1, 2, 3],
333+
}
334+
)
327335
segment = models.LineSegment(
328336
start_label="1",
329337
end_label="2",
@@ -344,11 +352,13 @@ def test_decelerating_motion() -> None:
344352

345353
def test_stationary_motion() -> None:
346354
"""Test with no movement (all points the same)."""
347-
points = pd.DataFrame({
348-
"x": [1, 1, 1],
349-
"y": [1, 1, 1],
350-
"seconds": [0, 1, 2],
351-
})
355+
points = pd.DataFrame(
356+
{
357+
"x": [1, 1, 1],
358+
"y": [1, 1, 1],
359+
"seconds": [0, 1, 2],
360+
}
361+
)
352362
segment = models.LineSegment(
353363
start_label="1",
354364
end_label="2",
@@ -369,11 +379,13 @@ def test_stationary_motion() -> None:
369379

370380
def test_no_hesitations_uniform_motion() -> None:
371381
"""Test with uniform motion where all velocities are equal."""
372-
points = pd.DataFrame({
373-
"x": [0, 1, 2, 3],
374-
"y": [0, 0, 0, 0],
375-
"seconds": [0, 1, 2, 3],
376-
})
382+
points = pd.DataFrame(
383+
{
384+
"x": [0, 1, 2, 3],
385+
"y": [0, 0, 0, 0],
386+
"seconds": [0, 1, 2, 3],
387+
}
388+
)
377389
segment = models.LineSegment(
378390
start_label="1",
379391
end_label="2",
@@ -392,11 +404,13 @@ def test_no_hesitations_uniform_motion() -> None:
392404

393405
def test_hesitation_at_start() -> None:
394406
"""Test when the line starts with a hesitation."""
395-
points = pd.DataFrame({
396-
"x": [0, 0.1, 1, 2],
397-
"y": [0, 0.1, 0, 0],
398-
"seconds": [0, 1, 2, 3],
399-
})
407+
points = pd.DataFrame(
408+
{
409+
"x": [0, 0.1, 1, 2],
410+
"y": [0, 0.1, 0, 0],
411+
"seconds": [0, 1, 2, 3],
412+
}
413+
)
400414
segment = models.LineSegment(
401415
start_label="1",
402416
end_label="2",
@@ -415,11 +429,13 @@ def test_hesitation_at_start() -> None:
415429

416430
def test_multiple_hesitations() -> None:
417431
"""Test when there are multiple hesitation periods."""
418-
points = pd.DataFrame({
419-
"x": [0, 100, 100.1, 200, 200.1, 300, 400, 500, 600],
420-
"y": [0, 0, 0, 0, 0, 0, 0, 0, 0],
421-
"seconds": [0, 1, 2, 3, 4, 5, 6, 7, 8],
422-
})
432+
points = pd.DataFrame(
433+
{
434+
"x": [0, 100, 100.1, 200, 200.1, 300, 400, 500, 600],
435+
"y": [0, 0, 0, 0, 0, 0, 0, 0, 0],
436+
"seconds": [0, 1, 2, 3, 4, 5, 6, 7, 8],
437+
}
438+
)
423439
segment = models.LineSegment(
424440
start_label="1",
425441
end_label="2",
@@ -438,11 +454,13 @@ def test_multiple_hesitations() -> None:
438454

439455
def test_less_than_three_velocities() -> None:
440456
"""Test early return when velocities length is less than 3."""
441-
points = pd.DataFrame({
442-
"x": [0, 1],
443-
"y": [0, 0],
444-
"seconds": [0, 1],
445-
})
457+
points = pd.DataFrame(
458+
{
459+
"x": [0, 1],
460+
"y": [0, 0],
461+
"seconds": [0, 1],
462+
}
463+
)
446464
segment = models.LineSegment(
447465
start_label="1",
448466
end_label="2",
@@ -461,11 +479,13 @@ def test_less_than_three_velocities() -> None:
461479

462480
def test_smoothness_less_than_three_points() -> None:
463481
"""Less than 3 points cannot define curvature."""
464-
points = pd.DataFrame({
465-
"x": [0, 1],
466-
"y": [0, 0],
467-
"seconds": [0, 1],
468-
})
482+
points = pd.DataFrame(
483+
{
484+
"x": [0, 1],
485+
"y": [0, 0],
486+
"seconds": [0, 1],
487+
}
488+
)
469489
segment = models.LineSegment(
470490
start_label="1",
471491
end_label="2",
@@ -555,10 +575,12 @@ def test_smoothness_single_180_degree_turn() -> None:
555575
556576
Since it represents maximal curvature.
557577
"""
558-
points = pd.DataFrame({
559-
"x": [0, 1, 0],
560-
"y": [0, 0, 0],
561-
})
578+
points = pd.DataFrame(
579+
{
580+
"x": [0, 1, 0],
581+
"y": [0, 0, 0],
582+
}
583+
)
562584
segment = models.LineSegment(
563585
start_label="1",
564586
end_label="2",
@@ -574,11 +596,13 @@ def test_smoothness_single_180_degree_turn() -> None:
574596

575597
def test_compute_segment_metrics_less_than_two_points() -> None:
576598
"""Test early return when segment has less than 2 points."""
577-
points = pd.DataFrame({
578-
"x": [0],
579-
"y": [0],
580-
"seconds": [0],
581-
})
599+
points = pd.DataFrame(
600+
{
601+
"x": [0],
602+
"y": [0],
603+
"seconds": [0],
604+
}
605+
)
582606
segment = models.LineSegment(
583607
start_label="1",
584608
end_label="2",
@@ -606,11 +630,13 @@ def test_compute_segment_metrics_less_than_two_points() -> None:
606630

607631
def test_compute_segment_metrics_invalid_start_label() -> None:
608632
"""Test early return when start_label not in trail circles."""
609-
points = pd.DataFrame({
610-
"x": [0, 50, 100],
611-
"y": [0, 0, 0],
612-
"seconds": [0, 1, 2],
613-
})
633+
points = pd.DataFrame(
634+
{
635+
"x": [0, 50, 100],
636+
"y": [0, 0, 0],
637+
"seconds": [0, 1, 2],
638+
}
639+
)
614640
segment = models.LineSegment(
615641
start_label="999",
616642
end_label="2",
@@ -639,11 +665,13 @@ def test_compute_segment_metrics_invalid_start_label() -> None:
639665

640666
def test_compute_segment_metrics_invalid_end_label() -> None:
641667
"""Test early return when end_label not in trail circles."""
642-
points = pd.DataFrame({
643-
"x": [0, 50, 100],
644-
"y": [0, 0, 0],
645-
"seconds": [0, 1, 2],
646-
})
668+
points = pd.DataFrame(
669+
{
670+
"x": [0, 50, 100],
671+
"y": [0, 0, 0],
672+
"seconds": [0, 1, 2],
673+
}
674+
)
647675
segment = models.LineSegment(
648676
start_label="1",
649677
end_label="999",
@@ -671,11 +699,13 @@ def test_compute_segment_metrics_invalid_end_label() -> None:
671699

672700
def test_compute_segment_metrics_valid_trajectory() -> None:
673701
"""Test successful computation of all metrics with valid trajectory."""
674-
points = pd.DataFrame({
675-
"x": [0, 25, 50, 75, 100],
676-
"y": [0, 0, 0, 0, 0],
677-
"seconds": [0, 1, 2, 3, 4],
678-
})
702+
points = pd.DataFrame(
703+
{
704+
"x": [0, 25, 50, 75, 100],
705+
"y": [0, 0, 0, 0, 0],
706+
"seconds": [0, 1, 2, 3, 4],
707+
}
708+
)
679709
segment = models.LineSegment(
680710
start_label="1",
681711
end_label="2",
@@ -709,11 +739,13 @@ def test_compute_segment_metrics_valid_trajectory() -> None:
709739

710740
def test_compute_segment_metrics_ink_end_equals_ink_start() -> None:
711741
"""Test when ink_end_idx equals ink_start_idx (no valid trajectory)."""
712-
points = pd.DataFrame({
713-
"x": [0, 50, 100],
714-
"y": [0, 0, 0],
715-
"seconds": [0, 1, 2],
716-
})
742+
points = pd.DataFrame(
743+
{
744+
"x": [0, 50, 100],
745+
"y": [0, 0, 0],
746+
"seconds": [0, 1, 2],
747+
}
748+
)
717749
segment = models.LineSegment(
718750
start_label="1",
719751
end_label="2",
@@ -742,11 +774,13 @@ def test_compute_segment_metrics_ink_end_equals_ink_start() -> None:
742774

743775
def test_compute_segment_metrics_ink_end_before_ink_start() -> None:
744776
"""Test when ink_end_idx is before ink_start_idx (invalid trajectory)."""
745-
points = pd.DataFrame({
746-
"x": [0, 50, 100],
747-
"y": [0, 0, 0],
748-
"seconds": [0, 1, 2],
749-
})
777+
points = pd.DataFrame(
778+
{
779+
"x": [0, 50, 100],
780+
"y": [0, 0, 0],
781+
"seconds": [0, 1, 2],
782+
}
783+
)
750784
segment = models.LineSegment(
751785
start_label="1",
752786
end_label="2",
@@ -775,11 +809,13 @@ def test_compute_segment_metrics_ink_end_before_ink_start() -> None:
775809

776810
def test_compute_segment_metrics_only_start_index_found() -> None:
777811
"""Test when only ink_start_idx is found (end is None)."""
778-
points = pd.DataFrame({
779-
"x": [0, 25, 50, 75],
780-
"y": [0, 0, 0, 0],
781-
"seconds": [0, 1, 2, 3],
782-
})
812+
points = pd.DataFrame(
813+
{
814+
"x": [0, 25, 50, 75],
815+
"y": [0, 0, 0, 0],
816+
"seconds": [0, 1, 2, 3],
817+
}
818+
)
783819
segment = models.LineSegment(
784820
start_label="1",
785821
end_label="2",

0 commit comments

Comments
 (0)