fusion-flap / nti-wavelet-tools

NTI Wavelet Tools is a data processing toolbox. Current development language is IDL (Interactive Data Language), but some features are only available for IDL 8.5 or later and Python 2.6. Old SVN repository and issue management site: https://deep.reak.bme.hu/projects/wavelet
MIT License
2 stars 0 forks source link

Check input parameters for calculation #25

Open poloskeipeter opened 4 years ago

poloskeipeter commented 4 years ago

Before initializing calculations input parameters should be checked and feedback should be provided to the user in order to correct their mistakes.

poloskeipeter commented 4 years ago

Only STFT parameters are being checked currently, checking if they are numerical or not.

gergopokol commented 4 years ago

This is a great idea! Two suggestions for modifications:

  1. I would rather use more formal messages. :)
  2. Checking the parameters is already useful. It would be even more useful if this would happen just after typing the input. Is there maybe a GUI functionality for this.
poloskeipeter commented 4 years ago

I can try to change the trigger of the check to the box modification event. Messages are just placeholders at the moment with the aim of giving some visual feedback that something happened. They will be revised once we will be around the brink of any public release.

gergopokol commented 4 years ago

Should check the relevant property in QT Designer.

poloskeipeter commented 4 years ago

So there are two parts to answer this topic: 1.) StackOverflow says that it is not possible to set up an input validator directly from QtDesigner, it should not be handled in QtDesigner, but in the GUI main.py. https://stackoverflow.com/questions/38701996/inputmethodhints-qt-imhdigitsonly-not-working 2.) a separate validator has to be created in order to check specific input fields. https://stackoverflow.com/questions/41087993/user-input-validation-in-pyqt5-and-python

from PyQt5.Qt import QApplication
from PyQt5.QtCore import QRegExp
from PyQt5.QtGui import QRegExpValidator
from PyQt5.QtWidgets import QWidget, QLineEdit

import sys

class MyWidget(QWidget):
    def __init__(self, parent=None):
        super(QWidget, self).__init__(parent)
        self.le_input = QLineEdit(self)

        reg_ex = QRegExp("[0-9]+.?[0-9]{,2}")
        input_validator = QRegExpValidator(reg_ex, self.le_input)
        self.le_input.setValidator(input_validator)

if __name__ == '__main__':
    a = QApplication(sys.argv)

    w = MyWidget()
    w.show()

    a.exec()
poloskeipeter commented 4 years ago

A question arose, regarding that the regular expression validator should allow scientific notation too, theoretical solution found: https://stackoverflow.com/questions/18152597/extract-scientific-number-from-string

poloskeipeter commented 4 years ago

Currently, 2 types of regular expressions are being set up. One is for integers and one for general numbers. Where-what should be allowed to be discussed.

poloskeipeter commented 4 years ago

step should be less than nperseg see #17 for reference