From 040836f35acf60d8f38eedbffcc07e99b4b53f73 Mon Sep 17 00:00:00 2001 From: samwaseda Date: Mon, 22 Apr 2024 07:28:34 +0000 Subject: [PATCH] add tests --- pyiron_atomistics/sphinx/base.py | 2 +- tests/sphinx/test_base.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyiron_atomistics/sphinx/base.py b/pyiron_atomistics/sphinx/base.py index 4629b9dca..b6ea9b11d 100644 --- a/pyiron_atomistics/sphinx/base.py +++ b/pyiron_atomistics/sphinx/base.py @@ -183,7 +183,7 @@ def id_pyi_to_spx(self): def id_spx_to_pyi(self): if self.structure is None: raise ValueError("Structure not set") - return np.argsort(id_pyi_to_spx) + return np.argsort(self.id_pyi_to_spx) @property def plane_wave_cutoff(self): diff --git a/tests/sphinx/test_base.py b/tests/sphinx/test_base.py index b51ed3579..68cc0521c 100644 --- a/tests/sphinx/test_base.py +++ b/tests/sphinx/test_base.py @@ -109,8 +109,15 @@ def tearDownClass(cls): ) def test_id_pyi_to_spx(self): - self.assertEqual(len(self.sphinx.id_pyi_to_spx), len(self.sphinx.structure)) - self.assertEqual(len(self.sphinx.id_spx_to_pyi), len(self.sphinx.structure)) + spx = self.project.create_job("Sphinx", "check_order") + elements = ["Fe", "C", "Ni", "Fe"] + x = np.random.random((len(elements), 3)) + c = np.eye(3) + spx.structure = Atoms(elements=elements, positions=x, cell=c) + self.assertTrue(np.all(spx.id_spx_to_pyi == [1, 0, 3, 2])) + self.assertTrue( + np.all(spx.id_pyi_to_spx[spx.id_spx_to_pyi] == np.arange(len(elements))) + ) def test_potential(self): self.assertEqual(['Fe_GGA'], self.sphinx.list_potentials())