[Numpy-discussion] Re: [SciPy-dev] matrix and ravel()
oliphant at ee.byu.edu
Wed Oct 12 13:37:49 EDT 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
>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.
I'm less concerned about this issue because it is so easy to get an
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
>The same goes double for asarray: it will be a really
>unwanted surprise if it does not return an array.
I'm much more concerned about this issue. I would like to hear more
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
if the object is already one).
asanyarray --- returns an nd-array or a sub-class if the object is
already a sub-class.
Please weigh in...
>Scipy-dev mailing list
>Scipy-dev at scipy.net
More information about the NumPy-Discussion