format_data#

adata_query._core._formatter.format_data(data: ndarray | Tensor, torch: bool = False, device: device = device(type='cpu')) ndarray | Tensor[source]#

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.

  • torch (Optional[bool]) –

    Toggle whether data should be formatted as torch.Tensor or np.ndarray.

    • Default: False

  • 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]