Opened 14 years ago
Closed 13 years ago
#5347 closed defect (fixed)
[with patch, positive review] divides() may fail for 1 on the rhs.
Reported by: | Martin Albrecht | Owned by: | somebody |
---|---|---|---|
Priority: | major | Milestone: | sage-4.1.2 |
Component: | basic arithmetic | Keywords: | ring element divides |
Cc: | Mike Hansen | Merged in: | Sage 4.1.2.alpha2 |
Authors: | John Cremona | Reviewers: | Mike Hansen |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
sage: K = GF(7) sage: K(3).divides(1) False sage: K(3).divides(K(1)) Traceback (most recent call last) ... ZeroDivisionError: reduction modulo right not defined.
This is because of this code added at http://hg.sagemath.org/sage-main/rev/0cb746e1a4bd
def divides(self, x): return (x % self) == 0
Attachments (1)
Change History (4)
Changed 13 years ago by
Attachment: | trac_5347-divides.patch added |
---|
comment:1 Changed 13 years ago by
Authors: | → John Cremona |
---|---|
Keywords: | ring element divides added |
Summary: | divides() may fail for 1 on the rhs. → [with patch, needs review] divides() may fail for 1 on the rhs. |
The patch handles this by testing all the easy cases of a.divides(b) (a is 1 or a unit, b is zero) before trying the % operation. Doctest added to show that it works.
comment:2 Changed 13 years ago by
Reviewers: | → Mike Hansen |
---|---|
Summary: | [with patch, needs review] divides() may fail for 1 on the rhs. → [with patch, positive review] divides() may fail for 1 on the rhs. |
Looks good to me.
comment:3 Changed 13 years ago by
Merged in: | → Sage 4.1.2.alpha2 |
---|---|
Resolution: | → fixed |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
Applies to 4.1.1