def testUpdates(self): buffer = SharedBuffer(array_len=self.array_len, array_type=self.array_type, np_array_type=self.np_array_type, array_lock=True) # Test updated flag functionality self.assertEqual(buffer.updated(), 0) buffer.write(np.zeros(self.array_len)) self.assertEqual(buffer.updated(), 1) buffer.read(1) self.assertEqual(buffer.updated(), 1) buffer.read_update(1) self.assertEqual(buffer.updated(), 0) buffer.set_data_update(1) self.assertEqual(buffer.updated(), 1) buffer.set_data_update(0) self.assertEqual(buffer.updated(), 0)
def testRead(self): buffer = SharedBuffer(array_len=2, array_type='d', np_array_type='d') buffer.write([1, 2]) data, timestamp, index = buffer.read() np.testing.assert_array_equal(data, [[1, 2]]) self.assertTrue(buffer.updated())