Skip to content

Commit 2ac868b

Browse files
authored
Merge branch 'MDAnalysis:develop' into devel-relprop
2 parents 08f8b98 + 5656fe4 commit 2ac868b

File tree

117 files changed

+8577
-5409
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+8577
-5409
lines changed

.pep8speaks.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
scanner:
2+
diff_only: True
3+
linter: pycodestyle
4+
5+
pycodestyle: # Valid if scanner.linter is pycodestyle
6+
max-line-length: 79
7+
ignore: ["E203", "E701"]
8+
exclude: []
9+
count: False
10+
first: False
11+
show-pep8: False
12+
show-source: False
13+
statistics: False
14+
hang-closing: False
15+
filename: []
16+
select: []
17+
18+
flake8: # Valid if scanner.linter is flake8
19+
max-line-length: 79
20+
ignore: ["E203", "E501", "E701"]
21+
exclude: []
22+
count: False
23+
show-source: False
24+
statistics: False
25+
hang-closing: False
26+
filename: []
27+
select: []
28+
29+
no_blank_comment: True
30+
descending_issues_order: False
31+
only_mention_files_with_errors: True
32+
33+
message:
34+
opened:
35+
header: ""
36+
footer: ""
37+
updated:
38+
header: ""
39+
footer: ""
40+
no_errors: "There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: "

benchmarks/benchmarks/GRO.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import MDAnalysis as mda
12
import numpy as np
23
from MDAnalysis.coordinates.GRO import GROReader
34
from MDAnalysis.topology.GROParser import GROParser
45
from MDAnalysisTests.datafiles import GRO
5-
import MDAnalysis as mda
6+
67

78
class GROReadBench(object):
89
def time_read_GRO_coordinates(self):

benchmarks/benchmarks/ag_methods.py

Lines changed: 61 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,31 @@
22
import numpy as np
33

44
try:
5-
from MDAnalysisTests.datafiles import (GRO, TPR, XTC,
6-
PSF, DCD,
7-
TRZ_psf, TRZ)
85
from MDAnalysis.exceptions import NoDataError
6+
from MDAnalysisTests.datafiles import DCD, GRO, PSF, TPR, TRZ, XTC, TRZ_psf
97
except:
108
pass
119

10+
1211
class AtomGroupMethodsBench(object):
1312
"""Benchmarks for the various MDAnalysis
1413
atomgroup methods.
1514
"""
15+
1616
# NOTE: the write() method has been
1717
# excluded as file writing is considered
1818
# a separate benchmarking category
1919

2020
params = (10, 100, 1000, 10000)
21-
param_names = ['num_atoms']
21+
param_names = ["num_atoms"]
2222

2323
def setup(self, num_atoms):
2424
self.u = MDAnalysis.Universe(GRO)
2525
self.ag = self.u.atoms[:num_atoms]
2626
self.weights = np.ones(num_atoms)
27-
self.vdwradii = {'H':1.0,
28-
'C':1.0,
29-
'N':1.0,
30-
'O':1.0,
31-
'DUMMY':1.0}
32-
self.rot_matrix = np.ones((3,3))
33-
self.trans = np.ones((4,4))
27+
self.vdwradii = {"H": 1.0, "C": 1.0, "N": 1.0, "O": 1.0, "DUMMY": 1.0}
28+
self.rot_matrix = np.ones((3, 3))
29+
self.trans = np.ones((4, 4))
3430

3531
def time_bbox_pbc(self, num_atoms):
3632
"""Benchmark bounding box calculation
@@ -60,15 +56,13 @@ def time_center_pbc(self, num_atoms):
6056
"""Benchmark center calculation with
6157
pbc active.
6258
"""
63-
self.ag.center(weights=self.weights,
64-
pbc=True)
59+
self.ag.center(weights=self.weights, pbc=True)
6560

6661
def time_center_no_pbc(self, num_atoms):
6762
"""Benchmark center calculation with
6863
pbc inactive.
6964
"""
70-
self.ag.center(weights=self.weights,
71-
pbc=False)
65+
self.ag.center(weights=self.weights, pbc=False)
7266

7367
def time_centroid_pbc(self, num_atoms):
7468
"""Benchmark centroid calculation with
@@ -83,8 +77,7 @@ def time_centroid_no_pbc(self, num_atoms):
8377
self.ag.centroid(pbc=False)
8478

8579
def time_concatenate(self, num_atoms):
86-
"""Benchmark atomgroup concatenation.
87-
"""
80+
"""Benchmark atomgroup concatenation."""
8881
self.ag.concatenate(self.ag)
8982

9083
def time_difference(self, num_atoms):
@@ -97,7 +90,7 @@ def time_groupby(self, num_atoms):
9790
"""Benchmark atomgroup groupby
9891
operation.
9992
"""
100-
self.ag.groupby('resnames')
93+
self.ag.groupby("resnames")
10194

10295
def time_guess_bonds(self, num_atoms):
10396
"""Benchmark atomgroup bond guessing
@@ -106,18 +99,15 @@ def time_guess_bonds(self, num_atoms):
10699
self.ag.guess_bonds(self.vdwradii)
107100

108101
def time_intersection(self, num_atoms):
109-
"""Benchmark ag intersection.
110-
"""
102+
"""Benchmark ag intersection."""
111103
self.ag.intersection(self.ag)
112104

113105
def time_is_strict_subset(self, num_atoms):
114-
"""Benchmark ag strict subset operation.
115-
"""
106+
"""Benchmark ag strict subset operation."""
116107
self.ag.is_strict_subset(self.ag)
117108

118109
def time_is_strict_superset(self, num_atoms):
119-
"""Benchmark ag strict superset operation.
120-
"""
110+
"""Benchmark ag strict superset operation."""
121111
self.ag.is_strict_superset(self.ag)
122112

123113
def time_isdisjoint(self, num_atoms):
@@ -155,19 +145,17 @@ def time_rotateby(self, num_atoms):
155145
"""Benchmark rotation by an angle
156146
of the ag coordinates.
157147
"""
158-
self.ag.rotateby(angle=45,
159-
axis=[1,0,0])
148+
self.ag.rotateby(angle=45, axis=[1, 0, 0])
160149

161150
def time_split(self, num_atoms):
162151
"""Benchmark ag splitting into
163152
multiple ags based on a simple
164153
criterion.
165154
"""
166-
self.ag.split('residue')
155+
self.ag.split("residue")
167156

168157
def time_subtract(self, num_atoms):
169-
"""Benchmark ag subtraction.
170-
"""
158+
"""Benchmark ag subtraction."""
171159
self.ag.subtract(self.ag)
172160

173161
def time_symmetric_difference(self, num_atoms):
@@ -187,7 +175,7 @@ def time_translate(self, num_atoms):
187175
translation vector to the ag
188176
coordinates.
189177
"""
190-
self.ag.translate([0,0.5,1])
178+
self.ag.translate([0, 0.5, 1])
191179

192180
def time_union(self, num_atoms):
193181
"""Benchmark union operation
@@ -202,14 +190,13 @@ def time_wrap(self, num_atoms):
202190
self.ag.wrap()
203191

204192

205-
206193
class AtomGroupAttrsBench(object):
207194
"""Benchmarks for the various MDAnalysis
208195
atomgroup attributes.
209196
"""
210197

211198
params = (10, 100, 1000, 10000)
212-
param_names = ['num_atoms']
199+
param_names = ["num_atoms"]
213200

214201
def setup(self, num_atoms):
215202
self.u = MDAnalysis.Universe(GRO)
@@ -235,7 +222,7 @@ def time_dihedral(self, num_atoms):
235222
"""
236223
self.ag[:4].dihedral
237224

238-
#TODO: use universe / ag that
225+
# TODO: use universe / ag that
239226
# is suitable for force calc
240227
def time_forces(self, num_atoms):
241228
"""Benchmark atomgroup force
@@ -246,7 +233,7 @@ def time_forces(self, num_atoms):
246233
except NoDataError:
247234
pass
248235

249-
#TODO: use universe / ag that
236+
# TODO: use universe / ag that
250237
# is suitable for velocity extraction
251238
def time_velocity(self, num_atoms):
252239
"""Benchmark atomgroup velocity
@@ -265,8 +252,7 @@ def time_improper(self, num_atoms):
265252
self.ag[:4].improper
266253

267254
def time_indices(self, num_atoms):
268-
"""Benchmark atom index calculation.
269-
"""
255+
"""Benchmark atom index calculation."""
270256
self.ag.ix
271257

272258
def time_atomcount(self, num_atoms):
@@ -326,15 +312,17 @@ def time_bond(self, num_atoms):
326312

327313
class CompoundSplitting(object):
328314
"""Test how fast can we split compounds into masks and apply them
329-
315+
330316
The benchmark used in Issue #3000. Parameterizes multiple compound number
331317
and size combinations.
332318
"""
333-
334-
params = [(100, 10000, 1000000), # n_atoms
335-
(1, 10, 100), # n_compounds
336-
(True, False), # homogeneous
337-
(True, False)] # contiguous
319+
320+
params = [
321+
(100, 10000, 1000000), # n_atoms
322+
(1, 10, 100), # n_compounds
323+
(True, False), # homogeneous
324+
(True, False),
325+
] # contiguous
338326

339327
def setup(self, n_atoms, n_compounds, homogeneous, contiguous):
340328
rg = np.random.Generator(np.random.MT19937(3000))
@@ -345,7 +333,7 @@ def setup(self, n_atoms, n_compounds, homogeneous, contiguous):
345333

346334
if n_compounds == 1 and not (homogeneous and contiguous):
347335
raise NotImplementedError
348-
336+
349337
if n_compounds == n_atoms:
350338
if not (homogeneous and contiguous):
351339
raise NotImplementedError
@@ -354,51 +342,56 @@ def setup(self, n_atoms, n_compounds, homogeneous, contiguous):
354342
ats_per_compound, remainder = divmod(n_atoms, n_compounds)
355343
if remainder:
356344
raise NotImplementedError
357-
compound_indices = np.tile(np.arange(n_compounds),
358-
(ats_per_compound, 1)).T.ravel()
345+
compound_indices = np.tile(
346+
np.arange(n_compounds), (ats_per_compound, 1)
347+
).T.ravel()
359348
else:
360-
compound_indices = np.sort(np.floor(rg.random(n_atoms)
361-
* n_compounds).astype(np.int))
362-
349+
compound_indices = np.sort(
350+
np.floor(rg.random(n_atoms) * n_compounds).astype(np.int)
351+
)
352+
363353
unique_indices = np.unique(compound_indices)
364354
if len(unique_indices) != n_compounds:
365355
raise RuntimeError
366-
356+
367357
if not contiguous:
368358
rg.shuffle(compound_indices)
369-
370-
self.u = MDAnalysis.Universe.empty(n_atoms,
371-
n_residues=n_compounds,
372-
n_segments=1,
373-
atom_resindex=compound_indices,
374-
trajectory=True)
375-
self.u.atoms.positions = rg.random((n_atoms, 3),
376-
dtype=np.float32) * 100
359+
360+
self.u = MDAnalysis.Universe.empty(
361+
n_atoms,
362+
n_residues=n_compounds,
363+
n_segments=1,
364+
atom_resindex=compound_indices,
365+
trajectory=True,
366+
)
367+
self.u.atoms.positions = rg.random((n_atoms, 3), dtype=np.float32) * 100
377368
self.u.dimensions = [50, 50, 50, 90, 90, 90]
378369

379370
def time_center_compounds(self, *args):
380-
self.u.atoms.center(None, compound='residues')
371+
self.u.atoms.center(None, compound="residues")
381372

382373

383374
class FragmentFinding(object):
384375
"""Test how quickly we find fragments (distinct molecules from bonds)"""
376+
385377
# if we try to parametrize over topology &
386378
# trajectory formats asv will use all
387379
# possible combinations, so instead handle
388380
# this in setup()
389-
params = ('large_fragment_small_solvents',
390-
'large_fragment',
391-
'polymer_chains', # 20ish polymer chains
392-
)
393-
param_names = ['universe_type']
381+
params = (
382+
"large_fragment_small_solvents",
383+
"large_fragment",
384+
"polymer_chains", # 20ish polymer chains
385+
)
386+
param_names = ["universe_type"]
394387

395388
def setup(self, universe_type):
396-
if universe_type == 'large_fragment_small_solvents':
397-
univ = (TPR, XTC)
398-
elif universe_type == 'large_fragment':
389+
if universe_type == "large_fragment_small_solvents":
390+
univ = (TPR, XTC)
391+
elif universe_type == "large_fragment":
399392
univ = (PSF, DCD)
400393
else:
401-
univ = (TRZ_psf, TRZ)
394+
univ = (TRZ_psf, TRZ)
402395
self.u = MDAnalysis.Universe(*univ)
403396

404397
def time_find_fragments(self, universe_type):
@@ -407,6 +400,7 @@ def time_find_fragments(self, universe_type):
407400

408401
class FragmentCaching(FragmentFinding):
409402
"""Test how quickly we find cached fragments"""
403+
410404
def setup(self, universe_type):
411405
super(FragmentCaching, self).setup(universe_type)
412406
frags = self.u.atoms.fragments # Priming the cache

0 commit comments

Comments
 (0)