Skip to content

Commit

Permalink
skip observables contained in particle groups
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ committed Jun 15, 2024
1 parent 347a0c0 commit f9c6ca1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions package/MDAnalysis/coordinates/H5MD.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@
:members:
"""
import logging

import numpy as np
import MDAnalysis as mda
Expand All @@ -230,6 +231,8 @@ class MockH5pyFile:
else:
HAS_H5PY = True

logger = logging.getLogger(__name__)


class H5MDReader(base.ReaderBase):
r"""Reader for the H5MD format.
Expand Down Expand Up @@ -675,8 +678,12 @@ def _copy_to_data(self):

if 'observables' in self._file:
for key in self._file['observables'].keys():
self.ts.data[key] = self._file['observables'][key][
'value'][self._frame]
try:
self.ts.data[key] = self._file['observables'][key][
'value'][self._frame]
except KeyError:
logger.warning(f"Unable to read '{key}' from 'observables'")

Check warning on line 685 in package/MDAnalysis/coordinates/H5MD.py

View check run for this annotation

Codecov / codecov/patch

package/MDAnalysis/coordinates/H5MD.py#L684-L685

Added lines #L684 - L685 were not covered by tests


# pulls 'time' and 'step' out of first available parent group
for name, value in self._has.items():
Expand Down

0 comments on commit f9c6ca1

Please sign in to comment.