示例#1
0
 def __ilshift__(self, A): 
     """ A can be two things :
       * G <<= any_gf_init will init the BlockGf with the initializer
       * G <<= g2 where g2 is a BlockGf will copy g2 into self
     """
     if isinstance(A, self.__class__) : 
         if self is not A : self.copy_from(A) # otherwise it is useless AND does not work !!
     elif isinstance(A, lazy_expressions.LazyExpr) : # A is a lazy_expression made of BlockGf, scalars, descriptors 
         A2= descriptors.convert_scalar_to_const(A)
         def e_t (x) : 
             if not isinstance(x, descriptors.Base) : return x
             tmp = self.copy()
             x(tmp)
             return tmp
         #e_t2 = self.__lazy_expr_eval_context__()
         self.copy_from ( lazy_expressions.eval_lazy_expr(e_t, A2) )
     elif isinstance(A, lazy_expressions.LazyExprTerminal) : #e.g. g<<= SemiCircular (...) 
         self <<= lazy_expressions.LazyExpr(A)
     elif descriptors.is_scalar(A) : #in the case it is a scalar .... 
         self <<= lazy_expressions.LazyExpr(A)
     elif isinstance(A, gf_init.Base) : # backwards compatibility, deprecated
         A(self)
     else :
         raise RuntimeError, " BlockGf: <<= operator : RHS not understood"
     return self
示例#2
0
    def __lshift__(self, A):
        """ A can be two things:
          * G << any_init will init the GFBloc with the initializer
          * G << g2 where g2 is a GFBloc will copy g2 into self
        """
        if isinstance(A, Gf):
            if self is not A:
                self.copy_from(
                    A)  # otherwise it is useless AND does not work !!
        elif isinstance(
                A, lazy_expressions.LazyExpr
        ):  # A is a lazy_expression made of GF, scalars, descriptors
            A2 = descriptors.convert_scalar_to_const(A)

            def e_t(x):
                if not isinstance(x, descriptors.Base): return x
                tmp = self.copy()
                x(tmp)
                return tmp

            self.copy_from(lazy_expressions.eval_expr_with_context(e_t, A2))
        elif isinstance(A, lazy_expressions.LazyExprTerminal
                        ):  #e.g. g<< SemiCircular (...)
            self << lazy_expressions.LazyExpr(A)
        elif descriptors.is_scalar(A):  #in the case it is a scalar ....
            self << lazy_expressions.LazyExpr(A)
        else:
            raise NotImplemented
        return self
示例#3
0
def _lshift_(self, A):
    """ A can be two things:
      * G << any_init will init the GFBloc with the initializer
      * G << g2 where g2 is a GFBloc will copy g2 into self
    """
    import descriptors
    if isinstance(A, self.__class__):
        if self is not A: self.copy_from(A) # otherwise it is useless AND does not work !!
    elif isinstance(A, lazy_expressions.LazyExpr): # A is a lazy_expression made of GF, scalars, descriptors
        A2 = descriptors.convert_scalar_to_const(A)
        def e_t (x):
            if not isinstance(x, descriptors.Base): return x
            tmp = self.copy()
            x(tmp)
            return tmp
        self.copy_from (lazy_expressions.eval_expr_with_context(e_t, A2) )
    elif isinstance(A, lazy_expressions.LazyExprTerminal): #e.g. g<< SemiCircular (...)
        self << lazy_expressions.LazyExpr(A)
    elif descriptors.is_scalar(A): #in the case it is a scalar ....
        self << lazy_expressions.LazyExpr(A)
    else:
        raise RuntimeError, " << operator: RHS  not understood"
    return self