Bug fixed. the tilde in python does not perform the logical not operation, it is the case in numpy though...