[Python-ideas] NAN handling in the statistics module
MRAB
python at mrabarnett.plus.com
Mon Jan 7 14:35:45 EST 2019
On 2019-01-07 16:34, Steven D'Aprano wrote:
> On Mon, Jan 07, 2019 at 10:05:19AM -0500, David Mertz wrote:
[snip]
>> It's not hard to manually check for NaNs and
>> generate those in your own code.
>
> That is correct, but by that logic, we don't need to support *any* form
> of NAN handling at all. It is easy (if inefficent) for the caller to
> pre-filter their data. I want to make it easier and more convenient and
> avoid having to iterate over the data twice if it isn't necessary.
>
Could the functions optionally accept a callback that will be called
when a NaN is first seen?
If the callback returns False, NaNs are suppressed, otherwise they are
retained and the function returns NaN (or whatever).
The callback would give the user a chance to raise a warning or an
exception, if desired.
More information about the Python-ideas
mailing list