Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/sasview_model.py

    rd32de68 r84f2962  
    381381                continue 
    382382            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]] 
    384384            if p.polydisperse: 
    385385                self.details[p.id+".width"] = [ 
     
    540540            # pylint: disable=unpacking-non-sequence 
    541541            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] 
    545547 
    546548 
     
    557559        """ 
    558560        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] 
    562566 
    563567    def evalDistribution(self, qdist): 
     
    593597            # Check whether we have a list of ndarrays [qx,qy] 
    594598            qx, qy = qdist 
    595             return self.calculate_Iq(qx, qy) 
     599            result, _ = self.calculate_Iq(qx, qy) 
     600            return result 
    596601 
    597602        elif isinstance(qdist, np.ndarray): 
    598603            # We have a simple 1D distribution of q-values 
    599             return self.calculate_Iq(qdist) 
     604            result, _ = self.calculate_Iq(qdist) 
     605            return result 
    600606 
    601607        else: 
     
    637643        if composition and composition[0] == 'product': # only P*S for now 
    638644            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 
    643651        else: 
    644652            return None 
    645653 
    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]]] 
    648659        """ 
    649660        Calculate Iq for one set of q with the current parameters. 
     
    653664        This should NOT be used for fitting since it copies the *q* vectors 
    654665        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. 
    655670        """ 
    656671        ## uncomment the following when trying to debug the uncoordinated calls 
     
    685700        result = calculator(call_details, values, cutoff=self.cutoff, 
    686701                            magnetic=is_magnetic) 
     702        lazy_results = getattr(calculator, 'results', 
     703                               lambda: collections.OrderedDict()) 
    687704        #print("result", result) 
    688         self._intermediate_results = getattr(calculator, 'results', None) 
     705 
    689706        calculator.release() 
    690707        #self._model.release() 
    691         return result 
     708 
     709        return result, lazy_results 
    692710 
    693711    def calculate_ER(self): 
     
    878896    q = np.linspace(-0.35, 0.35, 500) 
    879897    qx, qy = np.meshgrid(q, q) 
    880     result = model.calculate_Iq(qx.flatten(), qy.flatten()) 
     898    result, _ = model.calculate_Iq(qx.flatten(), qy.flatten()) 
    881899    result = result.reshape(qx.shape) 
    882900 
Note: See TracChangeset for help on using the changeset viewer.