ArrayBackend.get_dtype_identifier
- ArrayBackend.get_dtype_identifier(**kwargs) str[source]
Method for getting a dtype_identifier (str) from an array or a dtype. This is used to retrieve the dtype of a custom object as a string and pass it to another backend. The dtype must actually be a dtype object pertaining to the
selfbackend. Strings or Python types are not allowed here. Useodl.core.util.dtype_utils._universal_dtype_identifierfor a general conversion from dtype-ish objects to identifiers.Parameters
- **kwargs‘array’ or ‘dtype’
This function inputs either an array OR a dtype
Returns
dtype_identifier (str)
Examples
>>> backend = odl.lookup_array_backend('numpy') >>> backend.get_dtype_identifier(array=np.zeros(10)) 'float64' >>> backend.get_dtype_identifier(array=np.zeros(10, dtype = 'float32')) 'float32' >>> backend.get_dtype_identifier(array=np.zeros(10, float)) 'float64' >>> backend.get_dtype_identifier(dtype=np.dtype('float64')) 'float64' >>> backend.get_dtype_identifier(dtype=np.zeros(10, dtype = 'float32').dtype) 'float32' >>> backend.get_dtype_identifier(dtype=np.dtype(float)) 'float64' >>> backend.get_dtype_identifier(dtype=np.dtype(float), array=np.zeros(10, float)) Traceback (most recent call last): AssertionError: "array and dtype are mutually exclusive parameters" >>> backend.get_dtype_identifier(np.dtype(float)) Traceback (most recent call last): TypeError: "ArrayBackend.get_dtype_identifier() takes 1 positional argument but 2 were given"