[Numpy-discussion] mean of empty sequence gives nan

Peter Butterworth butterw@gmail....
Mon Sep 27 17:51:59 CDT 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