def boundingBox(booleanArray):
w = np.where(booleanArray)<EOL>p = []<EOL>for i in w:<EOL><INDENT>if len(i):<EOL><INDENT>p.append(slice(i.min(), i.max()))<EOL><DEDENT>else:<EOL><INDENT>p.append(slice(<NUM_LIT:0>, <NUM_LIT:0>))<EOL><INDENT>return None<EOL><DEDENT><DEDENT><DEDENT>return tuple(p)<EOL>
return indices of the smallest bounding box enclosing all
non-zero values within an array

>>> a = np.array([ [0,0,0,0],
...                [0,1,0,1],
...                [0,0,1,0],
...                [1,0,0,0],
...                [0,0,0,0] ])
>>> print ( boundingBox(a) ) 
(slice(1, 3, None), slice(0, 3, None))