Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/plottools/plottables.py

    r463e7ffc r45dffa69  
    4343# Support for ancient python versions 
    4444import copy 
    45 import numpy 
     45import numpy as np 
    4646import sys 
    4747import logging 
     
    229229            if p.hidden == True: 
    230230                continue 
    231             if not p.x == None: 
     231            if p.x is not None: 
    232232                for x_i in p.x: 
    233                     if min_value == None or x_i < min_value: 
     233                    if min_value is None or x_i < min_value: 
    234234                        min_value = x_i 
    235                     if max_value == None or x_i > max_value: 
     235                    if max_value is None or x_i > max_value: 
    236236                        max_value = x_i 
    237237        return min_value, max_value 
     
    562562        Returns True if there is no data stored in the plottable 
    563563        """ 
    564         if not self.x == None and len(self.x) == 0 \ 
    565             and not self.y == None and len(self.y) == 0: 
     564        if (self.x is not None and len(self.x) == 0 
     565            and self.y is not None and len(self.y) == 0): 
    566566            return True 
    567567        return False 
     
    679679        # Sanity check 
    680680        # Do the transofrmation only when x and y are empty 
    681         has_err_x = not (dx == None or len(dx) == 0) 
    682         has_err_y = not (dy == None or len(dy) == 0) 
    683  
    684         if(x != None) and (y != None): 
    685             if not dx == None and not len(dx) == 0 and not len(x) == len(dx): 
     681        has_err_x = not (dx is None or len(dx) == 0) 
     682        has_err_y = not (dy is None or len(dy) == 0) 
     683 
     684        if(x is not None) and (y is not None): 
     685            if dx is not None and not len(dx) == 0 and not len(x) == len(dx): 
    686686                msg = "Plottable.View: Given x and dx are not" 
    687687                msg += " of the same length" 
     
    693693                raise ValueError, msg 
    694694 
    695             if not dy == None and not len(dy) == 0 and not len(y) == len(dy): 
     695            if dy is not None and not len(dy) == 0 and not len(y) == len(dy): 
    696696                msg = "Plottable.View: Given y and dy are not of the same " 
    697697                msg += "length: len(y)=%s, len(dy)=%s" % (len(y), len(dy)) 
     
    708708                self.dy = None 
    709709            if not has_err_x: 
    710                 dx = numpy.zeros(len(x)) 
     710                dx = np.zeros(len(x)) 
    711711            if not has_err_y: 
    712                 dy = numpy.zeros(len(y)) 
     712                dy = np.zeros(len(y)) 
    713713            for i in range(len(x)): 
    714714                try: 
     
    797797        tempy = [] 
    798798        tempdy = [] 
    799         if self.dx == None: 
    800             self.dx = numpy.zeros(len(self.x)) 
    801         if self.dy == None: 
    802             self.dy = numpy.zeros(len(self.y)) 
     799        if self.dx is None: 
     800            self.dx = np.zeros(len(self.x)) 
     801        if self.dy is None: 
     802            self.dy = np.zeros(len(self.y)) 
    803803        if self.xLabel == "log10(x)": 
    804804            for i in range(len(self.x)): 
     
    827827        tempy = [] 
    828828        tempdy = [] 
    829         if self.dx == None: 
    830             self.dx = numpy.zeros(len(self.x)) 
    831         if self.dy == None: 
    832             self.dy = numpy.zeros(len(self.y)) 
     829        if self.dx is None: 
     830            self.dx = np.zeros(len(self.x)) 
     831        if self.dy is None: 
     832            self.dy = np.zeros(len(self.y)) 
    833833        if self.yLabel == "log10(y)": 
    834834            for i in range(len(self.x)): 
     
    860860        tempy = [] 
    861861        tempdy = [] 
    862         if self.dx == None: 
    863             self.dx = numpy.zeros(len(self.x)) 
    864         if self.dy == None: 
    865             self.dy = numpy.zeros(len(self.y)) 
    866         if xmin != None and xmax != None: 
     862        if self.dx is None: 
     863            self.dx = np.zeros(len(self.x)) 
     864        if self.dy is None: 
     865            self.dy = np.zeros(len(self.y)) 
     866        if xmin is not None and xmax is not None: 
    867867            for i in range(len(self.x)): 
    868868                if self.x[i] >= xmin and self.x[i] <= xmax: 
     
    12061206        """ 
    12071207        """ 
    1208         if  self._chisq == None: 
     1208        if  self._chisq is None: 
    12091209            chisqTxt = r'$\chi^2=$' 
    12101210        else: 
     
    12301230 
    12311231def sample_graph(): 
    1232     import numpy as nx 
     1232    import numpy as np 
    12331233 
    12341234    # Construct a simple graph 
    12351235    if False: 
    1236         x = nx.array([1, 2, 3, 4, 5, 6], 'd') 
    1237         y = nx.array([4, 5, 6, 5, 4, 5], 'd') 
    1238         dy = nx.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
     1236        x = np.array([1, 2, 3, 4, 5, 6], 'd') 
     1237        y = np.array([4, 5, 6, 5, 4, 5], 'd') 
     1238        dy = np.array([0.2, 0.3, 0.1, 0.2, 0.9, 0.3]) 
    12391239    else: 
    1240         x = nx.linspace(0, 1., 10000) 
    1241         y = nx.sin(2 * nx.pi * x * 2.8) 
    1242         dy = nx.sqrt(100 * nx.abs(y)) / 100 
     1240        x = np.linspace(0, 1., 10000) 
     1241        y = np.sin(2 * np.pi * x * 2.8) 
     1242        dy = np.sqrt(100 * np.abs(y)) / 100 
    12431243    data = Data1D(x, y, dy=dy) 
    12441244    data.xaxis('distance', 'm') 
Note: See TracChangeset for help on using the changeset viewer.