forked from XiaoLabJHU/GRN_Inference
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for mi2_matrix_build function
Showing
3 changed files
with
206 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,36 @@ | ||
import sys | ||
import os | ||
import pytest | ||
import numpy as np | ||
import scipy.io | ||
|
||
# Ensure the root directory is in the PYTHONPATH | ||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../CODE'))) | ||
from Building_MI_matrices import import_and_clean_input_file, get_dict_name, mi2_matrix_build # noqa: E402 | ||
|
||
|
||
def test_mi2_matrix_build(): | ||
# Define the input parameters | ||
input_file_name = 'tests/InSilicoSize50-Ecoli1_SS_all.tsv' | ||
bins_or_neighbors = 13 | ||
mi_est = 'Shannon' | ||
|
||
# Load the data | ||
in1_data_array = import_and_clean_input_file(input_file_name) | ||
|
||
# Load the expected result | ||
dict_name = get_dict_name("MI2", bins_or_neighbors, mi_est) | ||
expected_result = scipy.io.loadmat('tests/test_InSilicoSize50-Ecoli1_SS_all_MI2_FB13_Shan.mat') | ||
expected_result = expected_result[dict_name] | ||
|
||
# Compute the result | ||
mi2_matrix_build(input_file_name, in1_data_array, bins_or_neighbors, mi_est, self_info=False) | ||
result = scipy.io.loadmat('tests/InSilicoSize50-Ecoli1_SS_all_MI2_FB13_Shan.mat') | ||
result = result[dict_name] | ||
|
||
# Check the result | ||
assert np.allclose(result, expected_result, atol=1e-10) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main() |