Exemple #1
0
 def test_correlation_helper_for_group_with_one_row_and_length(self):
     # this should return a data frames with nans for group with 1 row
     retval = Analyzer.correlation_helper(self.df_features_with_groups_and_length[:6],
                                          'sc1', 'group', include_length=True)
     for df in retval:
         assert_equal(len(df), 2)
         assert_equal(len(df.columns), 3)
Exemple #2
0
 def test_that_correlation_helper_works_for_data_with_two_rows(self):
     # this should return 1/-1 for marginal correlations and nans for
     # partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:2], 'sc1',
                                          'group')
     assert_equal(abs(retval[0].values).sum(), 3)
     assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #3
0
 def test_that_correlation_helper_works_for_data_with_four_rows(self):
     # this should compute marginal correlations and return a unity
     # matrix for partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:4], 'sc1',
                                          'group')
     assert_equal(retval[0].isnull().values.sum(), 0)
     assert_almost_equal(abs(retval[1].values).sum(), 3)
Exemple #4
0
 def test_that_correlation_helper_works_for_data_with_three_rows(self):
     # this should compute marginal correlations but return Nans for
     # partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:3], 'sc1',
                                          'group')
     assert_equal(retval[0].isnull().values.sum(), 0)
     assert_equal(retval[1].isnull().values.sum(), 3)
    def test_that_correlation_helper_works_for_data_with_the_same_label(self):

        # this should return two data frames with nans
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', category=RuntimeWarning)
            retval = Analyzer.correlation_helper(self.df_features_same_score, 'sc1', 'group')
            assert_equal(retval[0].isnull().values.sum(), 3)
            assert_equal(retval[1].isnull().values.sum(), 3)
 def test_that_correlation_helper_works_for_data_with_one_row(self):
     # this should return two data frames with nans
     # we expect a runtime warning here so let's suppress it
     with warnings.catch_warnings():
         warnings.filterwarnings('ignore', category=RuntimeWarning)
         retval = Analyzer.correlation_helper(self.df_features[:1], 'sc1', 'group')
         assert_equal(retval[0].isnull().values.sum(), 3)
         assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #7
0
    def test_that_correlation_helper_works_for_data_with_the_same_label(self):

        # this should return two data frames with nans
        with warnings.catch_warnings():
            warnings.filterwarnings('ignore', category=RuntimeWarning)
            retval = Analyzer.correlation_helper(self.df_features_same_score,
                                                 'sc1', 'group')
            assert_equal(retval[0].isnull().values.sum(), 3)
            assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #8
0
 def test_correlation_helper_for_data_with_four_rows(self):
     # this should compute marginal correlations and return a unity
     # matrix for partial correlations
     # it should also raise a UserWarning
     with warnings.catch_warnings(record=True) as warning_list:
         retval = Analyzer.correlation_helper(self.df_features[:4], 'sc1', 'group')
     assert_equal(retval[0].isnull().values.sum(), 0)
     assert_almost_equal(np.abs(retval[1].values).sum(), 0.9244288637889855)
     assert issubclass(warning_list[-1].category, UserWarning)
Exemple #9
0
 def test_that_correlation_helper_works_for_data_with_one_row(self):
     # this should return two data frames with nans
     # we expect a runtime warning here so let's suppress it
     with warnings.catch_warnings():
         warnings.filterwarnings('ignore', category=RuntimeWarning)
         retval = Analyzer.correlation_helper(self.df_features[:1], 'sc1',
                                              'group')
         assert_equal(retval[0].isnull().values.sum(), 3)
         assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #10
0
 def test_that_correlation_helper_works_for_data_with_the_same_human_score(self):
     # this test should raise UserWarning because the determinant is very close to
     # zero. It also raises Runtime warning because
     # variance of human scores is 0.
     with warnings.catch_warnings(record=True) as warning_list:
         warnings.filterwarnings('ignore', category=RuntimeWarning)
         retval = Analyzer.correlation_helper(self.df_features_same_score, 'sc1', 'group')
         assert_equal(retval[0].isnull().values.sum(), 3)
         assert_equal(retval[1].isnull().values.sum(), 3)
         assert issubclass(warning_list[-1].category, UserWarning)
Exemple #11
0
 def test_correlation_helper_for_data_with_one_row(self):
     # this should return two data frames with nans
     retval = Analyzer.correlation_helper(self.df_features[:1], 'sc1', 'group')
     assert_equal(retval[0].isnull().values.sum(), 3)
     assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #12
0
    def test_correlation_helper(self):

        # test that there are no nans for data frame with 10 values
        retval = Analyzer.correlation_helper(self.df_features, 'sc1', 'group')
        assert_equal(retval[0].isnull().values.sum(), 0)
        assert_equal(retval[1].isnull().values.sum(), 0)
Exemple #13
0
 def test_correlation_helper_for_one_group_with_one_row(self):
     # this should return a data frames with nans for group with 1 row
     retval = Analyzer.correlation_helper(self.df_features_with_groups[:6], 'sc1', 'group')
     assert_equal(len(retval[0]), 2)
     assert_equal(len(retval[1]), 2)
     assert_equal(retval[0].isnull().values.sum(), 3)
 def test_that_correlation_helper_works_for_data_with_two_rows(self):
     # this should return 1/-1 for marginal correlations and nans for
     # partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:2], 'sc1', 'group')
     assert_equal(abs(retval[0].values).sum(), 3)
     assert_equal(retval[1].isnull().values.sum(), 3)
    def test_correlation_helper(self):

        # test that there are no nans for data frame with 10 values
        retval = Analyzer.correlation_helper(self.df_features, 'sc1', 'group')
        assert_equal(retval[0].isnull().values.sum(), 0)
        assert_equal(retval[1].isnull().values.sum(), 0)
Exemple #16
0
 def test_correlation_helper_for_data_with_groups(self):
     retval = Analyzer.correlation_helper(self.df_features_with_groups, 'sc1', 'group')
     assert_equal(len(retval[0]), 2)
     assert_equal(len(retval[1]), 2)
 def test_that_correlation_helper_works_for_data_with_three_rows(self):
     # this should compute marginal correlations but return Nans for
     # partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:3], 'sc1', 'group')
     assert_equal(retval[0].isnull().values.sum(), 0)
     assert_equal(retval[1].isnull().values.sum(), 3)
Exemple #18
0
 def test_correlation_helper_for_groups_and_length(self):
     retval = Analyzer.correlation_helper(self.df_features_with_groups_and_length,
                                          'sc1', 'group', include_length=True)
     for df in retval:
         assert_equal(len(df), 2)
         assert_equal(len(df.columns), 3)
 def test_that_correlation_helper_works_for_data_with_four_rows(self):
     # this should compute marginal correlations and return a unity
     # matrix for partial correlations
     retval = Analyzer.correlation_helper(self.df_features[:4], 'sc1', 'group')
     assert_equal(retval[0].isnull().values.sum(), 0)
     assert_almost_equal(abs(retval[1].values).sum(), 3)