-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I must have missed something -- since when does summing a multidimensional array return the grand total? I thought that it should sum over axis zero by default (at least, thats what the docs say). Here's what I am getting: (Pdb) pre Out[6]: array([[[ 13, 3, 1, 33, 52], [ 1, 0, 0, 0, 2], [ 4, 0, 0, 2, 6], [ 15, 1, 0, 20, 54]], [[380, 101, 9, 267, 321], [ 20, 4, 0, 7, 16], [ 31, 3, 1, 31, 22], [314, 27, 4, 276, 391]]], dtype=int64) (Pdb) sum(pre) Out[6]: 2432L Is this correct behaviour? - -- Christopher Fonnesbeck + Atlanta, GA + fonnesbeck at mac.com + Contact me on AOL IM using email address -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) iD8DBQFFBYSJGKaDpEGshJ0RAiPhAJ0d/MCGMciLgB2ZOwXf1FVj26NpTgCdG7h8 M83+mZsYGP2svVBGn8RtbNw= =mby0 -----END PGP SIGNATURE-----
listservs@mac.com wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I must have missed something -- since when does summing a multidimensional array return the grand total? I thought that it should sum over axis zero by default (at least, thats what the docs say). Here's what I am getting:
(Pdb) pre Out[6]: array([[[ 13, 3, 1, 33, 52], [ 1, 0, 0, 0, 2], [ 4, 0, 0, 2, 6], [ 15, 1, 0, 20, 54]],
[[380, 101, 9, 267, 321], [ 20, 4, 0, 7, 16], [ 31, 3, 1, 31, 22], [314, 27, 4, 276, 391]]], dtype=int64) (Pdb) sum(pre) Out[6]: 2432L
Is this correct behaviour?
Yes, you need to specify which axis you want to sum over if you have a multi-dimensional array. This is the "basic" behavior of most functions in numpy unless you import them from oldnumeric. See the fix_default_axis.py file for help on converting code that worked for numpy 0.9.8 to 1.0 where this switch was made. -Travis
participants (3)
-
Alan G Isaac
-
listservs@mac.com
-
Travis Oliphant