Changeset b2f0e5d in sasmodels for sasmodels/modelinfo.py
- Timestamp:
- Mar 29, 2019 8:14:32 AM (5 years ago)
- Branches:
- ticket-1257-vesicle-product
- Children:
- 98c045a
- Parents:
- 830cf6b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/modelinfo.py
ra34b811 rb2f0e5d 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() … … 459 458 #self._name_table= dict((p.id, p) for p in parameters) 460 459 460 461 461 # Set the kernel parameters. Assumes background and scale are the 462 462 # first two parameters in the parameter list, but these are not sent … … 495 495 self.pd_2d = set(p.name for p in self.call_parameters if p.polydisperse) 496 496 497 # Final checks 498 self.check_duplicates() 499 self.check_angles() 500 497 501 def set_zero_background(self): 498 502 """ … … 506 510 self.defaults = self._get_defaults() 507 511 508 def check_angles(self ):512 def check_angles(self, strict=False): 509 513 """ 510 514 Check that orientation angles are theta, phi and possibly psi. 515 516 *strict* should be True when checking a parameter table defined 517 in a model file, but False when checking from mixture models, etc., 518 where the parameters aren't being passed to a calculator directly. 511 519 """ 512 520 theta = phi = psi = -1 … … 524 532 if p.type != 'orientation': 525 533 raise TypeError("psi must be an orientation parameter") 526 elif p.type == 'orientation' :534 elif p.type == 'orientation' and strict: 527 535 raise TypeError("only theta, phi and psi can be orientation parameters") 528 536 if theta >= 0 and phi >= 0: … … 532 540 if psi >= 0 and psi != phi+1: 533 541 raise TypeError("psi must follow phi") 542 # TODO: Why must theta/phi/psi be at the end? Consistency only? 534 543 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") 544 if strict: 545 raise TypeError("orientation parameters must appear at the " 546 "end of the parameter table") 537 547 elif theta >= 0 or phi >= 0 or psi >= 0: 538 548 raise TypeError("oriented shapes must have both theta and phi and maybe psi") 549 550 def check_duplicates(self): 551 """ 552 Check for duplicate parameter names 553 """ 554 checked, dups = set(), set() 555 for p in self.call_parameters: 556 if p.id in checked: 557 dups.add(p.id) 558 else: 559 checked.add(p.id) 560 if dups: 561 raise TypeError("Duplicate parameters: {}" 562 .format(", ".join(sorted(dups)))) 539 563 540 564 def __getitem__(self, key):
Note: See TracChangeset
for help on using the changeset viewer.