Skip to content

Commit 8b0be5f

Browse files
authored
Fix incorrect self.atom assignment in SingleFrameReaderBase (#5055)
- fix n_atom bug in SingleFrameReaderBase - conform lammps init function to SingleFrameReaderBase
1 parent e49c1fa commit 8b0be5f

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

package/CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The rules for this file:
2121
* 2.10.0
2222

2323
Fixes
24+
* Fix incorrect `self.atom` assignment in SingleFrameReaderBase (Issue #5052, PR #5055)
2425
* Fixes bug in `analysis/hydrogenbonds.py`: `_donors` and `_hydrogens`
2526
were not updated when the `acceptors_sel` and `hydrogens_sel` were provided
2627
after initialization. (Issue #5010, PR #5018)

package/MDAnalysis/coordinates/LAMMPS.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ class DATAReader(base.SingleFrameReaderBase):
240240

241241
@store_init_arguments
242242
def __init__(self, filename, **kwargs):
243-
self.n_atoms = kwargs.pop("n_atoms", None)
244-
if self.n_atoms is None: # this should be done by parsing DATA first
243+
n_atoms = kwargs.pop("n_atoms", None)
244+
if n_atoms is None: # this should be done by parsing DATA first
245245
raise ValueError("DATAReader requires n_atoms keyword")
246246
self.atom_style = kwargs.pop("atom_style", None)
247-
super(DATAReader, self).__init__(filename, **kwargs)
247+
super(DATAReader, self).__init__(filename, n_atoms=n_atoms, **kwargs)
248248

249249
def _read_first_frame(self):
250250
with DATAParser(self.filename) as p:

package/MDAnalysis/coordinates/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,9 @@ class SingleFrameReaderBase(ProtoReader):
16551655
Calling `__iter__` now rewinds the reader before yielding a
16561656
:class:`Timestep` object (fixing behavior that was not
16571657
well defined previously).
1658+
.. versionchanged:: 2.10.0
1659+
Fixed a typo in the attribute assignment (`self.atom` → `self.atoms`),
1660+
which may affect subclasses relying on this value.
16581661
"""
16591662
_err = "{0} only contains a single frame"
16601663

@@ -1666,7 +1669,7 @@ def __init__(self, filename, convert_units=True, n_atoms=None, **kwargs):
16661669
self.convert_units = convert_units
16671670

16681671
self.n_frames = 1
1669-
self.n_atom = n_atoms
1672+
self.n_atoms = n_atoms
16701673

16711674
ts_kwargs = {}
16721675
for att in ('dt', 'time_offset'):

0 commit comments

Comments
 (0)