On 29 Nov., 00:09, John H Palmieri <jhpalmier...@gmail.com> wrote:
> I think it's this code in sage/rings/polynomial/
> multi_polynomial_ring_generic.pyx:
>
>     def __contains__(self, x):
>         """
>         This definition of containment does not involve a natural
>         inclusion from rings with less variables into rings with more.
>         """
>         try:
>             return x.parent() == self
>         except AttributeError:
>             return False

Is this really what we want? Simply testing equality of the parents? I
don't think that one should drop any coercion!

See Parent.__contains__, which is
    def __contains__(self, x):
        r"""
        True if there is an element of self that is equal to x under
        ==, or if x is already an element of self.  Also, True in
other
        cases involving the Symbolic Ring, which is handled specially.

        For many structures we test this by using :meth:`__call__` and
        then testing equality between x and the result.

        The Symbolic Ring is treated differently because it is
        ultra-permissive about letting other rings coerce in, but
        ultra-strict about doing comparisons.
...
        """
        P = parent_c(x)
        if P is self or P == self:
            return True
        try:
            x2 = self(x)
            EQ = (x2 == x)
            if EQ is True:
                return True
            elif EQ is False:
                return False
            elif EQ:
                return True
            else:
                from sage.symbolic.expression import is_Expression
                if is_Expression(EQ):  # if comparing gives an
Expression, then it must be an equation.
                    # We return *true* here, even though the equation
                    # EQ must have evaluated to False for us to get to
                    # this point. The reason is because... in practice
                    # SR is ultra-permissive about letting other rings
                    # coerce in, but ultra-strict about doing
                    # comparisons.
                    return True
                return False
        except (TypeError, ValueError):
            return False


Cheers,
Simon

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to