-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added test case for command line code (#20)
- Loading branch information
1 parent
475136c
commit c76ceac
Showing
7 changed files
with
1,117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import pandas as pd | ||
from pandas.testing import assert_frame_equal | ||
from pathlib import Path | ||
import subprocess | ||
|
||
test_dir = Path(__file__).parent | ||
input_dir = test_dir / "data/input" | ||
output_dir = test_dir / "data/output" | ||
|
||
|
||
def test_cmd_line_center(tmp_path): | ||
print(f"Running command in {tmp_path}") | ||
result = subprocess.run( | ||
[ | ||
"python", | ||
f"{test_dir.parent}/src/paste/paste-cmd-line.py", | ||
"-m", | ||
"center", | ||
"--seed", | ||
"0", | ||
"-f", | ||
f"{input_dir}/slice1.csv", | ||
f"{input_dir}/slice1_coor.csv", | ||
f"{input_dir}/slice2.csv", | ||
f"{input_dir}/slice2_coor.csv", | ||
f"{input_dir}/slice3.csv", | ||
f"{input_dir}/slice3_coor.csv", | ||
"-d", | ||
f"{tmp_path}", | ||
] | ||
) | ||
assert result.returncode == 0 | ||
assert_frame_equal( | ||
pd.read_csv(tmp_path / "paste_output/W_center"), | ||
pd.read_csv(output_dir / "W_center"), | ||
check_names=False, | ||
rtol=1e-05, | ||
atol=1e-08, | ||
) | ||
assert_frame_equal( | ||
pd.read_csv(tmp_path / "paste_output/H_center"), | ||
pd.read_csv(output_dir / "H_center"), | ||
rtol=1e-05, | ||
atol=1e-08, | ||
) | ||
|
||
for i, pi in enumerate(range(3)): | ||
assert_frame_equal( | ||
pd.read_csv( | ||
tmp_path / f"paste_output/slice_center_slice{i + 1}_pairwise.csv" | ||
), | ||
pd.read_csv(output_dir / f"slice_center_slice{i + 1}_pairwise.csv"), | ||
) | ||
|
||
|
||
def test_cmd_line_pairwise(tmp_path): | ||
print(f"Running command in {tmp_path}") | ||
result = subprocess.run( | ||
[ | ||
"python", | ||
f"{test_dir.parent}/src/paste/paste-cmd-line.py", | ||
"-m", | ||
"pairwise", | ||
"-f", | ||
f"{input_dir}/slice1.csv", | ||
f"{input_dir}/slice1_coor.csv", | ||
f"{input_dir}/slice2.csv", | ||
f"{input_dir}/slice2_coor.csv", | ||
f"{input_dir}/slice3.csv", | ||
f"{input_dir}/slice3_coor.csv", | ||
"-d", | ||
f"{tmp_path}", | ||
] | ||
) | ||
assert result.returncode == 0 | ||
assert_frame_equal( | ||
pd.read_csv(tmp_path / f"paste_output/slice1_slice2_pairwise.csv"), | ||
pd.read_csv(output_dir / "slices_1_2_pairwise.csv"), | ||
) |