title: Why does Python crash when I try to sum this numpy array?
body: <p>I'm working on Ubuntu 14.04 with Python 3.4 (Numpy 1.9.2 and PIL.Image 1.1.7). Here's what I do:</p>
  
  <pre><code>&gt;&gt;&gt; from PIL import Image
  &gt;&gt;&gt; import numpy as np
  
  &gt;&gt;&gt; img = Image.open("./tifs/18015.pdf_001.tif")
  &gt;&gt;&gt; arr = np.asarray(img)
  &gt;&gt;&gt; np.shape(arr)
  (5847, 4133)
  
  &gt;&gt;&gt; arr.dtype
  dtype('bool')
  
  # all of the following four cases where I incrementally increase
  # the number of rows to 700 are done instantly
  &gt;&gt;&gt; v = arr[1:100,1:100].sum(axis=0)
  &gt;&gt;&gt; v = arr[1:500,1:100].sum(axis=0)
  &gt;&gt;&gt; v = arr[1:600,1:100].sum(axis=0)
  &gt;&gt;&gt; v = arr[1:700,1:100].sum(axis=0)
  
  # but suddenly this line makes Python crash
  &gt;&gt;&gt; v = arr[1:800,1:100].sum(axis=0)
  
  fish: Job 1, “python3” terminated by signal SIGSEGV (Address boundary error)
  </code></pre>
  
  <p>Seems to me like Python runs out of memory all of a sudden. If that is the case - how can I allocate more memory to Python? As I can see from htop my 32GB memory capacity is not even remotely depleated.</p>
  
  <p>You may download the TIFF image <a href="http://joyofdata.de/public/pdf2txt/18015.pdf_001.tif" rel="nofollow">here</a>.</p>
  
  <hr>
  
  <p>If I create an empty boolean array, set the pixels explicitely and then apply the summation - then it works:</p>
  
  <pre><code>&gt;&gt;&gt; arr = np.empty((h,w), dtype=bool)
  &gt;&gt;&gt; arr.setflags(write=True)
  
  &gt;&gt;&gt; for r in range(h):
  &gt;&gt;&gt;     for c in range(w):
  &gt;&gt;&gt;         arr.itemset((r,c), img.getpixel((c,r)))
  
  &gt;&gt;&gt; v=arr.sum(axis=0)
  
  &gt;&gt;&gt; v.mean()
  5726.8618436970719
  
  &gt;&gt;&gt; arr.shape
  (5847, 4133)
  </code></pre>
  
  <p>But this "workaround" is not very satisfactory as copying every pixel takes way too long - maybe there is a faster method?</p>