Add guess_tables() to tecmag for reading sequence tables from PSEQ#257
Open
dpizetta wants to merge 1 commit into
Open
Add guess_tables() to tecmag for reading sequence tables from PSEQ#257dpizetta wants to merge 1 commit into
dpizetta wants to merge 1 commit into
Conversation
Closes jjhelmus#123. The PSEQ section of Tecmag .tnt files stores sequence tables (rfamp, delay tables, etc.) as pairs of length-prefixed Pascal strings. This adds guess_tables() to expose them as a dict. The pytnt library (chatcannon/pytnt, GPL-3.0) reads delay tables by matching the default TNMR naming pattern `de[0-9]+:[0-9]`. As noted by robbyblum in jjhelmus#123, most users assign descriptive names to their tables (e.g. "rfamp", "tp"), which pytnt's regex does not catch. This implementation generalizes the parser to find any valid Pascal-string pair in PSEQ, with strict length-prefix validation to reject coincidental substring matches. The function follows the API suggested by kaustubhmote in jjhelmus#123: a standalone guess_tables() function with optional name filtering. Single-value (scalar) entries are excluded since they typically represent sequence variable defaults rather than swept tables. SI-prefix conversion (e.g. '100u' -> 1e-4) mirrors pytnt's convert_si() behavior so unit-suffixed tokens are returned in base SI units. Tests cover the numeric parsing, SI conversion, scalar exclusion, name filtering, the convert_si=False mode, files without a PSEQ section, rejection of invalid length prefixes, rejection of non-ASCII names, and mixed whitespace separators.
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.
Closes #123.
The PSEQ section of Tecmag .tnt files stores sequence tables (rfamp, delay tables, etc.) as pairs of length-prefixed Pascal strings. This adds guess_tables() to expose them as a dict.
The pytnt library (chatcannon/pytnt, GPL-3.0) reads delay tables by matching the default TNMR naming pattern
de[0-9]+:[0-9]. As noted by robbyblum in #123, most users assign descriptive names to their tables (e.g. "rfamp", "tp"), which pytnt's regex does not catch. This implementation generalizes the parser to find any valid Pascal-string pair in PSEQ, with strict length-prefix validation to reject coincidental substring matches.The function follows the API suggested by kaustubhmote in #123: a standalone guess_tables() function with optional name filtering. Single-value (scalar) entries are excluded since they typically represent sequence variable defaults rather than swept tables.
SI-prefix conversion (e.g. '100u' -> 1e-4) mirrors pytnt's convert_si() behavior so unit-suffixed tokens are returned in base SI units.
Tests cover the numeric parsing, SI conversion, scalar exclusion, name filtering, the convert_si=False mode, files without a PSEQ section, rejection of invalid length prefixes, rejection of non-ASCII names, and mixed whitespace separators.