Changeset 17bbadd in sasmodels for sasmodels/model_test.py


Ignore:
Timestamp:
Mar 15, 2016 10:47:12 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:
754e27b
Parents:
5ceb7d0
Message:

refactor so all model defintion queries use model_info; better documentation of model_info structure; initial implementation of product model (broken)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    r13ed84c r17bbadd  
    5050import numpy as np 
    5151 
    52 from .core import list_models, load_model_definition, load_model, HAVE_OPENCL 
     52from .core import list_models, load_model_info, build_model, HAVE_OPENCL 
    5353from .core import make_kernel, call_kernel, call_ER, call_VR 
    5454from .exception import annotate_exception 
    5555 
     56#TODO: rename to tests so that tab completion works better for models directory 
    5657 
    5758def make_suite(loaders, models): 
     
    7677    for model_name in models: 
    7778        if model_name in skip: continue 
    78         model_definition = load_model_definition(model_name) 
     79        model_info = load_model_info(model_name) 
    7980 
    8081        #print('------') 
     
    8586        # don't try to call cl kernel since it will not be 
    8687        # available in some environmentes. 
    87         is_py = callable(getattr(model_definition, 'Iq', None)) 
     88        is_py = callable(model_info['Iq']) 
    8889 
    8990        if is_py:  # kernel implemented in python 
    9091            test_name = "Model: %s, Kernel: python"%model_name 
    9192            test_method_name = "test_%s_python" % model_name 
    92             test = ModelTestCase(test_name, model_definition, 
     93            test = ModelTestCase(test_name, model_info, 
    9394                                 test_method_name, 
    9495                                 platform="dll",  # so that 
     
    104105                # single precision.  The choice is determined by the 
    105106                # presence of *single=False* in the model file. 
    106                 test = ModelTestCase(test_name, model_definition, 
     107                test = ModelTestCase(test_name, model_info, 
    107108                                     test_method_name, 
    108109                                     platform="ocl", dtype=None) 
     
    114115                test_name = "Model: %s, Kernel: dll"%model_name 
    115116                test_method_name = "test_%s_dll" % model_name 
    116                 test = ModelTestCase(test_name, model_definition, 
     117                test = ModelTestCase(test_name, model_info, 
    117118                                     test_method_name, 
    118119                                     platform="dll", 
     
    132133        description file. 
    133134        """ 
    134         def __init__(self, test_name, definition, test_method_name, 
     135        def __init__(self, test_name, model_info, test_method_name, 
    135136                     platform, dtype): 
    136137            self.test_name = test_name 
    137             self.definition = definition 
     138            self.info = model_info 
    138139            self.platform = platform 
    139140            self.dtype = dtype 
     
    150151                ] 
    151152 
    152             tests = getattr(self.definition, 'tests', []) 
     153            tests = self.info['tests'] 
    153154            try: 
    154                 model = load_model(self.definition, dtype=self.dtype, 
    155                                    platform=self.platform) 
     155                model = build_model(self.info, dtype=self.dtype, 
     156                                    platform=self.platform) 
    156157                for test in smoke_tests + tests: 
    157158                    self._run_one_test(model, test) 
Note: See TracChangeset for help on using the changeset viewer.