@@ -242,11 +242,13 @@ def test_valid_ink_trajectory(
242242
243243def test_uniform_motion () -> None :
244244 """Test with points moving at constant velocity."""
245- points = pd .DataFrame ({
246- "x" : [0 , 1 , 2 , 3 ],
247- "y" : [0 , 0 , 0 , 0 ],
248- "seconds" : [0 , 1 , 2 , 3 ],
249- })
245+ points = pd .DataFrame (
246+ {
247+ "x" : [0 , 1 , 2 , 3 ],
248+ "y" : [0 , 0 , 0 , 0 ],
249+ "seconds" : [0 , 1 , 2 , 3 ],
250+ }
251+ )
250252 segment = models .LineSegment (
251253 start_label = "1" ,
252254 end_label = "2" ,
@@ -267,11 +269,13 @@ def test_uniform_motion() -> None:
267269
268270def test_accelerating_motion () -> None :
269271 """Test with motion accelerating over time."""
270- points = pd .DataFrame ({
271- "x" : [0 , 1 , 4 , 9 ],
272- "y" : [0 , 0 , 0 , 0 ],
273- "seconds" : [0 , 1 , 2 , 3 ],
274- })
272+ points = pd .DataFrame (
273+ {
274+ "x" : [0 , 1 , 4 , 9 ],
275+ "y" : [0 , 0 , 0 , 0 ],
276+ "seconds" : [0 , 1 , 2 , 3 ],
277+ }
278+ )
275279 segment = models .LineSegment (
276280 start_label = "1" ,
277281 end_label = "2" ,
@@ -283,25 +287,22 @@ def test_accelerating_motion() -> None:
283287
284288 segment .calculate_velocity_metrics ()
285289
286- assert segment .distance == pytest . approx ( 9.0 )
287- assert segment .mean_speed == pytest . approx ( 3.0 )
290+ assert segment .distance == 9.0
291+ assert segment .mean_speed == 3.0
288292 assert segment .speed_variance > 0.0
289- assert len (segment .velocities ) == 3
290- assert segment .velocities [0 ] == pytest .approx (1.0 )
291- assert segment .velocities [1 ] == pytest .approx (3.0 )
292- assert segment .velocities [2 ] == pytest .approx (5.0 )
293- assert len (segment .accelerations ) == 2
294- assert segment .accelerations [0 ] == pytest .approx (2.0 )
295- assert segment .accelerations [1 ] == pytest .approx (2.0 )
293+ assert segment .velocities == [1.0 , 3.0 , 5.0 ]
294+ assert segment .accelerations == [2.0 , 2.0 ]
296295
297296
298297def test_velocity_two_points_only () -> None :
299298 """Test velocity calculation with only two points."""
300- points = pd .DataFrame ({
301- "x" : [0 , 3 ],
302- "y" : [0 , 4 ],
303- "seconds" : [0 , 2 ],
304- })
299+ points = pd .DataFrame (
300+ {
301+ "x" : [0 , 3 ],
302+ "y" : [0 , 4 ],
303+ "seconds" : [0 , 2 ],
304+ }
305+ )
305306 segment = models .LineSegment (
306307 start_label = "1" ,
307308 end_label = "2" ,
@@ -313,21 +314,22 @@ def test_velocity_two_points_only() -> None:
313314
314315 segment .calculate_velocity_metrics ()
315316
316- assert segment .distance == pytest .approx (5.0 )
317- assert segment .mean_speed == pytest .approx (2.5 )
318- assert segment .speed_variance == pytest .approx (0.0 )
319- assert len (segment .velocities ) == 1
320- assert segment .velocities [0 ] == pytest .approx (2.5 )
321- assert len (segment .accelerations ) == 0
317+ assert segment .distance == 5.0
318+ assert segment .mean_speed == 2.5
319+ assert segment .speed_variance == 0.0
320+ assert segment .velocities == [2.5 ]
321+ assert segment .accelerations == [] # No acceleration with only one velocity point
322322
323323
324324def test_decelerating_motion () -> None :
325325 """Test with decelerating motion (negative acceleration)."""
326- points = pd .DataFrame ({
327- "x" : [0 , 4 , 7 , 9 ],
328- "y" : [0 , 0 , 0 , 0 ],
329- "seconds" : [0 , 1 , 2 , 3 ],
330- })
326+ points = pd .DataFrame (
327+ {
328+ "x" : [0 , 4 , 7 , 9 ],
329+ "y" : [0 , 0 , 0 , 0 ],
330+ "seconds" : [0 , 1 , 2 , 3 ],
331+ }
332+ )
331333 segment = models .LineSegment (
332334 start_label = "1" ,
333335 end_label = "2" ,
@@ -339,25 +341,22 @@ def test_decelerating_motion() -> None:
339341
340342 segment .calculate_velocity_metrics ()
341343
342- assert segment .distance == pytest . approx ( 9.0 )
343- assert segment .mean_speed == pytest . approx ( 3.0 )
344+ assert segment .distance == 9.0
345+ assert segment .mean_speed == 3.0
344346 assert segment .speed_variance > 0.0
345- assert len (segment .velocities ) == 3
346- assert segment .velocities [0 ] == pytest .approx (4.0 )
347- assert segment .velocities [1 ] == pytest .approx (3.0 )
348- assert segment .velocities [2 ] == pytest .approx (2.0 )
349- assert len (segment .accelerations ) == 2
350- assert segment .accelerations [0 ] == pytest .approx (- 1.0 )
351- assert segment .accelerations [1 ] == pytest .approx (- 1.0 )
347+ assert segment .velocities == [4.0 , 3.0 , 2.0 ]
348+ assert segment .accelerations == [- 1.0 , - 1.0 ]
352349
353350
354351def test_stationary_motion () -> None :
355352 """Test with no movement (all points the same)."""
356- points = pd .DataFrame ({
357- "x" : [1 , 1 , 1 ],
358- "y" : [1 , 1 , 1 ],
359- "seconds" : [0 , 1 , 2 ],
360- })
353+ points = pd .DataFrame (
354+ {
355+ "x" : [1 , 1 , 1 ],
356+ "y" : [1 , 1 , 1 ],
357+ "seconds" : [0 , 1 , 2 ],
358+ }
359+ )
361360 segment = models .LineSegment (
362361 start_label = "1" ,
363362 end_label = "2" ,
@@ -369,22 +368,22 @@ def test_stationary_motion() -> None:
369368
370369 segment .calculate_velocity_metrics ()
371370
372- assert segment .distance == pytest .approx (0.0 )
373- assert segment .mean_speed == pytest .approx (0.0 )
374- assert segment .speed_variance == pytest .approx (0.0 )
375- assert len (segment .velocities ) == 2
376- assert all (v == pytest .approx (0.0 ) for v in segment .velocities )
377- assert len (segment .accelerations ) == 1
378- assert segment .accelerations [0 ] == pytest .approx (0.0 )
371+ assert segment .distance == 0.0
372+ assert segment .mean_speed == 0.0
373+ assert segment .speed_variance == 0.0
374+ assert segment .velocities == [0.0 , 0.0 ]
375+ assert segment .accelerations == [0.0 ]
379376
380377
381378def test_no_hesitations_uniform_motion () -> None :
382379 """Test with uniform motion where all velocities are equal."""
383- points = pd .DataFrame ({
384- "x" : [0 , 1 , 2 , 3 ],
385- "y" : [0 , 0 , 0 , 0 ],
386- "seconds" : [0 , 1 , 2 , 3 ],
387- })
380+ points = pd .DataFrame (
381+ {
382+ "x" : [0 , 1 , 2 , 3 ],
383+ "y" : [0 , 0 , 0 , 0 ],
384+ "seconds" : [0 , 1 , 2 , 3 ],
385+ }
386+ )
388387 segment = models .LineSegment (
389388 start_label = "1" ,
390389 end_label = "2" ,
@@ -398,16 +397,18 @@ def test_no_hesitations_uniform_motion() -> None:
398397 segment .detect_hesitations ()
399398
400399 assert segment .hesitation_count == 0
401- assert segment .hesitation_duration == pytest . approx ( 0.0 )
400+ assert segment .hesitation_duration == 0.0
402401
403402
404403def test_hesitation_at_start () -> None :
405404 """Test when the line starts with a hesitation."""
406- points = pd .DataFrame ({
407- "x" : [0 , 0.1 , 1 , 2 ],
408- "y" : [0 , 0.1 , 0 , 0 ],
409- "seconds" : [0 , 1 , 2 , 3 ],
410- })
405+ points = pd .DataFrame (
406+ {
407+ "x" : [0 , 0.1 , 1 , 2 ],
408+ "y" : [0 , 0.1 , 0 , 0 ],
409+ "seconds" : [0 , 1 , 2 , 3 ],
410+ }
411+ )
411412 segment = models .LineSegment (
412413 start_label = "1" ,
413414 end_label = "2" ,
@@ -421,16 +422,18 @@ def test_hesitation_at_start() -> None:
421422 segment .detect_hesitations ()
422423
423424 assert segment .hesitation_count == 1
424- assert segment .hesitation_duration == pytest . approx ( 1.0 )
425+ assert segment .hesitation_duration == 1.0
425426
426427
427428def test_multiple_hesitations () -> None :
428429 """Test when there are multiple hesitation periods."""
429- points = pd .DataFrame ({
430- "x" : [0 , 100 , 100.1 , 200 , 200.1 , 300 , 400 , 500 , 600 ],
431- "y" : [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ],
432- "seconds" : [0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ],
433- })
430+ points = pd .DataFrame (
431+ {
432+ "x" : [0 , 100 , 100.1 , 200 , 200.1 , 300 , 400 , 500 , 600 ],
433+ "y" : [0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ],
434+ "seconds" : [0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ],
435+ }
436+ )
434437 segment = models .LineSegment (
435438 start_label = "1" ,
436439 end_label = "2" ,
@@ -444,16 +447,18 @@ def test_multiple_hesitations() -> None:
444447 segment .detect_hesitations ()
445448
446449 assert segment .hesitation_count == 2
447- assert segment .hesitation_duration == pytest . approx ( 2.0 )
450+ assert segment .hesitation_duration == 2.0
448451
449452
450453def test_less_than_three_velocities () -> None :
451454 """Test early return when velocities length is less than 3."""
452- points = pd .DataFrame ({
453- "x" : [0 , 1 ],
454- "y" : [0 , 0 ],
455- "seconds" : [0 , 1 ],
456- })
455+ points = pd .DataFrame (
456+ {
457+ "x" : [0 , 1 ],
458+ "y" : [0 , 0 ],
459+ "seconds" : [0 , 1 ],
460+ }
461+ )
457462 segment = models .LineSegment (
458463 start_label = "1" ,
459464 end_label = "2" ,
@@ -467,4 +472,4 @@ def test_less_than_three_velocities() -> None:
467472 segment .detect_hesitations ()
468473
469474 assert segment .hesitation_count == 0
470- assert segment .hesitation_duration == pytest . approx ( 0.0 )
475+ assert segment .hesitation_duration == 0.0
0 commit comments