Opened 12 years ago

Closed 7 years ago

#8949 closed defect (duplicate)

symbolic functions dont work with numpy.int32

Reported by: Wilfried Huss Owned by: Burcin Erocal
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords:
Cc: Jason Grout Merged in:
Authors: Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

sage: import numpy
sage: a = numpy.array([1,2])
sage: type(a[0])
<type 'numpy.int32'>
sage: f(x) = x^2
sage: f(a[0])
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
./sage-4.4.2/<ipython console> in <module>()

./sage-4.4.2/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__call__ (sage/symbolic/expression.cpp:15476)()

./sage-4.4.2/local/lib/python2.6/site-packages/sage/symbolic/callable.pyc in _call_element_(self, _the_element, *args, **kwds)
    454         d = dict(zip(map(repr, self.arguments()), args))
    455         d.update(kwds)
--> 456         return SR(_the_element.substitute(**d))
    457
    458

./sage-4.4.2/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.substitute (sage/symbolic/expression.cpp:14850)()

./sage-4.4.2/local/lib/python2.6/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.coerce_in (sage/symbolic/expression.cpp:10193)()

./sage-4.4.2/local/lib/python2.6/site-packages/sage/structure/parent_old.so in sage.structure.parent_old.Parent._coerce_ (sage/structure/parent_old.c:3288)()

./sage-4.4.2/local/lib/python2.6/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.coerce (sage/structure/parent.c:6970)()

TypeError: no canonical coercion from <type 'numpy.int32'> to Callable function ring with arguments (x,)

Change History (10)

comment:1 Changed 12 years ago by Jason Grout

Cc: Jason Grout added

comment:2 Changed 12 years ago by Jason Grout

I think #8824 may have the solution for this.

comment:4 Changed 9 years ago by Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:5 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:6 Changed 8 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:7 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:8 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. With the branch applied

sage: import numpy
sage: cos(numpy.float('12'))
0.8438539587324921

Though it is not perfect since the result is a Python float and not a numpy float.

Vincent

comment:9 Changed 7 years ago by Jeroen Demeyer

Reviewers: Jeroen Demeyer
Status: needs_reviewpositive_review

comment:10 Changed 7 years ago by Volker Braun

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