Code Duplication    Length = 20-20 lines in 2 locations

hyperactive/memory.py 1 location

@@ 136-155 (lines=20) @@
133
        opt_para.to_csv(self.date_path + "opt_para", index=False)
134
        """
135
136
    def _save_toCSV(self, meta_data_new, path):
137
        if os.path.exists(path):
138
            meta_data_old = pd.read_csv(path)
139
140
            if len(meta_data_old.columns) != len(meta_data_new.columns):
141
                print("Warning meta data dimensionality does not match")
142
                print("Meta data will not be saved")
143
                return
144
145
            meta_data = meta_data_old.append(meta_data_new)
146
147
            columns = list(meta_data.columns)
148
            noScore = ["mean_test_score", "cv_default_score", "eval_time", "run"]
149
            columns_noScore = [c for c in columns if c not in noScore]
150
151
            meta_data = meta_data.drop_duplicates(subset=columns_noScore)
152
        else:
153
            meta_data = meta_data_new
154
155
        meta_data.to_csv(path, index=False)
156
157
    def _read_func_metadata(self, model_func, _verb_):
158
        paths = self._get_func_data_names()

hyperactive/extensions/memory/memory.py 1 location

@@ 134-153 (lines=20) @@
131
        opt_para.to_csv(self.date_path + "opt_para", index=False)
132
        """
133
134
    def _save_toCSV(self, meta_data_new, path):
135
        if os.path.exists(path):
136
            meta_data_old = pd.read_csv(path)
137
138
            if len(meta_data_old.columns) != len(meta_data_new.columns):
139
                print("Warning meta data dimensionality does not match")
140
                print("Meta data will not be saved")
141
                return
142
143
            meta_data = meta_data_old.append(meta_data_new)
144
145
            columns = list(meta_data.columns)
146
            noScore = ["mean_test_score", "cv_default_score", "eval_time", "run"]
147
            columns_noScore = [c for c in columns if c not in noScore]
148
149
            meta_data = meta_data.drop_duplicates(subset=columns_noScore)
150
        else:
151
            meta_data = meta_data_new
152
153
        meta_data.to_csv(path, index=False)
154
155
    def _read_func_metadata(self, model_func, _verb_):
156
        paths = self._get_func_data_names()