From 472d48f646558441a6c9819b66f4d3bdadb69736 Mon Sep 17 00:00:00 2001 From: joshkamm Date: Sat, 16 Nov 2024 20:27:07 -0500 Subject: [PATCH] #11 wip allowing for comparing multiple matrices as in SENT --- examples/test_output.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/test_output.py b/examples/test_output.py index 4cca058..703d510 100644 --- a/examples/test_output.py +++ b/examples/test_output.py @@ -10,7 +10,21 @@ def test_output(filename): example_output_dir = script_dir.parent / "build" / "examples" / "geom_1" assert example_output_dir.exists() - output = np.loadtxt(example_output_dir / filename, skiprows=1) - reference_output = np.loadtxt(example_output_dir / f"{filename}_ref", skiprows=1) - assert output.shape == reference_output.shape - assert output == pytest.approx(reference_output, rel=1e-6, abs=1e-6) + + with open(example_output_dir / filename) as output, open( + example_output_dir / f"{filename}_ref" + ) as reference_output: + output = list(output) + for i, line in enumerate(reference_output): + if line.endswith(":"): + continue + assert np.fromstring(output[i], sep=" ") == pytest.approx( + np.fromstring(line, sep=" "), rel=1e-6, abs=1e-6 + ) + # matrix_boundaries = [line for line in file if line.endswith(':')] + [-1] + # for idx in range(len(matrix_boundaries)-1): + + # output = np.loadtxt(example_output_dir / filename, skiprows=matrix_boundaries[idx]) + # reference_output = np.loadtxt(example_output_dir / f"{filename}_ref", skiprows=matrix_boundaries[idx]+1, max_rows=matrix_boundaries[idx+1]-matrix_boundaries[idx]) + # assert output.shape == reference_output.shape + # assert output == pytest.approx(reference_output, rel=1e-6, abs=1e-6)