Changeset 40a87fa in sasmodels for sasmodels/kernelpy.py


Ignore:
Timestamp:
Aug 8, 2016 9:24:11 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2472141
Parents:
2d65d51
Message:

lint and latex cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelpy.py

    r32e3c9b r40a87fa  
    143143        if q_input.is_2d: 
    144144            form = model_info.Iqxy 
    145             qx, qy = q_input.q[:,0], q_input.q[:,1] 
     145            qx, qy = q_input.q[:, 0], q_input.q[:, 1] 
    146146            self._form = lambda: form(qx, qy, *kernel_args) 
    147147        else: 
     
    168168        self.q_input = None 
    169169 
    170 def _loops(parameters, form, form_volume, nq, details, 
    171            values, cutoff): 
     170def _loops(parameters, form, form_volume, nq, call_details, values, cutoff): 
    172171    # type: (np.ndarray, Callable[[], np.ndarray], Callable[[], float], int, details.CallDetails, np.ndarray, np.ndarray, float) -> None 
    173172    ################################################################ 
     
    180179    #                                                              # 
    181180    ################################################################ 
    182     NPARS = len(parameters) 
    183     parameters[:] = values[2:NPARS+2] 
     181    n_pars = len(parameters) 
     182    parameters[:] = values[2:n_pars+2] 
    184183    scale, background = values[0], values[1] 
    185     if details.num_active == 0: 
     184    if call_details.num_active == 0: 
    186185        norm = float(form_volume()) 
    187186        if norm > 0.0: 
     
    190189            return np.ones(nq, 'd')*background 
    191190 
    192     pd_value = values[2+NPARS:2+NPARS+details.pd_sum] 
    193     pd_weight = values[2+NPARS+details.pd_sum:] 
     191    pd_value = values[2+n_pars:2+n_pars + call_details.pd_sum] 
     192    pd_weight = values[2+n_pars + call_details.pd_sum:] 
    194193 
    195194    pd_norm = 0.0 
    196195    spherical_correction = 1.0 
    197196    partial_weight = np.NaN 
    198     weight =np.NaN 
    199  
    200     p0_par = details.pd_par[0] 
    201     p0_is_theta = (p0_par == details.theta_par) 
    202     p0_length = details.pd_length[0] 
     197    weight = np.NaN 
     198 
     199    p0_par = call_details.pd_par[0] 
     200    p0_is_theta = (p0_par == call_details.theta_par) 
     201    p0_length = call_details.pd_length[0] 
    203202    p0_index = p0_length 
    204     p0_offset = details.pd_offset[0] 
    205  
    206     pd_par = details.pd_par[:details.num_active] 
    207     pd_offset = details.pd_offset[:details.num_active] 
    208     pd_stride = details.pd_stride[:details.num_active] 
    209     pd_length = details.pd_length[:details.num_active] 
     203    p0_offset = call_details.pd_offset[0] 
     204 
     205    pd_par = call_details.pd_par[:call_details.num_active] 
     206    pd_offset = call_details.pd_offset[:call_details.num_active] 
     207    pd_stride = call_details.pd_stride[:call_details.num_active] 
     208    pd_length = call_details.pd_length[:call_details.num_active] 
    210209 
    211210    total = np.zeros(nq, 'd') 
    212     for loop_index in range(details.pd_prod): 
     211    for loop_index in range(call_details.pd_prod): 
    213212        # update polydispersity parameter values 
    214213        if p0_index == p0_length: 
     
    216215            parameters[pd_par] = pd_value[pd_offset+pd_index] 
    217216            partial_weight = np.prod(pd_weight[pd_offset+pd_index][1:]) 
    218             if details.theta_par >= 0: 
    219                 spherical_correction = max(abs(cos(pi/180 * parameters[details.theta_par])), 1e-6) 
     217            if call_details.theta_par >= 0: 
     218                cor = cos(pi / 180 * parameters[call_details.theta_par]) 
     219                spherical_correction = max(abs(cor), 1e-6) 
    220220            p0_index = loop_index%p0_length 
    221221 
     
    223223        parameters[p0_par] = pd_value[p0_offset + p0_index] 
    224224        if p0_is_theta: 
    225             spherical_correction = max(abs(cos(pi/180 * parameters[p0_par])), 1e-6) 
     225            cor = cos(pi/180 * parameters[p0_par]) 
     226            spherical_correction = max(abs(cor), 1e-6) 
    226227        p0_index += 1 
    227228        if weight > cutoff: 
     
    230231            # exclude all q for that NaN.  Even better would be to have an 
    231232            # INVALID expression like the C models, but that is too expensive. 
    232             I = form() 
    233             if np.isnan(I).any(): continue 
     233            Iq = form() 
     234            if np.isnan(Iq).any(): continue 
    234235 
    235236            # update value and norm 
    236237            weight *= spherical_correction 
    237             total += weight * I 
     238            total += weight * Iq 
    238239            pd_norm += weight * form_volume() 
    239240 
Note: See TracChangeset for help on using the changeset viewer.