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

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

Closed
jasongrout opened this issue Mar 3, 2010 · 3 comments
Closed

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

jasongrout opened this issue Mar 3, 2010 · 3 comments

Comments

@jasongrout
Copy link
Member

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

CC: @williamstein @robertwb

Component: algebra

Reviewer: Jeroen Demeyer

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

@jasongrout jasongrout added this to the sage-5.11 milestone Mar 3, 2010
@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@mezzarobba
Copy link
Member

comment:3

Now works, but see #15695.

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@videlec
Copy link
Contributor

videlec commented Mar 28, 2015

comment:6

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

@videlec videlec removed this from the sage-6.4 milestone Mar 28, 2015
@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

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

6 participants