#17984: fix Parent.__contains__
------------------------------------+--------------------------
       Reporter:  rws               |        Owner:
           Type:  defect            |       Status:  needs_work
       Priority:  major             |    Milestone:  sage-6.9
      Component:  basic arithmetic  |   Resolution:
       Keywords:                    |    Merged in:
        Authors:  Ralf Stephan      |    Reviewers:
Report Upstream:  N/A               |  Work issues:
         Branch:                    |       Commit:
   Dependencies:  #19040            |     Stopgaps:
------------------------------------+--------------------------
Description changed by rws:

Old description:

> In the catch-all `structure/parent.pyx:Parent.__contains__` we depend on
> the construction `bool(item==self(item))` to get the right result for,
> e.g. `sqrt(3) in RR/CC` but `bool(RR/CC(sqrt(3))==sqrt(3))` being `False`
> a trick was applied by the author that makes the function always return
> `True`. This trick uses the fact that Maxima doesn't know about the rings
> and will raise an exception, which is then caught.
>
> This way of programming strikes me as very wrong and previously I
> supported the notion that dedicated `__contains__` methods for both RR/CC
> weren needed. As you can see from the discussion this was not wanted.
>
> Of course, as soon as we want to get rid of Maxima this odd behaviour
> must be simulated, because there is no way to test containment in these
> inexact rings in a generic way.
>
> In order to make it more reliable the way we treat inclusion in inexact
> rings needs to be reconsidered.
>
> Previously this ticket proposed that:
> ...dedicated `__contains__` methods for both rings are needed.

New description:

 In the catch-all `structure/parent.pyx:Parent.__contains__` we depend on
 the construction `bool(item==self(item))` to get the right result for,
 e.g. `sqrt(3) in RR/CC` but `bool(RR/CC(sqrt(3))==sqrt(3))` being `False`
 a trick was applied by the author that makes the function always return
 `True`. This trick uses the fact that Maxima doesn't know about the rings
 and will raise an exception, which is then caught.

 This way of programming strikes me as very wrong and previously I
 supported the notion that dedicated `__contains__` methods for both RR/CC
 were needed. As you can see from the discussion this was not wanted.

 Of course, as soon as we want to get rid of Maxima this odd behaviour must
 be simulated, because there is no way to test containment in these inexact
 rings in a generic way.

 In order to make it more reliable the way we treat inclusion in inexact
 rings needs to be reconsidered.

 Previously this ticket proposed that:
 ...dedicated `__contains__` methods for both rings are needed.

--

--
Ticket URL: <http://trac.sagemath.org/ticket/17984#comment:37>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to