#9769: symbolic function do not work with numpy.int64 arguments
-----------------------------+------------------------
       Reporter:  maldun     |        Owner:  burcin
           Type:  defect     |       Status:  new
       Priority:  major      |    Milestone:  sage-6.2
      Component:  symbolics  |   Resolution:
       Keywords:             |    Merged in:
        Authors:             |    Reviewers:
Report Upstream:  N/A        |  Work issues:
         Branch:             |       Commit:
   Dependencies:             |     Stopgaps:
-----------------------------+------------------------

Old description:

> There seems to be some problems with the coercion of some datatypes to
> the symbolic ring:
>

> {{{
> sage: cos(MatrixSpace(ZZ, 2)([1, 2, -4, 7]))
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call
> last)
> .......
> TypeError: cannot coerce arguments: no canonical coercion from Full
> MatrixSpace of 2 by 2 dense matrices over Integer Ring to Symbolic Ring
>
> sage: import numpy
> sage: vec = numpy.array([1,2])
> sage: sin(vec)
> array([ 0.84147098,  0.90929743])
> sage: sin(vec[0])
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call
> last)
> ....
> TypeError: cannot coerce arguments: no canonical coercion from <type
> 'numpy.int64'> to Symbolic Ring
> ----
>
> sage: x = PolynomialRing(QQ, 'x').gen()
> sage: sin(x)
> sin(x)
> sage: x = PolynomialRing(RR, 'x').gen()
> sage: sin(x)
> ---------------------------------------------------------------------------
> TypeError                                 Traceback (most recent call
> last)
> .....
> TypeError: cannot coerce arguments: __call__() takes exactly 1 positional
> argument (0 given)
> sage: x = PolynomialRing(CC, 'x').gen()
> sage: sin(x)
> sin(x)
> }}}

New description:

 There seems to be some problems with the coercion of some datatypes to the
 symbolic ring:


 {{{
 sage: cos(MatrixSpace(ZZ, 2)([1, 2, -4, 7]))
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 .......
 TypeError: cannot coerce arguments: no canonical coercion from Full
 MatrixSpace of 2 by 2 dense matrices over Integer Ring to Symbolic Ring

 sage: import numpy
 sage: vec = numpy.array([1,2])
 sage: sin(vec)
 array([ 0.84147098,  0.90929743])
 sage: sin(vec[0])
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 ....
 TypeError: cannot coerce arguments: no canonical coercion from <type
 'numpy.int64'> to Symbolic Ring

--

Comment (by rws):

 Replying to [comment:2 burcin]:
 > {{{
 > sage: x = PolynomialRing(RR, 'x').gen()
 > sage: sin(x)
 > <boom>
 > }}}
 >
 > The problem here is really coercion, but it should be copied to another
 ticket (in the basic_arithmetic component):
 Incidentally this is part of #16197.

 > The `__call__()` function of RR[x] doesn't conform to the generic
 definition. You should be able to give the parameters as a keyword
 argument as well. This should be made to work:
 >
 > {{{
 > sage: R.<x> = RR[]
 > sage: (x^2+1)(x=5)
 > 11
 > }}}
 Will copy this info there.

--
Ticket URL: <http://trac.sagemath.org/ticket/9769#comment:5>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to