[Numpy-discussion] should the return type of matlib.reshape be ndarray or matrix?
Pengkui Luo
pengkui.luo@gmail....
Mon Oct 3 17:59:48 CDT 2011
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 'numpy.ndarray'>
>>> type( asmatrix(m) )
<class 'numpy.matrixlib.defmatrix.matrix'>
--
Pengkui
On Wed, Sep 28, 2011 at 22:09, Alan G Isaac <alan.isaac@gmail.com> wrote:
> Is this the intended behavior?
>
> >>> from numpy import matlib
> >>> m = matlib.reshape([1,2],(2,1))
> >>> type(m)
> <type 'numpy.ndarray'>
>
> For any 2d shape, I expected a matrix.
> (And probably an exception if the shape is not 2d.)
>
> Thanks,
> Alan Isaac
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20111003/c84f26ce/attachment.html
More information about the NumPy-Discussion
mailing list