示例#1
0
 def test_summarize_el_2(self):
     """
     Test summarize el 2
     """
     column_name = ['col1', 'col2', 'col3']
     xmatr = pd.DataFrame(
         [[0.1, 0.43, -0.02], [-0.78, 0.002, -0.3], [0.62, -0.008, 0.4]],
         columns=column_name)
     masktest = pd.DataFrame(
         [[True, False, False], [False, True, False], [False, False, True]],
         columns=column_name)
     output = summarize_el(xmatr, masktest, "feat")
     expected = pd.DataFrame([[0.1], [0.002], [0.4]],
                             columns=["feat1"],
                             dtype=object)
     assert xmatr.shape[0] == output.shape[0]
     assert output.equals(expected)
示例#2
0
 def test_summarize_el_3(self):
     """
     Test summarize el 3
     """
     column_name = ['col1', 'col2', 'col3']
     xmatr = pd.DataFrame(
         [["dfkj", "nfk", "bla"], ["Buble", "blue", "cool"],
          ["angry", "peace", "deep"]],
         columns=column_name)
     masktest = pd.DataFrame(
         [[True, False, False], [False, True, False], [False, True, True]],
         columns=column_name)
     output = summarize_el(xmatr, masktest, "temp")
     expected = pd.DataFrame(
         [['dfkj', np.nan], ['blue', np.nan], ['peace', 'deep']],
         columns=["temp1", "temp2"],
         dtype=object)
     assert xmatr.shape[0] == output.shape[0]
     assert output.equals(expected)
示例#3
0
 def test_summarize_el_4(self):
     """
     Test summarize el 4
     """
     column_name = ['col1', 'col2', 'col3']
     index_list = ['A', 'B', 'C']
     xmatr = pd.DataFrame(
         [[0.1, 0.43, -0.02], [-0.78, 0.002, -0.3], [0.62, -0.008, 0.4]],
         columns=column_name)
     masktest = pd.DataFrame(
         [[True, False, False], [False, True, False], [False, True, True]],
         columns=column_name)
     xmatr.index = index_list
     masktest.index = index_list
     output = summarize_el(xmatr, masktest, "temp")
     expected = pd.DataFrame(
         [[0.1, np.nan], [0.002, np.nan], [-0.008, 0.4]],
         columns=["temp1", "temp2"],
         dtype=object)
     expected.index = index_list
     assert xmatr.shape[0] == output.shape[0]
     assert output.equals(expected)