silx.test
:¶
silx.test
¶
This package provides access to the full silx test suite.
It is possible to disable tests depending on Qt by setting
silx.test.utils.test_options.WITH_QT_TEST = False
It will skip all tests from silx.test.gui
.
silx.test.utils
¶
Utilities for writing tests.
temp_dir()
provides a with context to create/delete a temporary directory.
-
utilstest
= <silx.resources.ExternalResources object>¶ This is the instance to be used. Singleton-like feature provided by module
-
test_options
= <silx.test.utils._TestOptions object>¶ Singleton providing configuration information for all the tests
-
temp_dir
(*args, **kwds)[source]¶ with context providing a temporary directory.
>>> import os.path >>> with temp_dir() as tmp: ... print(os.path.isdir(tmp)) # Use tmp directory
-
add_gaussian_noise
(y, stdev=1.0, mean=0.0)[source]¶ Add random gaussian noise to synthetic data.
Parameters: - y (ndarray) – Array of synthetic data
- mean (float) – Mean of the gaussian distribution of noise.
- stdev (float) – Standard deviation of the gaussian distribution of noise.
Returns: Array of data with noise added
-
add_poisson_noise
(y)[source]¶ Add random noise from a poisson distribution to synthetic data.
Parameters: y (ndarray) – Array of synthetic data Returns: Array of data with noise added
-
add_relative_noise
(y, max_noise=5.0)[source]¶ Add relative random noise to synthetic data. The maximum noise level is given in percents.
An array of noise in the interval [-max_noise, max_noise] (continuous uniform distribution) is generated, and applied to the data the following way:
\(yn = y * (1. + noise / 100.)\)
Parameters: - y (ndarray) – Array of synthetic data
- max_noise (float) – Maximum percentage of noise
Returns: Array of data with noise added