Ignore:
Timestamp:
Oct 11, 2018 12:20:56 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1249
Children:
98b9f32
Parents:
67ed543
Message:

improved support for py37 in sasgui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/calculator/data_operator.py

    r7432acb r5251ec6  
    202202        else: 
    203203            text = name 
    204         state_list = self.get_datalist().values() 
    205204        name_list = [] 
    206         for state in state_list: 
     205        for state in self.get_datalist().values(): 
    207206            if state.data is None: 
    208207                theory_list = state.get_theory() 
    209                 theory, _ = theory_list.values()[0] 
     208                theory, _ = list(theory_list.values())[0] 
    210209                d_name = str(theory.name) 
    211210            else: 
     
    393392        try: 
    394393            self.output = self.make_data_out(data1, data2) 
    395         except: 
     394        except Exception as exc: 
    396395            self._check_newname() 
    397396            self._set_textctrl_color(self.data1_cbox, 'pink') 
    398397            self._set_textctrl_color(self.data2_cbox, 'pink') 
    399             msg = "DataOperation: %s" % sys.exc_value 
     398            msg = "DataOperation: %s" % exc 
    400399            self.send_warnings(msg, 'error') 
    401400            self.output = None 
     
    411410        operator = self.operator_cbox.GetClientData(pos) 
    412411        try: 
    413             exec "output = data1 %s data2" % operator 
     412            output = eval("data1 %s data2" % operator, 
     413                          {"data1": data1, "data2": data2}) 
    414414        except: 
    415415            raise 
     
    532532        self.data2_cbox.SetClientData(pos3, val) 
    533533        dnames = [] 
    534         ids = self._data.keys() 
    535         for id in ids: 
     534        for id in self._data.keys(): 
    536535            if id is not None: 
    537536                if self._data[id].data is not None: 
     
    539538                else: 
    540539                    theory_list = self._data[id].get_theory() 
    541                     theory, _ = theory_list.values()[0] 
     540                    theory, _ = list(theory_list.values())[0] 
    542541                    dnames.append(theory.name) 
    543542        ind = np.argsort(dnames) 
    544543        if len(ind) > 0: 
    545             val_list = np.array(self._data.values())[ind] 
     544            val_list = np.array(list(self._data.values()))[ind] 
    546545            for datastate in val_list: 
    547546                data = datastate.data 
     
    588587        self.send_warnings('') 
    589588        self.data_namectr.SetBackgroundColour('white') 
    590         state_list = self.get_datalist().values() 
    591589        name = self.data_namectr.GetValue().strip() 
    592590        name_list = [] 
    593         for state in state_list: 
     591        for state in self.get_datalist().values(): 
    594592            if state.data is None: 
    595593                theory_list = state.get_theory() 
    596                 theory, _ = theory_list.values()[0] 
     594                theory, _ = list(theory_list.values())[0] 
    597595                d_name = str(theory.name) 
    598596            else: 
     
    889887    def _onProperties(self, event): 
    890888        """ 
    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] 
    900897            if first_item.x != []: 
    901898                from sas.sasgui.plottools.PropertyDialog import Properties 
     
    929926        and set the scale 
    930927        """ 
    931         list = [] 
    932         list = self.graph.returnPlottable() 
    933928        # Changing the scale might be incompatible with 
    934929        # currently displayed data (for instance, going 
     
    940935        _xscale = 'linear' 
    941936        _yscale = 'linear' 
    942         for item in list: 
     937        for item in self.graph.returnPlottable(): 
    943938            item.setLabel(self.xLabel, self.yLabel) 
    944939            # control axis labels from the panel itself 
Note: See TracChangeset for help on using the changeset viewer.