예제 #1
0
    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()
예제 #2
0
    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)
예제 #3
0
    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, [])
예제 #4
0
    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, [])
예제 #5
0
 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()
예제 #6
0
 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()