-
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.
* rename alignment_score to score * make function private, add wrapper * cleanup * type ignore * update tests * add test correct result * update docs
- Loading branch information
Showing
10 changed files
with
177 additions
and
43 deletions.
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
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
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
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
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
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
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
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
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
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,64 @@ | ||
import unittest | ||
|
||
import pandas as pd | ||
|
||
from multilayer_alignment.consensus import _get_consensus_labels_df | ||
|
||
|
||
class TestGetConsensusLabels(unittest.TestCase): | ||
""" | ||
Test functionality of consensus.get_consensus_labels_df() | ||
------------ | ||
Example | ||
------------ | ||
>>> python3 -m unittest -v tests.test_get_consensus_labels_df | ||
""" | ||
|
||
def test_on_empty(self): | ||
""" | ||
_get_consensus_labels_df returns a pd.DataFrame | ||
""" | ||
_a = dict() | ||
_res0 = _get_consensus_labels_df(_a) | ||
self.assertIsInstance( | ||
_res0, | ||
pd.DataFrame, | ||
f"""_get_consensus_labels_df should return a pd.DataFrame, | ||
but returned {type(_res0)}""", | ||
) | ||
self.assertTrue( | ||
_res0.empty, | ||
f"""_get_consensus_labels_df called on empty dictionary should return | ||
an empty pd.DataFrame, but returned {_res0}""", | ||
) | ||
|
||
def test_on_simple_sets(self): | ||
""" | ||
_get_consensus_labels_df returns a pd.DataFrame | ||
""" | ||
_a = {"A0_B1_C0": {0, 1}, "A1_B0_C1": {2}, "A1_B1_C0": {3}} | ||
_res0 = _get_consensus_labels_df(_a) | ||
self.assertIsInstance( | ||
_res0, | ||
pd.DataFrame, | ||
f"""_get_consensus_labels_df should return a pd.DataFrame, | ||
but returned {type(_res0)}""", | ||
) | ||
self.assertFalse( | ||
_res0.empty, | ||
f"""_get_consensus_labels_df called on non-empty dictionary should return | ||
a non-empty pd.DataFrame, but returned {_res0}""", | ||
) | ||
pd.testing.assert_frame_equal( | ||
_res0, | ||
pd.DataFrame( | ||
{ | ||
"id": [0, 1, 2, 3], | ||
"label": ["A0_B1_C0", "A0_B1_C0", "A1_B0_C1", "A1_B1_C0"], | ||
} | ||
), | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |