Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange Polynomial substitution problem #2360

Closed
sagetrac-jbmohler mannequin opened this issue Mar 1, 2008 · 7 comments
Closed

Strange Polynomial substitution problem #2360

sagetrac-jbmohler mannequin opened this issue Mar 1, 2008 · 7 comments

Comments

@sagetrac-jbmohler
Copy link
Mannequin

sagetrac-jbmohler mannequin commented Mar 1, 2008

I made a stupid error plugging a list into a polynomial, but it uncovered this very strange bug:

sage: R.<x,y,z,u,v,w>=ZZ[]
sage: P.<a>=ZZ[]
sage: e=[x^2,y^3]
sage: f=6*a^4
sage: f(x)
6*x^4
sage: f(e)
Exception exceptions.TypeError: "can't multiply sequence by non-int of type 'list'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand parent(s) for '*': 'Integer Ring' and '<type 'NoneType'>'" in 'sage.rings.polynomial.polynomial_compiled.mul_pd.eval' ignored
sage: f(x)
Exception exceptions.TypeError: "can't multiply sequence by non-int of type 'list'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand parent(s) for '*': 'Integer Ring' and '<type 'NoneType'>'" in 'sage.rings.polynomial.polynomial_compiled.mul_pd.eval' ignored

Notice that the plugging in the list seemed to ruin the polynomial good and proper.

Component: basic arithmetic

Issue created by migration from https://trac.sagemath.org/ticket/2360

@sagetrac-jbmohler
Copy link
Mannequin Author

sagetrac-jbmohler mannequin commented Mar 1, 2008

comment:2

Ah, it's even easier. No second mpoly ring required!

sage: P.<a>=ZZ[]
sage: f=6*a^4
sage: f(1)
6
sage: f([1,2,3])
Exception exceptions.TypeError: "can't multiply sequence by non-int of type 'list'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand parent(s) for '*': 'Integer Ring' and '<type 'NoneType'>'" in 'sage.rings.polynomial.polynomial_compiled.mul_pd.eval' ignored
sage: f(1)  #  WHAT HAPPENED -- this worked before.
Exception exceptions.TypeError: "can't multiply sequence by non-int of type 'list'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" in 'sage.rings.polynomial.polynomial_compiled.sqr_pd.eval' ignored
Exception exceptions.TypeError: "unsupported operand parent(s) for '*': 'Integer Ring' and '<type 'NoneType'>'" in 'sage.rings.polynomial.polynomial_compiled.mul_pd.eval' ignored

@malb
Copy link
Member

malb commented Jan 22, 2009

comment:3

The attached patch fixes the issue. Credit goes to Tom Boothby too.

@robertwb
Copy link
Contributor

comment:4

The patch fixes the issue, but I'd rather have the original error about multiplying lists propagate up instead of a generic "RuntimeError: Polynomial evaluation error in val()!"

@malb
Copy link
Member

malb commented Jan 24, 2009

Attachment: trac_2360_fix.patch.gz

@malb
Copy link
Member

malb commented Jan 24, 2009

comment:5

I updated the patch.

@robertwb
Copy link
Contributor

comment:6

OK, that looks good.

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 24, 2009

comment:7

Merged in Sage 3.3.alpha2.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.4.1, sage-3.3 Jan 24, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 24, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants