Exemplo n.º 1
0
 def test_multidim_setslice(self):
     from _numpypy import zeros, ones
     a = zeros((3, 3))
     b = ones((3, 3))
     a[:, 1:3] = b[:, 1:3]
     assert (a == [[0, 1, 1], [0, 1, 1], [0, 1, 1]]).all()
     a = zeros((3, 3))
     b = ones((3, 3))
     a[:, ::2] = b[:, ::2]
     assert (a == [[1, 0, 1], [1, 0, 1], [1, 0, 1]]).all()
Exemplo n.º 2
0
 def test_multidim_setslice(self):
     from _numpypy import zeros, ones
     a = zeros((3, 3))
     b = ones((3, 3))
     a[:, 1:3] = b[:, 1:3]
     assert (a == [[0, 1, 1], [0, 1, 1], [0, 1, 1]]).all()
     a = zeros((3, 3))
     b = ones((3, 3))
     a[:, ::2] = b[:, ::2]
     assert (a == [[1, 0, 1], [1, 0, 1], [1, 0, 1]]).all()
Exemplo n.º 3
0
    def test_ones_long(self):
        from _numpypy import ones, int64

        a = ones(10, dtype=long)
        for i in range(10):
            assert isinstance(a[i], int64)
            assert a[1] == 1
Exemplo n.º 4
0
 def test_ones(self):
     from _numpypy import ones
     a = ones(3)
     assert len(a) == 3
     assert a[0] == 1
     raises(IndexError, "a[3]")
     a[2] = 4
     assert a[2] == 4
Exemplo n.º 5
0
 def test_ones(self):
     from _numpypy import ones
     a = ones(3)
     assert len(a) == 3
     assert a[0] == 1
     raises(IndexError, "a[3]")
     a[2] = 4
     assert a[2] == 4
Exemplo n.º 6
0
 def test_where(self):
     from _numpypy import where, ones, zeros, array
     a = [1, 2, 3, 0, -3]
     a = where(array(a) > 0, ones(5), zeros(5))
     assert (a == [1, 1, 1, 0, 0]).all()
Exemplo n.º 7
0
 def test_flatiter_varray(self):
     from _numpypy import ones
     a = ones((2, 2))
     assert list(((a + a).flat)) == [2, 2, 2, 2]
Exemplo n.º 8
0
 def test_broadcast_call2(self):
     from _numpypy import zeros, ones
     a = zeros((4, 1, 5))
     b = ones((4, 3, 5))
     b[:] = (a + a)
     assert (b == zeros((4, 3, 5))).all()
Exemplo n.º 9
0
 def test_broadcast_setslice(self):
     from _numpypy import zeros, ones
     a = zeros((10, 10))
     b = ones(10)
     a[:, :] = b
     assert a[3, 5] == 1
Exemplo n.º 10
0
 def test_multidim_ones(self):
     from _numpypy import ones
     a = ones((1, 2, 3))
     assert a[0, 1, 2] == 1.0
Exemplo n.º 11
0
 def test_multidim_ones(self):
     from _numpypy import ones
     a = ones((1, 2, 3))
     assert a[0, 1, 2] == 1.0
Exemplo n.º 12
0
 def test_ones_long(self):
     from _numpypy import ones, longlong
     a = ones(10, dtype=long)
     for i in range(10):
         assert isinstance(a[i], longlong)
         assert a[1] == 1
Exemplo n.º 13
0
 def test_where(self):
     from _numpypy import where, ones, zeros, array
     a = [1, 2, 3, 0, -3]
     a = where(array(a) > 0, ones(5), zeros(5))
     assert (a == [1, 1, 1, 0, 0]).all()
Exemplo n.º 14
0
    def test_ones_bool(self):
        from _numpypy import ones, True_

        a = ones(10, dtype=bool)
        for i in range(10):
            assert a[i] is True_
Exemplo n.º 15
0
 def test_where_invalidates(self):
     from _numpypy import where, ones, zeros, array
     a = array([1, 2, 3, 0, -3])
     b = where(a > 0, ones(5), zeros(5))
     a[0] = 0
     assert (b == [1, 1, 1, 0, 0]).all()
Exemplo n.º 16
0
 def test_flatiter_varray(self):
     from _numpypy import ones
     a = ones((2, 2))
     assert list(((a + a).flat)) == [2, 2, 2, 2]
Exemplo n.º 17
0
 def test_broadcast_call2(self):
     from _numpypy import zeros, ones
     a = zeros((4, 1, 5))
     b = ones((4, 3, 5))
     b[:] = (a + a)
     assert (b == zeros((4, 3, 5))).all()
Exemplo n.º 18
0
 def test_broadcast_setslice(self):
     from _numpypy import zeros, ones
     a = zeros((10, 10))
     b = ones(10)
     a[:, :] = b
     assert a[3, 5] == 1
Exemplo n.º 19
0
    def test_ones_bool(self):
        from _numpypy import ones, True_

        a = ones(10, dtype=bool)
        for i in range(10):
            assert a[i] is True_
Exemplo n.º 20
0
 def test_where_invalidates(self):
     from _numpypy import where, ones, zeros, array
     a = array([1, 2, 3, 0, -3])
     b = where(a > 0, ones(5), zeros(5))
     a[0] = 0
     assert (b == [1, 1, 1, 0, 0]).all()