On Thu, Nov 22, 2012 at 10:15 AM, Sebastian Berg <[email protected]> wrote: > On Thu, 2012-11-22 at 16:05 +0100, Daπid wrote: >> On Thu, Nov 22, 2012 at 3:54 PM, <[email protected]> wrote: >> > Why don't operations on empty arrays not return empty arrays? >> >> Because functions like mean or std are expected to return a scalar. >> Functions that are piecewiese can (and should) return an empty array, >> but not the mean. > > I agree, this makes sense, note that: > > In [2]: a = np.empty((5,0)) > > In [3]: a.std(0) > Out[3]: array([], dtype=float64) > > In [4]: a.std(1) > /usr/bin/ipython:1: RuntimeWarning: invalid value encountered in divide > #!/usr/bin/env python > Out[4]: array([ nan, nan, nan, nan, nan]) > > However you are reducing, and with reducing you expect exactly 1 scalar > result (along that dimension).
Ok, I see. we cannot have an empty 1-D array shape (5,) Josef > >> _______________________________________________ >> NumPy-Discussion mailing list >> [email protected] >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> > > > _______________________________________________ > NumPy-Discussion mailing list > [email protected] > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
