def check_postprocessing(self, postprocessing): """ Check that postprocessing parameter has good attributes. Check if postprocessing is a dictionnary, and if its parameters are good. Parameters ---------- postprocessing : dict Dictionnary of postprocessing that need to be checked. """ check_postprocessing(self.x_pred, postprocessing)
def test_check_postprocessing_1(self): """ Unit test check_consistency_postprocessing """ x = pd.DataFrame( [[1, 2], [3, 4]], columns=['Col1', 'Col2'], index=['Id1', 'Id2'] ) columns_dict = {0: 'Col1', 1: 'Col2'} features_types = {features: str(x[features].dtypes) for features in x.columns} postprocessing1 = {0: {'Error': 'suffix', 'rule': ' t'}} postprocessing2 = {0: {'type': 'Error', 'rule': ' t'}} postprocessing3 = {0: {'type': 'suffix', 'Error': ' t'}} postprocessing4 = {0: {'type': 'suffix', 'rule': ' '}} postprocessing5 = {0: {'type': 'case', 'rule': 'lower'}} postprocessing6 = {0: {'type': 'case', 'rule': 'Error'}} with self.assertRaises(ValueError): check_postprocessing(features_types, postprocessing1) check_postprocessing(features_types, postprocessing2) check_postprocessing(features_types, postprocessing3) check_postprocessing(features_types, postprocessing4) check_postprocessing(features_types, postprocessing5) check_postprocessing(features_types, postprocessing6)