Changeset 5c962df in sasmodels


Ignore:
Timestamp:
Jan 30, 2016 9:02:03 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
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
Message:

delint

Location:
sasmodels
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/data.py

    reafc9fa r5c962df  
    351351    def wrapper(*args, **kw): 
    352352        """ 
    353         Trap and print errors from function %s 
    354         """%fn.__name__ 
     353        Trap and print errors from function. 
     354        """ 
    355355        try: 
    356356            return fn(*args, **kw) 
  • sasmodels/list_pars.py

    r823e620 r5c962df  
    99addition to just the parameter name. 
    1010""" 
     11from __future__ import print_function 
     12 
    1113import sys 
    1214 
     
    1618 
    1719def find_pars(): 
     20    """ 
     21    Find all parameters in all models. 
     22 
     23    Returns the reference table *{parameter: [model, model, ...]}* 
     24    """ 
    1825    partable = {} 
    1926    for name in sorted(MODELS): 
     
    2734 
    2835def 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    """ 
    2942    partable = find_pars() 
    3043    if names_only: 
     
    3548 
    3649def main(): 
     50    """ 
     51    Program to list the parameters used across all models. 
     52    """ 
    3753    if len(sys.argv) == 2 and sys.argv[1] == '-v': 
    3854        verbose = True 
  • sasmodels/model_test.py

    r823e620 r5c962df  
    4343Precision defaults to 5 digits (relative). 
    4444""" 
     45from __future__ import print_function 
    4546 
    4647import sys 
     
    5556 
    5657def 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    """ 
    5767 
    5868    ModelTestCase = _hide_model_case_from_nosetests() 
     
    111121def _hide_model_case_from_nosetests(): 
    112122    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        """ 
    113130        def __init__(self, test_name, definition, test_method_name, 
    114131                     platform, dtype): 
  • sasmodels/weights.py

    r823e620 r5c962df  
    2222 
    2323    def get_pars(self): 
     24        """ 
     25        Return the parameters to the disperser as a dictionary. 
     26        """ 
    2427        pars = {'type': self.type} 
    2528        pars.update(self.__dict__) 
     
    2831    # pylint: disable=no-self-use 
    2932    def set_weights(self, values, weights): 
     33        """ 
     34        Set the weights on the disperser if it is :class:`ArrayDispersion`. 
     35        """ 
    3036        raise RuntimeError("set_weights is only available for ArrayDispersion") 
    3137 
     
    6369 
    6470class 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    """ 
    6578    type = "gaussian" 
    6679    default = dict(npts=35, width=0, nsigmas=3) 
     
    7285 
    7386class RectangleDispersion(Dispersion): 
     87    r""" 
     88    Uniform dispersion, with width $\sqrt{3}\sigma$. 
     89 
     90    .. math:: 
     91 
     92        w = 1 
     93    """ 
    7494    type = "rectangle" 
    7595    default = dict(npts=35, width=0, nsigmas=1.70325) 
     
    81101 
    82102class 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    """ 
    83110    type = "lognormal" 
    84111    default = dict(npts=80, width=0, nsigmas=8) 
    85112    def _weights(self, center, sigma, lb, ub): 
    86113        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) 
    88115        return x, px 
    89116 
    90117 
    91118class 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    """ 
    92134    type = "schulz" 
    93135    default = dict(npts=80, width=0, nsigmas=8) 
     
    102144 
    103145class ArrayDispersion(Dispersion): 
     146    r""" 
     147    Empirical dispersion curve. 
     148 
     149    Use :meth:`set_weights` to set $w = f(x)$. 
     150    """ 
    104151    type = "array" 
    105152    default = dict(npts=35, width=0, nsigmas=1) 
     
    110157 
    111158    def set_weights(self, values, weights): 
     159        """ 
     160        Set the weights for the given x values. 
     161        """ 
    112162        self.values = np.ascontiguousarray(values, 'd') 
    113163        self.weights = np.ascontiguousarray(weights, 'd') 
Note: See TracChangeset for help on using the changeset viewer.