diff --git a/package/MDAnalysis/analysis/density.py b/package/MDAnalysis/analysis/density.py index 3846d69c17a..c849ba3ea8d 100644 --- a/package/MDAnalysis/analysis/density.py +++ b/package/MDAnalysis/analysis/density.py @@ -441,8 +441,11 @@ def _single_frame(self): h, _ = np.histogramdd(self._atomgroup.positions, bins=self._bins, range=self._arange, normed=False) - # manually reduce (not yet part of AnalysisBase but exists in pmda.parallel.AnalysisBase) - self._reduce(self._grid, h) + # reduce (proposed change #2542 to match the parallel version in pmda.density) + # return self._reduce(self._grid, h) + # + # serial code can simply do + self._grid += h def _conclude(self): # average: @@ -453,19 +456,21 @@ def _conclude(self): density.make_density() self.density = density - @staticmethod - def _reduce(res, result_single_frame): - """'accumulate' action for a time series - - If `res` is a numpy array, the `result_single_frame` is added to it - element-wise. If `res` and `result_single_frame` are lists then - `result_single_frame` is appended to `res`. - """ - if isinstance(res, list) and len(res) == 0: - res = result_single_frame - else: - res += result_single_frame - return res + # _reduce is not strictly necessary for the serial version but is necessary for + # pmda-style parallelism (see #2542) + # @staticmethod + # def _reduce(res, result_single_frame): + # """'accumulate' action for a time series + # + # If `res` is a numpy array, the `result_single_frame` is added to it + # element-wise. If `res` and `result_single_frame` are lists then + # `result_single_frame` is appended to `res`. + # """ + # if isinstance(res, list) and len(res) == 0: + # res = result_single_frame + # else: + # res += result_single_frame + # return res class Density(Grid):