<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Aug 2, 2021 at 7:04 PM Sebastian Berg <<a href="mailto:sebastian@sipsolutions.net">sebastian@sipsolutions.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
In NumPy 1.21, the output of `np.unique` changed in the presence of<br>
multiple NaNs.  Previously, all NaNs were returned when we now only<br>
return one (all NaNs were considered unique):<br>
<br>
    a = np.array([1, 1, np.nan, np.nan, np.nan])<br>
<br>
Before 1.21:<br>
<br>
    >>> np.unique(a)<br>
    array([ 1., nan, nan, nan])<br>
<br>
After 1.21:<br>
<br>
    array([ 1., nan])<br>
<br>
<br>
This change was requested in an old issue:<br>
<br>
     <a href="https://github.com/numpy/numpy/issues/2111" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/issues/2111</a><br>
<br>
And happened here:<br>
<br>
     <a href="https://github.com/numpy/numpy/pull/18070" rel="noreferrer" target="_blank">https://github.com/numpy/numpy/pull/18070</a><br>
<br>
While, it has a release note.  I am not sure the change got the<br>
attention it deserved.  This would be especially worrying if it is a<br>
regression for anyone?<br></blockquote><div><br></div><div>I think it's now the expected answer, not a regression. `unique` is not an elementwise function that needs to adhere to IEEE-754 where nan != nan. I can't remember reviewing this change, but it makes perfect sense to me.<br></div><div><br></div><div>Cheers,<br></div><div>Ralf</div><div><br></div></div></div>