[Numpy-discussion] complex comparisons

Travis Oliphant oliphant.travis at ieee.org
Mon Mar 20 10:12:02 CST 2006

Tim Hochberg wrote:
> I just noticed that complex arrays can be compared using [<, <=, > and 
> >=]. Do we really want  this? I'd prefer to follow numarray's lead 
> here and only support [==, !=] on complex arrays.
MATLAB has always provided complex comparisons by comparing the real 
part, so there is signifcant precedence for this. 

Anybody coming from MATLAB will appreciate it because while technically 
complex numbers are not ordered, often complex arrays are the result of 
calculations that result in real numbers but the data-type is still 

But, now that .real and .imag work on *all* array data-types it is not 
an absolute necessity to support complex comparisons.  I just think it's 
convenient and not especially confusing.


More information about the Numpy-discussion mailing list