Пример #1
0
 def test_copy_shm(self):
     source_manager = cishm.ShmManager(create=True)
     shape = (5,6)
     fake_image = numpy.arange(shape[0]*shape[1],dtype=numpy.uint8)
     fake_image.shape = shape
     curmsg = source_manager.copy_into_shm(0, fake_image) # copy into shared memory
     result_new = cishm.get_data_copy(curmsg)
     assert numpy.allclose( result_new, fake_image)
Пример #2
0
 def test_copy_shm_preallocated(self):
     source_manager = cishm.ShmManager(create=True)
     shape = (5,6)
     fake_image = numpy.arange(shape[0]*shape[1],dtype=numpy.uint8)
     fake_image.shape = shape
     curmsg = source_manager.copy_into_shm(0, fake_image) # copy into shared memory
     result_preallocated = numpy.empty( shape, dtype=numpy.uint8 )
     result_preallocated2 = cishm.get_data_copy(curmsg,result_preallocated)
     assert numpy.allclose( result_preallocated, fake_image )
     assert result_preallocated2 is result_preallocated