On Thu, Mar 19, 2015 at 2:48 AM, Ralf Stephan <[email protected]> wrote: > Hello, > single reals can be represented in RIF. But they are not elements > of that field, right? Due to some code quirks (discussed in #12984) > we have at the moment: > sage: 1/2 in RIF > True > sage: 1/5 in RIF > False > sage: 3.14 in RIF > True > sage: 3 in RIF > True > sage: pi in RIF > False > > As this behaviour is a RIF specialty it is more effective (and better > design) > to implement a dedicated RIF.__contains__ method than to fix > the quirky Parent.__contains__. But what should be "in RIF"?
Please don't implement a new special case __contains__ just yet. That could make things harder and more confusing, since it will definitely break the intention of contains, which is that "a in RIF" means that there is b in RIF such that a==b is true, and probably mask a deeper issue. The problem above is being caused by this: sage: RIF(1/5) == RIF(1/5) False What's going on there? I don't know. But let's sort out why RIF(1/5) isn't equal to itself. Even more surprising sage: a = RIF(1/5) sage: a == a False sage: a is a True However, sage: a.lower() == a.lower() True sage: a.upper() == a.upper() True The code to compare intervals is here: https://github.com/sagemath/sage/blob/master/src/sage/rings/real_mpfi.pyx#L3517 It looks like it just compares the endpoints, so I don't understand why a == a is false... Anyway, it's really hard looking at the code to come up with any argument for why a == a shouldn't be true! > Only intervals? Intervals and reals? > > Regards, > > -- > You received this message because you are subscribed to the Google Groups > "sage-devel" 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 http://groups.google.com/group/sage-devel. > For more options, visit https://groups.google.com/d/optout. -- William (http://wstein.org) -- You received this message because you are subscribed to the Google Groups "sage-devel" 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 http://groups.google.com/group/sage-devel. For more options, visit https://groups.google.com/d/optout.
