[docs] bug in built-in sum function

Hoeben, R. (KFI) r.hoeben at antoniusziekenhuis.nl
Tue Dec 29 06:22:56 EST 2015


Hi!

Sorry, a bit short on time so I decided to e-mail you the bug I came across.

The built-in sum function is not correctly summing all columns in my array. I noticed by coincidence and verified this in excel.
My matrix is 64x64.
(I am using spyder 2.3.0, and python 2.7.6 32bits on Windows)

sum(summedim)
Out[37]:
array([  148,   123,   130,   207,   293,   290,   401,   638,   928,
        1221,  1597,  2162,  3030,  4331,  6271,  8892, 11805, 14248,
       15602, 16510, 18550, 22730, 27386, 29778, 29970, 32941, 43589,
       59399,  6365,  9188,  5404,  1503,   785,  3809,  6611,  5109,
       62835, 50904, 39940, 33964, 32919, 34305, 35697, 35820, 32936,
       26407, 17595,  9770,  5008,  2895,  1872,  1142,   628,   476,
         541,   627,   763,   908,   862,   518,   150,     6,     0,     0], dtype=uint16)

sum(sum(summedim))
Out[38]: 821432

np.sum(summedim)
Out[39]: 1345720

The last output is correct, the marked outputs are incorrect. I don't know why the function does not work properly for just a few columns.
Though this is consistently the case in all 64x64 array's I was analysing

I am glad I noticed and now started using the np.sum function, but it might aid other users if this bug is fixed.

Happy holidays!
Kind regards,
Renske





[cid:image002.jpg at 01D14233.A5913FA0]

ir. Renske Hoeben

Klinisch Fysicus in opleiding

Afd. Klinische Fysica en Instrumentatie
Postbus 2500
3430 EM Nieuwegein
M   06  5274 1217
T    030  609 3070 (secretariaat)
E    r.hoeben at antoniusziekenhuis.nl

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20151229/3a62abc4/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 3044 bytes
Desc: image002.jpg
URL: <http://mail.python.org/pipermail/docs/attachments/20151229/3a62abc4/attachment-0001.jpg>


More information about the docs mailing list