Parse filename-like attribute values as full strings, not leading digits#1789
Open
mattdawkins wants to merge 1 commit into
Open
Parse filename-like attribute values as full strings, not leading digits#1789mattdawkins wants to merge 1 commit into
mattdawkins wants to merge 1 commit into
Conversation
Attribute values such as '0123ABC456' (e.g. the source_image filenames
the sea-lion suppressor writes) were truncated to their leading digits:
the desktop CSV parser used parseFloat, which accepts a numeric prefix,
so the value became the number 123. The attribute-definition inference
had the same bug and typed such attributes as numbers.
- Desktop _deduceType now uses Number(), which only converts fully
numeric strings (empty/whitespace stays a string).
- Desktop attributeProcessor infers 'number' only for fully numeric
values.
- The server parser had the adjacent Python gotcha: float() accepts
underscore digit separators ('20240624_120000') and inf/nan
spellings. Both its value parsing and type inference now require a
strictly numeric string.
Includes a regression test parsing (atr) values with filename-like,
numeric, and boolean content.
Co-Authored-By: Claude Fable 5 <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.
Problem
A detection attribute whose value is a filename like
0123ABC456(numbers, letters, numbers — e.g. thesource_imageattributes the sea-lion suppressor writes) displayed as just123: only the first digit group survived import.Cause
_deduceTypeinserializers/viame.ts) usedparseFloat, which parses a leading numeric prefix (parseFloat('0123ABC456') === 123), replacing the string with a number.attributeProcessor.ts) used the sameparseFloatcheck, so such attributes were also typed as numbers.dive_utils/serializers/viame.py) had the adjacent Python gotcha:float()accepts underscore digit separators (float('20240624_120000') == 20240624120000.0) andinf/nanspellings, corrupting underscore-separated filename stems the same way.Fix
_deduceTypeusesNumber(), which converts only fully numeric strings (with an explicit empty/whitespace guard, sinceNumber('') === 0).attributeProcessorinfersnumberonly for fully numeric values.Real numbers (
12.5,-3,1e5) and booleans still convert exactly as before. Regression test parses(atr)values with filename-like, underscore-separated, numeric, and boolean content and checks both values and inferred datatypes.Note: values already truncated in previously saved annotations can't be recovered — re-importing the source CSV restores them.
🤖 Generated with Claude Code