From ac51c37dfc6d473a295283cf02a928bb39febcb4 Mon Sep 17 00:00:00 2001 From: IAyaanHere Date: Wed, 14 Jan 2026 13:44:44 +0530 Subject: [PATCH 1/3] Test: Check for missing coordinates in LAMMPS DumpReader --- .../MDAnalysisTests/coordinates/test_lammps.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/testsuite/MDAnalysisTests/coordinates/test_lammps.py b/testsuite/MDAnalysisTests/coordinates/test_lammps.py index 3b203f5bae2..072edaf744a 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_lammps.py +++ b/testsuite/MDAnalysisTests/coordinates/test_lammps.py @@ -990,3 +990,21 @@ def test_box(self, u_dump, u_data, reference_box): ) assert_allclose(u_data.dimensions, reference_box, rtol=1e-5, atol=0) +def test_missing_coords_error(tmpdir): + # creating a dummy lammps file without x, y, z columns + f = tmpdir.join("bad_lammps.dump") + f.write("""ITEM: TIMESTEP + 0 + ITEM: NUMBER OF ATOMS + 1 + ITEM: BOX BOUNDS pp pp pp + 0.0 10.0 + 0.0 10.0 + 0.0 10.0 + ITEM: ATOMS id type + 1 1 + """) + + # reader should raise ValueError because coordinates are missing + with pytest.raises(ValueError, match="No coordinate information"): + mda.coordinates.LAMMPS.DumpReader(str(f)) \ No newline at end of file From 71bd26ad2b7c95ad470fc0702541093e3c0de0f8 Mon Sep 17 00:00:00 2001 From: IAyaanHere Date: Mon, 19 Jan 2026 21:38:33 +0530 Subject: [PATCH 2/3] Style: Fix formatting with Black v24 --- .../MDAnalysisTests/coordinates/test_lammps.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_lammps.py b/testsuite/MDAnalysisTests/coordinates/test_lammps.py index 072edaf744a..a942c151a2f 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_lammps.py +++ b/testsuite/MDAnalysisTests/coordinates/test_lammps.py @@ -990,10 +990,13 @@ def test_box(self, u_dump, u_data, reference_box): ) assert_allclose(u_data.dimensions, reference_box, rtol=1e-5, atol=0) + + def test_missing_coords_error(tmpdir): - # creating a dummy lammps file without x, y, z columns - f = tmpdir.join("bad_lammps.dump") - f.write("""ITEM: TIMESTEP + # creating a dummy lammps file without x, y, z columns + f = tmpdir.join("bad_lammps.dump") + f.write( + """ITEM: TIMESTEP 0 ITEM: NUMBER OF ATOMS 1 @@ -1003,8 +1006,9 @@ def test_missing_coords_error(tmpdir): 0.0 10.0 ITEM: ATOMS id type 1 1 - """) + """ + ) - # reader should raise ValueError because coordinates are missing - with pytest.raises(ValueError, match="No coordinate information"): - mda.coordinates.LAMMPS.DumpReader(str(f)) \ No newline at end of file + # reader should raise ValueError because coordinates are missing + with pytest.raises(ValueError, match="No coordinate information"): + mda.coordinates.LAMMPS.DumpReader(str(f)) From e1348ca386748742a31ff080b1ab889f4f99c415 Mon Sep 17 00:00:00 2001 From: IAyaanHere Date: Mon, 19 Jan 2026 23:01:37 +0530 Subject: [PATCH 3/3] Test: Update LAMMPS ValueError check to match specific f-string pattern --- .../coordinates/test_lammps.py | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_lammps.py b/testsuite/MDAnalysisTests/coordinates/test_lammps.py index a942c151a2f..3f5d567d5ee 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_lammps.py +++ b/testsuite/MDAnalysisTests/coordinates/test_lammps.py @@ -992,23 +992,27 @@ def test_box(self, u_dump, u_data, reference_box): assert_allclose(u_data.dimensions, reference_box, rtol=1e-5, atol=0) -def test_missing_coords_error(tmpdir): - # creating a dummy lammps file without x, y, z columns +def test_missing_requested_coordinate_convention(tmpdir): f = tmpdir.join("bad_lammps.dump") f.write( - """ITEM: TIMESTEP - 0 - ITEM: NUMBER OF ATOMS - 1 - ITEM: BOX BOUNDS pp pp pp - 0.0 10.0 - 0.0 10.0 - 0.0 10.0 - ITEM: ATOMS id type - 1 1 - """ + "ITEM: TIMESTEP\n" + "0\n" + "ITEM: NUMBER OF ATOMS\n" + "1\n" + "ITEM: BOX BOUNDS pp pp pp\n" + "0.0 10.0\n" + "0.0 10.0\n" + "0.0 10.0\n" + "ITEM: ATOMS id type xs ys zs\n" + "1 1 0.5 0.5 0.5\n" ) - # reader should raise ValueError because coordinates are missing - with pytest.raises(ValueError, match="No coordinate information"): - mda.coordinates.LAMMPS.DumpReader(str(f)) + with pytest.raises( + ValueError, + match=r"No coordinates following convention unwrapped found in timestep", + ): + mda.Universe( + str(f), + format="LAMMPSDUMP", + lammps_coordinate_convention="unwrapped", + )