-
Notifications
You must be signed in to change notification settings - Fork 15
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
Indexing Atoms broken on __getitem__ #1343
Comments
I am using a pyiron structure for atom probe simulations. I am also running into same error. However, strangely I am unable to reproduce the error when I just do this. from pyiron_atomistics import Atoms
s = Atoms('N2', [(0, 0, 0), (0, 0, 1.5)])
s[0] The above code block runs perfectly fine in my simulation environment. But, when I am trying to run my simulations I get the error. afaik the only difference is that I have a simulation class instance, whose attribute is pyiron structure. a = MySimulation()
print(a.structure[0].number) This gives me error. |
I was able to reproduce the error now. strangely, when index is of dtype np.int64 it gives an error. from pyiron_atomistics import Atoms
import numpy as np
s = Atoms('N2', [(0, 0, 0), (0, 0, 1.5)])
a = 0
print(type(a))
print(s[a])
a = np.int64(a)
print(type(a))
print(s[a]) This gives the following output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[24], line 9
7 a = np.int64(a)
8 print(type(a))
----> 9 print(s[a])
File ~/.venv/lib/python3.11/site-packages/pyiron_atomistics/atomistics/structure/atoms.py:2122, in Atoms.__getitem__(self, item)
2112 return Atom(
2113 element=element,
2114 position=position,
(...)
2118 **new_dict,
2119 )
2121 new_array = super(Atoms, self).__getitem__(item)
-> 2122 new_array.dimension = self.dimension
2123 if isinstance(item, tuple):
2124 item = list(item)
AttributeError: 'Atom' object has no attribute 'dimension' Not sure if this helps. |
Zhenyu and I figured out a hint for this (on a different problem). Can you check whether anywhere in |
triggers the exception below. Setting values is unaffected.
The text was updated successfully, but these errors were encountered: