コード例 #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()
コード例 #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()
コード例 #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
コード例 #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
コード例 #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
コード例 #6
0
ファイル: test_arrayops.py プロジェクト: Debug-Orz/Sypy
 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()
コード例 #7
0
 def test_flatiter_varray(self):
     from _numpypy import ones
     a = ones((2, 2))
     assert list(((a + a).flat)) == [2, 2, 2, 2]
コード例 #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()
コード例 #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
コード例 #10
0
 def test_multidim_ones(self):
     from _numpypy import ones
     a = ones((1, 2, 3))
     assert a[0, 1, 2] == 1.0
コード例 #11
0
 def test_multidim_ones(self):
     from _numpypy import ones
     a = ones((1, 2, 3))
     assert a[0, 1, 2] == 1.0
コード例 #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
コード例 #13
0
ファイル: test_arrayops.py プロジェクト: nipengadmaster/pypy
 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()
コード例 #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_
コード例 #15
0
ファイル: test_arrayops.py プロジェクト: Debug-Orz/Sypy
 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()
コード例 #16
0
 def test_flatiter_varray(self):
     from _numpypy import ones
     a = ones((2, 2))
     assert list(((a + a).flat)) == [2, 2, 2, 2]
コード例 #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()
コード例 #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
コード例 #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_
コード例 #20
0
ファイル: test_arrayops.py プロジェクト: nipengadmaster/pypy
 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()