Changeset 3221de0 in sasmodels for sasmodels/model_test.py


Ignore:
Timestamp:
Feb 1, 2018 9:40:30 AM (6 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:
b4272a2
Parents:
b3af1c2
Message:

restructure handling of opencl flags so it works with sasview

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/model_test.py

    rf354e46 r3221de0  
    6262from .exception import annotate_exception 
    6363from .modelinfo import expand_pars 
     64from .kernelcl import use_opencl 
    6465 
    6566# pylint: disable=unused-import 
     
    134135 
    135136            # test using dll if desired 
    136             if 'dll' in loaders or not core.HAVE_OPENCL: 
     137            if 'dll' in loaders or not use_opencl(): 
    137138                test_name = "%s-dll"%model_name 
    138139                test_method_name = "test_%s_dll" % model_info.id 
     
    145146 
    146147            # test using opencl if desired and available 
    147             if 'opencl' in loaders and core.HAVE_OPENCL: 
     148            if 'opencl' in loaders and use_opencl(): 
    148149                test_name = "%s-opencl"%model_name 
    149150                test_method_name = "test_%s_opencl" % model_info.id 
     
    367368 
    368369    # Build a test suite containing just the model 
    369     loaders = ['opencl'] if core.HAVE_OPENCL else ['dll'] 
     370    loaders = ['opencl'] if use_opencl() else ['dll'] 
    370371    models = [model] 
    371372    try: 
     
    424425        verbosity = 1 
    425426    if models and models[0] == 'opencl': 
    426         if not core.HAVE_OPENCL: 
     427        if not use_opencl(): 
    427428            print("opencl is not available") 
    428429            return 1 
     
    434435        models = models[1:] 
    435436    elif models and models[0] == 'opencl_and_dll': 
    436         loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     437        loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] 
    437438        models = models[1:] 
    438439    else: 
    439         loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     440        loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] 
    440441    if not models: 
    441442        print("""\ 
     
    466467    Run "nosetests sasmodels" on the command line to invoke it. 
    467468    """ 
    468     loaders = ['opencl', 'dll'] if core.HAVE_OPENCL else ['dll'] 
     469    loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] 
    469470    tests = make_suite(loaders, ['all']) 
    470471    def build_test(test): 
     
    476477        # variable test will be shared amongst all the tests, and we will be 
    477478        # repeatedly testing vesicle. 
    478         return lambda name: test.run_all(), test.test_name 
     479 
     480        # Note: in sasview sas.sasgui.perspectives.fitting.gpu_options 
     481        # requires that the test.description field be set. 
     482        wrap = lambda: test.run_all() 
     483        wrap.description = test.test_name 
     484        return wrap 
     485        # The following would work with nosetests and pytest: 
     486        #     return lambda name: test.run_all(), test.test_name 
     487 
    479488    for test in tests: 
    480489        yield build_test(test) 
Note: See TracChangeset for help on using the changeset viewer.