import dascore as dc
from dascore.units import units_match
assert units_match("m", "meter")
assert not units_match("m", "100 cm")
assert units_match(None, "")units_match
units_match(
units1: str | bytes | pint.registry.Quantity | pint.facets.plain.unit.PlainUnit | numpy.datetime64 | numpy.timedelta64 | int | float | ellipsis | None[str, <class ’bytes, Quantity, PlainUnit, datetime64, timedelta64, int, float, <class ’ellipsis, None] ,
units2: str | bytes | pint.registry.Quantity | pint.facets.plain.unit.PlainUnit | numpy.datetime64 | numpy.timedelta64 | int | float | ellipsis | None[str, <class ’bytes, Quantity, PlainUnit, datetime64, timedelta64, int, float, <class ’ellipsis, None] ,
)-> ‘bool’
Return True if two unit specifications name the same units.
Written for callers which can skip work when nothing would change, so it is deliberately stricter than == on the quantities: 1 m and 100 cm compare equal but converting between them is real work, and the spellings they leave behind differ.
Parameters
| Parameter | Description |
|---|---|
| units1 | A unit, quantity, or string, or None for “carries no units”. |
| units2 | The specification to compare against. |