Skip to content

Commit

Permalink
Some cleaning on dimensions for memory reader
Browse files Browse the repository at this point in the history
  • Loading branch information
jbarnoud committed Jul 24, 2017
1 parent 9846353 commit 8c272b3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions package/MDAnalysis/coordinates/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,24 @@ def __init__(self, coordinate_array, order='fac',
.format(provided_n_atoms, self.n_atoms))

self._dimensions_array = np.asanyarray(dimensions)
if self._dimensions_array is not None:
if (len(self._dimensions_array.shape) == 1
and self._dimensions_array.shape[0] != 6):
raise ValueError('The *dimensions* array must be formated as '
'[A B C alpha beta gamma] but your dimensions '
'have {} elements.'
.format(self._dimensions_array.shape[0]))
if len(self._dimensions_array.shape) > 1:
if self._dimensions_array.shape[0] != self.n_frames):
raise ValueError('The *dimensions* array does not have '
'the same number of frames as the '
'positions: {} dimensions frame but '
'{} positions frame.'
.format(self._dimensions_array.shape[0],
self.n_frames))
if self._dimensions_array.shape[1] != 6:
raise ValueError('The dimensions for each frame must be '
'of the form [A B C alpha beta gamma].')
self.ts = self._Timestep(self.n_atoms, **kwargs)
self.ts.dt = dt
self.ts.frame = -1
Expand Down

0 comments on commit 8c272b3

Please sign in to comment.