should the return type of matlib.reshape be ndarray or matrix?
Is this the intended behavior?
>>> from numpy import matlib
>>> m = matlib.reshape([1,2],(2,1))
>>> type(m)
On Wed, Sep 28, 2011 at 9:09 PM, Alan G Isaac
Is this the intended behavior?
>>> from numpy import matlib >>> m = matlib.reshape([1,2],(2,1)) >>> type(m)
For any 2d shape, I expected a matrix. (And probably an exception if the shape is not 2d.)
I think you are right. Chuck
Most functions in numpy return ndarray by default. Use numpy.asmatrix() if you want a matrix.
from numpy import matlib, asmatrix m = matlib.reshape([1,2],(2,1)) type(m)
type( asmatrix(m) )

Pengkui
On Wed, Sep 28, 2011 at 22:09, Alan G Isaac
Is this the intended behavior?
>>> from numpy import matlib >>> m = matlib.reshape([1,2],(2,1)) >>> type(m)
For any 2d shape, I expected a matrix. (And probably an exception if the shape is not 2d.)
Thanks, Alan Isaac _______________________________________________ NumPyDiscussion mailing list NumPyDiscussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpydiscussion
On 10/3/2011 6:59 PM, Pengkui Luo wrote:
Most functions in numpy return ndarray by default. Use numpy.asmatrix() if you want a matrix.
Please note that the example is using matlib.reshape, not numpy.reshape. Alan Isaac
participants (3)

Alan G Isaac

Charles R Harris

Pengkui Luo