For readability, I would prefer if you used the more explicit "np.logical_not", rather than "~"