Changeset 60f03de in sasmodels
- Timestamp:
- Apr 13, 2016 12:49:03 PM (9 years ago)
- 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:
- a5b8477
- Parents:
- 04dc697
- Location:
- sasmodels
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
r04dc697 r60f03de 71 71 def parse_parameter(name, units='', default=np.NaN, 72 72 user_limits=None, ptype='', description=''): 73 # type: (str, str, float, Limits, str, str) -> Parameter73 # type: (str, str, float, Sequence[Any], str, str) -> Parameter 74 74 """ 75 75 Parse an individual parameter from the parameter definition block. -
sasmodels/sasview_model.py
r04dc697 r60f03de 31 31 32 32 try: 33 from typing import Dict, Mapping, Any, Sequence, Tuple, NamedTuple, List, Optional, Union 33 from typing import Dict, Mapping, Any, Sequence, Tuple, NamedTuple, List, Optional, Union, Callable 34 34 from .modelinfo import ModelInfo, Parameter 35 35 from .kernel import KernelModel … … 38 38 [("number", int), ("control", str), ("choices", List[str]), 39 39 ("x_axis_label", str)]) 40 SasviewModelType = Callable[[int], "SasviewModel"] 40 41 except ImportError: 41 42 pass … … 50 51 # TODO: figure out how to say that the return type is a subclass 51 52 def load_standard_models(): 52 # type: () -> List[ type]53 # type: () -> List[SasviewModelType] 53 54 """ 54 55 Load and return the list of predefined models. … … 67 68 68 69 def load_custom_model(path): 69 # type: (str) -> type70 # type: (str) -> SasviewModelType 70 71 """ 71 72 Load a custom model given the model path. … … 77 78 78 79 def _make_standard_model(name): 79 # type: (str) -> type80 # type: (str) -> SasviewModelType 80 81 """ 81 82 Load the sasview model defined by *name*. … … 91 92 92 93 def _make_model_from_info(model_info): 93 # type: (ModelInfo) -> type94 # type: (ModelInfo) -> SasviewModelType 94 95 """ 95 96 Convert *model_info* into a SasView model wrapper. … … 99 100 attrs = _generate_model_attributes(model_info) 100 101 attrs['__init__'] = __init__ 101 ConstructedModel = type(model_info.name, (SasviewModel,), attrs) 102 ConstructedModel = type(model_info.name, (SasviewModel,), attrs) # type: SasviewModelType 102 103 return ConstructedModel 103 104 … … 220 221 dispersion = None # type: Dict[str, Any] 221 222 #: units and limits for each parameter 222 details = None # type: Mapping[str, Tuple[str, float, float]] 223 details = None # type: Dict[str, Sequence[Any]] 224 # # actual type is Dict[str, List[str, float, float]] 223 225 #: multiplicity value, or None if no multiplicity on the model 224 226 multiplicity = None # type: Optional[int] … … 311 313 beta is a list of the corresponding SLD values 312 314 """ 313 args = [] 315 args = [] # type: List[Union[float, np.ndarray]] 314 316 for p in self._model_info.parameters.kernel_parameters: 315 317 if p.id == self.multiplicity_info.control: 316 args.append( self.multiplicity)318 args.append(float(self.multiplicity)) 317 319 elif p.length == 1: 318 320 args.append(self.params.get(p.id, np.NaN)) … … 415 417 # pylint: disable=unpacking-non-sequence 416 418 q, phi = x 417 return self.calculate_Iq([q * math.cos(phi)], 418 [q * math.sin(phi)])[0] 419 else: 420 return self.calculate_Iq([float(x)])[0] 419 return self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)])[0] 420 else: 421 return self.calculate_Iq([x])[0] 421 422 422 423 … … 433 434 """ 434 435 if isinstance(x, (list, tuple)): 435 return self.calculate_Iq([ float(x[0])], [float(x[1])])[0]436 else: 437 return self.calculate_Iq([ float(x)])[0]436 return self.calculate_Iq([x[0]], [x[1]])[0] 437 else: 438 return self.calculate_Iq([x])[0] 438 439 439 440 def evalDistribution(self, qdist):
Note: See TracChangeset
for help on using the changeset viewer.