Ticket #3610 (closed defect: fixed)
[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
Change History
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.
Note: See
TracTickets for help on using
tickets.

