ndarray var method doesn't cope gracefully with empty arrays. #2759

Closed
charris opened this Issue Nov 21, 2012 · 2 comments

1 participant

@charris
NumPy member
In [3]: arange(0).var()
/home/charris/.local/lib/python2.7/site-packages/numpy/core/_methods.py:72: RuntimeWarning: invalid value encountered in true_divide
out=arrmean, casting='unsafe', subok=False)

/home/charris/.local/lib/python2.7/site-packages/numpy/core/_methods.py:96: RuntimeWarning: invalid value encountered in double_scalars
ret = ret / float(rcount)
Out[3]: nan

In [4]: arange(0).std()
Out[4]: nan

I also wonder if nan is the proper return for this case.

@charris
NumPy member

Also, arange(0).std(out=out) fails.

@charris
NumPy member

nan is the return decided on for these. The current cascade of warning could be cleaned up a bit, however.

@charris charris closed this Feb 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment