Next / Previous / Contents / Shipman's homepage

9.3. FoDim.__add__(): Add two dimensions

Because the two dimensions may have different units, we use Section 9.8, “FoDim.convert(): Change units” to convert the second dimension to the units of the first.

fohelpers.py
# - - -   F o D i m . _ _ a d d _ _

    def __add__(self, other):
        '''Add two dimensions.
        '''
        #-- 1 --
        # [ otherCon  :=  other expressed in units of (self.units) ]
        otherCon = other.convert(self.units)

        #-- 2 --
        return FoDim(self.n + otherCon.n, self.units)