HED allows one SI modifier on each component of a compound unit (spec 3.1.4.5). Speed/3 cm-per-us (centimeters per microsecond) is valid because cm and us are each a modified symbol. hed-python currently rejects it.
Current behavior: UnitEntry.finalize_entry in hed/schema/hed_schema_entry.py prepends each modifier to the whole unit string when the unit has SIUnit. For m-per-s this produces km-per-s, mm-per-s, and so on, which accepts some valid forms but rejects any form with a modifier on the second component, and it computes conversion factors as if the modifier applied to the whole string.
Expected behavior: for a unit whose name contains -per- or ^, split 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. The conversion factor is the listed factor times each modifier factor raised to its component's exponent, negative for denominator components: cm-per-ms^2 = 0.01 x (0.001)^-2 = 1e4 m-per-s^2; mm^3 = 1e-9 m^3.
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)
Tests: hed-tests case units-invalid-compound-units (json_test_data/validation_test_data/UNITS_INVALID.json) covers this and is currently skipped in spec_tests/test_errors.py. Same as hed-standard/hed-python#1404.
HED allows one SI modifier on each component of a compound unit (spec 3.1.4.5).
Speed/3 cm-per-us(centimeters per microsecond) is valid becausecmandusare each a modified symbol. hed-python currently rejects it.Current behavior:
UnitEntry.finalize_entryinhed/schema/hed_schema_entry.pyprepends each modifier to the whole unit string when the unit hasSIUnit. Form-per-sthis produceskm-per-s,mm-per-s, and so on, which accepts some valid forms but rejects any form with a modifier on the second component, and it computes conversion factors as if the modifier applied to the whole string.Expected behavior: for a unit whose name contains
-per-or^, split 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. The conversion factor is the listed factor times each modifier factor raised to its component's exponent, negative for denominator components:cm-per-ms^2= 0.01 x (0.001)^-2 = 1e4 m-per-s^2;mm^3= 1e-9 m^3.Examples:
Speed/3 cm-per-us,Speed/3 km-per-s,Acceleration/2 mm-per-s^2,Volume/2 mm^3Speed/3 kmm-per-s(two modifiers),Speed/3 m-per-sec(not a symbol),Speed/3 m-per-S(wrong case)Tests: hed-tests case
units-invalid-compound-units(json_test_data/validation_test_data/UNITS_INVALID.json) covers this and is currently skipped inspec_tests/test_errors.py. Same as hed-standard/hed-python#1404.