1、完善命名规范
2、完成<冗余数据切割和标签映射>的全部代码
This commit is contained in:
@ -42,7 +42,6 @@ ButtonState = {
|
||||
class SettingWindow(QMainWindow):
|
||||
|
||||
def __init__(self, mode, root_path, sampID):
|
||||
|
||||
super(SettingWindow, self).__init__()
|
||||
self.ui = Ui_MainWindow_preprocess_input_setting()
|
||||
self.ui.setupUi(self)
|
||||
@ -61,7 +60,6 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.pushButton_cancel.clicked.connect(self.close)
|
||||
|
||||
def __read_config__(self):
|
||||
|
||||
if not Path(ConfigParams.PREPROCESS_CONFIG_FILE_PATH).exists():
|
||||
with open(ConfigParams.PREPROCESS_CONFIG_FILE_PATH, "w") as f:
|
||||
dump(ConfigParams.PREPROCESS_CONFIG_NEW_CONTENT, f)
|
||||
@ -109,7 +107,6 @@ class SettingWindow(QMainWindow):
|
||||
self.ui.plainTextEdit_file_path_save.setPlainText(Config["Path"]["Save"])
|
||||
|
||||
def __write_config__(self):
|
||||
|
||||
# 从界面写入配置
|
||||
Config["InputConfig"]["Freq"] = self.ui.spinBox_input_freq.value()
|
||||
Config["OutputConfig"]["Freq"] = self.ui.spinBox_output_freq.value()
|
||||
@ -126,11 +123,9 @@ class SettingWindow(QMainWindow):
|
||||
self.close()
|
||||
|
||||
def __rollback_config__(self):
|
||||
|
||||
self.__read_config__()
|
||||
|
||||
def __update_ui__(self):
|
||||
|
||||
if self.mode == "BCG":
|
||||
self.ui.plainTextEdit_file_path_input.setPlainText(
|
||||
str((Path(self.root_path) /
|
||||
@ -168,7 +163,6 @@ class SettingWindow(QMainWindow):
|
||||
class MainWindow_preprocess(QMainWindow):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
super(MainWindow_preprocess, self).__init__()
|
||||
self.ui = Ui_MainWindow_preprocess()
|
||||
self.ui.setupUi(self)
|
||||
@ -197,7 +191,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def show(self, mode, root_path, sampID):
|
||||
|
||||
super().show()
|
||||
self.mode = mode
|
||||
self.root_path = root_path
|
||||
@ -244,7 +237,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
|
||||
@overrides
|
||||
def closeEvent(self, event):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
PublicFunc.statusbar_show_msg(self, PublicFunc.format_status_msg(Constants.SHUTTING_DOWN))
|
||||
@ -264,12 +256,10 @@ class MainWindow_preprocess(QMainWindow):
|
||||
|
||||
@staticmethod
|
||||
def __reset__():
|
||||
|
||||
ButtonState["Current"].update(ButtonState["Default"].copy())
|
||||
ButtonState["Current"]["pushButton_view"] = True
|
||||
|
||||
def __plot__(self):
|
||||
|
||||
# 清空画框
|
||||
self.reset_axes()
|
||||
|
||||
@ -293,7 +283,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
return status, info
|
||||
|
||||
def __update_config__(self):
|
||||
|
||||
if self.mode == "BCG":
|
||||
Config["Filter"]["BCGBandPassOrder"] = self.ui.spinBox_bandPassOrder.value()
|
||||
Config["Filter"]["BCGBandPassLow"] = self.ui.doubleSpinBox_bandPassLow.value()
|
||||
@ -306,7 +295,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
raise ValueError("模式不存在")
|
||||
|
||||
def __slot_btn_input__(self):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 清空画框
|
||||
@ -331,7 +319,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_view__(self):
|
||||
|
||||
PublicFunc.__disableAllButton__(self, ButtonState)
|
||||
|
||||
# 数据预处理
|
||||
@ -360,7 +347,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def __slot_btn_save__(self):
|
||||
|
||||
reply = QMessageBox.question(self, Constants.QUESTION_TITLE,
|
||||
Constants.QUESTION_CONTENT + Config["Path"]["Save"],
|
||||
QMessageBox.Yes | QMessageBox.No,
|
||||
@ -394,7 +380,6 @@ class MainWindow_preprocess(QMainWindow):
|
||||
PublicFunc.finish_operation(self, ButtonState)
|
||||
|
||||
def reset_axes(self):
|
||||
|
||||
self.ax0.clear()
|
||||
self.ax0.grid(True)
|
||||
self.ax0.xaxis.set_major_formatter(ConfigParams.FORMATTER)
|
||||
@ -403,20 +388,15 @@ class MainWindow_preprocess(QMainWindow):
|
||||
class Data:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.file_path_input = Config["Path"]["Input"]
|
||||
self.file_path_save = Config["Path"]["Save"]
|
||||
|
||||
self.raw_data = None
|
||||
self.processed_data = None
|
||||
|
||||
def open_file(self):
|
||||
|
||||
if not Path(Config["Path"]["Input"]).exists():
|
||||
return False, Constants.INPUT_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Data_Path_Not_Exist"]
|
||||
|
||||
try:
|
||||
self.raw_data = read_csv(self.file_path_input,
|
||||
self.raw_data = read_csv(Config["Path"]["Input"],
|
||||
encoding=ConfigParams.UTF8_ENCODING,
|
||||
header=None).to_numpy().reshape(-1)
|
||||
except Exception:
|
||||
@ -425,7 +405,6 @@ class Data:
|
||||
return True, Constants.INPUT_FINISHED
|
||||
|
||||
def preprocess(self):
|
||||
|
||||
if self.raw_data is None:
|
||||
return False, Constants.PREPROCESS_PROCESS_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Raw_Data_Not_Exist"]
|
||||
|
||||
@ -454,12 +433,11 @@ class Data:
|
||||
return True, Constants.PREPROCESS_PROCESS_FINISHED
|
||||
|
||||
def save(self, chunk):
|
||||
|
||||
if self.processed_data is None:
|
||||
return False, Constants.SAVING_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Processed_Data_Not_Exist"]
|
||||
|
||||
try:
|
||||
chunk.to_csv(self.file_path_save, mode='a', index=False, header=False, float_format='%.4f')
|
||||
chunk.to_csv(Config["Path"]["Save"], mode='a', index=False, header=False, float_format='%.4f')
|
||||
except Exception:
|
||||
return False, Constants.SAVING_FAILURE + Constants.PREPROCESS_FAILURE_REASON["Save_Exception"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user