def __add__(self, other):
        """
        Add two similar sets of coefficients or coefficients and a scalar:
        self + other. For the addition of a scalar, only the degree 0
        term is modified.
        """
        if isinstance(other, SHCoeffs):
            if (self.normalization == other.normalization and self.csphase ==
                    other.csphase and self.kind == other.kind and
                    self.lmax == other.lmax):
                coeffs = _np.empty([2, self.lmax+1, self.lmax+1],
                                   dtype=self.coeffs.dtype)
                coeffs[self.mask] = (self.coeffs[self.mask] +
                                     other.coeffs[self.mask])
                return SHCoeffs.from_array(coeffs, csphase=self.csphase,
                                           normalization=self.normalization)
            else:
                raise ValueError('The two sets of coefficients must have the '
                                 'same kind, normalization, csphase and '
                                 'lmax.')
        elif _np.isscalar(other) is True:
            if self.kind == 'real' and _np.iscomplexobj(other):
                raise ValueError('Can not add a complex constant to real '
                                 'coefficients.')
            coeffs = self.coeffs.copy()
            coeffs[0, 0, 0] += other
            return SHCoeffs.from_array(coeffs, csphase=self.csphase,
                                       normalization=self.normalization)
        else:
            raise NotImplementedError('Mathematical operator not implemented '
                                      'for these operands.')
def __add__ ( self , other ) : if isinstance ( other , SHCoeffs ) : if ( self . normalization == other . normalization and self . csphase == other . csphase and self . kind == other . kind and self . lmax == other . lmax ) : coeffs = _np . empty ( [ 2 , self . lmax + 1 , self . lmax + 1 ] , dtype = self . coeffs . dtype ) coeffs [ self . mask ] = ( self . coeffs [ self . mask ] + other . coeffs [ self . mask ] ) return SHCoeffs . from_array ( coeffs , csphase = self . csphase , normalization = self . normalization ) else : raise ValueError ( 'The two sets of coefficients must have the ' 'same kind, normalization, csphase and ' 'lmax.' ) elif _np . isscalar ( other ) is True : if self . kind == 'real' and _np . iscomplexobj ( other ) : raise ValueError ( 'Can not add a complex constant to real ' 'coefficients.' ) coeffs = self . coeffs . copy ( ) coeffs [ 0 , 0 , 0 ] += other return SHCoeffs . from_array ( coeffs , csphase = self . csphase , normalization = self . normalization ) else : raise NotImplementedError ( 'Mathematical operator not implemented ' 'for these operands.' )
Add two similar sets of coefficients or coefficients and a scalar:
        self + other. For the addition of a scalar, only the degree 0
        term is modified.