Changeset 6fd4e36 in sasview for src/sas/qtgui/PlotUtilities.py


Ignore:
Timestamp:
Mar 28, 2017 6:53:29 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
0268aed
Parents:
a9b568c
Message:

Chi2 display + minor refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/PlotUtilities.py

    r239214f r6fd4e36  
    11import sys 
    22import numpy 
     3import string 
     4 
    35from collections import OrderedDict 
    46 
     
    7577    # get histogram of data, all points into a bin in a way of summing 
    7678    image, xedges, yedges = numpy.histogram2d(x=qy_data, 
    77                                                 y=qx_data, 
    78                                                 bins=[y_bins, x_bins], 
    79                                                 weights=data) 
     79                                              y=qx_data, 
     80                                              bins=[y_bins, x_bins], 
     81                                              weights=data) 
    8082    # Now, normalize the image by weights only for weights>1: 
    8183    # If weight == 1, there is only one data point in the bin so 
     
    264266    ''' 
    265267 
    266     if color is not None: 
    267         # Check if it's an int 
    268         if isinstance(color, int): 
    269             # Check if it's within the range 
    270             if 0 <= color <=6: 
    271                 color = COLORS.values()[color] 
    272         # Check if it's an RGB string 
    273         elif isinstance(color, str): 
    274             # Assure the correctnes of the string 
    275             assert(color[0]=="#" and len(color) == 7) 
    276             import string 
    277             assert(all(c in string.hexdigits for c in color[1:])) 
    278         else: 
    279             raise AttributeError 
     268    if color is None: 
     269        return color 
     270 
     271    # Check if it's an int 
     272    if isinstance(color, int): 
     273        # Check if it's within the range 
     274        if 0 <= color <=6: 
     275            color = COLORS.values()[color] 
     276    # Check if it's an RGB string 
     277    elif isinstance(color, str): 
     278        # Assure the correctnes of the string 
     279        assert(color[0]=="#" and len(color) == 7) 
     280        assert(all(c in string.hexdigits for c in color[1:])) 
     281    else: 
     282        raise AttributeError 
    280283 
    281284    return color 
Note: See TracChangeset for help on using the changeset viewer.