Exemple #1
0
 def wfunc(self, right):
     """operator with Scalar checking"""
     try:
         result = (func(self.w, right) if rank(right) is None else func(
             self.w, right.w))
     except AttributeError:
         from isceobj.Util.geo.exceptions import NonCovariantOperation
         from isceobj.Util.geo.exceptions import error_message
         raise NonCovariantOperation(error_message(func, self, right))
     return Scalar(result)
Exemple #2
0
 def __div__(self, other):
     try:
         result = super(Scalar, self).__div__(other)
     except (TypeError, AttributeError):
         try:
             result = super(Scalar, self).__div__(other.w)
         except AttributeError:
             from isceobj.Util.geo.exceptions import (
                 UndefinedGeometricOperation, error_message)
             raise UndefinedGeometricOperation(
                 error_message(self.__class__.__div__, self, other))
         pass
     return result
Exemple #3
0
 def wrapped_op(self, other):
     try:
         result = self.__class__(*[
             op(*items)
             for items in itertools.zip_longest(self.iter(), other.iter())
         ])
     except (TypeError, AttributeError) as err:
         from isceobj.Util.geo.exceptions import (NonCovariantOperation,
                                                  error_message)
         x = (NonCovariantOperation
              if isinstance(other, PolyMorphicNumpyMixIn) else TypeError)
         raise x(error_message(op, self, other))
     return result
Exemple #4
0
 def __pow__(self, n):
     try:
         result = reduce(operator.mul, itertools.repeat(self, n))
     except TypeError as err:
         if isinstance(n, Geometric):
             from isceobj.Util.geo.exceptions import (
                 UndefinedGeometricOperation, error_message)
             raise UndefinedGeometricOperation(
                 error_message(self.__class__.__pow__, self, n))
         if n <= 1:
             raise ValueError("Vector exponent must be 1,2,3...,")
         raise err
     return result