1 | | This works: |

2 | | |

3 | | {{{ |

4 | | sage: R.<x,y>=PolynomialRing(QQ,2) |

5 | | sage: a=x^2+x*y+y |

6 | | sage: a.polynomial(x) |

7 | | x^2 + y*x + y |

8 | | }}} |

9 | | |

10 | | But this does not work: |

11 | | |

12 | | {{{ |

13 | | sage: R.<x,y>=PolynomialRing(GF(5),2) |

14 | | sage: a=x^2+x*y+y |

15 | | sage: a.polynomial(x) |

16 | | Traceback (most recent call last): |

17 | | ... |

18 | | TypeError: 'tuple' object cannot be interpreted as an index |

19 | | }}} |

20 | | |

21 | | The bug is essentially in: |

22 | | {{{ |

23 | | sage: B=QQ[x] |

24 | | sage: print B({0:1,1:2}) |

25 | | 2*x + 1 |

26 | | sage: print B({(0,):1,(1,):2}) |

27 | | 2*x + 1 |

28 | | sage: B=GF(5)[x] |

29 | | sage: print B({0:1,1:2}) |

30 | | 2*x + 1 |

31 | | sage: print B({(0,):1,(1,):2}) |

32 | | Traceback (most recent call last): |

33 | | ... |

34 | | TypeError: 'tuple' object cannot be interpreted as an index |

35 | | }} |

36 | | |

37 | | I think the second form is not acceptable. Then the function |

38 | | remove_from_tuple() in sage.rings.polynomial.multi_polynomial.pyx |

39 | | should be revised as it output (1,) from (1,2) for example |

| 1 | The patch 12159.patch modifies the code in remove_from_tuple() in sage.rings.polynomial.multi_polynomial.pyx. The patch 12160.patch adds a testing example in the docstring. |