Example #1
0
def test_sharedarray():    
    sa = SharedArray(shape=(10), dtype = 'int32')
    np_a = sa.to_numpy()
    np_a[:] = np.arange(10)
    
    sa2 = SharedArray(**sa.to_dict())
    np_a2 = sa.to_numpy()
    assert np_a is not np_a2
    assert np.all(np_a == np_a2)
Example #2
0
def test_sharedarray_multiprocess():
    sa = SharedArray(shape = (10), dtype = 'int32')
    np_a = sa.to_numpy()
    np_a[:] = 0
    
    proc = mp.Process(target=modify_sharedarray, args=(sa.to_dict(), ))
    proc.start()
    proc.join()
    assert np.all(np_a ==np.arange(10))
Example #3
0
def test_sharedarray_multiprocess():
    sa = SharedArray(shape=(10), dtype='int32')
    np_a = sa.to_numpy()
    np_a[:] = np.arange(10)

    # Start remote process, read data from shared array, then return to host
    # process.
    proc = mp.Process()
    sa_mod = proc._import('pyacq.core.sharedarray')
    sa2 = sa_mod.SharedArray(**sa.to_dict())
    np_a2 = sa2.to_numpy(_returnType='value')
    proc.close()

    assert np.all(np_a == np_a2)
Example #4
0
def test_sharedarray_multiprocess():
    sa = SharedArray(shape=(10), dtype = 'int32')
    np_a = sa.to_numpy()
    np_a[:] = np.arange(10)
    
    # Start remote process, read data from shared array, then return to host
    # process.
    proc = mp.Process()
    sa_mod = proc._import('pyacq.core.sharedarray')
    sa2 = sa_mod.SharedArray(**sa.to_dict())
    np_a2 = sa2.to_numpy(_returnType='value')
    proc.close()
    
    assert np.all(np_a == np_a2)
Example #5
0
def test_sharedarray():
    sa = SharedArray(shape=(10), dtype='int32')
    np_a = sa.to_numpy()
    np_a[:] = np.arange(10)

    sa2 = SharedArray(**sa.to_dict())
    np_a2 = sa.to_numpy()
    assert np_a is not np_a2
    assert np.all(np_a == np_a2)
Example #6
0
def modify_sharedarray(d):
    sa2 = SharedArray(**d)
    np_a2 = sa2.to_numpy()
    np_a2[:] = np.arange(10)