Changeset 89dba62 in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Mar 29, 2019 12:22:20 PM (5 years ago)
- Branches:
- ticket-1257-vesicle-product
- Children:
- 93cac17
- Parents:
- 98c045a (diff), de032da (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
ra34b811 r98c045a 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 p.type == 'orientation' and strict: 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") 541 # TODO: Why must theta/phi/psi be at the end? Consistency only? 534 542 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") 537 546 elif theta >= 0 or phi >= 0 or psi >= 0: 538 547 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)))) 539 562 540 563 def __getitem__(self, key):
Note: See TracChangeset
for help on using the changeset viewer.