Skip to content
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

create.structure.ase.read fails for trajectories #1604

Open
niklassiemer opened this issue Nov 18, 2024 · 0 comments
Open

create.structure.ase.read fails for trajectories #1604

niklassiemer opened this issue Nov 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@niklassiemer
Copy link
Member

from pyiron_atomistics import Project
pr = Project('MWE')
with open(pr.path + 'some.xyz', 'w') as f:
    f.write(4*"1\n\nH 0 0 0\n")
print(len(pr.create.structure.ase.read(pr.path+'some.xyz')))
pr.create.structure.ase.read(pr.path+'some.xyz', index=':')

prints 1 and raises

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[14], line 2
      1 print(len(pr.create.structure.ase.read(pr.path+'some.xyz')))
----> 2 pr.create.structure.ase.read(pr.path+'some.xyz', index=':')

File /cmmc/ptmp/pyironhb/mambaforge/envs/pyiron_mpie_cmti_2024-11-11/lib/python3.11/site-packages/pyiron_atomistics/atomistics/structure/factories/ase.py:57, in _ase_wraps.<locals>.decorator.<locals>.wrapper(*args, **kwargs)
     54 @wraps(ase_func)
     55 def wrapper(*args, **kwargs):
     56     state.publications.add(publication_ase())
---> 57     return func(*args, **kwargs)

File /cmmc/ptmp/pyironhb/mambaforge/envs/pyiron_mpie_cmti_2024-11-11/lib/python3.11/site-packages/pyiron_atomistics/atomistics/structure/factories/ase.py:84, in AseFactory.read(self, *args, **kwargs)
     82 @_ase_wraps(ase_read)
     83 def read(self, *args, **kwargs):
---> 84     return ase_to_pyiron(ase_read(*args, **kwargs))

File /cmmc/ptmp/pyironhb/mambaforge/envs/pyiron_mpie_cmti_2024-11-11/lib/python3.11/site-packages/pyiron_atomistics/atomistics/structure/atoms.py:3048, in ase_to_pyiron(ase_obj)
   3037 def ase_to_pyiron(ase_obj):
   3038     """
   3039     Convert an ase.atoms.Atoms structure object to its equivalent pyiron structure
   3040 
   (...)
   3046 
   3047     """
-> 3048     element_list = ase_obj.get_chemical_symbols()
   3049     cell = ase_obj.cell
   3050     positions = ase_obj.get_positions()

AttributeError: 'list' object has no attribute 'get_chemical_symbols'

Since the ase.io.read with index=":" returns a list of ase.Atoms objects. We would need to overlaod ase_to_pyiron to accept a list of ase_obj.

@niklassiemer niklassiemer added the bug Something isn't working label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant