[Numpy-discussion] What is diagonal for nd>2?
ndarray at mac.com
Thu Apr 6 14:46:10 CDT 2006
I see. However, something needs to be changed. In the current version
help(diagonal) prints the following:
Help on function diagonal in module numpy.core.oldnumeric:
diagonal(a, offset=0, axis1=0, axis2=1)
diagonal(a, offset=0, axis1=0, axis2=1) returns the given diagonals
defined by the last two dimensions of the array.
I would think axes 0 and 1 are the first, not the last two dimensions. We
can either change the documentation or change the defaults in the
oldnumeric. I would vote for the change in defaults because oldnumeric is a
compatibility module and should not introduce changes.
In addition, the fact that the reduced axes become the first (rather than
the last or one of the axis1 and axis2) dimension should be spelled out in
On 4/6/06, Pierre GM <pgmdevlist at mailcan.com> wrote:
> > Does anyone know when this change was introduced and why?
> Isn't it more a problem of default values ?
> By default, x.diagonal() == x.diagonal(0,0,1)
> array([[ 0, 20],
> [ 1, 21],
> [ 2, 22],
> [ 3, 23]])
> If you want the paired diagonal:
> array([[ 0, 5, 10, 15],
> [16, 21, 26, 31]])
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion