From cec6637b07f9634b33b19c3d923a09686d89dcf4 Mon Sep 17 00:00:00 2001 From: Shivans Gupta Date: Thu, 18 Jun 2026 19:14:19 +0530 Subject: [PATCH 1/4] Address review feedback in hydrogen bond tests --- .../analysis/test_hydrogenbonds_analysis.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py index 59b090c549..5e8ea4a52a 100644 --- a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py +++ b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py @@ -28,9 +28,7 @@ from numpy.testing import ( assert_allclose, assert_equal, - assert_array_almost_equal, assert_array_equal, - assert_almost_equal, ) import MDAnalysis @@ -108,7 +106,7 @@ def test_count_by_time(self, h): ref_counts = np.array([3, 2, 4, 4, 4, 4, 3, 2, 3, 3]) counts = h.count_by_time() - assert_array_almost_equal(h.times, ref_times) + assert_allclose(h.times, ref_times) assert_array_equal(counts, ref_counts) def test_count_by_type(self, h): @@ -241,7 +239,7 @@ def test_no_bond_info_exception(self, universe): u.add_TopologyAttr("mass", [15.999, 1.008, 1.008] * n_residues) u.add_TopologyAttr("charge", [-1.04, 0.52, 0.52] * n_residues) with pytest.raises(NoDataError, match="no bond information"): - h = HydrogenBondAnalysis(u, **kwargs) + HydrogenBondAnalysis(u, **kwargs) def test_no_bond_donor_sel(self, universe): @@ -258,7 +256,7 @@ def test_no_bond_donor_sel(self, universe): u.add_TopologyAttr("mass", [15.999, 1.008, 1.008] * n_residues) u.add_TopologyAttr("charge", [-1.04, 0.52, 0.52] * n_residues) h = HydrogenBondAnalysis(u, **kwargs) - donors = u.select_atoms(h.guess_donors()) + u.select_atoms(h.guess_donors()) def test_first_hbond(self, hydrogen_bonds): assert len(hydrogen_bonds.results.hbonds) == 2 @@ -273,15 +271,16 @@ def test_first_hbond(self, hydrogen_bonds): assert_equal(donor_index, 0) assert_equal(hydrogen_index, 2) assert_equal(acceptor_index, 3) - assert_almost_equal(da_dst, 2.5) - assert_almost_equal(angle, 180) + assert da_dst == pytest.approx(2.5) + assert angle == pytest.approx(180) + def test_count_by_time(self, hydrogen_bonds): ref_times = np.array([0, 1, 2]) # u.trajectory.dt is 1 ref_counts = np.array([1, 0, 1]) counts = hydrogen_bonds.count_by_time() - assert_array_almost_equal(hydrogen_bonds.times, ref_times) + assert_allclose(hydrogen_bonds.times, ref_times) assert_array_equal(counts, ref_counts) def test_hydrogen_bond_lifetime(self, hydrogen_bonds): @@ -716,7 +715,7 @@ def test_count_by_time(self, h): ref_counts = np.array([2, 4, 4, 2, 3]) counts = h.count_by_time() - assert_array_almost_equal(h.times, ref_times) + assert_allclose(h.times, ref_times) assert_array_equal(counts, ref_counts) def test_count_by_type(self, h): From 2114cf0c9aeffb3e353ba48a357ca8098700cb22 Mon Sep 17 00:00:00 2001 From: Shivans Gupta Date: Fri, 19 Jun 2026 18:47:43 +0530 Subject: [PATCH 2/4] Trigger From d01d0de5e8b95d2d1918e3bac48ece720798f2bc Mon Sep 17 00:00:00 2001 From: Shivans Gupta Date: Tue, 23 Jun 2026 21:10:29 +0530 Subject: [PATCH 3/4] Apply reviewer suggestion for assert_allclose tolerance --- .../MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py index 5e8ea4a52a..0cb38c8d29 100644 --- a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py +++ b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py @@ -106,7 +106,7 @@ def test_count_by_time(self, h): ref_counts = np.array([3, 2, 4, 4, 4, 4, 3, 2, 3, 3]) counts = h.count_by_time() - assert_allclose(h.times, ref_times) + assert_allclose(h.times, ref_times,atol=1e-6,rtol=0) assert_array_equal(counts, ref_counts) def test_count_by_type(self, h): From 2000ebb335aab0defcee3da60cd43235e77f4566 Mon Sep 17 00:00:00 2001 From: Shivans Gupta Date: Tue, 23 Jun 2026 22:43:52 +0530 Subject: [PATCH 4/4] Apply black formatting --- .../MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py index 0cb38c8d29..aedab96015 100644 --- a/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py +++ b/testsuite/MDAnalysisTests/analysis/test_hydrogenbonds_analysis.py @@ -106,7 +106,7 @@ def test_count_by_time(self, h): ref_counts = np.array([3, 2, 4, 4, 4, 4, 3, 2, 3, 3]) counts = h.count_by_time() - assert_allclose(h.times, ref_times,atol=1e-6,rtol=0) + assert_allclose(h.times, ref_times, atol=1e-6, rtol=0) assert_array_equal(counts, ref_counts) def test_count_by_type(self, h): @@ -274,7 +274,6 @@ def test_first_hbond(self, hydrogen_bonds): assert da_dst == pytest.approx(2.5) assert angle == pytest.approx(180) - def test_count_by_time(self, hydrogen_bonds): ref_times = np.array([0, 1, 2]) # u.trajectory.dt is 1 ref_counts = np.array([1, 0, 1])