parameters: (self, other, factor)
docstring: 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.
docstring_summary: Defines a conversion factor between two BaseUnits.
docstring_tokens: Defines a conversion factor between two BaseUnits .
function: def define_conversion_factor_to(self, 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.
          """
          if self.dimension != other.dimension:
              raise TypeError('Cannot define conversion for BaseUnits with different dimensions.')
          assert(factor != 0)
          assert(not self is other)
          # import all transitive conversions
          self._conversion_factor_to[other] = factor
          self._conversion_factor_to_by_name[other.name] = factor
          for (unit, cfac) in other._conversion_factor_to.items():
              if unit is self: continue
              if unit in self._conversion_factor_to: continue
              self._conversion_factor_to[unit] = factor * cfac
              unit._conversion_factor_to[self] = pow(factor * cfac, -1)
              self._conversion_factor_to_by_name[unit.name] = factor * cfac
              unit._conversion_factor_to_by_name[self.name] = pow(factor * cfac, -1)
          # and for the other guy
          invFac = pow(factor, -1.0)
          other._conversion_factor_to[self] = invFac
          other._conversion_factor_to_by_name[self.name] = invFac
          for (unit, cfac) in self._conversion_factor_to.items():
              if unit is other: continue
              if unit in other._conversion_factor_to: continue
              other._conversion_factor_to[unit] = invFac * cfac
              unit._conversion_factor_to[other] = pow(invFac * cfac, -1)
              other._conversion_factor_to_by_name[unit.name] = invFac * cfac
              unit._conversion_factor_to_by_name[other.name] = pow(invFac * cfac, -1)
function_tokens: def define_conversion_factor_to ( self , other , factor ) : if self . dimension != other . dimension : raise TypeError ( 'Cannot define conversion for BaseUnits with different dimensions.' ) assert ( factor != 0 ) assert ( not self is other ) # import all transitive conversions self . _conversion_factor_to [ other ] = factor self . _conversion_factor_to_by_name [ other . name ] = factor for ( unit , cfac ) in other . _conversion_factor_to . items ( ) : if unit is self : continue if unit in self . _conversion_factor_to : continue self . _conversion_factor_to [ unit ] = factor * cfac unit . _conversion_factor_to [ self ] = pow ( factor * cfac , - 1 ) self . _conversion_factor_to_by_name [ unit . name ] = factor * cfac unit . _conversion_factor_to_by_name [ self . name ] = pow ( factor * cfac , - 1 ) # and for the other guy invFac = pow ( factor , - 1.0 ) other . _conversion_factor_to [ self ] = invFac other . _conversion_factor_to_by_name [ self . name ] = invFac for ( unit , cfac ) in self . _conversion_factor_to . items ( ) : if unit is other : continue if unit in other . _conversion_factor_to : continue other . _conversion_factor_to [ unit ] = invFac * cfac unit . _conversion_factor_to [ other ] = pow ( invFac * cfac , - 1 ) other . _conversion_factor_to_by_name [ unit . name ] = invFac * cfac unit . _conversion_factor_to_by_name [ other . name ] = pow ( invFac * cfac , - 1 )