Skip to content

Commit

Permalink
added random seed (#3)
Browse files Browse the repository at this point in the history
 added random seed and a todo comment
  • Loading branch information
anushka255 authored Aug 7, 2024
1 parent 35779d9 commit 4f97346
Show file tree
Hide file tree
Showing 6 changed files with 799 additions and 802 deletions.
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")

0 comments on commit 4f97346

Please sign in to comment.