Changes in sasmodels/modelinfo.py [5ab99b7:95498a3] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/modelinfo.py

    r5ab99b7 r95498a3  
    1212from os.path import abspath, basename, splitext 
    1313import inspect 
    14 import logging 
    1514 
    1615import numpy as np  # type: ignore 
    17  
    18 from . import autoc 
    1916 
    2017# Optional typing 
     
    3633# pylint: enable=unused-import 
    3734 
    38 logger = logging.getLogger(__name__) 
    39  
    4035# If MAX_PD changes, need to change the loop macros in kernel_iq.c 
    4136MAX_PD = 5 #: Maximum number of simultaneously polydisperse parameters 
     
    7469        processed.append(parse_parameter(*p)) 
    7570    partable = ParameterTable(processed) 
     71    partable.check_angles() 
    7672    return partable 
    7773 
     
    426422        # type: (List[Parameter]) -> None 
    427423        self.kernel_parameters = parameters 
    428         self._check_angles() 
    429424        self._set_vector_lengths() 
    430425 
     
    476471        self.pd_2d = set(p.name for p in self.call_parameters if p.polydisperse) 
    477472 
    478     def _check_angles(self): 
     473    def check_angles(self): 
     474        """ 
     475        Check that orientation angles are theta, phi and possibly psi. 
     476        """ 
    479477        theta = phi = psi = -1 
    480478        for k, p in enumerate(self.kernel_parameters): 
     
    499497            if psi >= 0 and psi != phi+1: 
    500498                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") 
    504502        elif theta >= 0 or phi >= 0 or psi >= 0: 
    505503            raise TypeError("oriented shapes must have both theta and phi and maybe psi") 
     
    809807    info.sesans = getattr(kernel_module, 'sesans', None) # type: ignore 
    810808    # 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)) 
    811811    info.random = getattr(kernel_module, 'random', None) 
    812812 
     
    817817    info.hidden = getattr(kernel_module, 'hidden', None) # type: ignore 
    818818 
     819    if callable(info.Iq) and parameters.has_2d: 
     820        raise ValueError("oriented python models not supported") 
     821 
    819822    info.lineno = {} 
    820823    _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 been 
    828     # converted from python to C 
    829     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") 
    834824 
    835825    return info 
Note: See TracChangeset for help on using the changeset viewer.