Repository navigation
Read caret conversion factors as powers - #1453
Merged
Merged
Conversation
HED 8.0.0 to 8.2.0 and score 1.2.0 write SI modifier factors as 10^-15. Replacing the caret with e made that 10e-15, ten times too large, so Duration/1 fs on 8.2.0 converted to 1e-14 s. A shared parse_conversion_factor reads base^exponent as a power; the unit entry and the compliance check both use it. Decimals and e-notation are unchanged, including the literal 10e-6 of 8.3.0 and 8.4.0. The user guide's schema release section documents --set-ids and --require-ids and points at the hed-schemas release guide.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Fractional powers of negative bases can return complex values and later cause an unexpected TypeError.
1 open finding
What changed in this PR
This PR corrects caret-based schema conversion factors and expands schema-release documentation.
Changes:
- Adds shared parsing for decimal, e-notation, and caret powers.
- Adds conversion and compliance tests.
- Documents schema ID release commands.
| File | Description |
|---|---|
hed/schema/hed_schema_entry.py |
Adds shared conversion-factor parsing. |
hed/schema/schema_validation/attribute_validators.py |
Uses shared parsing during compliance checks. |
tests/models/test_hed_tag.py |
Tests caret-factor conversions. |
tests/schema/test_schema_attribute_validators.py |
Tests caret factors in compliance validation. |
docs/user_guide.md |
Documents schema release and ID workflows. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A negative base with a fractional exponent made ** return a complex number, which later failed in get_conversion_factor. math.pow raises ValueError there, so the parser returns None as its contract says.
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.

HED 8.0.0 to 8.2.0 and score 1.2.0 write SI modifier factors as 10^-15. Replacing the caret with e made that 10e-15, ten times too large, so Duration/1 fs on 8.2.0 converted to 1e-14 s. A shared parse_conversion_factor reads base^exponent as a power; the unit entry and the compliance check both use it. Decimals and e-notation are unchanged, including the literal 10e-6 of 8.3.0 and 8.4.0.
The user guide's schema release section documents --set-ids and --require-ids and points at the hed-schemas release guide.