I just discovered a logical bug in my code which was causing all sorts of problems. I was inadvertently doing a bitwise AND instead of a logical AND
try this=> numpy.array(r) or numpy.array(yourvariable) followed by the command to compare whatever you wish to.