On 04/16/2010 05:41 AM, Bastian Weber wrote:
Hi,


what is the proper way to convert a sage matrix to a numpy 2d-array?

The obvious way, i.e.

a=np.array(matrix([3 4]))

produces a 0d-array (thus a.shape is an empty tuple) which is not what I
want.


To answer your original question, I think if we defined __array__ in the top-level Sage matrix class, we could get this to work.

However, it still seems odd, since "a" does print out okay.

sage: import numpy as np
sage: a=np.array(matrix([[3, 4]]))
sage: a
array([3 4], dtype=object)
sage: a.shape
()

So I can print a, and it looks okay. What is going on there? Is that a bug in numpy?

Thanks,

Jason

--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to