Skip to content

Commit

Permalink
Merge pull request #981 from pyiron/load_sparse_list
Browse files Browse the repository at this point in the history
Remove sparse list
  • Loading branch information
samwaseda committed Jul 11, 2023
2 parents aee21f2 + a4d43dd commit 1211fd3
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 971 deletions.
4 changes: 2 additions & 2 deletions pyiron_atomistics/atomistics/job/atomistic.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def _get_structure(self, frame=-1, wrap_atoms=True):
if cell is not None:
snapshot.cell = cell
if indices is not None:
snapshot.indices = indices
snapshot.set_array("indices", indices)
if self.output.positions is not None:
if wrap_atoms:
snapshot.positions = self.output.positions[frame]
Expand Down Expand Up @@ -882,7 +882,7 @@ def __getitem__(self, item):
if self._cells is not None:
new_structure.cell = self._cells[item]
if self._indices is not None:
new_structure.indices = self._indices[item]
new_structure.set_array("indices", self._indices[item])
new_structure.positions = self._positions[item]
# This step is necessary for using ase.io.write for trajectories
new_structure.arrays["positions"] = new_structure.positions
Expand Down
2 changes: 1 addition & 1 deletion pyiron_atomistics/atomistics/master/phonopy.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def _restore_magmoms(self, structure):
Returns:
structure (pyiron_atomistics.atomistics.structure.atoms): output structure with magnetic moments
"""
if any(self._master.structure.get_initial_magnetic_moments() != None):
if self._master.structure.has("initial_magmoms"):
magmoms = self._master.structure.get_initial_magnetic_moments()
magmoms = np.tile(
magmoms,
Expand Down
15 changes: 7 additions & 8 deletions pyiron_atomistics/atomistics/structure/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
PeriodicTable,
ChemicalElement,
)
from pyiron_atomistics.atomistics.structure.sparse_list import SparseArrayElement
from ase.atom import Atom as ASEAtom

__author__ = "Sudarsan Surendralal"
Expand All @@ -22,7 +21,7 @@
__date__ = "Aug 1, 2020"


class Atom(ASEAtom, SparseArrayElement):
class Atom(ASEAtom):
"""
Class for representing a single atom derived from the `ASE atom class`_.
Expand Down Expand Up @@ -59,22 +58,19 @@ def __init__(
if element is None:
element = symbol

SparseArrayElement.__init__(self, **qwargs)
# super(SparseArrayElement, self).__init__(**qwargs)
# verify that element is given (as string, ChemicalElement object or nucleus number
if pse is None:
pse = PeriodicTable()

if element is None or element == "X":
if "Z" in qwargs:
el_symbol = pse.atomic_number_to_abbreviation(qwargs["Z"])
self._lists["element"] = pse.element(el_symbol)
qwargs["element"] = pse.element(el_symbol)
else:
if isinstance(element, str):
el_symbol = element
self._lists["element"] = pse.element(el_symbol)
qwargs["element"] = pse.element(el_symbol)
elif isinstance(element, ChemicalElement):
self._lists["element"] = element
qwargs["element"] = element
else:
raise ValueError("Unknown element type")

Expand Down Expand Up @@ -111,6 +107,9 @@ def __init__(
for key, val in qwargs.items():
self.data[key] = val

def __getattr__(self, key):
return self.data[key]

@property
def mass(self):
"""
Expand Down

0 comments on commit 1211fd3

Please sign in to comment.