Ignore:
Timestamp:
Sep 22, 2017 4:01:32 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
34d7b35
Parents:
9706d88
Message:

convert sascalc to python 2/3 syntax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/invariant/invariant.py

    rb1f20d1 r574adc7  
    424424        if not issubclass(data.__class__, LoaderData1D): 
    425425            #Process only data that inherited from DataLoader.Data_info.Data1D 
    426             raise ValueError, "Data must be of type DataLoader.Data1D" 
     426            raise ValueError("Data must be of type DataLoader.Data1D") 
    427427        #from copy import deepcopy 
    428428        new_data = (self._scale * data) - self._background 
     
    484484            msg = "Length x and y must be equal" 
    485485            msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 
    486             raise ValueError, msg 
     486            raise ValueError(msg) 
    487487        else: 
    488488            # Take care of smeared data 
     
    507507                #iterate between for element different 
    508508                #from the first and the last 
    509                 for i in xrange(1, n - 1): 
     509                for i in range(1, n - 1): 
    510510                    dxi = (data.x[i + 1] - data.x[i - 1]) / 2 
    511511                    total += gx[i] * data.y[i] * dxi 
     
    533533            msg = "Length of data.x and data.y must be equal" 
    534534            msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 
    535             raise ValueError, msg 
     535            raise ValueError(msg) 
    536536        else: 
    537537            #Create error for data without dy error 
     
    560560                #iterate between for element different 
    561561                #from the first and the last 
    562                 for i in xrange(1, n - 1): 
     562                for i in range(1, n - 1): 
    563563                    dxi = (data.x[i + 1] - data.x[i - 1]) / 2 
    564564                    total += (gx[i] * dy[i] * dxi) ** 2 
     
    742742        range = range.lower() 
    743743        if range not in ['high', 'low']: 
    744             raise ValueError, "Extrapolation range should be 'high' or 'low'" 
     744            raise ValueError("Extrapolation range should be 'high' or 'low'") 
    745745        function = function.lower() 
    746746        if function not in ['power_law', 'guinier']: 
    747747            msg = "Extrapolation function should be 'guinier' or 'power_law'" 
    748             raise ValueError, msg 
     748            raise ValueError(msg) 
    749749 
    750750        if range == 'high': 
    751751            if function != 'power_law': 
    752752                msg = "Extrapolation only allows a power law at high Q" 
    753                 raise ValueError, msg 
     753                raise ValueError(msg) 
    754754            self._high_extrapolation_npts = npts 
    755755            self._high_extrapolation_power = power 
     
    852852        """ 
    853853        if contrast <= 0: 
    854             raise ValueError, "The contrast parameter must be greater than zero" 
     854            raise ValueError("The contrast parameter must be greater than zero") 
    855855 
    856856        # Make sure Q star is up to date 
     
    859859        if self._qstar <= 0: 
    860860            msg = "Invalid invariant: Invariant Q* must be greater than zero" 
    861             raise RuntimeError, msg 
     861            raise RuntimeError(msg) 
    862862 
    863863        # Compute intermediate constant 
     
    869869        if discrim < 0: 
    870870            msg = "Could not compute the volume fraction: negative discriminant" 
    871             raise RuntimeError, msg 
     871            raise RuntimeError(msg) 
    872872        elif discrim == 0: 
    873873            return 1 / 2 
     
    881881                return volume2 
    882882            msg = "Could not compute the volume fraction: inconsistent results" 
    883             raise RuntimeError, msg 
     883            raise RuntimeError(msg) 
    884884 
    885885    def get_qstar_with_error(self, extrapolation=None): 
Note: See TracChangeset for help on using the changeset viewer.