Skip to content

Commit d6d8525

Browse files
committed
chore: rename variables to more explicit one, add test case descriptions.
1 parent 9751d1e commit d6d8525

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

tests/test_atom.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,24 +192,25 @@ def test_xyz_cartn(self):
192192

193193
# ----------------------------------------------------------------------------
194194
@pytest.mark.parametrize(
195-
"uiso, vl",
196-
[
195+
"uiso, lattice_vector",
196+
[ # C1: isotropic displacement, msd is direction-independent in lattice coordinates.
197+
# Expected the msd_latt equals Uisoequiv for any direction.
197198
(0.0123, [1, 2, 3]),
198199
],
199200
)
200-
def test_msd_latt_isotropic(uiso, vl):
201+
def test_msd_latt_isotropic(uiso, lattice_vector):
201202
"""Check Atom.msd_latt()."""
202203
hexagonal = Lattice(1, 1, 1, 90, 90, 120)
203204
atom = Atom("C", [0, 0, 0], lattice=hexagonal, Uisoequiv=uiso)
204-
205-
actual = atom.msd_latt(vl)
205+
actual = atom.msd_latt(lattice_vector)
206206
expected = pytest.approx(uiso, rel=0, abs=1e-15)
207207
assert actual == expected
208208

209209

210210
@pytest.mark.parametrize(
211-
"U, vc",
212-
[
211+
"U, cartesian_vector",
212+
[ # C2: anisotropic displacement with same physical direction expressed in lattice vs cartesian coords
213+
# Expected msd_latt(fractional(cartesian_vector)) == msd_cart(cartesian_vector)
213214
(
214215
numpy.array(
215216
[
@@ -234,37 +235,37 @@ def test_msd_latt_isotropic(uiso, vl):
234235
),
235236
],
236237
)
237-
def test_msd_latt_anisotropic(U, vc):
238+
def test_msd_latt_anisotropic(U, cartesian_vector):
238239
"""Check Atom.msd_latt() anisotropic coordinate-invariance."""
239240
hexagonal = Lattice(1, 1, 1, 90, 90, 120)
240241
atom = Atom("C", [0, 0, 0], lattice=hexagonal, U=U)
241-
242-
vl = hexagonal.fractional(vc)
243-
244-
actual = atom.msd_latt(vl)
245-
expected = pytest.approx(atom.msd_cart(vc), rel=1e-13, abs=1e-13)
242+
lattice_vector = hexagonal.fractional(cartesian_vector)
243+
actual = atom.msd_latt(lattice_vector)
244+
expected = pytest.approx(atom.msd_cart(cartesian_vector), rel=1e-13, abs=1e-13)
246245
assert actual == expected
247246

248247

249248
@pytest.mark.parametrize(
250-
"uiso, vc",
251-
[
249+
"uiso, cartesian_vector",
250+
[ # C1: isotropic displacement with msd is direction-independent in cartesian coordinates
251+
# Expected msd_cart equals Uisoequiv for any direction
252252
(0.0456, [0, 5, -2]),
253253
],
254254
)
255-
def test_msd_cart_isotropic(uiso, vc):
255+
def test_msd_cart_isotropic(uiso, cartesian_vector):
256256
"""Check Atom.msd_cart()."""
257257
hexagonal = Lattice(1, 1, 1, 90, 90, 120)
258258
atom = Atom("C", [0, 0, 0], lattice=hexagonal, Uisoequiv=uiso)
259259

260-
actual = atom.msd_cart(vc)
260+
actual = atom.msd_cart(cartesian_vector)
261261
expected = pytest.approx(uiso, rel=0, abs=1e-15)
262262
assert actual == expected
263263

264264

265265
@pytest.mark.parametrize(
266-
"U, vc, scale",
267-
[
266+
"U, cartesian_vector, scale",
267+
[ # C2: anisotropic displacement with msd_cart normalizes direction vector internally
268+
# Expected msd_cart(cartesian_vector) == msd_cart(scale * cartesian_vector)
268269
(
269270
numpy.array(
270271
[
@@ -291,13 +292,12 @@ def test_msd_cart_isotropic(uiso, vc):
291292
),
292293
],
293294
)
294-
def test_msd_cart_anisotropic(U, vc, scale):
295+
def test_msd_cart_anisotropic(U, cartesian_vector, scale):
295296
"""Check Atom.msd_cart() anisotropic normalization invariance."""
296297
hexagonal = Lattice(1, 1, 1, 90, 90, 120)
297298
atom = Atom("C", [0, 0, 0], lattice=hexagonal, U=U)
298-
299-
actual = atom.msd_cart(vc)
300-
expected = pytest.approx(atom.msd_cart(scale * vc), rel=1e-13, abs=1e-13)
299+
actual = atom.msd_cart(cartesian_vector)
300+
expected = pytest.approx(atom.msd_cart(scale * cartesian_vector), rel=1e-13, abs=1e-13)
301301
assert actual == expected
302302

303303

0 commit comments

Comments
 (0)