Opened 8 years ago

Closed 2 years ago

#8426 closed defect (duplicate)

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

Reported by: jason Owned by: AlexGhitza
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: algebra Keywords:
Cc: was, robertwb 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 4 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:2 Changed 4 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:3 Changed 4 years ago by mmezzarobba

Now works, but see #15695.

comment:4 Changed 3 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:5 Changed 3 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:6 Changed 3 years ago by vdelecroix

  • Milestone changed from sage-6.4 to sage-duplicate/invalid/wontfix
  • Status changed from new to 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 2 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:8 Changed 2 years ago by vbraun

  • Resolution set to duplicate
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.