Commit 4fe6c13
committed
fix(asc): address PR review feedback on timestamps_format
Reviewer feedback received (zariiii9003):
1. Use Literal type hint for timestamps_format parameter
- Changed: timestamps_format: str = "absolute"
- To: timestamps_format: Literal["absolute", "relative"] = "absolute"
- Added Literal to typing imports
2. Simplify log_event timestamp computation
- Moved monotonic clamp out of if/else blocks:
timestamp = max(timestamp, self.last_timestamp)
- Each branch now contains only simple arithmetic:
absolute: written_timestamp = timestamp - self.started
relative: written_timestamp = timestamp - self.last_timestamp
3. Use relative_timestamp=False in roundtrip tests
- Updated test_write_relative_timestamp_roundtrip and
test_write_absolute_timestamps_are_offsets_from_start to use
relative_timestamp=False so assertions verify original message
timestamps are recovered (100.0, 100.3, 101.0) rather than
file-stored offsets (0.0, 0.3, 1.0)
Additional issues found and fixed during review:
4. Removed outdated TODO comment in ASCReader
- Removed: "TODO - what is this used for? The ASC Writer only prints
absolute" — no longer accurate since ASCWriter now supports both
"absolute" and "relative" formats
5. Lowered assertAlmostEqual precision from places=5 to places=3
- The datetime triggerblock roundtrip (fromtimestamp -> strftime ->
strptime -> timestamp) only preserves millisecond precision due to
the ".NNN" format. places=5 (5 microseconds) is stricter than what
the format can guarantee; places=3 (0.5 ms) correctly reflects the
actual precision limit. Verified empirically: sub-millisecond
timestamps incur ~0.456 ms error which passes places=3 but fails
places=5.
6. Updated docstrings for both modified roundtrip tests to accurately
describe the new assertion semantics (original timestamp recovery)1 parent be2802e commit 4fe6c13
2 files changed
Lines changed: 16 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | | - | |
| 360 | + | |
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
| |||
442 | 441 | | |
443 | 442 | | |
444 | 443 | | |
| 444 | + | |
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
449 | | - | |
450 | | - | |
| 448 | + | |
451 | 449 | | |
452 | 450 | | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
| 451 | + | |
458 | 452 | | |
459 | 453 | | |
460 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
707 | | - | |
| 707 | + | |
708 | 708 | | |
709 | 709 | | |
710 | 710 | | |
| |||
714 | 714 | | |
715 | 715 | | |
716 | 716 | | |
717 | | - | |
| 717 | + | |
718 | 718 | | |
719 | 719 | | |
720 | 720 | | |
721 | | - | |
722 | | - | |
723 | | - | |
| 721 | + | |
| 722 | + | |
724 | 723 | | |
725 | 724 | | |
726 | 725 | | |
| |||
747 | 746 | | |
748 | 747 | | |
749 | 748 | | |
750 | | - | |
751 | | - | |
| 749 | + | |
| 750 | + | |
752 | 751 | | |
753 | 752 | | |
754 | 753 | | |
| |||
759 | 758 | | |
760 | 759 | | |
761 | 760 | | |
762 | | - | |
| 761 | + | |
763 | 762 | | |
764 | 763 | | |
765 | 764 | | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
770 | 769 | | |
771 | 770 | | |
772 | 771 | | |
| |||
0 commit comments