Changeset 5c962df in sasmodels
- Timestamp:
- Jan 30, 2016 9:02:03 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3a45c2c
- Parents:
- 5925e90
- Location:
- sasmodels
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/data.py
reafc9fa r5c962df 351 351 def wrapper(*args, **kw): 352 352 """ 353 Trap and print errors from function %s354 """ %fn.__name__353 Trap and print errors from function. 354 """ 355 355 try: 356 356 return fn(*args, **kw) -
sasmodels/list_pars.py
r823e620 r5c962df 9 9 addition to just the parameter name. 10 10 """ 11 from __future__ import print_function 12 11 13 import sys 12 14 … … 16 18 17 19 def find_pars(): 20 """ 21 Find all parameters in all models. 22 23 Returns the reference table *{parameter: [model, model, ...]}* 24 """ 18 25 partable = {} 19 26 for name in sorted(MODELS): … … 27 34 28 35 def list_pars(names_only=True): 36 """ 37 Print all parameters in all models. 38 39 If *names_only* then only print the parameter name, not the models it 40 occurs in. 41 """ 29 42 partable = find_pars() 30 43 if names_only: … … 35 48 36 49 def main(): 50 """ 51 Program to list the parameters used across all models. 52 """ 37 53 if len(sys.argv) == 2 and sys.argv[1] == '-v': 38 54 verbose = True -
sasmodels/model_test.py
r823e620 r5c962df 43 43 Precision defaults to 5 digits (relative). 44 44 """ 45 from __future__ import print_function 45 46 46 47 import sys … … 55 56 56 57 def make_suite(loaders, models): 58 """ 59 Construct the pyunit test suite. 60 61 *loaders* is the list of kernel drivers to use, which is one of 62 *["dll", "opencl"]*, *["dll"]* or *["opencl"]*. For python models, 63 the python driver is always used. 64 65 *models* is the list of models to test, or *["all"]* to test all models. 66 """ 57 67 58 68 ModelTestCase = _hide_model_case_from_nosetests() … … 111 121 def _hide_model_case_from_nosetests(): 112 122 class ModelTestCase(unittest.TestCase): 123 """ 124 Test suit for a particular model with a particular kernel driver. 125 126 The test suite runs a simple smoke test to make sure the model 127 functions, then runs the list of tests at the bottom of the model 128 description file. 129 """ 113 130 def __init__(self, test_name, definition, test_method_name, 114 131 platform, dtype): -
sasmodels/weights.py
r823e620 r5c962df 22 22 23 23 def get_pars(self): 24 """ 25 Return the parameters to the disperser as a dictionary. 26 """ 24 27 pars = {'type': self.type} 25 28 pars.update(self.__dict__) … … 28 31 # pylint: disable=no-self-use 29 32 def set_weights(self, values, weights): 33 """ 34 Set the weights on the disperser if it is :class:`ArrayDispersion`. 35 """ 30 36 raise RuntimeError("set_weights is only available for ArrayDispersion") 31 37 … … 63 69 64 70 class GaussianDispersion(Dispersion): 71 r""" 72 Gaussian dispersion, with 1-\ $\sigma$ width. 73 74 .. math:: 75 76 w = \exp\left(-\tfrac12 (x - c)^2/\sigma^2\right) 77 """ 65 78 type = "gaussian" 66 79 default = dict(npts=35, width=0, nsigmas=3) … … 72 85 73 86 class RectangleDispersion(Dispersion): 87 r""" 88 Uniform dispersion, with width $\sqrt{3}\sigma$. 89 90 .. math:: 91 92 w = 1 93 """ 74 94 type = "rectangle" 75 95 default = dict(npts=35, width=0, nsigmas=1.70325) … … 81 101 82 102 class LogNormalDispersion(Dispersion): 103 r""" 104 log Gaussian dispersion, with 1-\ $\sigma$ width. 105 106 .. math:: 107 108 w = \frac{\exp\left(-\tfrac12 (\ln x - c)^2/\sigma^2\right)}{x\sigma} 109 """ 83 110 type = "lognormal" 84 111 default = dict(npts=80, width=0, nsigmas=8) 85 112 def _weights(self, center, sigma, lb, ub): 86 113 x = self._linspace(center, sigma, max(lb, 1e-8), max(ub, 1e-8)) 87 px = np.exp(-0.5*(np.log(x)-center)**2 )/sigma**2/(x*sigma)114 px = np.exp(-0.5*(np.log(x)-center)**2/sigma**2)/(x*sigma) 88 115 return x, px 89 116 90 117 91 118 class SchulzDispersion(Dispersion): 119 r""" 120 Schultz dispersion, with 1-\ $\sigma$ width. 121 122 .. math:: 123 124 w = \frac{z^z\,R^{z-1}}{e^{Rz}\,c \Gamma(z)} 125 126 where $c$ is the center of the distribution, $R = x/c$ and $z=(c/\sigma)^2$. 127 128 This is evaluated using logarithms as 129 130 .. math:: 131 132 w = \exp\left(z \ln z + (z-1)\ln R - Rz - \ln c - \ln \Gamma(z) \right) 133 """ 92 134 type = "schulz" 93 135 default = dict(npts=80, width=0, nsigmas=8) … … 102 144 103 145 class ArrayDispersion(Dispersion): 146 r""" 147 Empirical dispersion curve. 148 149 Use :meth:`set_weights` to set $w = f(x)$. 150 """ 104 151 type = "array" 105 152 default = dict(npts=35, width=0, nsigmas=1) … … 110 157 111 158 def set_weights(self, values, weights): 159 """ 160 Set the weights for the given x values. 161 """ 112 162 self.values = np.ascontiguousarray(values, 'd') 113 163 self.weights = np.ascontiguousarray(weights, 'd')
Note: See TracChangeset
for help on using the changeset viewer.