max(some2Ddata,key=np.abs) works, but only for 1D complex arrays
np.max(abs(some2Ddata)) returns the magnitude of the max complex value, but not the value itself
I'm expecting:
some2Ddata = ((1+2j, 5+1j), (4+4j, 2+3j))
complexmax(some2Data)
Which should return 4+4j, not 5.657 (and definitely not 5+1j).
I find it hard to believe that there is not a standard built-in for this operation.
We can write a simple function for this. We can use
np.argmaxto get the index of the maximum value (which will be based onnp.abs). Becausenp.argmaxreturns the flattened index, we then usenp.unravel_index(as per thenp.argmaxdocumentation examples) to get the 2D index. Finally, we use that index on the original array.