Changes in sasmodels/sasview_model.py [d32de68:84f2962] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/sasview_model.py
rd32de68 r84f2962 381 381 continue 382 382 self.params[p.name] = p.default 383 self.details[p.id] = [p.units if not p.choices else p.choices, p.limits[0], p.limits[1]]383 self.details[p.id] = [p.units, p.limits[0], p.limits[1]] 384 384 if p.polydisperse: 385 385 self.details[p.id+".width"] = [ … … 540 540 # pylint: disable=unpacking-non-sequence 541 541 q, phi = x 542 return self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)])[0] 543 else: 544 return self.calculate_Iq([x])[0] 542 result, _ = self.calculate_Iq([q*math.cos(phi)], [q*math.sin(phi)]) 543 return result[0] 544 else: 545 result, _ = self.calculate_Iq([x]) 546 return result[0] 545 547 546 548 … … 557 559 """ 558 560 if isinstance(x, (list, tuple)): 559 return self.calculate_Iq([x[0]], [x[1]])[0] 560 else: 561 return self.calculate_Iq([x])[0] 561 result, _ = self.calculate_Iq([x[0]], [x[1]]) 562 return result[0] 563 else: 564 result, _ = self.calculate_Iq([x]) 565 return result[0] 562 566 563 567 def evalDistribution(self, qdist): … … 593 597 # Check whether we have a list of ndarrays [qx,qy] 594 598 qx, qy = qdist 595 return self.calculate_Iq(qx, qy) 599 result, _ = self.calculate_Iq(qx, qy) 600 return result 596 601 597 602 elif isinstance(qdist, np.ndarray): 598 603 # We have a simple 1D distribution of q-values 599 return self.calculate_Iq(qdist) 604 result, _ = self.calculate_Iq(qdist) 605 return result 600 606 601 607 else: … … 637 643 if composition and composition[0] == 'product': # only P*S for now 638 644 with calculation_lock: 639 self._calculate_Iq(qx) 640 # for compatibility with sasview 4.3 641 results = self._intermediate_results() 642 return results["P(Q)"], results["S(Q)"] 645 _, lazy_results = self._calculate_Iq(qx) 646 # for compatibility with sasview 4.x 647 results = lazy_results() 648 pq_data = results.get("P(Q)") 649 sq_data = results.get("S(Q)") 650 return pq_data, sq_data 643 651 else: 644 652 return None 645 653 646 def calculate_Iq(self, qx, qy=None): 647 # type: (Sequence[float], Optional[Sequence[float]]) -> np.ndarray 654 def calculate_Iq(self, 655 qx, # type: Sequence[float] 656 qy=None # type: Optional[Sequence[float]] 657 ): 658 # type: (...) -> Tuple[np.ndarray, Callable[[], collections.OrderedDict[str, np.ndarray]]] 648 659 """ 649 660 Calculate Iq for one set of q with the current parameters. … … 653 664 This should NOT be used for fitting since it copies the *q* vectors 654 665 to the card for each evaluation. 666 667 The returned tuple contains the scattering intensity followed by a 668 callable which returns a dictionary of intermediate data from 669 ProductKernel. 655 670 """ 656 671 ## uncomment the following when trying to debug the uncoordinated calls … … 685 700 result = calculator(call_details, values, cutoff=self.cutoff, 686 701 magnetic=is_magnetic) 702 lazy_results = getattr(calculator, 'results', 703 lambda: collections.OrderedDict()) 687 704 #print("result", result) 688 self._intermediate_results = getattr(calculator, 'results', None) 705 689 706 calculator.release() 690 707 #self._model.release() 691 return result 708 709 return result, lazy_results 692 710 693 711 def calculate_ER(self): … … 878 896 q = np.linspace(-0.35, 0.35, 500) 879 897 qx, qy = np.meshgrid(q, q) 880 result = model.calculate_Iq(qx.flatten(), qy.flatten())898 result, _ = model.calculate_Iq(qx.flatten(), qy.flatten()) 881 899 result = result.reshape(qx.shape) 882 900
Note: See TracChangeset
for help on using the changeset viewer.