[Numpy-discussion] remaining matrix-non-preserving functions (original) (raw)

Sven Schreiber svetosch at gmx.net
Sat Jun 3 10:43:07 EDT 2006


Hi all,

I just discovered that the diff function returns a numpy-array even for matrix inputs. Since I'm a card-carrying matrix fanatic, I hope that behavior qualifies as a bug.

Then I went through some (most?) other functions/methods for which IMO it's best to return matrices if the input is also a matrix-type. I found that the following functions share the problem of diff (see below for illustrations):

vstack and hstack (although I always use r_ and c_ and they work fine with matrices)

outer

msort

Should I open new tickets? (Or has this already been fixed since 0.9.8, which I used because this time building the svn version failed for me?)

Cheers, Sven

n.version '0.9.8' a matrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) b matrix([[0, 0, 0], [0, 0, 0]]) n.diff(a) array([[-1, 0], [ 1, -1], [ 0, 1]]) n.outer(a,b) array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) n.msort(a) array([[0, 0, 0], [0, 0, 0], [1, 1, 1]]) n.vstack([a,b]) array([[1, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 0], [0, 0, 0]]) n.hstack([a,b.T]) array([[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]])



More information about the NumPy-Discussion mailing list