parse_value returns string values with their <...> delimiters attached (#176) - #179
Merged
headmeister merged 1 commit intoJul 27, 2026
Merged
Conversation
…Fixes isi-nmr#176 Spec 2.2: the angle brackets delimit a JCAMP-DX string, they are not part of its value. `parse_value` returned whole `<...>` matches, so every consumer had to strip them -- which the library itself did in 26 places across the property recipes, and which `metadata` never did, leaving two brukerapi APIs reporting different values for the same parameter. `_STRING_RE` now captures the inside, and every parse path unquotes: a value of all-delimited strings skips the numeric casts, since `<1> <2>` is a list of two strings and never of two numbers. `<>` reads as the empty string. Nothing about a Python string says whether it is a JCAMP string or an undelimited enum symbol, so writing has to be told. A parameter keeps whichever form it was already written in, which is what makes read-modify-write -- the frame-group and slice-package splitters -- put `<FG_SLICE>` and `<a.u.>` back as they were, while `VisuCoreFrameType=MAGNITUDE_IMAGE` stays bare. With that in place the workarounds go: the 26 `[1:-1]` slices and the delimited literals in brukerapi/config, and the `.strip("<>")` and `f"<{fg}>"` guards in dataset, schemas, splitters and mergers. Three recipes that relied on `[1:-1]` to break the `#PARAM.accessor` substitution needed parentheses instead. Verified against the 3,468-target corpus: identical load outcome, shape, dtype and error message for every one. The property references regenerate with the delimiters dropped and nothing else changed, and every visu_pars still rewrites byte-for-byte. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NuK1cZi8U54WXAdXMmGpzy
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.
Fixes #176.
Spec 2.2: the angle brackets delimit a JCAMP-DX string, they are not part of its value.
parse_valuereturned whole<...>matches, so every consumer had to strip them:<>reads as the empty string, per point 4 of the issue. A caller still cannot tell##$KEY=<>from##$KEY=by value — both are''.What changed
_STRING_REcaptures the inside, keeping the two-alternative escape handling from Parse escaped delimiters and nested structs instead of discarding them (J3, J4, J5) #158, and every parse path unquotes. A value whose elements are all delimited strings skips the numeric casts, because<1> <2>is a list of the strings"1"and"2"and never of two numbers.strsays whether it is a JCAMP string or an undelimited enum symbol, so a parameter keeps whichever form it was already written in. That is what makes read-modify-write —FrameGroupSplitter,SlicePackageSplitter— put<FG_SLICE>and<a.u.>back as they were, whileVisuCoreFrameType=MAGNITUDE_IMAGEstays bare.[1:-1]slices and the delimited literals inbrukerapi/config/, and the.strip("<>")/f"<{fg}>"guards indataset.py,schemas.py,splitters.pyandmergers.py.[1:-1]to stop#PARAM.method(...)from being read as a#PARAM+ accessor substitution; they take parentheses instead ((#ACQ_sw_version).replace(...)).dim_typeexpectations, docs and the split example follow.Effect on the public API
dim_typeandmetadataare the visible ones:FrameGroupSplitter("FG_ECHO")andfilter(parameter='PULPROG', value='RARE.ppg')take the undelimited name; the delimited form no longer matches.Verification
<X>→X; no affine, date, shape or id moved.visu_parsstill rewrite byte-for-byte. (99recofiles differ in where the 78-column wrap falls, identically on master — pre-existing, not from this change.)test_affine_agrees_with_the_paravision_nifti_sformfailures are the same ones master has.🤖 Generated with Claude Code
https://claude.ai/code/session_01NuK1cZi8U54WXAdXMmGpzy