#20293: matrix constructor fails on numpy.matrix
---------------------------------+------------------------
Reporter: cnassau | Owner:
Type: defect | Status: new
Priority: major | Milestone: sage-7.2
Component: numerical | Resolution:
Keywords: numpy, matrix | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
---------------------------------+------------------------
Comment (by cnassau):
I think the reason might be that with Sage 7.2.beta0 the numpy.matrix is
not recognized as a numpy type:
{{{
sage: import numpy
sage: n = numpy.matrix([[1,2],[3,4]],float)
sage: from sage.structure.coerce import is_numpy_type
sage: is_numpy_type(type(n))
False
}}}
The code in `is_numpy_type` checks whether the `tp_name` field of its
argument begins with "numpy."; in this case the `tp_name` is just
"`matrix`". Maybe we should check {{{type(n).__module__}}} instead, since
the official doc
https://docs.python.org/2/c-api/typeobj.html#c.PyTypeObject.tp_name
says that "dynamically allocated types" should not contain the module name
in the `tp_type`.
{{{
sage: n = numpy.matrix([[1,2],[3,4]],float)
sage: type(n).__module__
'numpy.matrixlib.defmatrix'
sage: n = numpy.array([[1,2],[3,4]],float)
sage: type(n).__module__
'numpy'
}}}
I currently do not know how to code this check in cython, though.
--
Ticket URL: <http://trac.sagemath.org/ticket/20293#comment:1>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.