Changeset 04dc697 in sasmodels for sasmodels/sasview_model.py


Ignore:
Timestamp:
Apr 13, 2016 11:39:09 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:
60f03de
Parents:
a18c5b3
Message:

more type hinting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    ra18c5b3 r04dc697  
    3131 
    3232try: 
    33     from typing import Dict, Mapping, Any, Sequence, Tuple, NamedTuple, List, Optional 
     33    from typing import Dict, Mapping, Any, Sequence, Tuple, NamedTuple, List, Optional, Union 
    3434    from .modelinfo import ModelInfo, Parameter 
    3535    from .kernel import KernelModel 
     
    4242 
    4343# TODO: separate x_axis_label from multiplicity info 
    44 # The x-axis label belongs with the profile generating function 
     44# The profile x-axis label belongs with the profile generating function 
    4545MultiplicityInfo = collections.namedtuple( 
    4646    'MultiplicityInfo', 
     
    220220    dispersion = None  # type: Dict[str, Any] 
    221221    #: units and limits for each parameter 
    222     details = None     # type: Mapping[str, Tuple(str, float, float)] 
    223     #: multiplicity used, or None if no multiplicity controls 
     222    details = None     # type: Mapping[str, Tuple[str, float, float]] 
     223    #: multiplicity value, or None if no multiplicity on the model 
    224224    multiplicity = None     # type: Optional[int] 
     225    #: memory for polydispersity array if using ArrayDispersion (used by sasview). 
     226    _persistency_dict = None # type: Dict[str, Tuple[np.ndarray, np.ndarray]] 
    225227 
    226228    def __init__(self, multiplicity=None): 
    227         # type: () -> None 
    228  
    229         ## _persistency_dict is used by sas.perspectives.fitting.basepage 
    230         ## to store dispersity reference. 
    231         self._persistency_dict = {} 
     229        # type: (Optional[int]) -> None 
    232230 
    233231        # TODO: _persistency_dict to persistency_dict throughout sasview 
     
    252250            hidden = set() 
    253251 
     252        self._persistency_dict = {} 
    254253        self.params = collections.OrderedDict() 
    255254        self.dispersion = {} 
     
    375374 
    376375    def getParamList(self): 
    377         # type: () - > Sequence[str] 
     376        # type: () -> Sequence[str] 
    378377        """ 
    379378        Return a list of all available parameters for the model 
    380379        """ 
    381         param_list = self.params.keys() 
     380        param_list = list(self.params.keys()) 
    382381        # WARNING: Extending the list with the dispersion parameters 
    383382        param_list.extend(self.getDispParamList()) 
     
    385384 
    386385    def getDispParamList(self): 
    387         # type: () - > Sequence[str] 
     386        # type: () -> Sequence[str] 
    388387        """ 
    389388        Return a list of polydispersity parameters for the model 
     
    398397 
    399398    def clone(self): 
    400         # type: () - > "SasviewModel" 
     399        # type: () -> "SasviewModel" 
    401400        """ Return a identical copy of self """ 
    402401        return deepcopy(self) 
     
    439438 
    440439    def evalDistribution(self, qdist): 
    441         # type: (Union[np.ndarray, Tuple[np.ndarray, np.ndarray], List[np.ndarray]) -> np.ndarray 
     440        # type: (Union[np.ndarray, Tuple[np.ndarray, np.ndarray], List[np.ndarray]]) -> np.ndarray 
    442441        r""" 
    443442        Evaluate a distribution of q-values. 
Note: See TracChangeset for help on using the changeset viewer.