def test_append_with_rewrite(self): if not mpirank: arr = np.random.rand(2, 128) else: arr = np.random.rand(1, 128) test_obs = Observable(arr, 'simulated') test_obs.rw_flag = True brr = np.random.rand(1, 128) test_obs.append(brr) global_shape = test_obs.shape globalrr = test_obs.global_data if not mpirank: assert global_shape == globalrr.shape assert np.allclose(test_obs.data[0], brr[0])
def test_append_after_rewrite(self): arr = np.random.rand(1, 128) test_obs = Observable(arr, 'simulated') if not mpirank: brr = np.random.rand(2, 128) else: brr = np.random.rand(1, 128) test_obs.rw_flag = True test_obs.append(brr) crr = np.random.rand(1, 128) # rw_flag must have be switched off test_obs.append(crr) global_shape = test_obs.shape globalrr = test_obs.global_data if not mpirank: assert global_shape == globalrr.shape fullrr = np.vstack([brr, crr]) assert np.alltrue(np.isin(test_obs.data, fullrr))