Skip to content

Commit

Permalink
#11 flesh out pytest for geom_1 example
Browse files Browse the repository at this point in the history
add numpy to pixi pytest environment
  • Loading branch information
joshkamm committed Nov 7, 2024
1 parent cf0f67c commit c2cf043
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 35 deletions.
18 changes: 17 additions & 1 deletion examples/geom_1/test_output.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
import os
from pathlib import Path
import numpy as np
import pytest


def test_output():
assert True
# convert from script location to corresponding location in build directory
script_dir = Path(os.path.abspath(__file__)).parent
script_dir_parts = list(script_dir.parts)
script_dir_parts.insert(-2, "build")
script_build_dir = Path(*script_dir_parts)

assert script_build_dir.exists()
A = np.loadtxt(script_build_dir / "A", skiprows=1)
A_ref = np.loadtxt(script_build_dir / "A_ref", skiprows=1)
assert A.shape == A_ref.shape
assert A == pytest.approx(A_ref)
222 changes: 190 additions & 32 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ depends-on = ["configure-athena", "build", "pytest"]
[tasks.test]
description = "Test SlaterGPU executable on a small molecular system"
cwd = "build/examples/geom_1"
cmd = "/export/SLURM/default/bin/srun -p zimA10 -N1 -n1 -c2 --gpus=1 ../sgpu.exe"
cmd = "/export/SLURM/default/bin/srun -p zim2080 -N1 -n1 -c2 --gpus=1 ../sgpu.exe"

[feature.pytest.tasks.pytest]
description = "Invoke pytest to sanity check output from test task"
depends-on = ["test"]
cwd = "build/examples/geom_1"
cwd = "examples/geom_1"
cmd = "pytest"

[feature.athena]
Expand Down Expand Up @@ -168,6 +168,7 @@ openmpi = "=3.1"

[feature.pytest.dependencies]
pytest = ">=8.3.3,<9"
numpy = ">=2.1.3,<3"

[environments]
athena = {features = ["athena"]}
Expand Down

0 comments on commit c2cf043

Please sign in to comment.