From 15825c22007baeceebee98d19515ff038c1c2ae4 Mon Sep 17 00:00:00 2001 From: MisterMLiL <99662459+MisterMLiL@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:54:47 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=B1=D0=B0=D0=B3=20"index=200=20is=20out?= =?UTF-8?q?=20of=20bounds"=20(#59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #43 --- statapp/main_window.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/statapp/main_window.py b/statapp/main_window.py index f24ecbc..9acd5ae 100644 --- a/statapp/main_window.py +++ b/statapp/main_window.py @@ -1,7 +1,7 @@ import numpy as np from PySide2.QtCore import Slot, QSize from PySide2.QtGui import QIcon -from PySide2.QtWidgets import QMainWindow, QMessageBox +from PySide2.QtWidgets import QMainWindow, QMessageBox, QAction from statapp.calculations import generate_x_values from statapp.generate_factor_window import GenerateFactorWindow @@ -24,7 +24,10 @@ class MainWindow(QMainWindow): icon = QIcon() icon.addFile(resource_path("ui/images/logo.ico"), QSize(), QIcon.Normal, QIcon.Off) - self.setWindowIcon(icon) + + self.ui.generateXaction.setEnabled(False) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) self.isDataChanged = False self.model = InputValuesModel() @@ -34,6 +37,7 @@ class MainWindow(QMainWindow): @Slot() def on_openfileaction_triggered(self): current_data = self.model.getData() + data = np.array([]) if current_data.size > 1: file = '' if self.fileModel.file_name: @@ -53,15 +57,28 @@ class MainWindow(QMainWindow): return else: data = self.fileModel.loadFile() - if data is not None: + if data is not None and data.shape[0] > 0: self.model.updateAllData(data) self.isDataChanged = False else: data = self.fileModel.loadFile() - if data is not None: + if data is not None and data.shape[0] > 0: self.model.updateAllData(data) self.isDataChanged = False + if data.shape[1] == 1: + self.ui.generateXaction.setEnabled(True) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) + elif data.shape[1] > 1: + self.ui.generateXaction.setEnabled(True) + self.ui.varianceAnalysisAction.setEnabled(True) + self.ui.correlationAnalisisAction.setEnabled(True) + else: + self.ui.generateXaction.setEnabled(False) + self.ui.varianceAnalysisAction.setEnabled(False) + self.ui.correlationAnalisisAction.setEnabled(False) + @Slot() def on_savefileaction_triggered(self): self.isDataChanged = not self.fileModel.saveFile(self.model.getData()) @@ -78,6 +95,7 @@ class MainWindow(QMainWindow): y = np.random.normal(gw.mat, gw.deviation, size=(gw.count, 1)) self.model.updateAllData(y.round(2)) self.isDataChanged = True + self.generateXaction_action.setEnabled(True) @Slot() def on_generateXaction_triggered(self): @@ -91,6 +109,8 @@ class MainWindow(QMainWindow): # dd = dd.reshape(len(dd), 1) data = np.concatenate((data, x_arr), axis=1) self.model.updateAllData(data) + self.varianceAnalysisAction_action.setEnabled(True) + self.correlationAnalisisAction_action.setEnabled(True) self.isDataChanged = True @Slot()