Repository navigation
Add core helpers: shortest_decimal, EnumConverter, own_annotations - #308
Merged
Merged
Conversation
- _core/numeric.py: shortest_decimal, the shortest decimal that a file stores as the same single-precision number (through an optional unit conversion), and float32_repr. - _core/enum.py: EnumConverter, the converter of a free-text field with known terms (a known term becomes the enum member, any other string stays a string). - _core/compat.py: own_annotations, the annotations a class declares itself, read portably on Python 3.14 (PEP 649/749). - _core/compare.py: differs, which does not trust != on arrays. - _core/properties.py: a module docstring and __all__. With tests for the numeric helpers, and API pages for properties, numeric and enum. Stacked on the vocabulary enums, which the EnumConverter example uses (SpaceEnum). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw
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.
Part of #233, split out of #287. Stacked on #307:
EnumConverter's docstring example usesSpaceEnum.Small general-purpose helpers in
brainhops._core:numeric.shortest_decimal(value, encode)(andfloat32_repr): the shortest decimal that a writer would store as the same float32 afterencode. For example, an MGH TR stored as float32 milliseconds reads back as2.0007s rather than2.000699951171875.enum.EnumConverter(enum): a field converter that accepts members, values or names. Unlike a closure, it has a repr, compares equal and pickles.compat.own_annotations(cls): a class's own annotations on Python 3.8 to 3.14, under PEP 649 lazy annotations.compare.differs.__all__forproperties.py.Also adds the tests (
tests/test_core_numeric.py) and thedocs/api/_corepages and nav entries.Stack
FormatDispatchermixin and small fixes, based onmain🤖 Generated with Claude Code
https://claude.ai/code/session_01VmK1jLTwd2hMkvYnMWEyYw
Generated by Claude Code