# [Numpy-discussion] Re: [SciPy-dev] matrix and ravel()

Travis Oliphant oliphant at ee.byu.edu
Wed Oct 12 13:37:49 CDT 2005

Alan G Isaac wrote:

>>Travis Oliphant wrote:
>>
>>
>>>Not really a side-effect.  An intended feature.   Matrices are supposed
>>>to be matrices (i.e. 2-d arrays).  They cannot be 1-d arrays no matter
>>>how hard you try....  If you want to ravel a matrix and get a 1-d array
>>>out,  you are not using matrices right....  Use a 1-d array (i.e. the .A
>>>attribute).
>>>
>>>

>1. Better support for matrices is very welcome; I use them
>   a lot.
>2. I expect ravel to return a 1-d array, not a matrix.  My
>   background is a matrix programming language (GAUSS from
>   before its N-dimensional array support), and yet the
>
>
>   behavior of ravel never surprised me.
>
>
array out of a matrix.

>3. I expect a row and column vectorization functions (named
>   e.g., vecr and vecc) to do row and column vectorization.
>   I do not have a strong opinion on whether what is really
>   wanted is a vec function that takes an axis argument,
>   although this is probably right.  In particular, both row
>   and column vectorization of matrices is common, and this
>   is just a choice of axis.
>
>
These are m.T.ravel()  and m.ravel()  right now.  To get a 1-d array it
is m.A.ravel()

>The same goes double for asarray: it will be a really
>unwanted surprise if it does not return an array.
>
>
people way in on what should be the behavior here.

In particular, here are two proposals.

1) current behavior

array (and asarray) --- returns the object itself if it is a sub-class
of the array
(or an array scalar).
asndarray ---  returns an actual nd array object

2) new behavior

array (and asarray)  always return an ndarray base-class object (or a
big-nd array
if the object is already one).
asanyarray ---  returns an nd-array or a sub-class if the object is

--Travis

>fwiw,
>Alan Isaac
>
>
>_______________________________________________
>Scipy-dev mailing list
>Scipy-dev at scipy.net
>http://www.scipy.net/mailman/listinfo/scipy-dev
>
>