Skip to content

Commit 44f3340

Browse files
committed
format and tweak comment
1 parent dfaa79f commit 44f3340

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

  • package/MDAnalysis/analysis

package/MDAnalysis/analysis/pca.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,8 @@ def _prepare(self):
295295
)
296296
n_dim = self._n_atoms * 3
297297
self.cov = np.zeros((n_dim, n_dim))
298-
# Batch frames into BLAS matmul for covariance updates.
299-
# Peak memory: 2 * n_dim^2 * 8 (cov + matmul temporary)
300-
# + batch_size * n_dim * 8 (frame buffer).
298+
# Batch frames into BLAS matmul for covariance updates
299+
# while keeping memory usage reasonable.
301300
self._batch_size = min(self.n_frames, 500)
302301
self._frame_data = np.empty((self._batch_size, n_dim))
303302
self._batch_idx = 0 # tracks when to update self.cov
@@ -350,8 +349,8 @@ def _conclude(self):
350349
if self._batch_idx > 0:
351350
# Accumulate remaining frames from the final batch
352351
self.cov += (
353-
self._frame_data[:self._batch_idx].T
354-
@ self._frame_data[:self._batch_idx]
352+
self._frame_data[: self._batch_idx].T
353+
@ self._frame_data[: self._batch_idx]
355354
)
356355
self.cov /= self.n_frames - 1
357356
del self._frame_data

0 commit comments

Comments
 (0)