Skip to content

Compound units should accept an SI modifier on each component #850

Description

@VisLab

HED 8.5.0 allows SI modifiers on each component of a compound unit. Speed/3 cm-per-us (centimeters per microsecond) is valid because cm and us are each a modified symbol. hed-javascript currently rejects it.

Current behavior: when a unit has SIUnit, hed-javascript prepends each modifier to the whole unit string. For m-per-s this produces km-per-s, mm-per-s, and so on, which happens to accept some valid forms but rejects any form with a modifier on the second component.

Expected behavior: for a unit whose name contains -per- or ^, split the annotated unit on -per- and match each component against the schema component, allowing one SI symbol modifier in front of each. Exponents stay attached to their component.

Examples:

  • valid: Speed/3 cm-per-us, Speed/3 km-per-s, Acceleration/2 mm-per-s^2, Volume/2 mm^3
  • invalid: Speed/3 kmm-per-s (two modifiers), Speed/3 m-per-sec (not a symbol), Speed/3 m-per-S (wrong case)

Where: src/schema/entries.js, class SchemaUnit (constructor and validateUnit).

Tests: hed-tests case units-invalid-compound-units (commit e3fc564) covers this; add the same strings to tests/jsonTestData/tagParserTests.data.js.

Same change is needed in hed-typescript (src/schema/entries/unit.ts).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions