noise_elements

odl.util.testutils.noise_elements(space, n=1)[source]

Create a list of n noise arrays and elements in space.

The arrays contain white noise with standard deviation 1 in the case of floating point dtypes and uniformly spaced values between -10 and 10 in the case of integer dtypes.

The returned elements have the same values as the arrays.

For product spaces the method is called recursively for all sub-spaces.

Parameters:
spaceLinearSpace

Space in which to create an element. The LinearSpace.element method of the space needs to accept input of numpy.ndarray type.

nint, optional

Number of elements to create.

Returns:
arraysnumpy.ndarray or tuple of numpy.ndarray

A single array if n == 1, otherwise a tuple of arrays.

elementsspace element or tuple of space elements

A single element if n == 1, otherwise a tuple of elements.

Notes

This method is intended for internal testing purposes. For more explicit example elements see odl.phantoms and LinearSpaceElement.examples.

Examples

Create single noise element:

>>> space = odl.rn(3)
>>> arr, vector = noise_elements(space)

Create multiple noise elements:

>>> [arr1, arr2], [vector1, vector2] = noise_elements(space, n=2)