Home

3.10. Unit test support

«  3.9. Python model evaluator   ::   Contents   ::   3.11. 1-D resolution functions  »

3.10. Unit test support

3.10.1. sasmodels.model_test

Run model unit tests.

Usage:

python -m sasmodels.model_test [opencl|dll|opencl_and_dll] model1 model2 ...

if model1 is 'all', then all except the remaining models will be tested

Each model is tested using the default parameters at q=0.1, (qx,qy)=(0.1,0.1), and the ER and VR are computed. The return values at these points are not considered. The test is only to verify that the models run to completion, and do not produce inf or NaN.

Tests are defined with the tests attribute in the model.py file. tests is a list of individual tests to run, where each test consists of the parameter values for the test, the q-values and the expected results. For the effective radius test, the q-value should be ‘ER’. For the VR test, the q-value should be ‘VR’. For 1-D tests, either specify the q value or a list of q-values, and the corresponding I(q) value, or list of I(q) values.

That is:

tests = [
    [ {parameters}, q, I(q)],
    [ {parameters}, [q], [I(q)] ],
    [ {parameters}, [q1, q2, ...], [I(q1), I(q2), ...]],

    [ {parameters}, (qx, qy), I(qx, Iqy)],
    [ {parameters}, [(qx1, qy1), (qx2, qy2), ...],
                    [I(qx1,qy1), I(qx2,qy2), ...]],

    [ {parameters}, 'ER', ER(pars) ],
    [ {parameters}, 'VR', VR(pars) ],
    ...
]

Parameters are key:value pairs, where key is one of the parameters of the model and value is the value to use for the test. Any parameters not given in the parameter list will take on the default parameter value.

Precision defaults to 5 digits (relative).

sasmodels.model_test.main()

Run tests given is sys.argv.

Returns 0 if success or 1 if any tests fail.

sasmodels.model_test.make_suite(loaders, models)
sasmodels.model_test.model_tests()

Test runner visible to nosetests.

Run “nosetests sasmodels” on the command line to invoke it.

«  3.9. Python model evaluator   ::   Contents   ::   3.11. 1-D resolution functions  »