vrijdag 20 december 2013

How to create a logical array in numpy

This took me a while to find: the numpy equivalents of Matlab's true and false constructors.

To create a 3x3 array of False: np.zeros((3, 3), dtype=bool)
To create a 3x3 array of True: np.ones((3, 3), dtype=bool)