diff --git a/package/CHANGELOG b/package/CHANGELOG index 36e4ef5f723..a01407ba373 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -13,7 +13,7 @@ The rules for this file: * release numbers follow "Semantic Versioning" http://semver.org ------------------------------------------------------------------------------ -??/??/16 kain88-de, jdetle, fiona-naughton, richardjgowers, tyler.je.reddy +??/??/16 kain88-de, fiona-naughton, richardjgowers, tyler.je.reddy, jdetle * 0.15.1 @@ -24,7 +24,8 @@ Fixes * SingleFrameReader now raises StopIteration instead of IOError on calling next (Issue #869) * Display of Deprecation warnings doesn't affect other modules anymore (Issue #754) - + * Changed nframes to n_frames in analysis modules for consistency (Issue #890) + Changes * Added protected variable _frame_index to to keep track of frame iteration number in AnalysisBase diff --git a/package/MDAnalysis/analysis/align.py b/package/MDAnalysis/analysis/align.py index 6a496b3ba4c..4b1c2c755a0 100644 --- a/package/MDAnalysis/analysis/align.py +++ b/package/MDAnalysis/analysis/align.py @@ -558,7 +558,7 @@ def _prepare(self): self._ref_com = self.ref_atoms.center_of_mass() self._ref_coordinates = self.ref_atoms.positions - self._ref_com # allocate the array for selection atom coords - self.rmsd = np.zeros((self.nframes,)) + self.rmsd = np.zeros((self.n_frames,)) def _single_frame(self): index = self._ts.frame @@ -717,8 +717,8 @@ def rms_fit_trj( traj_coordinates = traj_atoms.positions.copy() # RMSD timeseries - nframes = len(frames) - rmsd = np.zeros((nframes,)) + n_frames = len(frames) + rmsd = np.zeros((n_frames,)) # R: rotation matrix that aligns r-r_com, x~-x~com # (x~: selected coordinates, x: all coordinates) @@ -727,7 +727,7 @@ def rms_fit_trj( R = np.matrix(rot.reshape(3, 3)) percentage = ProgressMeter( - nframes, + n_frames, interval=10, quiet=quiet, format="Fitted frame %(step)5d/%(numsteps)d [%(percentage)5.1f%%] r") diff --git a/package/MDAnalysis/analysis/base.py b/package/MDAnalysis/analysis/base.py index 6c073a9627e..5c6a3dad112 100644 --- a/package/MDAnalysis/analysis/base.py +++ b/package/MDAnalysis/analysis/base.py @@ -71,7 +71,7 @@ def _setup_frames(self, trajectory, start=None, self.start = start self.stop = stop self.step = step - self.nframes = len(range(start, stop, step)) + self.n_frames = len(range(start, stop, step)) def _single_frame(self): """Calculate data from a single frame of trajectory @@ -99,7 +99,7 @@ def run(self, **kwargs): self._trajectory[self.start:self.stop:self.step]): self._frame_index = i self._ts = ts - # logger.info("--> Doing frame {} of {}".format(i+1, self.nframes)) + # logger.info("--> Doing frame {} of {}".format(i+1, self.n_frames)) self._single_frame() logger.info("Finishing up") self._conclude() diff --git a/package/MDAnalysis/analysis/lineardensity.py b/package/MDAnalysis/analysis/lineardensity.py index 511aa13838e..69df9fbc28b 100644 --- a/package/MDAnalysis/analysis/lineardensity.py +++ b/package/MDAnalysis/analysis/lineardensity.py @@ -1,5 +1,5 @@ # -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # # MDAnalysis --- http://www.MDAnalysis.org # Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein @@ -46,7 +46,7 @@ class LinearDensity(AnalysisBase): binsize : float Bin width in Angstrom used to build linear density - histograms. Defines the resolution of the resulting density + histograms. Defines the resolution of the resulting density profile (smaller --> higher resolution) [0.25] start : int @@ -58,7 +58,7 @@ class LinearDensity(AnalysisBase): Example ------- - First create a LinearDensity object by supplying a selection, + First create a LinearDensity object by supplying a selection, then use the `run` method: ldens = LinearDensity(selection) ldens.run() @@ -161,7 +161,7 @@ def _conclude(self): # Average results over the number of configurations for dim in ['x', 'y', 'z']: for key in ['pos', 'pos_std', 'char', 'char_std']: - self.results[dim][key] /= self.nframes + self.results[dim][key] /= self.n_frames # Compute standard deviation for the error self.results[dim]['pos_std'] = np.sqrt(self.results[dim]['pos_std'] - np.square(self.results[dim]['pos'])) diff --git a/package/MDAnalysis/analysis/polymer.py b/package/MDAnalysis/analysis/polymer.py index ef01a42f94d..9e54492b114 100644 --- a/package/MDAnalysis/analysis/polymer.py +++ b/package/MDAnalysis/analysis/polymer.py @@ -1,5 +1,5 @@ # -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # # MDAnalysis --- http://www.MDAnalysis.org # Copyright (c) 2006-2015 Naveen Michaud-Agrawal, Elizabeth J. Denning, Oliver Beckstein @@ -84,7 +84,7 @@ def _single_frame(self): # could optimise this by writing a "self dot array" # we're only using the upper triangle of np.inner # function would accept a bunch of coordinates and spit out the - # decorrel for that + # decorrel for that n = len(self._atomgroups[0]) for chain in self._atomgroups: @@ -101,7 +101,7 @@ def _conclude(self): n = len(self._atomgroups[0]) norm = np.linspace(n - 1, 1, n - 1) - norm *= len(self._atomgroups) * self.nframes + norm *= len(self._atomgroups) * self.n_frames self.results = self._results / norm self._calc_bond_length() @@ -169,5 +169,3 @@ def expfunc(x, a): a = curve_fit(expfunc, x, y)[0][0] return a - - diff --git a/package/MDAnalysis/analysis/rdf.py b/package/MDAnalysis/analysis/rdf.py index 8b3d08c6d2e..a4b54de230e 100644 --- a/package/MDAnalysis/analysis/rdf.py +++ b/package/MDAnalysis/analysis/rdf.py @@ -144,9 +144,9 @@ def _conclude(self): vol *= 4/3.0 * np.pi # Average number density - box_vol = self.volume / self.nframes + box_vol = self.volume / self.n_frames density = N / box_vol - rdf = self.count / (density * vol * self.nframes) + rdf = self.count / (density * vol * self.n_frames) self.rdf = rdf diff --git a/package/MDAnalysis/analysis/rms.py b/package/MDAnalysis/analysis/rms.py index 668a8e7ea0d..7b44115b259 100644 --- a/package/MDAnalysis/analysis/rms.py +++ b/package/MDAnalysis/analysis/rms.py @@ -461,11 +461,11 @@ def run(self, start=None, stop=None, step=None, rot = None # RMSD timeseries - nframes = len(np.arange(0, len(trajectory))[start:stop:step]) - rmsd = np.zeros((nframes, 3 + len(self.groupselections_atoms))) + n_frames = len(np.arange(0, len(trajectory))[start:stop:step]) + rmsd = np.zeros((n_frames, 3 + len(self.groupselections_atoms))) percentage = ProgressMeter( - nframes, interval=10, format="RMSD %(rmsd)5.2f A at frame " + n_frames, interval=10, format="RMSD %(rmsd)5.2f A at frame " "%(step)5d/%(numsteps)d [%(percentage)5.1f%%]\r") for k, ts in enumerate(trajectory[start:stop:step]): diff --git a/testsuite/MDAnalysisTests/analysis/test_base.py b/testsuite/MDAnalysisTests/analysis/test_base.py index bc9a163de46..038a2baacc4 100644 --- a/testsuite/MDAnalysisTests/analysis/test_base.py +++ b/testsuite/MDAnalysisTests/analysis/test_base.py @@ -55,28 +55,28 @@ def tearDown(self): def test_default(self): an = FrameAnalysis(self.u.trajectory) - assert_(an.nframes == len(self.u.trajectory)) + assert_(an.n_frames == len(self.u.trajectory)) an.run() assert_(an.frames == list(range(len(self.u.trajectory)))) def test_start(self): an = FrameAnalysis(self.u.trajectory, start=20) - assert_(an.nframes == len(self.u.trajectory) - 20) + assert_(an.n_frames == len(self.u.trajectory) - 20) an.run() assert_(an.frames == list(range(20, len(self.u.trajectory)))) def test_stop(self): an = FrameAnalysis(self.u.trajectory, stop=20) - assert_(an.nframes == 20) + assert_(an.n_frames == 20) an.run() assert_(an.frames == list(range(20))) def test_step(self): an = FrameAnalysis(self.u.trajectory, step=20) - assert_(an.nframes == 5) + assert_(an.n_frames == 5) an.run() assert_(an.frames == list(range(98))[::20])