<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 31, 2013 at 4:52 PM, Neal Becker <span dir="ltr"><<a href="mailto:ndbecker2@gmail.com" target="_blank">ndbecker2@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Cera, Tim wrote:<br>
<br>
> I don't work with complex numbers, but just sampling what others do:<br>
><br>
><br>
> Python: no ordering, results in TypeError<br>
><br>
> Matlab: sorts by magnitude<br>
> <a href="http://www.mathworks.com/help/matlab/ref/sort.html" target="_blank">http://www.mathworks.com/help/matlab/ref/sort.html</a><br>
><br>
> R: sorts first by real, then by imaginary<br>
> <a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/sort.html" target="_blank">http://stat.ethz.ch/R-manual/R-patched/library/base/html/sort.html</a><br>
><br>
> Numpy: sorts first by real, then by imaginary (the documentation link<br>
> below calls this sort 'lexicographical' which I don't think is<br>
> correct)<br>
> <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html" target="_blank">http://docs.scipy.org/doc/numpy/reference/generated/numpy.sort.html</a><br>
><br>
><br>
> I would think that the Matlab sort might be more useful, but easy<br>
> enough by using the absolute value.<br>
><br>
> I think what Numpy does is normal enough to not justify a warning, but<br>
> leave this to others because as I pointed out in the beginning I don't<br>
> work with complex numbers.<br>
><br>
> Kindest regards,<br>
> Tim<br>
<br>
</div>But I'm not proposing to change numpy's result, which I'm sure would raise many<br>
objections.  I'm just asking to give a warning, because I think in most cases<br>
this is actually a mistake on the user's part.  Just like the warning currently<br>
given when complex data are truncated to real part.<br></blockquote><div><br></div><div>Keep in mind that warnings can be highly annoying. If you're a user who uses this functionality regularly (and you know what you're doing), then you're going to be very unhappy to have to wrap each function call in:<br>
</div><div>    olderr = np.seterr(all='ignore')<br></div><div>    max(...)<br></div><div>    np.seterr(**olderr)<br></div><div>or in:<br></div><div>    with warnings.catch_warnings():<br></div><div>        warnings.filterwarnings('ignore', ...)<br>
</div><div>        max(...)<br></div></div><br></div><div class="gmail_extra">The actual behavior isn't documented now it looks like, so that should be done. In the Notes section of max/min probably. <br><br></div><div class="gmail_extra">
As for your proposal, it would be good to know if adding a warning would actually catch any bugs. For the truncation warning it caught several in scipy and other libs IIRC.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">
Ralf<br><br></div></div>