Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added random seed #3

Merged
merged 7 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions tests/data/output/H_center.csv

Large diffs are not rendered by default.

508 changes: 254 additions & 254 deletions tests/data/output/W_center.csv

Large diffs are not rendered by default.

310 changes: 155 additions & 155 deletions tests/data/output/center_slice2_pairwise.csv

Large diffs are not rendered by default.

364 changes: 182 additions & 182 deletions tests/data/output/center_slice3_pairwise.csv

Large diffs are not rendered by default.

362 changes: 181 additions & 181 deletions tests/data/output/center_slice4_pairwise.csv

Large diffs are not rendered by default.

27 changes: 12 additions & 15 deletions tests/test_paste.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
output_dir = test_dir / "data/output"


def assert_checksum_equals(generated_file, oracle):
def assert_checksum_equals(temp_dir, filename):
generated_file = temp_dir / filename
oracle = output_dir / filename

assert (
hashlib.md5(
"".join(open(generated_file, "r").readlines()).encode("utf8")
Expand All @@ -32,16 +35,12 @@ def test_pairwise_alignment(slices):
b_distribution=slices[1].obsm["weights"],
G_init=None,
)
outcome_df = pd.DataFrame(
pd.DataFrame(
outcome, index=slices[0].obs.index, columns=slices[1].obs.index
)
outcome_df.to_csv(temp_dir / "slices_1_2_pairwise.csv")
assert_checksum_equals(
temp_dir / "slices_1_2_pairwise.csv", output_dir / "slices_1_2_pairwise.csv"
)
).to_csv(temp_dir / "slices_1_2_pairwise.csv")
assert_checksum_equals(temp_dir, "slices_1_2_pairwise.csv")


# TODO: possibly some randomness to the code that needs to be dealt with
def test_center_alignment(slices):
temp_dir = Path(tempfile.mkdtemp())

Expand All @@ -52,6 +51,7 @@ def test_center_alignment(slices):
lmbda=n_slices * [1.0 / n_slices],
alpha=0.1,
n_components=15,
random_seed=0,
threshold=0.001,
dissimilarity="kl",
distributions=[slices[i].obsm["weights"] for i in range(len(slices))],
Expand All @@ -63,15 +63,12 @@ def test_center_alignment(slices):
temp_dir / "H_center.csv"
)

# assert_checksum_equals(temp_dir / "W_center.csv", output_dir / "W_center.csv")
#
# assert_checksum_equals(temp_dir / "H_center.csv", output_dir / "H_center.csv")
# TODO: The following computations seem to be architecture dependent (need to look into as for how)
# assert_checksum_equals(temp_dir, "W_center.csv")
# assert_checksum_equals(temp_dir, "H_center.csv")

for i, pi in enumerate(pairwise_info):
pd.DataFrame(
pi, index=center_slice.obs.index, columns=slices[i].obs.index
).to_csv(temp_dir / f"center_slice{i+1}_pairwise.csv")
# assert_checksum_equals(
# temp_dir / f"center_slice{i}_pairwise.csv",
# output_dir / f"center_slice{i}_pairwise.csv",
# )
assert_checksum_equals(temp_dir, f"center_slice{i+1}_pairwise.csv")