Skip to content

Commit f0b13a6

Browse files
committed
fix unit test
1 parent 0ba29c3 commit f0b13a6

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

dpdata/plugins/lammps.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def from_system(
109109
return data
110110

111111
def to_system(
112-
self, data, file_name: FileType, frame_idx=0, output_spins=False, **kwargs
112+
self, data, file_name: FileType, frame_idx=0, **kwargs
113113
):
114114
"""Dump the system in lammps data format.
115115
@@ -121,13 +121,11 @@ def to_system(
121121
The output file name
122122
frame_idx : int
123123
The index of the frame to dump
124-
output_spins : bool, optional
125-
Whether to output spin information columns. Default is False.
126-
When True, outputs additional columns for spin direction and magnitude.
127124
**kwargs : dict
128125
other parameters
129126
"""
130127
assert frame_idx < len(data["coords"])
128+
output_spins = bool(kwargs.pop("output_spins", False))
131129
w_str = dpdata.lammps.lmp.from_system_data(
132130
data, frame_idx, output_spins=output_spins
133131
)

tests/test_lammps_spin.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def setUp(self):
4848
def tearDown(self):
4949
pass # if os.path.isfile(self.lmp_coord_name):os.remove(self.lmp_coord_name)
5050

51-
def test_dump_input(self):
52-
self.tmp_system.to("lammps/lmp", self.lmp_coord_name)
51+
def test_dump_input(self, output_spins=False):
52+
self.tmp_system.to("lammps/lmp", self.lmp_coord_name, output_spins=output_spins)
5353
self.assertTrue(os.path.isfile(self.lmp_coord_name))
5454
with open(self.lmp_coord_name) as f:
5555
c = f.read()
@@ -58,9 +58,9 @@ def test_dump_input(self):
5858
2 2 1.2621856000 0.7018028000 0.5513885000 0.0000000000 0.8000000000 0.6000000000 5.0000000000"""
5959
self.assertTrue(coord_ref in c)
6060

61-
def test_dump_input_zero_spin(self):
61+
def test_dump_input_zero_spin(self, output_spins=True):
6262
self.tmp_system.data["spins"] = [[[0, 0, 0], [0, 0, 0]]]
63-
self.tmp_system.to("lammps/lmp", self.lmp_coord_name)
63+
self.tmp_system.to("lammps/lmp", self.lmp_coord_name, output_spins=output_spins)
6464
self.assertTrue(os.path.isfile(self.lmp_coord_name))
6565
with open(self.lmp_coord_name) as f:
6666
c = f.read()

0 commit comments

Comments
 (0)