Skip to content

Commit b439dac

Browse files
author
Shyue Ping Ong
committed
Add __getattr__ to DummySpecies. Fixes #3167.
1 parent f4e6057 commit b439dac

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

pymatgen/core/periodic_table.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,9 @@ def __init__(
14141414
else:
14151415
self._spin = spin
14161416

1417+
def __getattr__(self, attr):
1418+
raise AttributeError
1419+
14171420
def __lt__(self, other):
14181421
"""
14191422
Sets a default sort order for atomic species by Pauling electronegativity,

pymatgen/core/tests/test_periodic_table.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,10 @@ def test_init(self):
515515
self.specie2 = DummySpecies("X", 2, spin=3)
516516
assert self.specie2.spin == 3
517517

518+
def test_attr(self):
519+
with pytest.raises(AttributeError):
520+
_ = self.specie2.ionic_radius
521+
518522
def test_eq(self):
519523
assert DummySpecies("Xg") != DummySpecies("Xh")
520524
assert DummySpecies("Xg") != DummySpecies("Xg", 3)

0 commit comments

Comments
 (0)