Changeset 93cac17 in sasmodels


Ignore:
Timestamp:
Mar 29, 2019 4:43:48 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
ticket-1257-vesicle-product
Children:
7eb2a4d
Parents:
89dba62 (diff), 065d77d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ticket_822_v5_unit_tests' into ticket-1257-vesicle-product

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/product.py

    rb2f0e5d r93cac17  
    295295    The result may be an array or a float. 
    296296    """ 
     297    # CRUFT: remove effective_radius once SasView 5.0 is released. 
    297298    if beta_mode: 
    298299        # TODO: 1. include calculated Q vector 
     
    304305            ("S_eff(Q)", 1 + (F**2 / Fsq)*(S-1)), 
    305306            ("effective_radius", radius_effective), 
     307            ("radius_effective", radius_effective), 
    306308            # ("I(Q)", scale*(Fsq + (F**2)*(S-1)) + bg), 
    307309        )) 
     
    311313            ("S(Q)", S), 
    312314            ("effective_radius", radius_effective), 
     315            ("radius_effective", radius_effective), 
    313316        )) 
    314317    return parts 
  • sasmodels/mixture.py

    rb297ba9 rb2f0e5d  
    117117            combined_pars.append(p) 
    118118    parameters = ParameterTable(combined_pars) 
     119    # Allow for the scenario in which each component has all its PD parameters 
     120    # active simultaneously.  details.make_details() will throw an error if 
     121    # too many are used from any one component. 
    119122    parameters.max_pd = sum(part.parameters.max_pd for part in parts) 
    120123 
  • sasmodels/modelinfo.py

    ra34b811 r98c045a  
    7070        processed.append(parse_parameter(*p)) 
    7171    partable = ParameterTable(processed) 
    72     partable.check_angles() 
     72    partable.check_angles(strict=True) 
    7373    return partable 
    7474 
     
    446446        # properties, such as default=0.0 for structure factor backgrounds. 
    447447        self.common_parameters = [Parameter(*p) for p in COMMON_PARAMETERS] 
    448  
    449448        self.kernel_parameters = parameters 
    450449        self._set_vector_lengths() 
     
    495494        self.pd_2d = set(p.name for p in self.call_parameters if p.polydisperse) 
    496495 
     496        # Final checks 
     497        self.check_duplicates() 
     498        self.check_angles() 
     499 
    497500    def set_zero_background(self): 
    498501        """ 
     
    506509        self.defaults = self._get_defaults() 
    507510 
    508     def check_angles(self): 
     511    def check_angles(self, strict=False): 
    509512        """ 
    510513        Check that orientation angles are theta, phi and possibly psi. 
     514 
     515        *strict* should be True when checking a parameter table defined 
     516        in a model file, but False when checking from mixture models, etc., 
     517        where the parameters aren't being passed to a calculator directly. 
    511518        """ 
    512519        theta = phi = psi = -1 
     
    524531                if p.type != 'orientation': 
    525532                    raise TypeError("psi must be an orientation parameter") 
    526             elif p.type == 'orientation': 
     533            elif p.type == 'orientation' and strict: 
    527534                raise TypeError("only theta, phi and psi can be orientation parameters") 
    528535        if theta >= 0 and phi >= 0: 
     
    532539            if psi >= 0 and psi != phi+1: 
    533540                raise TypeError("psi must follow phi") 
     541            # TODO: Why must theta/phi/psi be at the end?  Consistency only? 
    534542            if (psi >= 0 and psi != last_par) or (psi < 0 and phi != last_par): 
    535                 raise TypeError("orientation parameters must appear at the " 
    536                                 "end of the parameter table") 
     543                if strict: 
     544                    raise TypeError("orientation parameters must appear at the " 
     545                                    "end of the parameter table") 
    537546        elif theta >= 0 or phi >= 0 or psi >= 0: 
    538547            raise TypeError("oriented shapes must have both theta and phi and maybe psi") 
     548 
     549    def check_duplicates(self): 
     550        """ 
     551        Check for duplicate parameter names 
     552        """ 
     553        checked, dups = set(), set() 
     554        for p in self.call_parameters: 
     555            if p.id in checked: 
     556                dups.add(p.id) 
     557            else: 
     558                checked.add(p.id) 
     559        if dups: 
     560            raise TypeError("Duplicate parameters: {}" 
     561                            .format(", ".join(sorted(dups)))) 
    539562 
    540563    def __getitem__(self, key): 
Note: See TracChangeset for help on using the changeset viewer.