def test_usecols(self): reader = NumPyFileReader(self.f4) cols = (0, 2) it = reader.iterator(chunk=0, return_trajindex=False, cols=cols) with it: for x in it: np.testing.assert_equal(x, self.d2[:, cols])
def test_lagged_stridden_access(self): reader = NumPyFileReader(self.f1) strides = [2, 3, 5, 7, 15] lags = [1, 3, 7, 10, 30] for stride in strides: for lag in lags: chunks = [] for _, _, Y in reader.iterator(stride, lag): chunks.append(Y) chunks = np.vstack(chunks) np.testing.assert_equal(chunks, self.d[lag::stride])
def test_lagged_stridden_access(self): reader = NumPyFileReader(self.f1) strides = [2, 3, 5, 7, 15] lags = [1, 3, 7, 10, 30] for stride in strides: for lag in lags: chunks = [] for _, _, Y in reader.iterator(stride, lag): chunks.append(Y) chunks = np.vstack(chunks) np.testing.assert_equal(chunks, self.d[lag::stride])
def test_lagged_stridden_access_multiple_files(self): reader = NumPyFileReader(self.files2d) strides = [2, 3, 5, 7, 15] lags = [1, 3, 7, 10, 30] for stride in strides: for lag in lags: chunks = { i: [] for i in range(reader.number_of_trajectories()) } for itraj, _, Y in reader.iterator(stride, lag): chunks[itraj].append(Y) for i, k in enumerate(chunks.values()): stack = np.vstack(k) d = np.load(self.files2d[i]) np.testing.assert_equal( stack, d[lag::stride], "not equal for stride=%i" " and lag=%i" % (stride, lag))