DataFormatter#

class adata_query._core._formatter.DataFormatter(data: Tensor | ndarray, *args, **kwargs)[source]#

Bases: ABCParse

Format data to interface with numpy or torch, on a specified device.

Parameters:

data (Union[np.ndarray, torch.Tensor]) – Input data to be formatted. Typically an np.ndarray, torch.Tensor, or ArrayView.

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_numpy() ndarray[source]#

Sends data to np.ndarray

to_torch(device: device = device(type='cpu')) Tensor[source]#

Description of function.

Parameters:
  • device (Optional[torch.device]) – If torch==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]