DataFormatter#
- class adata_query._core._formatter.DataFormatter(data: Tensor | ndarray, *args, **kwargs)[source]#
Bases:
ABCParseFormat data to interface with numpy or torch, on a specified device.
- Parameters:
data (
Union[np.ndarray, torch.Tensor]) – Inputdatato be formatted. Typically annp.ndarray,torch.Tensor, orArrayView.- Returns:
None
- property device_type: str#
Returns device type
- property is_ArrayView: bool#
Checks if device is of type ArrayView
- property is_numpy_array: bool#
Checks if device is of type np.ndarray
- property is_torch_Tensor: bool#
Checks if device is of type torch.Tensor
- property on_cpu: bool#
Checks if device is on cuda or mps
- property on_gpu: bool#
Checks if device is on cuda or mps
- to_torch(device: device = device(type='cpu')) Tensor[source]#
Description of function.
- Parameters:
device (
Optional[torch.device]) – Iftorch==True, the device (e.g.:"cpu","cuda:0","mps:0") may be set. The default value,autodevice.AutoDevice()will indicate the use of GPU, if available.Default (-) –
autodevice.AutoDevice()
- Returns:
formatted_data- Return type:
Union[np.ndarray, torch.Tensor]