def test_su_default(self, idadf): if len(idadf.columns) > 1: result = su(idadf, features = idadf.columns) assert(isinstance(result, pandas.core.frame.DataFrame)) assert(len(result.columns) == len(idadf.columns)) assert(len(result.index) == len(idadf.columns)) result2 = su(idadf) assert(all(result == result2)) result = result.fillna(0) # np.nan values are not equal when compared assert(all(result == result.T)) # symmetry
def test_su_one_target_one_feature(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target=idadf.columns[0], features=[idadf.columns[1]]) assert (isinstance(result, float)) result2 = su(idadf, target=idadf.columns[1], features=[idadf.columns[0]]) assert (round(result, 3) == round(result2, 3)) # symmetry
def test_su_valueError(self, idadf): if len(idadf.columns) > 0: with pytest.raises( ValueError ): # Cannot compute correlation coefficients of only one column (...), need at least 2 su(idadf, features=idadf.columns[0]) with pytest.raises( ValueError ): # The correlation value of two same columns is always maximal su(idadf, target=idadf.columns[0], features=idadf.columns[0])
def test_su_default(self, idadf): if len(idadf.columns) > 1: result = su(idadf, features=idadf.columns) assert (isinstance(result, pandas.core.frame.DataFrame)) assert (len(result.columns) == len(idadf.columns)) assert (len(result.index) == len(idadf.columns)) result2 = su(idadf) assert (all(result == result2)) result = result.fillna( 0) # np.nan values are not equal when compared assert (all(result == result.T)) # symmetry
def test_su_one_target_one_feature(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target = idadf.columns[0], features=[idadf.columns[1]]) assert(isinstance(result, float)) result2 = su(idadf, target = idadf.columns[1], features=[idadf.columns[0]]) assert(round(result,3) == round(result2,3)) # symmetry
def test_su_multiple_target(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target = [idadf.columns[0],idadf.columns[1]]) assert(isinstance(result, pandas.core.frame.DataFrame)) assert(len(result.columns) == 2) assert(len(result.index) == len(idadf.columns))
def test_su_one_target(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target = idadf.columns[0]) assert(isinstance(result, pandas.core.series.Series)) assert(len(result) == (len(idadf.columns)-1))
def test_su_valueError(self, idadf): if len(idadf.columns) > 0: with pytest.raises(ValueError): # Cannot compute correlation coefficients of only one column (...), need at least 2 su(idadf, features = idadf.columns[0]) with pytest.raises(ValueError): # The correlation value of two same columns is always maximal su(idadf, target= idadf.columns[0], features = idadf.columns[0])
def test_su_multiple_target(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target=[idadf.columns[0], idadf.columns[1]]) assert (isinstance(result, pandas.core.frame.DataFrame)) assert (len(result.columns) == 2) assert (len(result.index) == len(idadf.columns))
def test_su_one_target(self, idadf): if len(idadf.columns) > 1: result = su(idadf, target=idadf.columns[0]) assert (isinstance(result, pandas.core.series.Series)) assert (len(result) == (len(idadf.columns) - 1))