convert_attr_units
convert_attr_units(
attrs: <class ‘dict ,
name: str ,
to_units: str ,
from_units = ““,
)-> ’dict’
Convert one attr to the units patch attrs use, dropping the file’s units.
Patch attrs record each physical quantity in the units the inventory documents, so a file’s own unit declaration is spent here at the parse boundary rather than travelling beside the value as a companion attr. A file which declares no units keeps its value: the format’s documented default is then the assumption, and the reader says so. A file which declares units that cannot be used – unreadable, or of the wrong dimension – has a value of unknown scale, so the value is dropped with a warning rather than passed off as canonical.
Parameters
| Parameter | Description |
|---|---|
| attrs | The parsed attrs, modified in place and returned. |
| name | The attr to convert. |
| to_units | The units the patch attr uses. |
| from_units |
The units the format documents when it states none of its own, for a header whose units live in the key name rather than beside it. A declared unit still wins. |