Changeset f942f4d in sasmodels


Ignore:
Timestamp:
Mar 28, 2019 10:23:15 AM (6 months ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ticket-1257-vesicle-product, ticket_1156, ticket_822_more_unit_tests
Children:
9562dd2, b39bf3b
Parents:
6652522 (diff), 6dccecc (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ticket_822_v5_unit_tests' of github.com:sasview/sasmodels into ticket_822_v5_unit_tests

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/direct_model.py

    rfacb052 ra7db39fa  
    5959    """ 
    6060    mesh = get_mesh(calculator.info, pars, dim=calculator.dim, mono=mono) 
    61     print("in call_kernel: pars:", list(zip(*mesh))[0]) 
     61    #print("in call_kernel: pars:", list(zip(*mesh))[0]) 
    6262    call_details, values, is_magnetic = make_kernel_args(calculator, mesh) 
    6363    #print("in call_kernel: values:", values) 
     
    118118        active = lambda name: True 
    119119 
    120     print("in get_mesh: pars:",[p.id for p in parameters.call_parameters]) 
     120    #print("in get_mesh: pars:",[p.id for p in parameters.call_parameters]) 
    121121    mesh = [_get_par_weights(p, values, active(p.name)) 
    122122            for p in parameters.call_parameters] 
  • sasmodels/model_test.py

    r6652522 rf942f4d  
    240240                    s_name = pars.pop('@S') 
    241241                    ps_test = [pars] + list(test[1:]) 
     242                    #print("PS TEST PARAMS!!!",ps_test) 
    242243                    # build the P@S model 
    243244                    s_info = load_model_info(s_name) 
    244                     #print("in run_all: s_info:", s_info) 
    245245                    ps_info = product.make_product_info(self.info, s_info) 
    246246                    ps_model = build_model(ps_info, dtype=self.dtype, 
    247247                                           platform=self.platform) 
    248248                    # run the tests 
     249                    self.info = ps_model.info 
     250                    #print("SELF.INFO PARAMS!!!",[p.id for p in self.info.parameters.call_parameters]) 
     251                    #print("PS MODEL PARAMETERS:",[p.id for p in ps_model.info.parameters.call_parameters]) 
    249252                    results.append(self.run_one(ps_model, ps_test)) 
    250253 
     
    397400        if par == product.STRUCTURE_MODE_ID: 
    398401            continue 
    399         if par == "radius_effective":    # test should not need this?? 
    400             continue 
    401402        parts = par.split('_pd') 
    402403        if len(parts) > 1 and parts[1] not in ("", "_n", "nsigma", "type"): 
  • sasmodels/models/cylinder.py

    r0b8a1fc r6652522  
    110110---------------------------- 
    111111 
    112 * **Author:**  
    113 * **Last Modified by:**  
    114 * **Last Reviewed by:**  
     112* **Author:** 
     113* **Last Modified by:** 
     114* **Last Reviewed by:** 
    115115* **Source added by :** Steve King **Date:** March 25, 2019 
    116116""" 
     
    184184            phi_pd=10, phi_pd_n=5) 
    185185 
    186 # pylint: disable=bad-whitespace, line-too-long 
     186# Test 1-D and 2-D models 
    187187qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    188 # After redefinition of angles, find new tests values.  Was 10 10 in old coords 
     188theta, phi = 80.1534480601659, 10.1510817110481  # (10, 10) in sasview 3.x 
    189189tests = [ 
    190190    [{}, 0.2, 0.042761386790780453], 
    191191    [{}, [0.2], [0.042761386790780453]], 
    192     #  new coords 
    193     [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
    194     [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
    195     # old coords 
    196     #[{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
    197     #[{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
     192    [{'theta': theta, 'phi': phi}, (qx, qy), 0.03514647218513852], 
     193    [{'theta': theta, 'phi': phi}, [(qx, qy)], [0.03514647218513852]], 
    198194] 
    199 del qx, qy  # not necessary to delete, but cleaner 
    200  
    201 # Default radius and length 
    202 def calc_volume(radius, length): 
    203     """Return form volume for cylinder.""" 
    204     return pi*radius**2*length 
    205 def calc_r_effs(radius, length): 
    206     """Return effective radii for modes 0-7 of cylinder.""" 
    207     return [ 
     195del qx, qy, theta, phi  # not necessary to delete, but cleaner 
     196 
     197def _extend_with_reff_tests(radius, length): 
     198    """Test R_eff and form volume calculations""" 
     199    # V and Vr are the same for each R_eff mode 
     200    V = pi*radius**2*length  # shell volume = form volume for solid objects 
     201    Vr = 1.0  # form:shell volume ratio 
     202    # Use test value for I(0.2) from above to check Fsq value.  Need to 
     203    # remove scale and background before testing. 
     204    q = 0.2 
     205    scale, background = V, 0.001 
     206    Fsq = (0.042761386790780453 - background)*scale 
     207    F = None  # Need target value for <F> 
     208    # Various values for R_eff, depending on mode 
     209    r_effs = [ 
    208210        0., 
    209211        0.5*(0.75*radius*(2.0*radius*length 
     
    216218        np.sqrt(4*radius**2 + length**2)/2., 
    217219    ] 
    218 r_effs = calc_r_effs(parameters[2][2], parameters[3][2]) 
    219 cyl_vol = calc_volume(parameters[2][2], parameters[3][2]) 
    220 #tests.extend([ 
    221 #    ({'effective_radius_type': 0}, 0.1, 667.7347318577124, 1.0000, r_effs[0], cyl_vol, 1.0), 
    222      # first & second None do not work here, replacind 2nd Non by real number gives error also 
    223 #    ({'effective_radius_type': 1}, 0.1, None, None, r_effs[1], None, None), 
    224 #    ({'effective_radius_type': 2}, 0.1, None, None, r_effs[2], None, None), 
    225 #   ({'effective_radius_type': 3}, 0.1, None, None, r_effs[3], None, None), 
    226 #    ({'effective_radius_type': 4}, 0.1, None, None, r_effs[4], None, None), 
    227 #    ({'effective_radius_type': 5}, 0.1, None, None, r_effs[5], None, None), 
    228 #    ({'effective_radius_type': 6}, 0.1, None, None, r_effs[6], None, None), 
    229 #    ({'effective_radius_type': 7}, 0.1, None, None, r_effs[7], None, None), 
    230 #]) 
    231 del r_effs, cyl_vol 
    232 # pylint: enable=bad-whitespace, line-too-long 
     220    tests.extend([ 
     221        ({'radius_effective_mode': 0}, q, F, Fsq, r_effs[0], V, Vr), 
     222        ({'radius_effective_mode': 1}, q, F, Fsq, r_effs[1], V, Vr), 
     223        ({'radius_effective_mode': 2}, q, F, Fsq, r_effs[2], V, Vr), 
     224        ({'radius_effective_mode': 3}, q, F, Fsq, r_effs[3], V, Vr), 
     225        ({'radius_effective_mode': 4}, q, F, Fsq, r_effs[4], V, Vr), 
     226        ({'radius_effective_mode': 5}, q, F, Fsq, r_effs[5], V, Vr), 
     227        ({'radius_effective_mode': 6}, q, F, Fsq, r_effs[6], V, Vr), 
     228        ({'radius_effective_mode': 7}, q, F, Fsq, r_effs[7], V, Vr), 
     229    ]) 
     230 
     231# Test Reff and volume with default model parameters 
     232_extend_with_reff_tests(parameters[2][2], parameters[3][2]) 
     233del _extend_with_reff_tests 
    233234 
    234235# ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc 
Note: See TracChangeset for help on using the changeset viewer.