Skip to content

Commit

Permalink
fix IndexError
Browse files Browse the repository at this point in the history
  • Loading branch information
PythonFZ authored Dec 21, 2023
1 parent d1b4f43 commit dee4b74
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions znh5md/znh5md/h5ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ def _gather_value(particles_data, key, idx):
Returns None if the key is not present in the data.
"""
if key in particles_data:
if key in [GRP.species, GRP.position, GRP.velocity, GRP.forces, GRP.momentum]:
# use PARTICLES_GRP
return rm_nan(particles_data[key][idx])
return particles_data[key][idx]
try:
if key in particles_data:
if key in [GRP.species, GRP.position, GRP.velocity, GRP.forces, GRP.momentum]:
# use PARTICLES_GRP
return rm_nan(particles_data[key][idx])
return particles_data[key][idx]
except IndexError:
# a property might not be available at all frames.
pass
return None


Expand Down

0 comments on commit dee4b74

Please sign in to comment.