<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Be sure to file a ticket...<div><br></div><div>-Travis</div><div><br><div><div>On May 30, 2012, at 9:05 PM, chris farrow wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi all,
<div><br></div><div>I encountered an odd bug today that I wanted to bring to everyone's attention. First the code:</div><div><br></div><div><div><font face="courier new, monospace">>>> import numpy as np</font></div>

<div><font face="courier new, monospace">>>> shape = (8, 8)</font></div><div><font face="courier new, monospace">>>> dtype = np.dtype(np.uint8)</font></div><div><font face="courier new, monospace">>>> image = np.random.randint(0, 256, shape).astype(dtype)</font></div>

<div><font face="courier new, monospace">>>> image.tofile("test_image.bin")</font></div><div><font face="courier new, monospace">>>> image = np.memmap("test_image.bin", dtype=dtype, shape=shape, mode='r')</font></div>

<div><font face="courier new, monospace">>>> arr = image[::2,::2]</font></div><div><font face="courier new, monospace">>>> np.sum(arr.flat)</font></div></div><div><br></div><div>On my system (numpy 1.6.1, git revision 68538b74483009c2c2d1644ef00397014f95a696, on OSX, python 2.7.3 (32-bit)), this causes a bus error when run.</div>

<div><br></div><div>Here's what I've discovered so far about this:</div><div>- the bus error only occurs with mode 'r'</div><div>- the dimensionality of the array appears to be irrelevant</div><div>- if the array slice does not change the strides, the bus error does not occur</div>

<div>- no 'arr.flat', no bus error</div><div>- Other aggregating functions (e.g. fmin.reduce) will induce the error</div><div>- Iterating over arr.flat will *not* cause a bus error</div><div><br></div><div>Based on this, I suspect the issue is with the C-facing side of the flat iterator.</div>

<div><br></div><div>Enjoy!</div><div><br></div><div>Chris</div>
_______________________________________________<br>NumPy-Discussion mailing list<br><a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>http://mail.scipy.org/mailman/listinfo/numpy-discussion<br></blockquote></div><br></div></body></html>