def test_reduce_keepdims(self): from _numpypy import add, arange a = arange(12).reshape(3, 4) b = add.reduce(a, 0, keepdims=True) assert b.shape == (1, 4) assert (add.reduce(a, 0, keepdims=True) == [12, 15, 18, 21]).all()
def test_reduceND(self): from _numpypy import add, arange a = arange(12).reshape(3, 4) assert (add.reduce(a, 0) == [12, 15, 18, 21]).all() assert (add.reduce(a, 1) == [6.0, 22.0, 38.0]).all() raises(ValueError, add.reduce, a, 2)
def test_reduce_1d(self): from _numpypy import add, maximum assert add.reduce([1, 2, 3]) == 6 assert maximum.reduce([1]) == 1 assert maximum.reduce([1, 2, 3]) == 3 raises(ValueError, maximum.reduce, [])
def test_reduceND(self): from _numpypy import add, arange a = arange(12).reshape(3, 4) assert (add.reduce(a, 0) == [12, 15, 18, 21]).all() assert (add.reduce(a, 1) == [6.0, 22.0, 38.0]).all()