BUG: trajectory add/get_particle_info() not compatible with strings #46
Labels
bug
Something isn't working
module: trajectory
release: patch
Issues that need to be addressed in a patch release
status: to do
Issues that someone needs to work on
Milestone
Description:
When saving particle type info in the trajectory file, a string can be used as
ptype
. But when trying to get the info, an error occurs due to the reader expecting an int instead of a string.Code for reproduction:
Error message:
ValueError Traceback (most recent call last)
Cell In[27], line 1
----> 1 traj_particles.get_particle_info()
File ~/Documents/git_amep/amep/trajectory.py:233, in ParticleTrajectory.get_particle_info(self, ptype)
231 p = {}
232 for t in list(root['particles'].keys()):
--> 233 p[int(t)] = dict(a for a in root['particles'][t].attrs.items())
234 elif str(ptype) in list(root['particles'].keys()):
235 p = dict(a for a in root['particles'][str(ptype)].attrs.items())
ValueError: invalid literal for int() with base 10: 'asdf'
Python and AMEP versions:
1.0.2_dev (github version 10.7.2024), python 3.10
Additional information:
amep.trajectory.ParticleTrajectory
traj_particles.get_particle_info(ptype)
should only return info for ptype=int.How did you install AMEP?
None
The text was updated successfully, but these errors were encountered: