class documentation

Bi-directional unit conversion of values. This adapter converts values to a different unit system based on their name. There is a name->units mapper for getitem conversions and a separate name->units adapter for setitem conversions so that read/write can result in different unit conversions. This is useful when, for example, you want a context to preserve its current units for all its variables, but something using this context ( a shell or plot, or whatever) wants the values in another unit system. If units aren't found for a particular name, the converter silently lets the variable pass through. If units are found, but a converter isn't, or the converter fails, a ConversionError is raised. Users can pass in a dictionary of converters functions to be used for unit conversion.

Method adapt_getitem Convert 'value' to the desired units for objects of the given 'name'
Method adapt_setitem Convert 'value' to the desired units for objects of the given 'name'
Class Variable converters Undocumented
Class Variable getitem_units Undocumented
Class Variable setitem_units Undocumented
Method _convert Find a converter for value and convert it to new_units.
def adapt_getitem(self, context, name, value): (source)

Convert 'value' to the desired units for objects of the given 'name' The getitem_units name->units mapper is used to look up the proper units. If no units are found for 'name', the value passes through unaltered. If a units are found, but an appropriate converter is not, or the conversion fails, a ConversionError is raised.

def adapt_setitem(self, context, name, value): (source)

Convert 'value' to the desired units for objects of the given 'name' The setitem_units name->units mapper is used to look up the proper units. If no units are found for 'name', the value passes through unaltered. If a units are found, but an appropriate converter is not, or the conversion fails, a ConversionError is raised.

getitem_units = (source)

Undocumented

setitem_units = (source)

Undocumented

def _convert(self, value, new_units): (source)

Find a converter for value and convert it to new_units. If no converter is found for the type, raise ConversionError