(self)
return is_in
Helper for .has()
Helper for .has()
Helper for . has ()
def _has_matcher(self):
        """Helper for .has()"""
        def _ncsplit(expr):
            # this is not the same as args_cnc because here
            # we don't assume expr is a Mul -- hence deal with args --
            # and always return a set.
            cpart, ncpart = [], []
            for arg in expr.args:
                if arg.is_commutative:
                    cpart.append(arg)
                else:
                    ncpart.append(arg)
            return set(cpart), ncpart

        c, nc = _ncsplit(self)
        cls = self.__class__

        def is_in(expr):
            if expr == self:
                return True
            elif not isinstance(expr, Basic):
                return False
            elif isinstance(expr, cls):
                _c, _nc = _ncsplit(expr)
                if (c & _c) == c:
                    if not nc:
                        return True
                    elif len(nc) <= len(_nc):
                        for i in xrange(len(_nc) - len(nc)):
                            if _nc[i:i + len(nc)] == nc:
                                return True
            return False
        return is_in
def _has_matcher ( self ) : def _ncsplit ( expr ) : # this is not the same as args_cnc because here # we don't assume expr is a Mul -- hence deal with args -- # and always return a set. cpart , ncpart = [ ] , [ ] for arg in expr . args : if arg . is_commutative : cpart . append ( arg ) else : ncpart . append ( arg ) return set ( cpart ) , ncpart c , nc = _ncsplit ( self ) cls = self . __class__ def is_in ( expr ) : if expr == self : return True elif not isinstance ( expr , Basic ) : return False elif isinstance ( expr , cls ) : _c , _nc = _ncsplit ( expr ) if ( c & _c ) == c : if not nc : return True elif len ( nc ) <= len ( _nc ) : for i in xrange ( len ( _nc ) - len ( nc ) ) : if _nc [ i : i + len ( nc ) ] == nc : return True return False return is_in