Changeset f619de7 in sasmodels for sasmodels/core.py


Ignore:
Timestamp:
Apr 11, 2016 9:14:50 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:
7ae2b7f
Parents:
9a943d0
Message:

more type hinting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/core.py

    r6d6508e rf619de7  
    2626    HAVE_OPENCL = False 
    2727 
     28try: 
     29    from typing import List, Union, Optional, Any 
     30    DType = Union[None, str, np.dtype] 
     31    from .kernel import KernelModel 
     32except ImportError: 
     33    pass 
     34 
     35 
    2836# TODO: refactor composite model support 
    2937# The current load_model_info/build_model does not reuse existing model 
     
    3947 
    4048def list_models(): 
     49    # type: () -> List[str] 
    4150    """ 
    4251    Return the list of available models on the model path. 
     
    4857 
    4958def isstr(s): 
     59    # type: (Any) -> bool 
    5060    """ 
    5161    Return True if *s* is a string-like object. 
     
    5565    return True 
    5666 
    57 def load_model(model_name, **kw): 
     67def load_model(model_name, dtype=None, platform='ocl'): 
     68    # type: (str, DType, str) -> KernelModel 
    5869    """ 
    5970    Load model info and build model. 
     71 
     72    *model_name* is the name of the model as used by :func:`load_model_info`. 
     73    Additional keyword arguments are passed directly to :func:`build_model`. 
    6074    """ 
    61     return build_model(load_model_info(model_name), **kw) 
     75    return build_model(load_model_info(model_name), 
     76                       dtype=dtype, platform=platform) 
    6277 
    6378 
    6479def load_model_info(model_name): 
     80    # type: (str) -> modelinfo.ModelInfo 
    6581    """ 
    6682    Load a model definition given the model name. 
     
    86102 
    87103def build_model(model_info, dtype=None, platform="ocl"): 
     104    # type: (modelinfo.ModelInfo, DType, str) -> KernelModel 
    88105    """ 
    89106    Prepare the model for the default execution platform. 
     
    138155 
    139156def precompile_dll(model_name, dtype="double"): 
     157    # type: (str, DType) -> Optional[str] 
    140158    """ 
    141159    Precompile the dll for a model. 
Note: See TracChangeset for help on using the changeset viewer.