# BaseUnit¶

class simtk.unit.baseunit.BaseUnit(base_dim, name, symbol)

Physical unit expressed in exactly one BaseDimension.

For example, meter_base_unit could be a BaseUnit for the length dimension. The BaseUnit class is used internally in the more general Unit class.

__init__(base_dim, name, symbol)

Creates a new BaseUnit.

Parameters
• self: The newly created BaseUnit.
• base_dim: (BaseDimension) The dimension of the new unit, e.g. ‘mass’
• name: (string) Name of the unit, e.g. “kilogram”
• symbol: (string) Symbol for the unit, e.g. ‘kg’. This symbol will appear in
Quantity string descriptions.

Methods

 __init__(base_dim, name, symbol) Creates a new BaseUnit. conversion_factor_to(other) Returns a conversion factor from this BaseUnit to another BaseUnit. define_conversion_factor_to(other, factor) Defines a conversion factor between two BaseUnits. get_dimension_tuple() Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key. iter_base_dimensions() Returns a dictionary of BaseDimension:exponent pairs, describing the dimension of this unit. iter_base_units()
__lt__(other)

Comparison function that sorts BaseUnits by BaseDimension

iter_base_dimensions()

Returns a dictionary of BaseDimension:exponent pairs, describing the dimension of this unit.

get_dimension_tuple()

Returns a sorted tuple of (BaseDimension, exponent) pairs, that can be used as a dictionary key.

__str__()

Returns a string with the name of this BaseUnit

define_conversion_factor_to(other, factor)

Defines a conversion factor between two BaseUnits.

self * factor = other

Parameters:
• self: (BaseUnit) ‘From’ unit in conversion.
• other: (BaseUnit) ‘To’ unit in conversion.
• factor: (float) Conversion factor.

After calling this method, both self and other will have stored conversion factors for one another, plus all other BaseUnits which self and other have previously defined.

Both self and other must have the same dimension, otherwise a TypeError will be raised.

Returns None.

conversion_factor_to(other)

Returns a conversion factor from this BaseUnit to another BaseUnit.

It does not matter which existing BaseUnit you define the conversion factor to. Conversions for all other known BaseUnits will be computed at the same time.

Raises TypeError if dimension does not match. Raises LookupError if no conversion has been defined. (see define_conversion_factor_to).