Opened 13 years ago

Closed 8 years ago

## #8426 closed defect (duplicate)

# polynomial * constant does not work if constant is a numpy type

Reported by: | Jason Grout | Owned by: | Alex Ghitza |
---|---|---|---|

Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |

Component: | algebra | Keywords: | |

Cc: | William Stein, Robert Bradshaw | Merged in: | |

Authors: | Reviewers: | Jeroen Demeyer | |

Report Upstream: | N/A | Work issues: | |

Branch: | Commit: | ||

Dependencies: | Stopgaps: |

### Description

This should work:

import numpy R.<x>=RR[] x*numpy.float32('23.0')

Instead, I get:

--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /home/jason/tmp/<ipython console> in <module>() /home/jason/sage/local/lib/python2.6/site-packages/sage/structure/element.so in sage.structure.element.RingElement.__mul__ (sage/structure/element.c:11337)() /home/jason/sage/local/lib/python2.6/site-packages/sage/structure/coerce.so in sage.structure.coerce.CoercionModel_cache_maps.bin_op (sage/structure/coerce.c:6994)() TypeError: unsupported operand parent(s) for '*': 'Univariate Polynomial Ring in x over Real Field with 53 bits of precision' and '<type 'numpy.float32'>'

Note that this does work:

sage: numpy.float32('23.0')*x 23.0000000000000*x

### Change History (8)

### comment:1 Changed 9 years ago by

Milestone: | sage-5.11 → sage-5.12 |
---|

### comment:2 Changed 9 years ago by

Milestone: | sage-6.1 → sage-6.2 |
---|

### comment:3 Changed 9 years ago by

### comment:4 Changed 9 years ago by

Milestone: | sage-6.2 → sage-6.3 |
---|

### comment:5 Changed 8 years ago by

Milestone: | sage-6.3 → sage-6.4 |
---|

### comment:6 Changed 8 years ago by

Milestone: | sage-6.4 → sage-duplicate/invalid/wontfix |
---|---|

Status: | new → needs_review |

Hello,

I propose to close this as duplicates because of #18076 that fixes it. With the branch applied I got

sage: import numpy sage: R.<x> = RR[] sage: x * numpy.float32('23.0') 23.0000000000000*x

and even the pushout works

sage: R.<x> = ZZ[] sage: x * numpy.float32('23.0') 23.0*x sage: parent(_) Univariate Polynomial Ring in x over Real Double Field

Vincent

### comment:7 Changed 8 years ago by

Reviewers: | → Jeroen Demeyer |
---|---|

Status: | needs_review → positive_review |

### comment:8 Changed 8 years ago by

Resolution: | → duplicate |
---|---|

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

Now works, but see #15695.