GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 3ad708de authored by Thomas Vincent's avatar Thomas Vincent

docstring and code style

parent 7855f5ab
......@@ -48,9 +48,7 @@ _logger = logging.getLogger(__name__)
class Roi3DSelectorWidget(Qt.QWidget):
"""
Widget displaying three RoiAxisWidgets, one for each axis.
"""
"""Widget displaying three RoiAxisWidgets, one for each axis."""
sigRoiChanged = Qt.Signal(object)
"""Signal emitted when one of the slider is moved.
......@@ -60,7 +58,7 @@ class Roi3DSelectorWidget(Qt.QWidget):
"""
sigRoiToggled = Qt.Signal(bool)
""" Signal emitted when the QGroupWidget is toggled on/off. """
"""Signal emitted when the QGroupWidget is toggled on/off. """
def __init__(self, *args, **kwargs):
super(Roi3DSelectorWidget, self).__init__(*args, **kwargs)
......@@ -107,37 +105,34 @@ class Roi3DSelectorWidget(Qt.QWidget):
class FitWidget(Qt.QWidget):
"""
Fit process widget.
:param qspaceFile:
:param kwargs:
"""Fit process widget.
:param str qspaceFile:
"""
sigFitTypeChanged = Qt.Signal(object)
""" Signal emitted when the fit type is changed
"""
"""Signal emitted when the fit type is changed"""
sigProcessDone = Qt.Signal(object)
""" Signal emitted when a fit is done. Argument is the name of the file
containing the results.
"""Signal emitted when a fit is done.
Argument is the name of the file containing the results.
"""
sigProcessStarted = Qt.Signal()
""" Signal emitted when a fit is started. Argument is the name of the file
containing the results.
"""Signal emitted when a fit is started.
Argument is the name of the file containing the results.
"""
__sigFitDone = Qt.Signal()
__progressDelay = 500
__PROGRESS_DELAY = 500
# TODO : pass the actual roi values
def __init__(self,
qspaceFile,
**kwargs):
def __init__(self, qspaceFile, **kwargs):
super(FitWidget, self).__init__(**kwargs)
self.__qspaceH5 = qspaceH5 = QSpaceH5(qspaceFile)
self.__qspaceH5 = QSpaceH5(qspaceFile)
self.__progTimer = None
self.__outputFile = None
......@@ -185,8 +180,8 @@ class FitWidget(Qt.QWidget):
layout.addRow(self.__statusLabel)
# Set sliders range and step
with qspaceH5:
qDimensions = qspaceH5.qspace_dimension_values
with self.__qspaceH5:
qDimensions = self.__qspaceH5.qspace_dimension_values
for slider, binCenters in zip(self.roiWidget().sliders(), qDimensions):
slider.setPositionCount(len(binCenters) + 1)
......@@ -197,19 +192,20 @@ class FitWidget(Qt.QWidget):
self.__sigFitDone.connect(self.__slotFitDone)
def roiWidget(self):
"""
Returns the Roi3DSelectorWidget instance.
:return:
"""Returns the Roi3DSelectorWidget instance.
:rtype: Roi3DSelectorWidget
"""
return self.__roiWidget
def setQSpaceIndex(self, index):
"""
"""Set slider backgrounds from given QSpace index.
Selects the qspace cube at *index* in the qspace H5 file, and
displays the corresponding profiles in the sliders.
(profile = cube summed along the corresponding axis)
:param index:
:return:
:param int index: QSpace index
"""
qspace = self.__qspaceH5.qspace_slice(index)
dim2_sum = qspace.sum(axis=0).sum(axis=0)
......@@ -230,16 +226,14 @@ class FitWidget(Qt.QWidget):
self.__runButton.setEnabled(outputFile is not None)
def getFitName(self):
"""
Returns the name of the selected fit.
(e.g : Gaussian, Centroid, ...)
:return:
"""Returns the name of the selected fit, e.g., Gaussian, Centroid.
:rtype: str
"""
# TODO : real enum
return self.__fitTypeCb.currentText()
def __slotRunClicked(self):
# TODO : put some safeguards
self.__lock(True)
......@@ -278,7 +272,7 @@ class FitWidget(Qt.QWidget):
try:
self.sigProcessStarted.emit()
self.__fitter.peak_fit(blocking=False, callback=self.__sigFitDone.emit)
self.__progTimer.start(self.__progressDelay)
self.__progTimer.start(self.__PROGRESS_DELAY)
except Exception as ex:
# TODO : popup
self.__statusLabel.setText('ERROR')
......@@ -289,7 +283,7 @@ class FitWidget(Qt.QWidget):
def __slotProgTimer(self):
if self.__fitter:
self.__progBar.setValue(self.__fitter.progress())
self.__progTimer.start(self.__progressDelay)
self.__progTimer.start(self.__PROGRESS_DELAY)
def __lock(self, lock):
enable = not lock
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment