Ignore:
Timestamp:
May 18, 2017 2:48:06 PM (8 years ago)
Author:
Ricardo M. Ferraz Leal <ricleal@…>
Branches:
master, 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, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7b15990
Parents:
e123eb9
Message:

Added Design by contract

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/manipulations.py

    rb290a9e r46cd1c3  
    787787        return Data1D(x=phi_values[idx], y=phi_bins[idx], dy=phi_err[idx]) 
    788788 
    789 ################################################################################ 
    790789 
    791790class _Sector(object): 
     
    802801    """ 
    803802 
    804     def __init__(self, r_min, r_max, phi_min=0, phi_max=2 * math.pi, nbins=20, base = None): 
     803    def __init__(self, r_min, r_max, phi_min=0, phi_max=2 * math.pi, nbins=20, 
     804                 base=None): 
     805        ''' 
     806        :param base: must be a valid base for an algorithm, i.e., 
     807        a positive number 
     808        ''' 
    805809        self.r_min = r_min 
    806810        self.r_max = r_max 
     
    838842        y_err = np.zeros(self.nbins) 
    839843        x_err = np.zeros(self.nbins) 
    840         y_counts = np.zeros(self.nbins) # Cycle counts (for the mean) 
     844        y_counts = np.zeros(self.nbins)  # Cycle counts (for the mean) 
    841845 
    842846        # Get the min and max into the region: 0 <= phi < 2Pi 
     
    936940                # We take the center of ring area, not radius. 
    937941                # This is more accurate than taking the radial center of ring. 
    938                 #delta_r = (self.r_max - self.r_min) / self.nbins 
    939                 #r_inner = self.r_min + delta_r * i 
    940                 #r_outer = r_inner + delta_r 
    941                 #x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2) 
     942                # delta_r = (self.r_max - self.r_min) / self.nbins 
     943                # r_inner = self.r_min + delta_r * i 
     944                # r_outer = r_inner + delta_r 
     945                # x[i] = math.sqrt((r_inner * r_inner + r_outer * r_outer) / 2) 
    942946                x[i] = x[i] / y_counts[i] 
    943947        y_err[y_err == 0] = np.average(y_err) 
     
    952956        # elif len(y[idx])!= self.nbins: 
    953957        #    print "resulted",self.nbins- len(y[idx]), 
    954         #"empty bin(s) due to tight binning..." 
     958        # "empty bin(s) due to tight binning..." 
    955959        return Data1D(x=x[idx], y=y[idx], dy=y_err[idx], dx=d_x) 
    956960 
Note: See TracChangeset for help on using the changeset viewer.