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:

Status badges

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 Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:2 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:3 Changed 9 years ago by Marc Mezzarobba

Now works, but see #15695.

comment:4 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:5 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:6 Changed 8 years ago by Vincent Delecroix

Milestone: sage-6.4sage-duplicate/invalid/wontfix
Status: newneeds_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 Jeroen Demeyer

Reviewers: Jeroen Demeyer
Status: needs_reviewpositive_review

comment:8 Changed 8 years ago by Volker Braun

Resolution: duplicate
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.