[Numpy-discussion] 5 bugs in numpy 0.9.8 (was: remaining matrix-non-preserving functions)

Sven Schreiber svetosch at gmx.net
Thu Jun 8 12:56:57 CDT 2006


Well as I got no replies it seems my earlier title wasn't drastic enough ;-)
And mere mortals like me can't seem to file new tickets anymore, so I'm
re-posting a summary here:

affected functions:
diff
vstack
hstack
outer
msort

symptom:
given numpy-matrices as inputs, these functions still return
numpy-arrays (as opposed to the applicable rest of numpy's functions)

Cheers,
Sven

Sven Schreiber schrieb:
> 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]])
> 
> 
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
> 





More information about the Numpy-discussion mailing list