Changeset eeb772e in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Apr 1, 2019 8:54:03 AM (5 years ago)
- Parents:
- 3448301 (diff), 7eb2a4d (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. - git-author:
- Paul Kienzle <pkienzle@…> (04/01/19 08:54:03)
- git-committer:
- GitHub <noreply@…> (04/01/19 08:54:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
ra34b811 r7eb2a4d 70 70 processed.append(parse_parameter(*p)) 71 71 partable = ParameterTable(processed) 72 partable.check_angles( )72 partable.check_angles(strict=True) 73 73 return partable 74 74 … … 446 446 # properties, such as default=0.0 for structure factor backgrounds. 447 447 self.common_parameters = [Parameter(*p) for p in COMMON_PARAMETERS] 448 449 448 self.kernel_parameters = parameters 450 449 self._set_vector_lengths() … … 495 494 self.pd_2d = set(p.name for p in self.call_parameters if p.polydisperse) 496 495 496 # Final checks 497 self.check_duplicates() 498 self.check_angles() 499 497 500 def set_zero_background(self): 498 501 """ … … 506 509 self.defaults = self._get_defaults() 507 510 508 def check_angles(self ):511 def check_angles(self, strict=False): 509 512 """ 510 513 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. 511 518 """ 512 519 theta = phi = psi = -1 … … 524 531 if p.type != 'orientation': 525 532 raise TypeError("psi must be an orientation parameter") 526 elif p.type == 'orientation':533 elif strict and p.type == 'orientation': 527 534 raise TypeError("only theta, phi and psi can be orientation parameters") 528 535 if theta >= 0 and phi >= 0: … … 532 539 if psi >= 0 and psi != phi+1: 533 540 raise TypeError("psi must follow phi") 534 if (psi >= 0 and psi != last_par) or (psi < 0 and phi != last_par): 541 # TODO: Why must theta/phi/psi be at the end? Consistency only? 542 if strict and phi != last_par and psi != last_par: 535 543 raise TypeError("orientation parameters must appear at the " 536 544 "end of the parameter table") 537 545 elif theta >= 0 or phi >= 0 or psi >= 0: 538 546 raise TypeError("oriented shapes must have both theta and phi and maybe psi") 547 548 def check_duplicates(self): 549 """ 550 Check for duplicate parameter names 551 """ 552 checked, dups = set(), set() 553 for p in self.call_parameters: 554 if p.id in checked: 555 dups.add(p.id) 556 else: 557 checked.add(p.id) 558 if dups: 559 raise TypeError("Duplicate parameters: {}" 560 .format(", ".join(sorted(dups)))) 539 561 540 562 def __getitem__(self, key):
Note: See TracChangeset
for help on using the changeset viewer.