Skip to content

Read caret conversion factors as powers - #1453

Merged
VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:fix_conversion_factor
Oct 9, 2026
Merged

VisLab merged 2 commits into
hed-standard:mainfrom
VisLab:fix_conversion_factor

Conversation

@VisLab

@VisLab VisLab commented Oct 8, 2026

Copy link
Copy Markdown
Member

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread hed/schema/hed_schema_entry.py Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation consistently fixes caret parsing with focused regression coverage and accurate documentation.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@VisLab
VisLab merged commit 46a733d into hed-standard:main Oct 9, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants