Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#6036 closed defect (fixed)

[with patch, positive review] a bug in polynomial() for PolynomialRing(GF(5),2)

Reported by: klee Owned by: Somebody
Priority: minor Milestone: sage-4.0
Component: basic arithmetic Keywords:
Cc: Merged in: 4.0.rc0
Authors: Kwankyu Lee Reviewers: Mike Hansen
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by klee)

This works:

sage: R.<x,y>=PolynomialRing(QQ,2)
sage: a=x^2+x*y+y
sage: a.polynomial(x)
x^2 + y*x + y

But this does not work:

sage: R.<x,y>=PolynomialRing(GF(5),2)
sage: a=x^2+x*y+y
sage: a.polynomial(x)
Traceback (most recent call last):
...
TypeError: 'tuple' object cannot be interpreted as an index 

I traced this bug, and found that

sage: B=QQ[x]
sage: print B({0:1,1:2})
2*x + 1
sage: print B({(0,):1,(1,):2})
2*x + 1
sage: B=GF(5)[x]
sage: print B({0:1,1:2})
2*x + 1
sage: print B({(0,):1,(1,):2})
Traceback (most recent call last):
...
TypeError: 'tuple' object cannot be interpreted as an index

I think the second form is not acceptable. Then the function remove_from_tuple() in sage.rings.polynomial.multi_polynomial.pyx should be revised as it output (1,) from (1,2) for example.

Attachments (3)

12159.patch (654 bytes) - added by klee 12 years ago.
12160.patch (872 bytes) - added by klee 12 years ago.
trac_6036.patch (1.1 KB) - added by mhansen 12 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 Changed 12 years ago by mabshoff

  • Component changed from algebra to basic arithmetic
  • Milestone changed from sage-4.0 to sage-4.0.1
  • Summary changed from a bug in polynomial() to a bug in polynomial() for PolynomialRing(GF(5),2)

Changed 12 years ago by klee

Changed 12 years ago by klee

comment:2 Changed 12 years ago by klee

  • Description modified (diff)
  • Summary changed from a bug in polynomial() for PolynomialRing(GF(5),2) to [with patch, needs review] a bug in polynomial() for PolynomialRing(GF(5),2)

comment:3 Changed 12 years ago by klee

  • Description modified (diff)

Changed 12 years ago by mhansen

comment:4 Changed 12 years ago by mhansen

  • Summary changed from [with patch, needs review] a bug in polynomial() for PolynomialRing(GF(5),2) to [with patch, positive review] a bug in polynomial() for PolynomialRing(GF(5),2)

I attached a folded patch -- it should be applied instead of the other two.

Looks good to me.

comment:5 Changed 12 years ago by mabshoff

  • Milestone changed from sage-4.0.1 to sage-4.0
  • Resolution set to fixed
  • Status changed from new to closed

Merged trac_6036.patch in Sage 4.0.rc0.

Cheers,

Michael

comment:6 Changed 12 years ago by davidloeffler

  • Authors set to Kwankyu Lee
  • Merged in set to 4.0.rc0
  • Reviewers set to Mike Hansen
Note: See TracTickets for help on using tickets.