>>> nan1 = float('nan')
>>> nan2 = 1e350 - 1e350
>>> nan3 = 1e400 / 1e399
>>> nan1, nan2, nan3
(nan, nan, nan)
>>> things = [1, 2, 3, nan1, nan2]
>>> nan1 in things, nan3 in things
(True, False)
>>> nan1 == nan1
False
>>> nan1 is nan1
True
The "in" operator might not do what you hope with NaNs.
On Fri, Dec 27, 2019 at 2:15 PM Juancarlo Añez <[email protected]> wrote:
> The signature could be:
>
> def median(it, exclude=None):
>
> With *exclude* being a value, or collection supporting the *in* operator
>
> On Thu, Dec 26, 2019 at 4:14 PM David Mertz <[email protected]> wrote:
>
>> Maybe we can just change the function signature:
>>
>> statistics.median(it, do_wrong_ass_thing_with_nans=False)
>>
>> :-)
>>
>> But yes, the problem is really with sorted(). However, the implementation
>> of statistics.median() doesn't HAVE TO use sorted(), that's just one
>> convenient way to do it.
>>
>> There IS NO right answer for `sorted([nan, 1, 2, 3])`. However, there is
>> a very plausibly right answer for `statistics.median([nan, 1, 2, 3])` ...
>> or rather, both 'nan' and '2' are plausible (one approach is what Numpy
>> does, the other is what Pandas does).
>>
>> --
>> Keeping medicines from the bloodstreams of the sick; food
>> from the bellies of the hungry; books from the hands of the
>> uneducated; technology from the underdeveloped; and putting
>> advocates of freedom in prisons. Intellectual property is
>> to the 21st century what the slave trade was to the 16th.
>> _______________________________________________
>> Python-ideas mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>> https://mail.python.org/mailman3/lists/python-ideas.python.org/
>> Message archived at
>> https://mail.python.org/archives/list/[email protected]/message/524SWHDA3HVPDIQ6F6S3OMFGFXPCVGLO/
>> Code of Conduct: http://python.org/psf/codeofconduct/
>>
>
>
> --
> Juancarlo *Añez*
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/TRN2MKZQ5RUHVWBVWG3VG5FBPNPPOCVF/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
--
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons. Intellectual property is
to the 21st century what the slave trade was to the 16th.
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/IPFYYK366HJ6G6BXOXUZAOQ26FZMJQXX/
Code of Conduct: http://python.org/psf/codeofconduct/