abracudabra.conversion.carray ============================= .. py:module:: abracudabra.conversion.carray .. autoapi-nested-parse:: Convert to numpy or cupy arrays. Functions --------- .. autoapisummary:: abracudabra.conversion.carray._torch_to_array abracudabra.conversion.carray._array_to_array abracudabra.conversion.carray._pandas_frame_to_array abracudabra.conversion.carray._cudf_frame_to_array abracudabra.conversion.carray._any_to_array abracudabra.conversion.carray.to_array Module Contents --------------- .. py:function:: _torch_to_array(tensor: torch.Tensor, /, device: str | abracudabra.device.base.Device | None = None) -> abracudabra.annotations.Array Convert a torch tensor to a numpy array. .. py:function:: _array_to_array(array: abracudabra.annotations.Array, /, device: str | abracudabra.device.base.Device | None = None) -> abracudabra.annotations.Array Convert a numpy/cupy array to a numpy/cupy array. The array is converted to the desired device if specified. .. py:function:: _pandas_frame_to_array(frame: pandas.Index | pandas.Series[Any] | pandas.DataFrame, /, device: str | abracudabra.device.base.Device | None = None) -> abracudabra.annotations.Array .. py:function:: _cudf_frame_to_array(frame: cudf.Index | cudf.Series | cudf.DataFrame, /, device: str | abracudabra.device.base.Device | None = None) -> abracudabra.annotations.Array .. py:function:: _any_to_array(sequence: object, /, device: str | abracudabra.device.base.Device | None) -> abracudabra.annotations.Array .. py:function:: to_array(sequence: abracudabra.annotations.Array | abracudabra.annotations.Series | abracudabra.annotations.DataFrame | torch.Tensor, /, device: str | abracudabra.device.base.Device | None = None, *, strict: bool = False) -> abracudabra.annotations.Array Convert an array, series, or dataframe to a numpy array. :param sequence: The sequence to convert. :param device: The device to convert the sequence to. If None, the sequence stays on the same device. :param strict: Whether to raise an error if the sequence is not a valid type. A numpy/cupy array, pandas/cudf series or dataframe, or torch tensor are valid types. If False, the sequence is converted to a numpy/cupy array if possible, but it might raise an error if the conversion is not possible. :returns: A numpy/cupy array.