DerivedUnit¶
- class justunits.DerivedUnit(*sub_units)¶
- Parameters
*sub_units –
target_style –
Examples
DerivedUnit are comparable and hashable. The order of units is neglected for the comparison resulting into a⋅b == b⋅a.
>>> import justunits >>> energy = justunits.from_string("N*m") >>> ygrene = justunits.from_string("m*N") >>> energy == ygrene True
DerivedUnit
is hashable likeAUnit
to support usage as key within within mappings. In the current implementation the order of internal units is neglected. Meaning a⋅b and b⋅a are considered being the same.>>> hash(energy) == hash(ygrene) True
>>> map = {energy: "energy"} >>> map[ygrene] 'energy'
>>> pressure = justunits.from_string("N/m") >>> pressure != energy True
>>> hash(pressure) == hash(energy) False