Jan. 7, 2019
3:27 p.m.
On Mon, Jan 07, 2019 at 07:35:45PM +0000, MRAB wrote:
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).
That's an interesting API which I shall have to think about.
The callback would give the user a chance to raise a warning or an exception, if desired.
One practical annoyance of this API is that you cannot include raise from a lambda, so people desiring "fail fast" semantics can't do this: result = mean(data, callback=lambda: raise Exception) They have to pre-declare the callback using def. -- Steve