Say I have a numpy array
A = numpy.array([-1, 1, 2, -2, 3, -3])
I would like to get all numbers whose squares equal 1 or 9 (so the expected result is [1, -1, 3, -3]). I tried A[A**2 in [1, 9]] but got an error. Is there any built-in function to handle this simple task without doing loops? Thanks.