Total Complexity | 3 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import numpy as np |
||
2 | import pandas as pd |
||
3 | import unittest |
||
4 | from klib.describe import corr_mat |
||
5 | # from klib.utils import _missing_vals |
||
6 | |||
7 | if __name__ == '__main__': |
||
8 | unittest.main() |
||
9 | |||
10 | |||
11 | class Test_corr_mat(unittest.TestCase): |
||
12 | |||
13 | @classmethod |
||
14 | def setUpClass(cls): |
||
15 | cls.data_corr_df = pd.DataFrame([[1, 0, 3, 4], |
||
16 | [3, 4, 5, 6], |
||
17 | ['a', 'b', pd.NA, 'd'], |
||
18 | [5, False, np.nan, pd.NaT]], |
||
19 | columns=['Col1', 'Col2', 'Col3', 'Col4']) |
||
20 | |||
21 | cls.data_corr_list = [1, 2, -3, 4, 5, 0] |
||
22 | |||
23 | def test_output_type(self): |
||
24 | # Test conversion from pd.io.formats.style.Styler to pd.core.frame.DataFrame |
||
25 | self.assertTrue(type(corr_mat(self.data_corr_df)), type(pd.DataFrame)) |
||
26 | self.assertTrue(type(corr_mat(self.data_corr_list)), type(pd.DataFrame)) |
||
27 | |||
28 | def test_output_shape(self): |
||
29 | # Test for output of equal dimensions |
||
30 | self.assertEqual(corr_mat(self.data_corr_df).data.shape[0], corr_mat(self.data_corr_df).data.shape[1]) |
||
31 | self.assertEqual(corr_mat(self.data_corr_list).data.shape[0], corr_mat(self.data_corr_list).data.shape[1]) |
||
32 |