Changeset 0b96ed1 in sasmodels

Ignore:
Timestamp:
Oct 30, 2018 10:36:38 AM (13 days ago)
Parents:
c6084f1 (diff), 7b5898f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
git-committer:
Message:
Files:
6 edited

Unmodified
Removed
• sasmodels/model_test.py

 r12eec1e from __future__ import print_function import argparse import sys import unittest def main(*models): def main(): # type: (*str) -> int """ test_args = {} if models and models[0] == '-v': verbosity = 2 models = models[1:] else: verbosity = 1 if models and models[0] == 'opencl': parser = argparse.ArgumentParser(description="Test SasModels Models") parser.add_argument("-v", "--verbose", action="store_const", default=1, const=2, help="Use verbose output") parser.add_argument("engine", metavar="[engine]", help="Engines on which to run the test.  " "Valid values are opencl, dll, and opencl_and_dll. " "Defaults to opencl_and_dll if no value is given") parser.add_argument("models", nargs="*", help='The names of the models to be tested.  ' 'If the first model is "all", then all except the ' 'remaining models will be tested.') args, models = parser.parse_known_args() if args.engine == "opencl": if not use_opencl(): print("opencl is not available") return 1 loaders = ['opencl'] models = models[1:] elif models and models[0] == 'dll': # TODO: test if compiler is available? loaders = ['dll'] models = models[1:] elif models and models[0] == 'opencl_and_dll': elif args.engine == "dll": loaders = ["dll"] elif args.engine == "opencl_and_dll": loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] models = models[1:] else: # Default to running both engines loaders = ['opencl', 'dll'] if use_opencl() else ['dll'] if not models: print("""\ usage: python -m sasmodels.model_test [-v] [opencl|dll] model1 model2 ... If -v is included on the command line, then use verbose output. If neither opencl nor dll is specified, then models will be tested with both OpenCL and dll; the compute target is ignored for pure python models. If model1 is 'all', then all except the remaining models will be tested. """) return 1 runner = TestRunner(verbosity=verbosity, **test_args) result = runner.run(make_suite(loaders, models)) args.models.insert(0, args.engine) runner = TestRunner(verbosity=args.verbose, **test_args) result = runner.run(make_suite(loaders, args.models)) return 1 if result.failures or result.errors else 0 if __name__ == "__main__": sys.exit(main(*sys.argv[1:])) sys.exit(main())
• doc/guide/plugin.rst

 r2015f02 def random(): ... This function provides a model-specific random parameter set which shows model features in the USANS to SANS range.  For example, core-shell sphere sets the outer radius of the sphere logarithmically in [20, 20,000], which sets the Q value for the transition from flat to falling.  It then uses a beta distribution to set the percentage of the shape which is shell, giving a preference for very thin or very thick shells (but never 0% or 100%).  Using -sets=10 in sascomp should show a reasonable variety of curves over the default sascomp q range. The parameter set is returned as a dictionary of {parameter: value, ...}. Any model parameters not included in the dictionary will default according to This function provides a model-specific random parameter set which shows model features in the USANS to SANS range.  For example, core-shell sphere sets the outer radius of the sphere logarithmically in [20, 20,000], which sets the Q value for the transition from flat to falling.  It then uses a beta distribution to set the percentage of the shape which is shell, giving a preference for very thin or very thick shells (but never 0% or 100%).  Using -sets=10 in sascomp should show a reasonable variety of curves over the default sascomp q range. The parameter set is returned as a dictionary of {parameter: value, ...}. Any model parameters not included in the dictionary will default according to the code in the _randomize_one() function from sasmodels/compare.py. erf, erfc, tgamma, lgamma:  **do not use** Special functions that should be part of the standard, but are missing or inaccurate on some platforms. Use sas_erf, sas_erfc and sas_gamma instead (see below). Note: lgamma(x) has not yet been tested. or inaccurate on some platforms. Use sas_erf, sas_erfc, sas_gamma and sas_lgamma instead (see below). Some non-standard constants and functions are also provided: Gamma function sas_gamma\ $(x) = \Gamma(x)$. The standard math function, tgamma(x) is unstable for $x < 1$ The standard math function, tgamma(x), is unstable for $x < 1$ on some platforms. :code:source = ["lib/sas_gamma.c", ...] (sas_gamma.c _) sas_gammaln(x): log gamma function sas_gammaln\ $(x) = \log \Gamma(|x|)$. The standard math function, lgamma(x), is incorrect for single precision on some platforms. :code:source = ["lib/sas_gammainc.c", ...] (sas_gammainc.c _) sas_gammainc(a, x), sas_gammaincc(a, x): Incomplete gamma function sas_gammainc\ $(a, x) = \int_0^x t^{a-1}e^{-t}\,dt / \Gamma(a)$ and complementary incomplete gamma function sas_gammaincc\ $(a, x) = \int_x^\infty t^{a-1}e^{-t}\,dt / \Gamma(a)$ :code:source = ["lib/sas_gammainc.c", ...] (sas_gammainc.c _) sas_erf(x), sas_erfc(x): If $n$ = 0 or 1, it uses sas_J0($x$) or sas_J1($x$), respectively. Warning: JN(n,x) can be very inaccurate (0.1%) for x not in [0.1, 100]. The standard math function jn(n, x) is not available on all platforms. Sine integral Si\ $(x) = \int_0^x \tfrac{\sin t}{t}\,dt$. Warning: Si(x) can be very inaccurate (0.1%) for x in [0.1, 100]. This function uses Taylor series for small and large arguments: For large arguments, For large arguments use the following Taylor series, .. math:: - \frac{\sin(x)}{x}\left(\frac{1}{x} - \frac{3!}{x^3} + \frac{5!}{x^5} - \frac{7!}{x^7}\right) For small arguments, For small arguments , .. math::
• explore/precision.py

 rdf69efa The standard math function, tgamma(x) is unstable for $x < 1$ on some platforms. sas_gammaln(x): log gamma function sas_gammaln\ $(x) = \log \Gamma(|x|)$. The standard math function, lgamma(x), is incorrect for single precision on some platforms. sas_gammainc(a, x), sas_gammaincc(a, x): Incomplete gamma function sas_gammainc\ $(a, x) = \int_0^x t^{a-1}e^{-t}\,dt / \Gamma(a)$ and complementary incomplete gamma function sas_gammaincc\ $(a, x) = \int_x^\infty t^{a-1}e^{-t}\,dt / \Gamma(a)$ sas_erf(x), sas_erfc(x): from numpy import pi, nan, inf from scipy.special import gamma as sas_gamma from scipy.special import gammaln as sas_gammaln from scipy.special import gammainc as sas_gammainc from scipy.special import gammaincc as sas_gammaincc from scipy.special import erf as sas_erf from scipy.special import erfc as sas_erfc