I want to do nose testing of numpy arrays of complex floats that are unordered.
So for instance, if
a = [1+1j, 1-1j, 2+2j, 2-2j, 2+2j, 2-2j]
and
b = [2+2j, 2-2j, 1+1j, 1.000000000000001-1j, 2+2j, 2-2j]
the assert should succeed, as they have approximately the same values the same number of times. Order doesn't matter.
For regular floats, assert_array_almost_equal(np.sort(a), np.sort(b))
would be fine, but that doesn't work here because it sorts by real part first and then imaginary part, so because of the float error, they are sorted to:
a: [ 1.-1.j, 1.+1.j, 2.-2.j, 2.-2.j, 2.+2.j, 2.+2.j]
b: [ 1.+1.j, 1.-1.j, 2.-2.j, 2.-2.j, 2.+2.j, 2.+2.j]
Is there a built-in way to do this? If not, I guess I could resort to something like cplxreal, but that seems like a lot to add to a testing file.