本文整理汇总了Python中buffer.Buffer.set_data方法的典型用法代码示例。如果您正苦于以下问题:Python Buffer.set_data方法的具体用法?Python Buffer.set_data怎么用?Python Buffer.set_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer.Buffer
的用法示例。
在下文中一共展示了Buffer.set_data方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_buffer_resize
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_buffer_resize(self):
data = np.zeros(10)
B = Buffer(data=data)
data = np.zeros(20)
B._need_resize == False
B.set_data(data)
assert B.nbytes == data.nbytes
assert B._need_resize == True
示例2: test_offlimit_offset
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_offlimit_offset(self):
data = np.zeros(10)
B = Buffer(data=data, resizeable=False)
with self.assertRaises(ValueError):
B.set_data(np.ones(1),offset=10*data.dtype.itemsize)
示例3: test_negative_offset
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_negative_offset(self):
data = np.zeros(10)
B = Buffer(data=data, resizeable=False)
with self.assertRaises(ValueError):
B.set_data(np.ones(1),offset=-1)
示例4: test_oversized_data
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_oversized_data(self):
data = np.zeros(10)
B = Buffer(data=data, resizeable=False)
with self.assertRaises(ValueError):
B.set_data(np.ones(20))
示例5: test_data_copy
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_data_copy(self):
data = np.zeros(100)
B = Buffer(data=data)
B.set_data(data=data[:50], offset=0, copy=True)
assert B._pending_data[-1][0].base is not data
示例6: test_data_storage
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_data_storage(self):
data = np.zeros(100)
B = Buffer(data=data)
B.set_data(data=data[:50], offset=0, copy=False)
assert B._pending_data[-1][0].base is data
示例7: test_set_whole_data
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_set_whole_data(self):
data = np.zeros(100)
B = Buffer(data=data)
B.set_data(data=data)
assert len(B._pending_data) == 1
示例8: test_buffer_forbidden_resize
# 需要导入模块: from buffer import Buffer [as 别名]
# 或者: from buffer.Buffer import set_data [as 别名]
def test_buffer_forbidden_resize(self):
data = np.zeros(10)
B = Buffer(data=data, resizeable=False)
data = np.zeros(20)
with self.assertRaises(ValueError):
B.set_data(data)