Changeset 5251ec6 in sasview for src/sas/sasgui/perspectives/calculator/data_operator.py
- Timestamp:
- Oct 11, 2018 12:20:56 PM (6 years ago)
- Branches:
- master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
- Children:
- 98b9f32
- Parents:
- 67ed543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/calculator/data_operator.py
r7432acb r5251ec6 202 202 else: 203 203 text = name 204 state_list = self.get_datalist().values()205 204 name_list = [] 206 for state in s tate_list:205 for state in self.get_datalist().values(): 207 206 if state.data is None: 208 207 theory_list = state.get_theory() 209 theory, _ = theory_list.values()[0]208 theory, _ = list(theory_list.values())[0] 210 209 d_name = str(theory.name) 211 210 else: … … 393 392 try: 394 393 self.output = self.make_data_out(data1, data2) 395 except :394 except Exception as exc: 396 395 self._check_newname() 397 396 self._set_textctrl_color(self.data1_cbox, 'pink') 398 397 self._set_textctrl_color(self.data2_cbox, 'pink') 399 msg = "DataOperation: %s" % sys.exc_value398 msg = "DataOperation: %s" % exc 400 399 self.send_warnings(msg, 'error') 401 400 self.output = None … … 411 410 operator = self.operator_cbox.GetClientData(pos) 412 411 try: 413 exec "output = data1 %s data2" % operator 412 output = eval("data1 %s data2" % operator, 413 {"data1": data1, "data2": data2}) 414 414 except: 415 415 raise … … 532 532 self.data2_cbox.SetClientData(pos3, val) 533 533 dnames = [] 534 ids = self._data.keys() 535 for id in ids: 534 for id in self._data.keys(): 536 535 if id is not None: 537 536 if self._data[id].data is not None: … … 539 538 else: 540 539 theory_list = self._data[id].get_theory() 541 theory, _ = theory_list.values()[0]540 theory, _ = list(theory_list.values())[0] 542 541 dnames.append(theory.name) 543 542 ind = np.argsort(dnames) 544 543 if len(ind) > 0: 545 val_list = np.array( self._data.values())[ind]544 val_list = np.array(list(self._data.values()))[ind] 546 545 for datastate in val_list: 547 546 data = datastate.data … … 588 587 self.send_warnings('') 589 588 self.data_namectr.SetBackgroundColour('white') 590 state_list = self.get_datalist().values()591 589 name = self.data_namectr.GetValue().strip() 592 590 name_list = [] 593 for state in s tate_list:591 for state in self.get_datalist().values(): 594 592 if state.data is None: 595 593 theory_list = state.get_theory() 596 theory, _ = theory_list.values()[0]594 theory, _ = list(theory_list.values())[0] 597 595 d_name = str(theory.name) 598 596 else: … … 889 887 def _onProperties(self, event): 890 888 """ 891 when clicking on Properties on context menu , 892 The Property dialog is displayed 893 The user selects a transformation for x or y value and 894 a new plot is displayed 895 """ 896 list = [] 897 list = self.graph.returnPlottable() 898 if len(list.keys()) > 0: 899 first_item = list.keys()[0] 889 When clicking on Properties on context menu, the 890 Property dialog is displayed the user selects a 891 transformation for x or y value and a new plot is displayed 892 """ 893 plottables = self.graph.returnPlottable() 894 if plottables: 895 # TODO: key order is random prior to py 3.7 896 first_item = list(plottables.keys())[0] 900 897 if first_item.x != []: 901 898 from sas.sasgui.plottools.PropertyDialog import Properties … … 929 926 and set the scale 930 927 """ 931 list = []932 list = self.graph.returnPlottable()933 928 # Changing the scale might be incompatible with 934 929 # currently displayed data (for instance, going … … 940 935 _xscale = 'linear' 941 936 _yscale = 'linear' 942 for item in list:937 for item in self.graph.returnPlottable(): 943 938 item.setLabel(self.xLabel, self.yLabel) 944 939 # control axis labels from the panel itself
Note: See TracChangeset
for help on using the changeset viewer.