Ticket #1334 (closed defect: fixed)
[with patch, with positive review] Constant polynomial can't be converted to rational
| Reported by: | robertwb | Owned by: | dmharvey |
|---|---|---|---|
| Priority: | major | Milestone: | sage-2.8.15 |
| Component: | basic arithmetic | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
sage: R.<x> = QQ['x'] sage: QQ(R(1/2)) Traceback (most recent call last): ... TypeError: Unable to coerce 1/2 (<type 'sage.rings.polynomial.polynomial_element.Polynomial_generic_dense'>) to Rational
Attachments
Change History
comment:1 Changed 5 years ago by dmharvey
- Owner changed from somebody to dmharvey
- Status changed from new to assigned
comment:2 Changed 5 years ago by dmharvey
Fixed it:
sage: R.<x> = QQ['x'] sage: QQ(R(1/2)) 1/2
More generally this patch allows coercion of any polynomial to QQ, as long as it's a constant polynomial whose constant term can be coerced into QQ.
comment:3 Changed 5 years ago by dmharvey
- Summary changed from Constant polynomial can't be converted to rational to [with patch] Constant polynomial can't be converted to rational
comment:4 Changed 5 years ago by cwitty
- Summary changed from [with patch] Constant polynomial can't be converted to rational to [with patch, with positive review] Constant polynomial can't be converted to rational
Looks good to me. (doctests pass, code looks good)
Note: See
TracTickets for help on using
tickets.

