Convert raw values to physical values - #50
Merged
Conversation
reader.py previously appended only a Raw value column. Add a Physical
value column derived from the format/*.csv conversion rules.
Conversion order per signal:
1. Look up the (possibly multi-byte) aggregated raw value in the
Value table column. On hit, emit the matched label.
2. Otherwise apply the Conversion column:
- linear formula E=N, E=N+K, E=N*K, E=N*K+K (and -K variants)
- Ascii printable byte -> char, else 0xHH
- Not defined / N/A / empty -> leave the cell empty
Multi-byte signals follow the existing "Subsequent byte" marker on
continuation rows. The leading row carries the formula and value table;
the reader counts the contiguous Subsequent byte rows to determine
width and aggregates the bytes in big-endian (Motorola) order. Byte
order is fixed in the tool, not encoded per signal, per automotive
convention.
CSV format changes:
- Value table entries are now separated by `;` instead of `,` and have
no whitespace around `:`. Example: `0xFE:Invalid;0xFF:N/A`. This
eliminates the embedded-comma quoting that complicated machine
parsing and survives copy/paste between editors.
format/README.md documents the new conventions (Value table syntax,
Conversion column verbs, multi-byte representation, byte order).
test/test_conversion.py exercises _parse_value_table, _parse_linear,
and _convert against every form found in format/*.csv (24 cases) plus
the integrated value-table-then-formula precedence (3 cases).
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The format CSVs had one row per DID using `N/A` in the Conversion column to mean "no formula". Replace those with `Not defined` so the column has a single canonical verb for that case. Drop the redundant `N/A` handling in _convert (since the spec now disallows it) and the corresponding unit test. Update format/README.md to remove the confusing whole-cell-N/A note and the `Not defined or N/A` bullet. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Each docstring states what the test asserts. Several inline comments that simply restated the intent are removed; the docstring now carries that information. Inline comments are kept only where they spell out a non-obvious arithmetic step (e.g., 200 * 0.1 - 300 = -280). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #11