nabu.testutils module¶
- nabu.testutils.generate_tests_scenarios(configurations)[source]¶
Generate “scenarios” of tests.
- The parameter is a dictionary where:
the key is the name of a parameter
the value is a list of possible parameters
- This function returns a list of dictionary where:
the key is the name of a parameter
the value is one value of this parameter
- nabu.testutils.get_data(*dataset_path)[source]¶
Get a dataset file from silx.org/pub/nabu/data dataset_args is a list describing a nested folder structures, ex. [“path”, “to”, “my”, “dataset.h5”]
- nabu.testutils.get_array_of_given_shape(img, shape, dtype)[source]¶
From a given image, returns an array of the wanted shape and dtype.
- nabu.testutils.compare_arrays(arr1, arr2, tol, diff=None, absolute_value=True, percent=None, method='max', return_residual=False)[source]¶
Utility to compare two arrays.
- Parameters:
arr1 (numpy.ndarray) – First array to compare
arr2 (numpy.ndarray) – Second array to compare
tol (float) – Tolerance indicating whether arrays are close to eachother.
diff (numpy.ndarray, optional) – Difference arr1 - arr2. If provided, this array is taken instead of arr1 and arr2.
absolute_value (bool, optional) – Whether to take absolute value of the difference.
percent (float) – If set, a “relative” comparison is performed instead of a subtraction: red(|arr1 - arr2|) / (red(|arr1|) * percent) < tol where “red” is the reduction method (mean, max or median).
method – Reduction method. Can be “max”, “mean”, or “median”.
- Returns:
(is_close, residual) if return_residual is set to True
is_close otherwise
Examples
When using method=”mean” and absolute_value=True, this function computes the Mean Absolute Difference (MAD) metric. When also using percent=1.0, this computes the Relative Mean Absolute Difference (RMD) metric.
- nabu.testutils.compare_shifted_images(img1, img2, fwhm_ratio=0.7, return_upper_bound=False)[source]¶
Compare two images that are slightly shifted from one another. Typically, tomography reconstruction wight slightly different CoR. Each image is Fourier-transformed, and the modulus is taken to get rid of the shift between the images. An apodization is done to filter the high frequencies that are usually less relevant.
- Parameters:
img1 (numpy.ndarray) – First image
img2 (numpy.ndarray) – Second image
fwhm_ratio (float, optional) – Ratio defining the apodization in the frequency domain. A small value (eg. 0.2) means that essentually only the low frequencies will be compared. A value of 1.0 means no apodization
return_upper_bound (bool, optional) – Whether to return a (coarse) upper bound of the comparison metric
Notes
- This function roughly computes
where F is the absolute value of the Fourier transform, and phi some shrinking function (here arcsinh).
- class nabu.testutils.NXDatasetMock(data_volume, image_keys, rotation_angles=None, incident_energy=19.0, other_params=None)[source]¶
Bases:
object
An alternative to tomoscan.esrf.mock.MockHDF5, with a different interface. Attributes are not supported !
- property dataset_hdf5_url¶
- property flats¶
- property darks¶