Changes in src/sas/sascalc/corfunc/corfunc_calculator.py [a26f67f:dbfd307] in sasview
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/corfunc/corfunc_calculator.py
ra26f67f rdbfd307 30 30 self.start = start 31 31 self.stop = stop 32 self._lastx = []33 self._lasty = []32 self._lastx = np.empty(0, dtype='d') 33 self._lasty = None 34 34 35 35 def __call__(self, x): 36 36 # If input is a single number, evaluate the function at that number 37 37 # and return a single number 38 if type(x) == float or type(x) == int:38 if isinstance(x, (float, int)): 39 39 return self._smoothed_function(np.array([x]))[0] 40 40 # If input is a list, and is different to the last input, evaluate … … 42 42 # the function was called, return the result that was calculated 43 43 # last time instead of explicity evaluating the function again. 44 elif self._lastx == [] or x.tolist() != self._lastx.tolist(): 45 self._lasty = self._smoothed_function(x) 46 self._lastx = x 44 if not np.array_equal(x, self._lastx): 45 self._lastx, self._lasty = x, self._smoothed_function(x) 47 46 return self._lasty 48 47 … … 88 87 # Only process data of the class Data1D 89 88 if not issubclass(data.__class__, Data1D): 90 raise ValueError(" Data must be of the type DataLoader.Data1D")89 raise ValueError("Correlation function cannot be computed with 2D data.") 91 90 92 91 # Prepare the data … … 246 245 """Fit the Guinier region of the curve""" 247 246 A = np.vstack([q**2, np.ones(q.shape)]).T 248 return lstsq(A, np.log(iq)) 247 # CRUFT: numpy>=1.14.0 allows rcond=None for the following default 248 rcond = np.finfo(float).eps * max(A.shape) 249 return lstsq(A, np.log(iq), rcond=rcond) 249 250 250 251 def _fit_porod(self, q, iq):
Note: See TracChangeset
for help on using the changeset viewer.