Skip to content

Commit 91c7fb0

Browse files
Remove typecheck from magmom test
Remove the typecheck for MAGMOM being a dict
1 parent 2cfdc3c commit 91c7fb0

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

pymatgen/io/vasp/sets.py

-3
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,6 @@ def incar(self) -> Incar:
502502

503503
for k, v in settings.items():
504504
if k == "MAGMOM":
505-
if isinstance(v, list):
506-
incar[k] = v
507-
continue
508505
mag = []
509506
for site in structure:
510507
if hasattr(site, "magmom"):

pymatgen/io/vasp/tests/test_sets.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,13 @@ def test_get_incar(self):
256256
incar = MITRelaxSet(struct).incar
257257
self.assertEqual(incar["LDAUU"], [4.0, 0])
258258

259+
# This seems counterintuitive at first, but even if the prior INCAR has a MAGMOM flag,
260+
# because the structure has no site properties, the default MAGMOM is assigned from the
261+
# config dictionary.
262+
struct = Structure(lattice, ["Fe", "F"], coords)
263+
incar = MPRelaxSet(struct, prev_incar=os.path.join(self.TEST_FILES_DIR, "INCAR")).incar
264+
self.assertEqual(incar["MAGMOM"], [5, 0.6])
265+
259266
# Make sure this works with species.
260267
struct = Structure(lattice, ["Fe2+", "O2-"], coords)
261268
incar = MPRelaxSet(struct).incar
@@ -272,10 +279,6 @@ def test_get_incar(self):
272279
incar = MPRelaxSet(struct).incar
273280
self.assertEqual(incar["MAGMOM"], [5, 4.1])
274281

275-
struct = Structure(lattice, [Species("Fe", 2, {"spin": 4.1}), "Mn"], coords)
276-
incar = MPRelaxSet(struct, user_incar_settings={"MAGMOM": [1.0, 1.0]}).incar
277-
self.assertEqual(incar["MAGMOM"], [1.0, 1.0])
278-
279282
struct = Structure(lattice, ["Mn3+", "Mn4+"], coords)
280283
incar = MITRelaxSet(struct).incar
281284
self.assertEqual(incar["MAGMOM"], [4, 3])
@@ -525,16 +528,6 @@ def test_valid_magmom_struct(self):
525528
)
526529
vis.incar.items()
527530

528-
# Test the behavior of passing in the wrong type of MAGMOM to user_incar_settings
529-
struct = self.structure.copy()
530-
with pytest.raises(TypeError, match=r"MAGMOM must be supplied"):
531-
vis = MPRelaxSet(
532-
struct,
533-
user_incar_settings={"MAGMOM": [5.0, 5.0]},
534-
user_potcar_settings={"Fe": "Fe"},
535-
)
536-
vis.incar.items()
537-
538531

539532
class MPStaticSetTest(PymatgenTest):
540533
def setUp(self):

0 commit comments

Comments
 (0)