std() crashes for multidimensional arrays when no axis is specified
Closed this issue · 1 comments
terhorst commented
>> A = np.array([[1,2,3],[4,5,6]]); A array([[1, 2, 3], [4, 5, 6]]) >> A.std() 1.707825127659933 >> B = DataArray(A, 'xy'); B DataArray([[1, 2, 3], [4, 5, 6]]) ('x', 'y') >> B.std('x') DataArray([ 1.5, 1.5, 1.5]) ('y',) >> B.std() --------------------------------------------------------------------------- IndexError Traceback (most recent call last) /Users/terhorst/Documents/Work/datarray/build/lib/ in () ----> 1 B.std() /Users/terhorst/Documents/Work/datarray/build/lib/datarray/datarray.py in runs_op(*args, **kwargs) 518 # do nothing special if not a DataArray, otherwise 519 # this is a full reduction, so we lose all axes --> 520 return super_op(inst, **kwargs) 521 522 axes = list(inst.axes) /Users/terhorst/Documents/Work/datarray/build/lib/datarray/datarray.py in __array_prepare__(self, obj, context) 688 this_ax = these_axes.pop(-1) 689 # print self.shape # dbg --> 690 this_dim = self.shape[this_ax.index] 691 that_dim = other.shape[that_ax.index] 692 if that_ax.name != this_ax.name: IndexError: tuple index out of range
fperez commented
Hey, thanks for jumping on this so quick!