Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve libdcd cython #3888

Merged
merged 42 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1e7f5b1
add annotate_cython setup.cfg option
hmacdope Oct 26, 2022
ff6677e
improve some of the DCD
hmacdope Oct 26, 2022
c1b6147
continue adding types
hmacdope Oct 26, 2022
b8074fc
add types and fix is_periodic
hmacdope Oct 26, 2022
c8ba7d7
change whence dict
hmacdope Oct 26, 2022
5c25473
further improve dcd
hmacdope Oct 26, 2022
8a3b558
continue to improve reading
hmacdope Oct 26, 2022
41d6cca
incremental improvements
hmacdope Oct 26, 2022
64092cc
rever cython range
hmacdope Oct 27, 2022
4519bbd
revert n_frames check
hmacdope Oct 27, 2022
d9276ab
add note to DCD for query
hmacdope Oct 27, 2022
9a4f0cf
move DCD reader to no copy API and update tests accordingly
hmacdope Oct 28, 2022
fb40390
update chanelog
hmacdope Oct 28, 2022
8e82299
small changes
hmacdope Oct 28, 2022
adb30bf
suggestions from code review
hmacdope Oct 29, 2022
0e3761b
Merge branch 'develop' into improve_dcd_cython
orbeckst Oct 31, 2022
73fbb39
add module level directives
hmacdope Nov 1, 2022
72acd3b
try contiguous
hmacdope Nov 1, 2022
749da5e
Revert "try contiguous"
hmacdope Nov 1, 2022
5832c77
Merge remote-tracking branch 'upstream/develop' into improve_dcd_cython
hmacdope Nov 6, 2022
cd79359
update changelog
hmacdope Nov 6, 2022
def0c14
experimental pxdify
hmacdope Nov 6, 2022
873a9be
pxdify libdcd
hmacdope Nov 7, 2022
be3b51a
Merge remote-tracking branch 'upstream/develop' into improve_dcd_cython
hmacdope Nov 12, 2022
43bbf3e
fix bad changelog merge
hmacdope Nov 15, 2022
5d646b8
fix bad changelog merge2
hmacdope Nov 15, 2022
e9584e3
deprecate DCD
hmacdope Nov 15, 2022
23f2912
fix docs and tests
hmacdope Nov 15, 2022
070be37
fix changelog
hmacdope Nov 22, 2022
edc613f
apply oliver suggestions
hmacdope Nov 22, 2022
ec1f44a
add temporary buffer to DCD reader
hmacdope Nov 22, 2022
8d36ba0
Merge remote-tracking branch 'upstream/develop' into improve_dcd_cython
hmacdope Nov 22, 2022
8c8bd13
add DCD to public libmdanalysis API
hmacdope Nov 22, 2022
51eec87
fix up changeleog
hmacdope Nov 23, 2022
8dad311
fix libdma import
hmacdope Nov 23, 2022
5ef937a
fix up changeleog again
hmacdope Nov 23, 2022
d565b22
go back to compiling as C
hmacdope Nov 23, 2022
283372f
fix changelog c++
hmacdope Nov 23, 2022
d61ef01
remove c++
hmacdope Nov 23, 2022
c0a1d72
fix dcd imports
hmacdope Nov 23, 2022
24bf4b1
fix is_periodic
hmacdope Nov 23, 2022
64ad08a
make int cast explicit
hmacdope Nov 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package/MDAnalysis/coordinates/DCD.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,10 @@ def _read_next_timestep(self, ts=None):
if ts is None:
# use a copy to avoid that ts always points to the same reference
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
# removing this breaks lammps reader
ts = self.ts.copy() # why is this copy required ??
ts = self.ts # why is this copy required ??
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
frame = self._file.read()
self._frame += 1
ts = self._frame_to_ts(frame, ts)
self.ts = ts
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
self._frame_to_ts(frame, ts)
return ts

def Writer(self, filename, n_atoms=None, **kwargs):
Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/analysis/test_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def test_project_compare_projections(u_fresh):
project1 = pca.project_single_frame(1)

u_fresh.trajectory[0]
coord0 = project0(u_fresh.trajectory.ts).positions
coord0 = project0(u_fresh.trajectory.ts).positions.copy()
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
u_fresh.trajectory[0]
coord1 = project1(u_fresh.trajectory.ts).positions
assert not np.allclose(coord0, coord1, rtol=1e-05)
Expand Down
11 changes: 11 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,17 @@ def test_pickle_reader(self, reader):
assert_equal(len(reader), len(reader_p))
assert_equal(reader.ts, reader_p.ts,
"Timestep is changed after pickling")

def test_frame_collect_all_same(self, reader):
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
# check that the timestep resets so that the base pointer is the same
# for all timesteps in a collection witht eh exception of memoryreader
if isinstance(reader, mda.coordinates.memory.MemoryReader):
pytest.xfail()
hmacdope marked this conversation as resolved.
Show resolved Hide resolved
collected_ts = []
for i, ts in enumerate(reader):
collected_ts.append(ts.positions)
for array in collected_ts:
assert_allclose(array, collected_ts[0])


class MultiframeReaderTest(BaseReaderTest):
Expand Down
2 changes: 1 addition & 1 deletion testsuite/MDAnalysisTests/coordinates/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_n_frames(self, u):
assert_equal(u.trajectory.n_frames, self.n_frames)

def test_dimensions(self, u):
mean_dimensions = np.mean([ts.dimensions for ts in u.trajectory],
mean_dimensions = np.mean([ts.dimensions.copy() for ts in u.trajectory],
axis=0)
assert_almost_equal(mean_dimensions, self.mean_dimensions)

Expand Down
12 changes: 6 additions & 6 deletions testsuite/MDAnalysisTests/core/test_atomgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ def test_write_coordinates(self, u, tmpdir):
def test_write_frames(self, u, tmpdir, frames):
destination = str(tmpdir / 'test.dcd')
selection = u.trajectory[frames]
ref_positions = np.stack([ts.positions for ts in selection])
ref_positions = np.stack([ts.positions.copy() for ts in selection])
u.atoms.write(destination, frames=frames)

u_new = mda.Universe(destination)
new_positions = np.stack([ts.positions for ts in u_new.trajectory])
new_positions = np.stack([ts.positions.copy() for ts in u_new.trajectory])

assert_array_almost_equal(new_positions, ref_positions)

Expand All @@ -141,11 +141,11 @@ def test_write_frames(self, u, tmpdir, frames):
def test_write_frame_iterator(self, u, tmpdir, frames):
destination = str(tmpdir / 'test.dcd')
selection = u.trajectory[frames]
ref_positions = np.stack([ts.positions for ts in selection])
ref_positions = np.stack([ts.positions.copy() for ts in selection])
u.atoms.write(destination, frames=selection)

u_new = mda.Universe(destination)
new_positions = np.stack([ts.positions for ts in u_new.trajectory])
new_positions = np.stack([ts.positions.copy() for ts in u_new.trajectory])

assert_array_almost_equal(new_positions, ref_positions)

Expand All @@ -165,8 +165,8 @@ def test_write_frames_all(self, u, tmpdir, compression):
destination = str(tmpdir / 'test.dcd' + compression)
u.atoms.write(destination, frames='all')
u_new = mda.Universe(destination)
ref_positions = np.stack([ts.positions for ts in u.trajectory])
new_positions = np.stack([ts.positions for ts in u_new.trajectory])
ref_positions = np.stack([ts.positions.copy() for ts in u.trajectory])
new_positions = np.stack([ts.positions.copy() for ts in u_new.trajectory])
assert_array_almost_equal(new_positions, ref_positions)

@pytest.mark.parametrize('frames', ('invalid', 8, True, False, 3.2))
Expand Down