Changeset 4c2c535 in sasmodels


Ignore:
Timestamp:
Dec 21, 2015 10:26:36 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:
cade620
Parents:
c138211
Message:

return NAN to signal invalid kernel parameters (for python as well)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernelpy.py

    r9404dd3 r4c2c535  
    203203            args[pd_index[0]] = fast_value[fast_index] 
    204204            weight[0] = fast_weight[fast_index] 
    205         # This computes the weight, and if it is sufficient, calls the 
    206         # scattering function and adds it to the total.  If there is a volume 
    207         # normalization, it will also be added here. 
    208         # Note: make sure this is consistent with the code in PY_LOOP_BODY!! 
    209         # Note: can precompute w1*w2*...*wn 
     205 
     206        # Computes the weight, and if it is not sufficient then ignore this 
     207        # parameter set. 
     208        # Note: could precompute w1*...*wn so we only need to multiply by w0 
    210209        w = np.prod(weight) 
    211210        if w > cutoff: 
    212             I = form(*args) 
    213             #positive = (I >= 0.0) 
    214  
    215211            # Note: can precompute spherical correction if theta_index is not 
    216212            # the fast index. Correction factor for spherical integration 
     
    219215                                    if theta_index >= 0 else 1.0) 
    220216            #spherical_correction = 1.0 
    221             ret += w * I * spherical_correction #* positive 
    222             norm += w #* positive 
     217 
     218            # Call the scattering function and adds it to the total. 
     219            I = form(*args) 
     220            if np.isnan(I).any(): continue 
     221            ret += w * I * spherical_correction 
     222            norm += w 
    223223 
    224224            # Volume normalization. 
     
    230230                vol_args = [args[index] for index in vol_index] 
    231231                vol_weight = np.prod(weight[vol_weight_index]) 
    232                 vol += vol_weight * form_volume(*vol_args) #* positive 
    233                 vol_norm += vol_weight #* positive 
     232                vol += vol_weight * form_volume(*vol_args) 
     233                vol_norm += vol_weight 
    234234 
    235235    positive = (vol * vol_norm != 0.0) 
Note: See TracChangeset for help on using the changeset viewer.