<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        color:black;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-CA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:black;mso-fareast-language:EN-US'>I see your point. How about passing number of significant figures instead of atol.<o:p></o:p></span></p><p class=MsoNormal><span style='color:black;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:black;mso-fareast-language:EN-US'>In fact, that’s what I originally intended but I thought that it could be expressed via atol and rtol, whereas number of significant figures doesn’t seem to suffer from the ambiguity you pointed out.<o:p></o:p></span></p><p class=MsoNormal><span style='color:black;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> NumPy-Discussion <numpy-discussion-bounces+aminthefresh=gmail.com@python.org> <b>On Behalf Of </b>Stephan Hoyer<br><b>Sent:</b> Thursday, July 16, 2020 3:06 PM<br><b>To:</b> Discussion of Numerical Python <numpy-discussion@python.org><br><b>Subject:</b> Re: [Numpy-discussion] Augment unique method<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Thu, Jul 16, 2020 at 11:41 AM Roman Yurchak <<a href="mailto:rth.yurchak@gmail.com">rth.yurchak@gmail.com</a>> wrote:<o:p></o:p></p></div><div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>One issue with adding a tolerance to np.unique for floats is say you have<br>  [0, 0.1, 0.2, 0.3, 0.4, 0.5] with atol=0.15<br><br>Should this return a single element or multiple ones? One once side each <br>consecutive float is closer than the tolerance to the next one but the <br>first one and the last one are clearly not within atol.<br><br>Generally this is similar to what DBSCAN clustering algorithm does (e.g. <br>in scikit-learn) and that would probably be out of scope for np.unique.<o:p></o:p></p></blockquote><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I agree, I don't think there's an easy answer for selecting "approximately unique" floats in the case of overlap.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>np.unique() does actually have well defined behavior for float, comparing floats for exact equality. This isn't always directly useful, but it definitely is well defined.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>My suggestion for this use-case would be round floats to the desired precision before passing them into np.unique().<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in'><p class=MsoNormal>Roman<br><br>On 16/07/2020 20:27, Amin Sadeghi wrote:<br>> It would be handy to add "atol" and "rtol" optional arguments to the <br>> "unique" method. I'm proposing this since uniqueness is a bit vague for <br>> floats. This change would be clearly backwards-compatible.<br>> <br>> _______________________________________________<br>> NumPy-Discussion mailing list<br>> <a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br>> <a href="https://mail.python.org/mailman/listinfo/numpy-discussion" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><br>> <br><br>_______________________________________________<br>NumPy-Discussion mailing list<br><a href="mailto:NumPy-Discussion@python.org" target="_blank">NumPy-Discussion@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/numpy-discussion" target="_blank">https://mail.python.org/mailman/listinfo/numpy-discussion</a><o:p></o:p></p></blockquote></div></div></div></body></html>