Skip to content

Commit 585c81c

Browse files
committed
cleaning up code included extra spaces and commented sections
1 parent 492cbe5 commit 585c81c

File tree

1 file changed

+12
-34
lines changed

1 file changed

+12
-34
lines changed

src/sas/qtgui/Calculators/DataOperationUtilityPanel.py

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from PySide6 import QtGui
88
from PySide6 import QtWidgets
99
import numpy as np
10-
from typing import Optional
1110

1211
from sas.qtgui.Plotting.PlotterData import Data1D
1312
from sas.qtgui.Plotting.Plotter import PlotterWidget
@@ -27,6 +26,7 @@
2726
TRIMMED_COLOR = '#FFFFFF' # white
2827
TRIMMED_ALPHA = 0.3 # semi-transparent points trimmed for operation
2928

29+
3030
class DataOperationUtilityPanel(QtWidgets.QDialog, Ui_DataOperationUtility):
3131
def __init__(self, parent=None):
3232
super(DataOperationUtilityPanel, self).__init__()
@@ -132,13 +132,11 @@ def onClose(self):
132132
self.cbData2.addItems(['No Data Available'])
133133
self.close()
134134

135-
136135
def onCompute(self):
137136
""" perform calculation - don't send to data explorer"""
138137
# set operator to be applied
139138
operator = self.cbOperator.currentText()
140139
# calculate and send data to DataExplorer
141-
output = None
142140
if self.data1 is None or self.data2 is None:
143141
logging.warning("Please set both Data1 and Data2 to complete operation.")
144142
try:
@@ -184,8 +182,7 @@ def onPrepareOutputData(self):
184182
self.output,
185183
name=name)
186184

187-
new_datalist_item = {name + str(time.time()):
188-
self.output}
185+
new_datalist_item = {name + str(time.time()): self.output}
189186
self.communicator. \
190187
updateModelFromDataOperationPanelSignal.emit(new_item, new_datalist_item)
191188

@@ -230,7 +227,7 @@ def onSelectData1(self):
230227
self.newPlot(self.graphData1, self.layoutData1)
231228
self.data1 = None
232229
self.data1OK = False
233-
self.cmdCompute.setEnabled(False) # self.onCheckChosenData())
230+
self.cmdCompute.setEnabled(False) # self.onCheckChosenData())
234231
return
235232

236233
else:
@@ -288,7 +285,6 @@ def onSelectData2(self):
288285
else:
289286
self.cautionStatement.setText("")
290287

291-
292288
def onInputCoefficient(self):
293289
""" Check input of number when a coefficient is required
294290
for operation """
@@ -332,12 +328,12 @@ def onCheckChosenData(self):
332328

333329
elif self.data1.__class__.__name__ == 'Data2D' \
334330
and (len(self.data2.qx_data) != len(self.data1.qx_data) \
335-
or len(self.data2.qy_data) != len(self.data1.qy_data)
336-
or not all(i == j for i, j in
337-
zip(self.data1.qx_data, self.data2.qx_data))
338-
or not all(i == j for i, j in
339-
zip(self.data1.qy_data, self.data2.qy_data))
340-
):
331+
or len(self.data2.qy_data) != len(self.data1.qy_data)
332+
or not all(i == j for i, j in
333+
zip(self.data1.qx_data, self.data2.qx_data))
334+
or not all(i == j for i, j in
335+
zip(self.data1.qy_data, self.data2.qy_data))
336+
):
341337
self.cbData1.setStyleSheet(BG_RED)
342338
self.cbData2.setStyleSheet(BG_RED)
343339
logging.error('Cannot compute 2D data of different lengths')
@@ -443,28 +439,10 @@ def operationData1D(self, operation_data, reference_data=None):
443439
new_operation_data.dy = np.zeros(2)
444440
new_operation_data.dx = np.zeros(2)
445441
else:
446-
try:
447-
new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None)
448-
new_operation_data.copy_from_datainfo(data1d=operation_data)
449-
except:
450-
new_operation_data = None
451-
442+
new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None)
443+
new_operation_data.copy_from_datainfo(data1d=operation_data)
452444
return new_operation_data
453445

454-
# for d_op, c_op in zip(data_op, color_op):
455-
# if isinstance(d_op, Data1D):
456-
# op_data = Data1D(x=d_op._operation.x, y=d_op._operation.y, dy=d_op._operation.dy, dx=None)
457-
# op_data.copy_from_datainfo(data1d=d_op._operation)
458-
# plotter.plot(data=op_data, hide_error=True, marker='.', color=c_op)
459-
# else:
460-
# op_data = Data1D(2)
461-
# op_data.copy_from_datainfo(data1d=data)
462-
# op_data.x = np.array([data.x.min(), data.x.max()])
463-
# op_data.y = np.array([d_op, d_op])
464-
# op_data.dy = np.zeros(2)
465-
# op_data.dx = np.zeros(2)
466-
# plotter.plot(data=op_data, hide_error=True, marker='-', color=c_op)
467-
468446
def updatePlot(self, graph, layout, data, color=None, operation_data=False):
469447
""" plot data in graph after clearing its layout """
470448

@@ -542,7 +520,7 @@ def updatePlot(self, graph, layout, data, color=None, operation_data=False):
542520
hide_error=True, marker='o', color=DATA2_COLOR,
543521
markerfacecolor=None, markeredgecolor=None)
544522
plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor,
545-
markeredgecolor=markeredgecolor)
523+
markeredgecolor=markeredgecolor)
546524
else:
547525
plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor,
548526
markeredgecolor=markeredgecolor, alpha=alpha)

0 commit comments

Comments
 (0)