[Numpy-discussion] mean of empty sequence gives nan

Peter Butterworth butterw at gmail.com
Mon Sep 27 18:51:59 EDT 2010


In numpy 1.5.0, I got the following for mean of an empty sequence (or array):

In [21]: mean([])
Warning: invalid value encountered in double_scalars
Out[21]: nan

Is this behaviour expected ?


Also, would it be possible to have more explicit warning messages about the
problem being related numpy ?
It seems these message cause quite a bit of confusion to users. The
following would be more helpful :

Warning: invalid value encountered in numpy double_scalars



More information about the NumPy-Discussion mailing list