Skip to content

Commit 74c455a

Browse files
caitwolfCaitlyn Wolf
authored andcommitted
cleaning up code included extra spaces and commented sections
1 parent bdd88a0 commit 74c455a

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__()
@@ -130,13 +130,11 @@ def onClose(self):
130130
self.cbData2.addItems(['No Data Available'])
131131
self.close()
132132

133-
134133
def onCompute(self):
135134
""" perform calculation - don't send to data explorer"""
136135
# set operator to be applied
137136
operator = self.cbOperator.currentText()
138137
# calculate and send data to DataExplorer
139-
output = None
140138
if self.data1 is None or self.data2 is None:
141139
logging.warning("Please set both Data1 and Data2 to complete operation.")
142140
try:
@@ -182,8 +180,7 @@ def onPrepareOutputData(self):
182180
self.output,
183181
name=name)
184182

185-
new_datalist_item = {name + str(time.time()):
186-
self.output}
183+
new_datalist_item = {name + str(time.time()): self.output}
187184
self.communicator. \
188185
updateModelFromDataOperationPanelSignal.emit(new_item, new_datalist_item)
189186

@@ -228,7 +225,7 @@ def onSelectData1(self):
228225
self.newPlot(self.graphData1, self.layoutData1)
229226
self.data1 = None
230227
self.data1OK = False
231-
self.cmdCompute.setEnabled(False) # self.onCheckChosenData())
228+
self.cmdCompute.setEnabled(False) # self.onCheckChosenData())
232229
return
233230

234231
else:
@@ -286,7 +283,6 @@ def onSelectData2(self):
286283
else:
287284
self.cautionStatement.setText("")
288285

289-
290286
def onInputCoefficient(self):
291287
""" Check input of number when a coefficient is required
292288
for operation """
@@ -330,12 +326,12 @@ def onCheckChosenData(self):
330326

331327
elif self.data1.__class__.__name__ == 'Data2D' \
332328
and (len(self.data2.qx_data) != len(self.data1.qx_data) \
333-
or len(self.data2.qy_data) != len(self.data1.qy_data)
334-
or not all(i == j for i, j in
335-
zip(self.data1.qx_data, self.data2.qx_data))
336-
or not all(i == j for i, j in
337-
zip(self.data1.qy_data, self.data2.qy_data))
338-
):
329+
or len(self.data2.qy_data) != len(self.data1.qy_data)
330+
or not all(i == j for i, j in
331+
zip(self.data1.qx_data, self.data2.qx_data))
332+
or not all(i == j for i, j in
333+
zip(self.data1.qy_data, self.data2.qy_data))
334+
):
339335
self.cbData1.setStyleSheet(BG_RED)
340336
self.cbData2.setStyleSheet(BG_RED)
341337
logging.error('Cannot compute 2D data of different lengths')
@@ -441,28 +437,10 @@ def operationData1D(self, operation_data, reference_data=None):
441437
new_operation_data.dy = np.zeros(2)
442438
new_operation_data.dx = np.zeros(2)
443439
else:
444-
try:
445-
new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None)
446-
new_operation_data.copy_from_datainfo(data1d=operation_data)
447-
except:
448-
new_operation_data = None
449-
440+
new_operation_data = Data1D(x=operation_data.x, y=operation_data.y, dy=operation_data.dy, dx=None)
441+
new_operation_data.copy_from_datainfo(data1d=operation_data)
450442
return new_operation_data
451443

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

@@ -540,7 +518,7 @@ def updatePlot(self, graph, layout, data, color=None, operation_data=False):
540518
hide_error=True, marker='o', color=DATA2_COLOR,
541519
markerfacecolor=None, markeredgecolor=None)
542520
plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor,
543-
markeredgecolor=markeredgecolor)
521+
markeredgecolor=markeredgecolor)
544522
else:
545523
plotter.plot(data=data, hide_error=True, marker='o', color=color, markerfacecolor=markerfacecolor,
546524
markeredgecolor=markeredgecolor, alpha=alpha)

0 commit comments

Comments
 (0)