1import numpy
2data = numpy.array([[ 1, 2, 5 ]])
3mask = numpy.array([[0,1,0]])
4
5numpy.ma.masked_array(data, ~mask)
6# note this probably won't work right for non-boolean (T/F) values
7
8# or
9numpy.ma.masked_array(data, numpy.logical_not(mask))
10
11
12# for example
13
14>>> a = numpy.array([False,True,False])
15>>> ~a
16array([ True, False, True], dtype=bool)
17>>> numpy.logical_not(a)
18array([ True, False, True], dtype=bool)
19>>> a = numpy.array([0,1,0])
20>>> ~a
21array([-1, -2, -1])
22>>> numpy.logical_not(a)
23array([ True, False, True], dtype=bool)
24
25
26