Changeset 81751c2 in sasmodels


Ignore:
Timestamp:
Oct 25, 2018 4:16:04 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
869fd7b
Parents:
39a06c9
Message:

allow structure factor tests in model file. Refs #822.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • doc/guide/plugin.rst

    r304c775 r81751c2  
    10351035        [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    10361036         0.1, None, None, 120., None, 1.],  # q, F, F^2, R_eff, V, form:shell 
     1037        [{"@S": "hardsphere"}, 0.1, None], 
    10371038    ] 
    10381039 
     
    10561057  effective radius test, but include values for the first two elements, 
    10571058  $<F(q)>$ and $<F^2(q)>$. 
     1059- for testing interaction between form factor and structure factor, specify 
     1060  the structure factor name in the parameters as *{"@S": "name", ...}* with 
     1061  the remaining list of parameters defined by the *P@S* product model. 
    10581062 
    10591063.. _Test_Your_New_Model: 
  • sasmodels/model_test.py

    r39a06c9 r81751c2  
    6464from .kernelcl import use_opencl 
    6565from .kernelcuda import use_cuda 
     66from . import product 
    6667 
    6768# pylint: disable=unused-import 
     
    214215                ({}, [0.001, 0.01, 0.1], [None]*3), 
    215216                ({}, [(0.1, 0.1)]*2, [None]*2), 
    216                 # test that Fq will run 
     217                # test that Fq will run, and return R_eff, V, V_r 
    217218                ({}, 0.1, None, None, None, None, None), 
    218219                ] 
     
    221222            if self.info.tests is not None: 
    222223                tests += self.info.tests 
     224            S_tests = [test for test in tests if '@S' in test[0]] 
     225            P_tests = [test for test in tests if '@S' not in test[0]] 
    223226            try: 
    224227                model = build_model(self.info, dtype=self.dtype, 
    225228                                    platform=self.platform) 
    226                 results = [self.run_one(model, test) for test in tests] 
     229                results = [self.run_one(model, test) for test in P_tests] 
     230                for test in S_tests: 
     231                    # pull the S model name out of the test defn 
     232                    pars = test[0].copy() 
     233                    s_name = pars.pop('@S') 
     234                    ps_test = [pars] + list(test[1:]) 
     235                    # build the P@S model 
     236                    s_info = load_model_info(s_name) 
     237                    ps_info = product.make_product_info(self.info, s_info) 
     238                    ps_model = build_model(ps_info, dtype=self.dtype, 
     239                                           platform=self.platform) 
     240                    # run the tests 
     241                    results.append(self.run_one(ps_model, ps_test)) 
     242 
    227243                if self.stash: 
    228244                    for test, target, actual in zip(tests, self.stash[0], results): 
  • sasmodels/models/sphere.py

    r304c775 r81751c2  
    8585    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, 
    8686     0.1, None, None, 120., None, 1.0], 
     87    [{"@S": "hardsphere"}, 0.1, None], 
    8788] 
Note: See TracChangeset for help on using the changeset viewer.