-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: trajectory add/get_particle_info() not compatible with strings #46
Comments
Feature request: allow iterable of ptypes. |
ptype might be a string ("CH2" for unified-atom models in MD simulations for example). |
It is not quite straight forward to make the readers work with strings as particletypes. Since strings are variable length we would need to allocate space that might or might not get used. We gonna have to talk this through again. |
The GSD format stores the atom types as null terminated strings: https://gsd.readthedocs.io/en/stable/schema-hoomd.html#chunk-particles-types Discussion points:
|
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: