get_array_and_backend
- odl.get_array_and_backend(x, must_be_contiguous=False)
Convenience function for getting an
ArrayBackendfrom anarray-likeargument.Parameters
- xArray-Like.
It can be a
np.ndarray, atorch.Tensor, an ODLTensoror aProductSpaceElement. Object to return theArrayBackendand actual underlying array from.- must_be_contiguousbool
Boolean flag to indicate whether or not to make the array contiguous.
Returns
- xactual array
-> unwrapped from the LinearSpaceElement -> returned as is if it was already an array.
backend : ODL
ArrayBackendobjectExamples
>>> array, backend = get_array_and_backend(np.zeros(2)) >>> array array([ 0., 0.]) >>> backend ArrayBackend(impl=numpy) >>> array, backend = get_array_and_backend([1,2,3]) Traceback (most recent call last): ValueError: f"The registered array backends are ['numpy']. The argument provided is a list, check that the backend you want to use is supported and has been correctly instanciated."