mirror of
https://github.com/shizand/statapp.git
synced 2024-12-23 12:12:59 +03:00
parent
2f5988a2eb
commit
dc7c4875d7
20
statapp/constants.py
Normal file
20
statapp/constants.py
Normal file
@ -0,0 +1,20 @@
|
||||
#
|
||||
# Copyright (c) 2023 Maxim Slipenko, Eugene Lazurenko.
|
||||
#
|
||||
# This file is part of Statapp
|
||||
# (see https://github.com/shizand/statapp).
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
NUMBERS_PRECISION = 5
|
@ -23,6 +23,7 @@ from PySide2.QtGui import QIcon
|
||||
from PySide2.QtWidgets import QDialog, QHeaderView
|
||||
|
||||
from statapp.calculations import correlationAnalysis
|
||||
from statapp.constants import NUMBERS_PRECISION
|
||||
from statapp.mathtex_header_view import MathTexHeaderView
|
||||
from statapp.models.correlation_analysis_model import CorrelationAnalysisModel
|
||||
from statapp.ui.ui_correlation_analysis_window import Ui_CorrelationAnalysisWindow
|
||||
@ -36,7 +37,7 @@ class CorrelationAnalysisWindow(QDialog):
|
||||
self.ui.setupUi(self)
|
||||
|
||||
res = correlationAnalysis(data)
|
||||
self.model = CorrelationAnalysisModel(res.round(2))
|
||||
self.model = CorrelationAnalysisModel(res.round(NUMBERS_PRECISION))
|
||||
self.ui.tableView.setModel(self.model)
|
||||
self.ui.tableView.setVerticalHeader(
|
||||
MathTexHeaderView(self.ui.tableView)
|
||||
|
@ -23,7 +23,7 @@ from statapp.calculations import linearPolynom
|
||||
from statapp.mathtex_header_view import MathTexHeaderView
|
||||
from statapp.models.regression_result_model import RegressionResultModel
|
||||
from statapp.ui.ui_linear_polynom_window import Ui_LinearPolynomWindow
|
||||
from statapp.utils import addIcon
|
||||
from statapp.utils import addIcon, FloatDelegate
|
||||
|
||||
|
||||
class LinearPolynomWindow(QDialog):
|
||||
@ -36,6 +36,7 @@ class LinearPolynomWindow(QDialog):
|
||||
result = linearPolynom(data)
|
||||
|
||||
self.model = RegressionResultModel(result)
|
||||
self.ui.tableView.setItemDelegate(FloatDelegate())
|
||||
self.ui.tableView.setModel(self.model)
|
||||
self.ui.tableView.setVerticalHeader(MathTexHeaderView(self.ui.tableView))
|
||||
header = self.ui.tableView.horizontalHeader()
|
||||
|
@ -23,6 +23,7 @@ from PySide2.QtCore import Slot
|
||||
from PySide2.QtWidgets import QMainWindow, QMessageBox
|
||||
|
||||
from statapp.calculations import generateXValues, generateYValues
|
||||
from statapp.constants import NUMBERS_PRECISION
|
||||
from statapp.generate_factor_window import GenerateFactorWindow
|
||||
from statapp.linear_polynom_window import LinearPolynomWindow
|
||||
from statapp.mathtex_header_view import MathTexHeaderView
|
||||
@ -32,7 +33,7 @@ from statapp.about_window import AboutWindow
|
||||
from statapp.models.fileslc_model import FileSLCModel
|
||||
from statapp.squared_polynom_window import SquaredPolynomWindow
|
||||
from statapp.ui.ui_main_window import Ui_MainWindow
|
||||
from statapp.utils import buildMessageBox, addIcon
|
||||
from statapp.utils import buildMessageBox, addIcon, FloatDelegate
|
||||
from statapp.variance_analysis import VarianceAnalysisWindow
|
||||
from statapp.correlation_analysis import CorrelationAnalysisWindow
|
||||
|
||||
@ -62,6 +63,7 @@ class MainWindow(QMainWindow):
|
||||
self.isDataChanged = False
|
||||
self.model = InputValuesModel()
|
||||
self.fileModel = FileSLCModel()
|
||||
self.ui.tableView.setItemDelegate(FloatDelegate())
|
||||
self.ui.tableView.setModel(self.model)
|
||||
self.ui.tableView.setHorizontalHeader(
|
||||
MathTexHeaderView(self.ui.tableView, orientation=QtCore.Qt.Horizontal)
|
||||
@ -150,7 +152,7 @@ class MainWindow(QMainWindow):
|
||||
|
||||
if gw.exec():
|
||||
y = generateYValues(gw.mat, gw.deviation, gw.count)
|
||||
self.model.updateAllData(y.round(2))
|
||||
self.model.updateAllData(y.round(NUMBERS_PRECISION))
|
||||
self.isDataChanged = True
|
||||
|
||||
@Slot()
|
||||
@ -161,7 +163,7 @@ class MainWindow(QMainWindow):
|
||||
data = self.model.getData()
|
||||
y = self.model.getY()
|
||||
xValues = generateXValues(gfw.mat, gfw.deviation, gfw.typeConnection, y)
|
||||
data = np.concatenate((data, xValues.round(2)), axis=1)
|
||||
data = np.concatenate((data, xValues.round(NUMBERS_PRECISION)), axis=1)
|
||||
self.model.updateAllData(data)
|
||||
self.isDataChanged = True
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
import numpy as np
|
||||
from PySide2.QtWidgets import QFileDialog, QMessageBox
|
||||
|
||||
from statapp.constants import NUMBERS_PRECISION
|
||||
from statapp.utils import buildMessageBox
|
||||
|
||||
|
||||
@ -57,7 +58,7 @@ class FileSLCModel:
|
||||
None, "Сохранить файл", "", "Text Files (*.txt);;CSV Files (*.csv)"
|
||||
)
|
||||
if self.fileName:
|
||||
np.savetxt(self.fileName, data, delimiter=",", fmt='%10.5f')
|
||||
np.savetxt(self.fileName, data, delimiter=",", fmt=f"%.{NUMBERS_PRECISION}f")
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -23,7 +23,7 @@ from statapp.calculations import squaredPolynom
|
||||
from statapp.mathtex_header_view import MathTexHeaderView
|
||||
from statapp.models.regression_result_model import RegressionResultModel
|
||||
from statapp.ui.ui_squared_polynom_window import Ui_SquaredPolynomWindow
|
||||
from statapp.utils import addIcon
|
||||
from statapp.utils import addIcon, FloatDelegate
|
||||
|
||||
|
||||
class SquaredPolynomWindow(QDialog):
|
||||
@ -36,6 +36,7 @@ class SquaredPolynomWindow(QDialog):
|
||||
result = squaredPolynom(data)
|
||||
|
||||
self.model = RegressionResultModel(result)
|
||||
self.ui.tableView.setItemDelegate(FloatDelegate())
|
||||
self.ui.tableView.setModel(self.model)
|
||||
self.ui.tableView.setVerticalHeader(MathTexHeaderView(self.ui.tableView))
|
||||
header = self.ui.tableView.horizontalHeader()
|
||||
|
@ -71,6 +71,9 @@
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
</property>
|
||||
@ -83,6 +86,9 @@
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
</property>
|
||||
|
@ -44,6 +44,9 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="matSpinBox">
|
||||
<property name="decimals">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
</property>
|
||||
@ -68,6 +71,9 @@
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="deviationSpinBox">
|
||||
<property name="decimals">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1000000.000000000000000</double>
|
||||
</property>
|
||||
|
2
statapp/ui/ui_generate_factor_window.py
generated
2
statapp/ui/ui_generate_factor_window.py
generated
@ -71,6 +71,7 @@ class Ui_GenerateFactorWindow(object):
|
||||
self.matSpinBox = QDoubleSpinBox(GenerateFactorWindow)
|
||||
self.matSpinBox.setObjectName(u"matSpinBox")
|
||||
self.matSpinBox.setFont(font)
|
||||
self.matSpinBox.setDecimals(5)
|
||||
self.matSpinBox.setMaximum(1000000.000000000000000)
|
||||
|
||||
self.gridLayout.addWidget(self.matSpinBox, 1, 1, 1, 1)
|
||||
@ -78,6 +79,7 @@ class Ui_GenerateFactorWindow(object):
|
||||
self.deviationSpinBox = QDoubleSpinBox(GenerateFactorWindow)
|
||||
self.deviationSpinBox.setObjectName(u"deviationSpinBox")
|
||||
self.deviationSpinBox.setFont(font)
|
||||
self.deviationSpinBox.setDecimals(5)
|
||||
self.deviationSpinBox.setMaximum(1000000.000000000000000)
|
||||
|
||||
self.gridLayout.addWidget(self.deviationSpinBox, 2, 1, 1, 1)
|
||||
|
2
statapp/ui/ui_generate_window.py
generated
2
statapp/ui/ui_generate_window.py
generated
@ -62,6 +62,7 @@ class Ui_GenerateWindow(object):
|
||||
|
||||
self.matSpinBox = QDoubleSpinBox(GenerateWindow)
|
||||
self.matSpinBox.setObjectName(u"matSpinBox")
|
||||
self.matSpinBox.setDecimals(5)
|
||||
self.matSpinBox.setMaximum(1000000.000000000000000)
|
||||
|
||||
self.gridLayout.addWidget(self.matSpinBox, 1, 1, 1, 1)
|
||||
@ -80,6 +81,7 @@ class Ui_GenerateWindow(object):
|
||||
|
||||
self.deviationSpinBox = QDoubleSpinBox(GenerateWindow)
|
||||
self.deviationSpinBox.setObjectName(u"deviationSpinBox")
|
||||
self.deviationSpinBox.setDecimals(5)
|
||||
self.deviationSpinBox.setMaximum(1000000.000000000000000)
|
||||
|
||||
self.gridLayout.addWidget(self.deviationSpinBox, 2, 1, 1, 1)
|
||||
|
@ -22,7 +22,9 @@ import sys
|
||||
|
||||
from PySide2.QtCore import QSize
|
||||
from PySide2.QtGui import QIcon
|
||||
from PySide2.QtWidgets import QMessageBox
|
||||
from PySide2.QtWidgets import QMessageBox, QDoubleSpinBox, QStyledItemDelegate
|
||||
|
||||
from statapp.constants import NUMBERS_PRECISION
|
||||
|
||||
|
||||
def resourcePath(relative):
|
||||
@ -58,3 +60,19 @@ def buildMessageBox(title, text, icon, buttons, defaultButton):
|
||||
msgBox.setDefaultButton(defaultButton)
|
||||
|
||||
return msgBox
|
||||
|
||||
|
||||
class FloatDelegate(QStyledItemDelegate):
|
||||
def __init__(self, parent=None):
|
||||
QStyledItemDelegate.__init__(self, parent=parent)
|
||||
|
||||
def createEditor(self, parent, option, index):
|
||||
editor = QDoubleSpinBox(parent)
|
||||
editor.setDecimals(NUMBERS_PRECISION)
|
||||
editor.setMaximum(10**8)
|
||||
editor.setMinimum(-10**8)
|
||||
return editor
|
||||
|
||||
def displayText(self, value, locale):
|
||||
# Грязный хак, скорее всего нужно было использовать locale
|
||||
return f'{value:.{NUMBERS_PRECISION}f}'
|
||||
|
@ -20,10 +20,11 @@
|
||||
from PySide2.QtWidgets import QDialog, QHeaderView
|
||||
|
||||
from statapp.calculations import varianceAnalysis
|
||||
from statapp.constants import NUMBERS_PRECISION
|
||||
from statapp.mathtex_header_view import MathTexHeaderView
|
||||
from statapp.models.variance_analysis_model import VarianceAnalysisModel
|
||||
from statapp.ui.ui_variance_analysis_window import Ui_VarianceAnalysisWindow
|
||||
from statapp.utils import addIcon
|
||||
from statapp.utils import addIcon, FloatDelegate
|
||||
|
||||
|
||||
class VarianceAnalysisWindow(QDialog):
|
||||
@ -33,7 +34,8 @@ class VarianceAnalysisWindow(QDialog):
|
||||
self.ui.setupUi(self)
|
||||
|
||||
res = varianceAnalysis(data)
|
||||
self.model = VarianceAnalysisModel(res.round(2))
|
||||
self.model = VarianceAnalysisModel(res.round(NUMBERS_PRECISION))
|
||||
self.ui.tableView.setItemDelegate(FloatDelegate())
|
||||
self.ui.tableView.setModel(self.model)
|
||||
self.ui.tableView.setVerticalHeader(
|
||||
MathTexHeaderView(self.ui.tableView)
|
||||
|
Loading…
Reference in New Issue
Block a user