Ticket #3610 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

[with patch, positive review] __contains__ for RealIntervalFields does not work correctly.

Reported by: mhansen Owned by: somebody
Priority: major Milestone: sage-3.3
Component: basic arithmetic Keywords:
Cc: Work issues:
Report Upstream: Reviewers:
Authors: Merged in:
Dependencies: Stopgaps:

Description

sage: (R(2.1) + R(2.2))^2 in R
False
sage: R = RealIntervalField(32)
sage: a = (R(2.1) + R(2.2))^2 
sage: a
[18.489999987 .. 18.490000010]
sage: a in R
False
sage: a.parent()
Real Interval Field with 32 bits of precision
sage: a == a
False

This is caused by the following code in which gets inherited from parent.pyx:

        try:
            x2 = self(x)
            return bool(x2 == x)
        except TypeError:
            return False

Since equality is not reflexive for RealIntervals?, this doesn't work as intended.

Attachments

trac3610.patch Download (1.2 KB) - added by cwitty 4 years ago.

Change History

Changed 4 years ago by cwitty

comment:1 Changed 4 years ago by cwitty

  • Summary changed from __contains__ for RealIntervalFields does not work correctly. to [with patch, needs review] __contains__ for RealIntervalFields does not work correctly.

comment:2 Changed 4 years ago by robertwb

  • Summary changed from [with patch, needs review] __contains__ for RealIntervalFields does not work correctly. to [with patch, positive review] __contains__ for RealIntervalFields does not work correctly.

Looks good to me, and is probably an worthwhile optimization as well.

comment:3 Changed 4 years ago by mabshoff

  • Status changed from new to closed
  • Resolution set to fixed
  • Milestone changed from sage-3.4.1 to sage-3.3

Merged in Sage 3.3.alpha2

Cheers,

Michael

Note: See TracTickets for help on using tickets.