def test_resize(self): data = np.zeros(10) B = DataBuffer(data=data) data = np.zeros(20) B.set_data(data) assert B.nbytes == data.nbytes assert B._need_resize is True
def test_set_data_base(self): dtype = np.dtype([('position', np.float32, 3), ('texcoord', np.float32, 2), ('color', np.float32, 4)]) data = np.zeros(10, dtype=dtype) B = DataBuffer(data, store=True) B.set_data(data) assert len(B._pending_data) == 1
def test_set_data_offset(self): data = np.zeros(100, np.float32) subdata = data[:10] B = DataBuffer(data) B.set_data(subdata, offset=10) offset = B._pending_data[-1][2] print (offset) assert offset == 10*4
def test_invalid_view_after_set_data(self): dtype = np.dtype([('position', np.float32, 3), ('texcoord', np.float32, 2), ('color', np.float32, 4)]) data = np.zeros(10, dtype=dtype) B = DataBuffer(data) Z = B[5:] B.set_data(np.zeros(15, dtype=dtype)) assert Z._valid is False