def reduce(self, func, axis=<NUM_LIT:0>):
axes = sorted(tupleize(axis))<EOL>if isinstance(func, ufunc):<EOL><INDENT>inshape(self.shape, axes)<EOL>reduced = func.reduce(self, axis=tuple(axes))<EOL><DEDENT>else:<EOL><INDENT>reshaped = self._align(axes)<EOL>reduced = reduce(func, reshaped)<EOL><DEDENT>new_array = self._constructor(reduced)<EOL>expected_shape = [self.shape[i] for i in range(len(self.shape)) if i not in axes]<EOL>if new_array.shape != tuple(expected_shape):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return new_array<EOL>
Reduce an array along an axis.

Applies an associative/commutative function of two arguments
cumulatively to all arrays along an axis. Array will be aligned
so that the desired set of axes are in the keys, which may
require a transpose/reshape.

Parameters
----------
func : function
    Function of two arrays that returns a single array

axis : tuple or int, optional, default=(0,)
    Axis or multiple axes to reduce along.

Returns
-------
BoltArrayLocal