Skip to content

Commit

Permalink
Merge pull request #100 from pyiron/get_chemical_symbols
Browse files Browse the repository at this point in the history
Get chemical symbols
  • Loading branch information
samwaseda authored Mar 3, 2021
2 parents d4f571f + 988d929 commit d7581cb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pyiron_atomistics/atomistics/structure/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,11 @@ def __repr__(self):
to_return = super().__repr__()
return to_return.replace('given positions', 'each atom')

@property
def chemical_symbols(self):
"""Returns chemical symbols of the neighboring atoms."""
return self._ref_structure.get_chemical_symbols()[self.indices]

@property
def shells(self):
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/atomistics/structure/test_neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import unittest
import numpy as np
from pyiron_atomistics.atomistics.structure.atoms import Atoms, CrystalStructure
from pyiron_atomistics.atomistics.structure.factory import StructureFactory
import warnings


Expand Down Expand Up @@ -339,6 +340,13 @@ def test_norm_order(self):
with self.assertRaises(ValueError):
neigh.norm_order = 3

def test_chemical_symbols(self):
basis = StructureFactory().ase_bulk('Fe', cubic=True)
basis[0] = 'Ni'
neigh = basis.get_neighbors(num_neighbors=1)
self.assertEqual(neigh.chemical_symbols[0,0], 'Fe')
self.assertEqual(neigh.chemical_symbols[1,0], 'Ni')


if __name__ == "__main__":
unittest.main()

0 comments on commit d7581cb

Please sign in to comment.