Skip to content

Commit

Permalink
Merge branch 'lmp-spin' of https://github.com/pxlxingliang/dpdata int…
Browse files Browse the repository at this point in the history
…o lmp-spin
  • Loading branch information
root committed Oct 23, 2024
2 parents 78bab7e + 1c758bd commit 4c2656c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/test_lammps_spin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import numpy as np
from context import dpdata

from dpdata.lammps.dump import get_spin

TRAJ_NO_ID = """ITEM: TIMESTEP
Expand Down Expand Up @@ -127,7 +128,7 @@ def test_read_dump_spin(self):

if os.path.isdir("lammps/dump"):
shutil.rmtree("lammps/dump")

def test_read_dump_partial_spin(self):
# test if dpdata can read the spins when the spin data is not complete
with self.assertWarns(UserWarning) as cm:
Expand All @@ -138,12 +139,15 @@ def test_read_dump_partial_spin(self):
input_file="lammps/in.lmp",
)
self.assertTrue("spins" not in tmp_system.data)

self.assertIn("Warning: spin info is not found in frame", str(cm.warning))

def test_get_spin_failed(self):
with self.assertWarns(UserWarning) as cm:
spin = get_spin(TRAJ_NO_ID.split("\n"),["c_spin[1]", "c_spin[2]", "c_spin[3]", "c_spin[4]"])
spin = get_spin(
TRAJ_NO_ID.split("\n"),
["c_spin[1]", "c_spin[2]", "c_spin[3]", "c_spin[4]"],
)
self.assertTrue(spin is None)
self.assertIn("Error processing spin data:", str(cm.warning))

self.assertIn("Error processing spin data:", str(cm.warning))

0 comments on commit 4c2656c

Please sign in to comment.