(isid, new=new)
return ident_remove
Create a rule to remove identities

    isid - fn :: x -> Bool  --- whether or not this element is an identity

    >>> from sympy.strategies import rm_id
    >>> from sympy import Basic
    >>> remove_zeros = rm_id(lambda x: x==0)
    >>> remove_zeros(Basic(1, 0, 2))
    Basic(1, 2)
    >>> remove_zeros(Basic(0, 0)) # If only identites then we keep one
    Basic(0)

    See Also:
        unpack
Create a rule to remove identities
Create a rule to remove identities
def rm_id(isid, new=new):
    """ Create a rule to remove identities

    isid - fn :: x -> Bool  --- whether or not this element is an identity

    >>> from sympy.strategies import rm_id
    >>> from sympy import Basic
    >>> remove_zeros = rm_id(lambda x: x==0)
    >>> remove_zeros(Basic(1, 0, 2))
    Basic(1, 2)
    >>> remove_zeros(Basic(0, 0)) # If only identites then we keep one
    Basic(0)

    See Also:
        unpack
    """
    def ident_remove(expr):
        """ Remove identities """
        ids = list(map(isid, expr.args))
        if sum(ids) == 0:           # No identities. Common case
            return expr
        elif sum(ids) != len(ids):  # there is at least one non-identity
            return new(expr.__class__,
                       *[arg for arg, x in zip(expr.args, ids) if not x])
        else:
            return new(expr.__class__, expr.args[0])

    return ident_remove
def rm_id ( isid , new = new ) : def ident_remove ( expr ) : """ Remove identities """ ids = list ( map ( isid , expr . args ) ) if sum ( ids ) == 0 : # No identities. Common case return expr elif sum ( ids ) != len ( ids ) : # there is at least one non-identity return new ( expr . __class__ , * [ arg for arg , x in zip ( expr . args , ids ) if not x ] ) else : return new ( expr . __class__ , expr . args [ 0 ] ) return ident_remove