Skip to content

Commit c5988e6

Browse files
Merge branch 'develop' of github.com:mdanalysis/mdanalysis into ncrst-reader
2 parents d6627c7 + e64755c commit c5988e6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

benchmarks/benchmarks/analysis/rms.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import MDAnalysis
2+
import numpy as np
23

34
try:
45
from MDAnalysisTests.datafiles import DCD, PSF
@@ -14,23 +15,20 @@
1415
class SimpleRmsBench(object):
1516
"""Benchmarks for MDAnalysis.analysis.rms.rmsd"""
1617

17-
params = ([100, 500, 2000], [None, [1.0, 0.5]], [False, True], [False, True])
18-
param_names = ["num_atoms", "weights", "center", "superposition"]
18+
params = ([100, 500, 2000], [True, False], [False, True], [False, True])
19+
param_names = ["num_atoms", "use_weights", "center", "superposition"]
1920

20-
def setup(self, num_atoms, weights, center, superposition):
21+
def setup(self, num_atoms, use_weights, center, superposition):
2122
# mimic rmsd docstring example code
2223
self.u = MDAnalysis.Universe(PSF, DCD)
2324
# ag.positions is the new syntax
2425
# but older commit hashes will need to use
2526
# ag.coordinates()
26-
try:
27-
self.A = self.u.atoms.positions.copy()[:num_atoms]
28-
self.u.trajectory[-1]
29-
self.B = self.u.atoms.positions.copy()[:num_atoms]
30-
except:
31-
self.A = self.u.atoms.positions.copy()[:num_atoms]
32-
self.u.trajectory[-1]
33-
self.B = self.u.atoms.positions.copy()[:num_atoms]
27+
self.A = self.u.atoms.positions.copy()[:num_atoms]
28+
self.u.trajectory[-1]
29+
self.B = self.u.atoms.positions.copy()[:num_atoms]
30+
self.atoms = self.u.atoms[:num_atoms]
31+
self.weights = self.atoms.masses/np.sum(self.atoms.masses) if use_weights else None
3432

3533
def time_rmsd(self, num_atoms, weights, center, superposition):
3634
"""Benchmark rmsd function using a setup similar to
@@ -40,7 +38,7 @@ def time_rmsd(self, num_atoms, weights, center, superposition):
4038
rms.rmsd(
4139
a=self.A,
4240
b=self.B,
43-
weights=weights,
41+
weights=self.weights,
4442
center=center,
4543
superposition=superposition,
4644
)

package/CHANGELOG

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The rules for this file:
1515

1616
-------------------------------------------------------------------------------
1717
??/??/?? IAlibay, orbeckst, BHM-Bob, TRY-ER, Abdulrahman-PROG, pbuslaev,
18-
yuxuanzhuang, yuyuan871111, jpkrowe, jeremyleung521
18+
yuxuanzhuang, yuyuan871111, tanishy7777, jpkrowe, jeremyleung521
1919

2020
* 2.10.0
2121

@@ -29,7 +29,9 @@ Fixes
2929
* Reads `segids` column in `PDBParser` from 73-76 instead of 67-76 to
3030
align the standard of a PDBReader (e.g., Chimera, CHARMM, Gemmi).
3131
(Issue #4948, PR #5001)
32-
32+
* Fixes the benchmark `SimpleRmsBench` in `benchmarks/analysis/rms.py`
33+
by changing the way weights for RMSD are calculated, instead of
34+
directly passing them. (Issue #3520, PR #5006)
3335
Enhancements
3436
* Allow NCDF reader to read Amber Restart Files with extension `.ncrst`
3537
(Issue #5030, PR#5031)

0 commit comments

Comments
 (0)