Inherits from
- HasPrivateTraits: enthought.traits.has_traits.HasPrivateTraits
Attributes
- default_system
default_system = Instance(UnitSystem)
- preferred_names
preferred_names = Dict(Str, Str)
- unit_converters
unit_converters = Dict(Str, Any)
- unit_families
unit_families = Dict(Str, Instance(UnitFamily))
- unit_members
unit_members = Dict(Str, Str)
- unit_systems
unit_systems = List(Instance(UnitSystem))
Inherited from base classes
Method summary
- __init__(self)
- add_family(self, family_name, description, inverse)
- add_member(self, member_name, family)
- add_system(self, system)
- add_unit_system(self, unit_system)
- are_compatible_families(self, family1, family2)
- change_unit_system(self, obj, new_unit_system = None)
- convert(self, obj, new_unit_system = None)
- default_units_for(self, family_name)
- default_units_for_name(self, name)
- get_default(self)
- get_family_name(self, name)
- get_family_name_for_value(self, unit_value)
- get_inverse_family_name(self, family_name)
- get_inverse_name(self, family_name)
- get_unit_converter(self, obj)
- get_unit_system(self, system = None)
- get_valid_unit_strings(self, family_name)
- get_valid_units(self, family_name)
- is_compatible(self, units, family_name)
- lookup_system(self, name)
- set_default(self, system)
Inherited from base classes
- __deepcopy__(self, memo)
- __getstate__(self)
- __prefix_trait__(self, name, is_set)
- __reduce_ex__(self, protocol)
- __setstate__(self, state, trait_change_notify = True)
- add_class_trait(cls, name, *trait)
- add_trait(self, name, *trait)
- add_trait_category(cls, category)
- add_trait_listener(self, object, prefix = '')
- all_trait_names(self)
- base_trait(self, name)
- class_default_traits_view(cls)
- class_editable_traits(cls)
- class_trait_names(cls, **metadata)
- class_trait_view(cls, name = None, view_element = None)
- class_trait_view_elements(cls)
- class_traits(cls, **metadata)
- clone_traits(self, traits = None, memo = None, copy = None, **metadata)
- configure_traits(self, filename = None, view = None, kind = None, edit = True, context = None, handler = None, id = '', scrollable = None, **args)
- copy_traits(self, other, traits = None, memo = None, copy = None, **metadata)
- copyable_trait_names(self, **metadata)
- default_traits_view(self)
- edit_traits(self, view = None, parent = None, kind = None, context = None, handler = None, id = '', scrollable = None, **args)
- editable_traits(self)
- has_traits_interface(self, *interfaces)
- on_trait_change(self, handler, name = None, remove = False, dispatch = 'same', priority = False, deferred = False)
- print_traits(self, show_help = False, **metadata)
- remove_trait(self, name)
- remove_trait_listener(self, object, prefix = '')
- reset_traits(self, traits = None, **metadata)
- set_trait_dispatch_handler(cls, name, klass, override = False)
- sync_trait(self, trait_name, object, alias = None, mutual = True, remove = False)
- trait(self, name, force = False, copy = False)
- trait_context(self)
- trait_get(self, *names, **metadata)
- trait_monitor(cls, handler, remove = False)
- trait_names(self, **metadata)
- trait_set(self, trait_change_notify = True, **traits)
- trait_setq(self, **traits)
- trait_subclasses(cls, all = False)
- trait_view(self, name = None, view_element = None)
- trait_view_elements(self)
- trait_views(self, klass = None)
- traits(self, **metadata)
- validate_trait(self, name, value)
Methods
- __init__(self)
Creates a new unit manager.
- add_family(self, family_name, description, inverse)
Maintains dict of families w/ description & inverse values
- add_member(self, member_name, family)
Adds a member to the unit_members dict used to lookup unit aliases
Parameters
- member_name:
- the alias
- family:
- the name of the unit_family to which the alias maps
- add_system(self, system)
Adds unit system(s) to the unit_manager's list of systems
- add_unit_system(self, unit_system)
Allows addition of new system at run-time. This is also used by at initialization to populate systems known by the unit_manager from a unit_db (loaded from a text file)
- are_compatible_families(self, family1, family2)
Returns True if family2 is compatible with family1. Equal families are compatible. All families are compatible with None. That is when family1 is 'None' any value for family2 is considered compatible.
- change_unit_system(self, obj, new_unit_system = None)
Changes unit system for supported object types.
Supported types are types with a registered unit conversion function. This unit conversion function will be invoked to return a new object whose data is equal to the data of obj converted to new_unit_system. If new_unit_system is unspecified, the target unit system is the system default unit system.
If the units cannot be converted (i.e., a Quantity instance has no family_name), an exception is logged and raised.
- convert(self, obj, new_unit_system = None)
Convert obj to specified new_unit_system new_unit_system may be a unit_system or a string or None (default) if you wish to use the default system
- default_units_for(self, family_name)
Returns the default unit system units for the specified family.
- default_units_for_name(self, name)
Return the units in the default unit system for the name. name must be a member of a family.
- get_default(self)
Returns the default unit system.
- get_family_name(self, name)
Returns family name given a member name
- get_family_name_for_value(self, unit_value)
Walks the unit_db looking for a unit with a matching value. This is potentially expensive, so only do it if you must.
- get_inverse_family_name(self, family_name)
Returns the inverse family name of the given family name (or member name)
- get_inverse_name(self, family_name)
Returns the 'preferred' name of the inverse of the given family name (or member name)
- get_unit_converter(self, obj)
Convenience function to lookup converter
- get_unit_system(self, system = None)
Used to simplify the method change_unit_system() method that can take a String, an UnitSystem or None.
- get_valid_unit_strings(self, family_name)
Returns a list of units that are compatible with a family given a family name (or alias)
- get_valid_units(self, family_name)
Returns a list of units that are compatible with a family given a family name (or alias)
- is_compatible(self, units, family_name)
Returns True if the family_name and units are compatible. Just because two units have the same derivation, does not mean they are compatible, it just means that value conversion is simle.
- lookup_system(self, name)
Returns the unit system with the specified name or raises an exception if no such system exists.
- set_default(self, system)
Sets the default unit system.
Probably called when the project is loaded.