Changes in sasmodels/modelinfo.py [5ab99b7:95498a3] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
r5ab99b7 r95498a3 12 12 from os.path import abspath, basename, splitext 13 13 import inspect 14 import logging15 14 16 15 import numpy as np # type: ignore 17 18 from . import autoc19 16 20 17 # Optional typing … … 36 33 # pylint: enable=unused-import 37 34 38 logger = logging.getLogger(__name__)39 40 35 # If MAX_PD changes, need to change the loop macros in kernel_iq.c 41 36 MAX_PD = 5 #: Maximum number of simultaneously polydisperse parameters … … 74 69 processed.append(parse_parameter(*p)) 75 70 partable = ParameterTable(processed) 71 partable.check_angles() 76 72 return partable 77 73 … … 426 422 # type: (List[Parameter]) -> None 427 423 self.kernel_parameters = parameters 428 self._check_angles()429 424 self._set_vector_lengths() 430 425 … … 476 471 self.pd_2d = set(p.name for p in self.call_parameters if p.polydisperse) 477 472 478 def _check_angles(self): 473 def check_angles(self): 474 """ 475 Check that orientation angles are theta, phi and possibly psi. 476 """ 479 477 theta = phi = psi = -1 480 478 for k, p in enumerate(self.kernel_parameters): … … 499 497 if psi >= 0 and psi != phi+1: 500 498 raise TypeError("psi must follow phi") 501 #if (psi >= 0 and psi != last_par) or (psi < 0 and phi != last_par):502 #raise TypeError("orientation parameters must appear at the "503 #"end of the parameter table")499 if (psi >= 0 and psi != last_par) or (psi < 0 and phi != last_par): 500 raise TypeError("orientation parameters must appear at the " 501 "end of the parameter table") 504 502 elif theta >= 0 or phi >= 0 or psi >= 0: 505 503 raise TypeError("oriented shapes must have both theta and phi and maybe psi") … … 809 807 info.sesans = getattr(kernel_module, 'sesans', None) # type: ignore 810 808 # Default single and opencl to True for C models. Python models have callable Iq. 809 info.opencl = getattr(kernel_module, 'opencl', not callable(info.Iq)) 810 info.single = getattr(kernel_module, 'single', not callable(info.Iq)) 811 811 info.random = getattr(kernel_module, 'random', None) 812 812 … … 817 817 info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 818 818 819 if callable(info.Iq) and parameters.has_2d: 820 raise ValueError("oriented python models not supported") 821 819 822 info.lineno = {} 820 823 _find_source_lines(info, kernel_module) 821 if getattr(kernel_module, 'py2c', False):822 try:823 autoc.convert(info, kernel_module)824 except Exception as exc:825 logger.warn(str(exc) + " while converting %s from C to python"%name)826 827 # Needs to come after autoc.convert since the Iq symbol may have been828 # converted from python to C829 info.opencl = getattr(kernel_module, 'opencl', not callable(info.Iq))830 info.single = getattr(kernel_module, 'single', not callable(info.Iq))831 832 if callable(info.Iq) and parameters.has_2d:833 raise ValueError("oriented python models not supported")834 824 835 825 return info
Note: See TracChangeset
for help on using the changeset viewer.