Skip to content

Commit

Permalink
#11 wip allowing for comparing multiple matrices as in SENT
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkamm committed Nov 17, 2024
1 parent 389fe02 commit 472d48f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions examples/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 472d48f

Please sign in to comment.