Skip to content

Commit

Permalink
Docstring software #29
Browse files Browse the repository at this point in the history
  • Loading branch information
Enmartz committed Dec 12, 2022
1 parent ea0aff1 commit 4264575
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 22 deletions.
30 changes: 30 additions & 0 deletions Desarrollo/ReDS/launcher_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,42 @@


def solve_path(relative_path):
'''Solve path for different OS'''
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath('.'), relative_path)


class UILauncherWindow(QtWidgets.QMainWindow):
'''
Main class to launch the software.
This class is the main class to launch the software. It contains the main window
and the buttons to launch the modules.
Attributes
----------
main_A_window : QWidget
Main window of the module A.
main_B_window : QWidget
Main window of the module B.
ui_main_A_window : UIMainAWindow
Main window of the module A.
ui_main_B_window : UIMainBWindow
Main window of the module B.
Methods
-------
open_module_A()
Open the main window of the module A.
open_module_B()
Open the main window of the module B.
retranslateUi()
Translate the UI.
setupUi()
Setup the UI.
'''

def __init__(self):
super(UILauncherWindow, self).__init__()
self.setupUi()
Expand Down
104 changes: 90 additions & 14 deletions Desarrollo/ReDS/mainA_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,52 @@


def solve_path(relative_path):
'''Solve path for different OS'''
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath('.'), relative_path)


class UIMainAWindow(QtWidgets.QMainWindow):
'''
Class for module A. Trace reconstruction.
Attributes
----------
launcher : QMainWindow
Main window of the application.
global_variables : dict
Dictionary with global variables.
directories : dict
Dictionary with directories.
tab_widgets : dict
Dictionary with tab widgets.
'''

def __init__(self, launcher):
'''
Parameters
----------
launcher : QMainWindow
Main window of the application.
'''
super(UIMainAWindow, self).__init__()
self.launcher = launcher
self.setupUi()

self.sampling = Sampling()

def closeEvent(self, event):
'''
Close event.
Parameters
----------
event : QEvent
Close event.
'''
message_box = QtWidgets.QMessageBox(self)
message_box.pos()
message_box.setIcon(QtWidgets.QMessageBox.Question)
Expand All @@ -71,6 +103,11 @@ def closeEvent(self, event):
event.ignore()

def setupUi(self):
'''
Setup UI.
Init components, variables and connections.
'''
self.setWindowTitle("ReDs")
self.setWindowIcon(QIcon("assets/icons/g868.ico"))
self.setObjectName("mainWindow")
Expand Down Expand Up @@ -765,6 +802,14 @@ def setupUi(self):
self.init_visible_widgets(width=320)

def init_visible_widgets(self, width=320):
'''
Initialize the visible widgets
Parameters
----------
width : int, optional
The width of the widget, by default 320
'''
self.inputGroupBox.setMinimumWidth(width)
self.inputGroupBox.setMaximumWidth(width)
self.algorithmGroupBox.setMinimumWidth(width)
Expand Down Expand Up @@ -795,13 +840,45 @@ def init_visible_widgets(self, width=320):
self.jitterPushButton.setVisible(False)

def init_global_variables(self):

# variables setup

# Tab mode ['main', 'tuning', 'comparison']
# View mode ['normal', 'report']
# Data mode ['complete', 'incomplete']

'''
Initialize the global variables.
These variables are used to store the data of the experiments.
Variables
----------
global_varibles : dict
The global variables
# Tab mode ['main', 'tuning', 'comparison']
# View mode ['normal', 'report']
# Data mode ['complete', 'incomplete']
tab_mode : list
The tab mode according to selected tool
data_mode : list
The view mode according to kind of datasets
directories : dict
The directories of the project
state : dict
The state of the project, considering tab mode, view mode and data mode
graphics : dict
The graphics of the project
threads : list
The threads of the project for multiple experiments
workers : list
The workers of the project for multiple experiments
all_tabs : dict
The tabs of the project for generating a normal or report view
tab_widgets: dict
The tab widgets of the project
iters: int
The number of iterations for experiments
max_iter: int
The maximum number of iterations for experiments
max_iter_progress: int
The maximum number of iterations for progress bar for multiple experiments
'''
self.global_variables = dict(tab_mode='main', view_mode='normal', data_mode='complete', algorithm_name='')

tab_mode = ['main', 'tuning', 'comparison']
Expand Down Expand Up @@ -2132,7 +2209,8 @@ def reset_values(self):

def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("mainWindow", "ReDs - Reconstruccion de Receptores | Universidad Industrial de Santander"))
self.setWindowTitle(
_translate("mainWindow", "ReDs - Reconstruccion de Receptores | Universidad Industrial de Santander"))
self.inputGroupBox.setTitle(_translate("mainWindow", "Datos sísmicos"))
self.typeDataLabel.setText(_translate("mainWindow", "Tipo:"))
self.dataComboBox.setItemText(0, _translate("mainWindow", "Datos completos"))
Expand Down Expand Up @@ -2211,17 +2289,15 @@ def retranslateUi(self):

self.toolBar.setWindowTitle(_translate("mainWindow", "toolBar"))
self.aboutOfAction.setText(_translate("mainWindow", "about"))
self.aboutOfAction.setToolTip(
_translate("mainWindow", "<html><head/><body><p>Acerca de este proyecto</p></body></html>"))
self.aboutOfAction.setToolTip(_translate("mainWindow", "Acerca de ReDs"))
self.reportAction.setText(_translate("mainWindow", "report"))
self.reportAction.setToolTip(_translate("mainWindow", "Visualización de resultados"))
self.mainAction.setText(_translate("mainWindow", "main"))
self.mainAction.setToolTip(_translate("mainWindow", "Ir al menú principal"))
self.mainAction.setToolTip(_translate("mainWindow", "Ir a Modo Individual"))
self.tuningAction.setText(_translate("mainWindow", "tuning"))
self.tuningAction.setToolTip(_translate("mainWindow", "Ajuste de parámetros"))
self.tuningAction.setToolTip(_translate("mainWindow", "Ir a Modo Ajuste de Parámetros"))
self.comparisonAction.setText(_translate("mainWindow", "comparison"))
self.comparisonAction.setToolTip(
_translate("mainWindow", "Hacer comparación de experimento con todos los algoritmos"))
self.comparisonAction.setToolTip(_translate("mainWindow", "Ir a Modo Comparación de Algoritmos"))


if __name__ == "__main__":
Expand Down
14 changes: 6 additions & 8 deletions Desarrollo/ReDS/mainB_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from itertools import product
from pathlib import Path

import hdf5storage
from scipy.io import loadmat
import numpy as np
import pandas as pd
from PyQt5.Qt import Qt
Expand Down Expand Up @@ -1609,7 +1609,7 @@ def load_seismic_data(self, uploaded_directory):
if Path(uploaded_directory).suffix == '.npy':
data = np.load(uploaded_directory)
else:
data = hdf5storage.loadmat(uploaded_directory)
data = loadmat(uploaded_directory)
keys = list(data.keys())
keys.remove('__header__')
keys.remove('__version__')
Expand Down Expand Up @@ -1866,17 +1866,15 @@ def retranslateUi(self):

self.toolBar.setWindowTitle(_translate("mainWindow", "toolBar"))
self.aboutOfAction.setText(_translate("mainWindow", "about"))
self.aboutOfAction.setToolTip(
_translate("mainWindow", "<html><head/><body><p>Acerca de este proyecto</p></body></html>"))
self.aboutOfAction.setToolTip(_translate("mainWindow", "Acerca de ReDs"))
self.reportAction.setText(_translate("mainWindow", "report"))
self.reportAction.setToolTip(_translate("mainWindow", "Visualización de resultados"))
self.mainAction.setText(_translate("mainWindow", "main"))
self.mainAction.setToolTip(_translate("mainWindow", "Ir al menú principal"))
self.mainAction.setToolTip(_translate("mainWindow", "Ir a Modo Individual"))
self.tuningAction.setText(_translate("mainWindow", "tuning"))
self.tuningAction.setToolTip(_translate("mainWindow", "Ajuste de parámetros"))
self.tuningAction.setToolTip(_translate("mainWindow", "Ir a Modo Ajuste de Parámetros"))
self.comparisonAction.setText(_translate("mainWindow", "comparison"))
self.comparisonAction.setToolTip(
_translate("mainWindow", "Hacer comparación de experimento con todos los algoritmos"))
self.comparisonAction.setToolTip(_translate("mainWindow", "Ir a Modo Comparación de Algoritmos"))


if __name__ == "__main__":
Expand Down

0 comments on commit 4264575

Please sign in to comment.