@@ -127,15 +127,15 @@ def test_correlation_matrix_shared_comp_minimal():
127
127
@pytest .mark .parametrize ("ks" , [[10 , 20 ], [5 , 9 ]])
128
128
@pytest .mark .parametrize ("genes" , ["all" , ["PPBP" , "SPARC" , "S100A8" ], ["PPBP" , "S100A9" , "LYZ" , "BLVRB" ]])
129
129
def test_knns_shared_comp (small_adata , ks , genes ):
130
- """
131
- #TODO: test for same set of neighbors per row instead of asserting that the order is also the same. (Lead to
132
- failures when there were some changes in the knn function.)
133
- """
130
+ """ """
134
131
df = knns (small_adata , genes = genes , ks = ks )
135
132
# to create the reference dataframe
136
133
# df.to_csv(f"tests/evaluation/test_data/knn_df_{ks}_{genes}.csv")
137
134
ref_df = pd .read_csv (f"tests/evaluation/test_data/knn_df_{ ks } _{ genes } .csv" , index_col = 0 )
138
- assert df .equals (ref_df )
135
+ # It's sufficient to check that the same values per row are present, order can differ based on platform and algorithm
136
+ df_sorted = pd .DataFrame (np .sort (df .values , axis = 1 ), index = df .index , columns = df .columns )
137
+ ref_df_sorted = pd .DataFrame (np .sort (ref_df .values , axis = 1 ), index = ref_df .index , columns = ref_df .columns )
138
+ assert df_sorted .equals (ref_df_sorted )
139
139
140
140
141
141
############################
@@ -246,7 +246,7 @@ def test_max_marker_correlations(small_adata, marker_list, small_probeset):
246
246
# mmc.to_csv("tests/evaluation/test_data/max_marker_correlation.csv")
247
247
mmc_ref = pd .read_csv ("tests/evaluation/test_data/max_marker_correlation.csv" , index_col = 0 )
248
248
mmc_ref .columns .name = "index"
249
- assert pd .testing .assert_frame_equal (mmc , mmc_ref ) is None
249
+ pd .testing .assert_frame_equal (mmc , mmc_ref , check_exact = False , atol = 1e-5 )
250
250
251
251
252
252
########################
0 commit comments