Changeset bbd9062 in sasmodels


Ignore:
Timestamp:
Oct 31, 2018 10:44:44 AM (2 weeks ago)
Author:
GitHub <noreply@…>
Parents:
c6084f1 (diff), a4f1a73 (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.
git-author:
Paul Kienzle <pkienzle@…> (10/31/18 10:44:44)
git-committer:
GitHub <noreply@…> (10/31/18 10:44:44)
Message:

Merge a4f1a73be1e90dfd9e4088cd4b158df12b39b726 into c6084f192171c34cf1111bfae238f49f5ebf15f5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    rce1eed5 ra4f1a73  
    2525from . import core 
    2626from . import custom 
     27from . import kernelcl 
    2728from . import product 
    2829from . import generate 
     
    3031from . import modelinfo 
    3132from .details import make_kernel_args, dispersion_mesh 
     33from .kernelcl import reset_environment 
    3234 
    3335# pylint: disable=unused-import 
     
    6870#: has changed since we last reloaded. 
    6971_CACHED_MODULE = {}  # type: Dict[str, "module"] 
     72 
     73def reset_environment(): 
     74    # type: () -> None 
     75    """ 
     76    Clear the compute engine context so that the GUI can change devices. 
     77 
     78    This removes all compiled kernels, even those that are active on fit 
     79    pages, but they will be restored the next time they are needed. 
     80    """ 
     81    kernelcl.reset_environment() 
     82    for model in MODELS.values(): 
     83        model._model = None 
    7084 
    7185def find_model(modelname): 
     
    680694    def _calculate_Iq(self, qx, qy=None): 
    681695        if self._model is None: 
    682             self._model = core.build_model(self._model_info) 
     696            # Only need one copy of the compiled kernel regardless of how many 
     697            # times it is used, so store it in the class.  Also, to reset the 
     698            # compute engine, need to clear out all existing compiled kernels, 
     699            # which is much easier to do if we store them in the class. 
     700            self.__class__._model = core.build_model(self._model_info) 
    683701        if qy is not None: 
    684702            q_vectors = [np.asarray(qx), np.asarray(qy)] 
Note: See TracChangeset for help on using the changeset viewer.