コード例 #1
0
ファイル: test_buffer.py プロジェクト: vanossj/vispy
    def test_set_whole_data(self):
        data = np.zeros(100)
        B = Buffer(data=data)
        B._glir.clear()
        B.set_data(data=data)
        glir_cmds = B._glir.clear()
        assert len(glir_cmds) == 2
        assert glir_cmds[0][0] == 'SIZE'
        assert glir_cmds[1][0] == 'DATA'

        # And sub data
        B.set_subdata(data[:50], 20)
        glir_cmds = B._glir.clear()
        assert len(glir_cmds) == 1
        assert glir_cmds[0][0] == 'DATA'
        assert glir_cmds[0][2] == 20  # offset

        # And sub data
        B.set_subdata(data)
        glir_cmds = B._glir.clear()
        assert glir_cmds[-1][0] == 'DATA'

        # Wrong ways to set subdata
        self.assertRaises(ValueError, B.set_subdata, data[:50], -1)  # neg
        self.assertRaises(ValueError, B.set_subdata, data, 10)  # no fit
コード例 #2
0
ファイル: test_buffer.py プロジェクト: marqh/vispy
 def test_set_whole_data(self):
     data = np.zeros(100)
     B = Buffer(data=data)
     B._context.glir.clear()
     B.set_data(data=data)
     glir_cmds = B._context.glir.clear()
     assert len(glir_cmds) == 2
     assert glir_cmds[0][0] == 'SIZE'
     assert glir_cmds[1][0] == 'DATA'
 
     # And sub data
     B.set_subdata(data[:50], 20)
     glir_cmds = B._context.glir.clear()
     assert len(glir_cmds) == 1
     assert glir_cmds[0][0] == 'DATA'
     assert glir_cmds[0][2] == 20  # offset
     
     # And sub data
     B.set_subdata(data)
     glir_cmds = B._context.glir.clear()
     assert glir_cmds[-1][0] == 'DATA'
     
     # Wrong ways to set subdata
     self.assertRaises(ValueError, B.set_subdata, data[:50], -1)  # neg
     self.assertRaises(ValueError, B.set_subdata, data, 10)  # no fit
コード例 #3
0
ファイル: test_buffer.py プロジェクト: ds604/vispy
 def test_wrong_data(self):
     buffer = Buffer(target=gl.GL_ARRAY_BUFFER)
     
     # String
     with self.assertRaises(ValueError):
         buffer.set_data('foo')
     
     # Bytes
     some_bytes = 'foo'.encode('utf-8')
     with self.assertRaises(ValueError):
         buffer.set_data(some_bytes)
     
     # Now with subdata
     data = np.zeros(100, np.float32)
     buffer.set_data(data)
     
     
     # String
     with self.assertRaises(ValueError):
         buffer.set_subdata(0, 'foo')
     with self.assertRaises(ValueError):
         buffer.set_subdata('foo', data)
     
     # Bytes
     some_bytes = 'foo'.encode('utf-8')
     with self.assertRaises(ValueError):
         buffer.set_subdata(0, some_bytes)
     with self.assertRaises(ValueError):
         buffer.set_subdata(some_bytes, data)
コード例 #4
0
ファイル: test_buffer.py プロジェクト: ds604/vispy
    def test_pending_data(self):
        data = np.zeros(100, np.float32)

        buffer = Buffer(target=gl.GL_ARRAY_BUFFER)
        self.assertEqual(len(buffer._pending_data), 0)
        
        buffer = Buffer(data=data, target=gl.GL_ARRAY_BUFFER)
        self.assertEqual(len(buffer._pending_data), 1)

        buffer.set_data(data)
        self.assertEqual(len(buffer._pending_data), 1)

        buffer.set_subdata(0, data[:50])
        self.assertEqual(len(buffer._pending_data), 2)

        buffer.set_data(data)
        self.assertEqual(len(buffer._pending_data), 1)
コード例 #5
0
ファイル: test_buffer.py プロジェクト: dengemann/vispy
    def test_setting_subdata(self):

        data = np.zeros(100, np.float32)
        buffer = Buffer(target=gl.GL_ARRAY_BUFFER)

        # Set subdata when no data is set
        self.assertRaises(RuntimeError, buffer.set_subdata, 0, data)

        # Set nbytes and try again
        buffer.set_nbytes(data.nbytes)
        buffer.set_subdata(0, data)

        # Subpart
        buffer.set_subdata(0, data[:50])
        buffer.set_subdata(50, data[50:])

        # Too big
        self.assertRaises(ValueError, buffer.set_subdata, 1, data)

        # Weird
        self.assertRaises(ValueError, buffer.set_subdata, -1, data)

        # Weirder
        self.assertRaises(ValueError, buffer.set_subdata, 1000000, data)
コード例 #6
0
ファイル: test_buffer.py プロジェクト: ds604/vispy
 def test_setting_subdata(self):
     
     data = np.zeros(100, np.float32)
     buffer = Buffer(target=gl.GL_ARRAY_BUFFER)
     
     # Set subdata when no data is set
     with self.assertRaises(RuntimeError):
         buffer.set_subdata(0, data)
     
     # Set nbytes and try again
     buffer.set_nbytes(data.nbytes)
     buffer.set_subdata(0, data)
     
     # Subpart
     buffer.set_subdata(0, data[:50])
     buffer.set_subdata(50, data[50:])
     
     # Too big
     with self.assertRaises(ValueError):
         buffer.set_subdata(1, data)
     
     # Weird
     with self.assertRaises(ValueError):
         buffer.set_subdata(-1, data)
     
     # Weirder
     with self.assertRaises(ValueError):
         buffer.set_subdata(1000000, data)