(
data: DataType,
feature_names: Optional[FeatureNames],
feature_types: Optional[FeatureTypes],
enable_categorical: bool,
)
| 1644 | |
| 1645 | |
| 1646 | def _proxy_transform( |
| 1647 | data: DataType, |
| 1648 | feature_names: Optional[FeatureNames], |
| 1649 | feature_types: Optional[FeatureTypes], |
| 1650 | enable_categorical: bool, |
| 1651 | ) -> TransformedData: |
| 1652 | if _is_cudf_pandas(data): |
| 1653 | data = data._fsproxy_fast # pylint: disable=protected-access |
| 1654 | if _is_cudf_df(data) or _is_cudf_ser(data): |
| 1655 | return _transform_cudf_df( |
| 1656 | data, feature_names, feature_types, enable_categorical |
| 1657 | ) |
| 1658 | if _is_cupy_alike(data): |
| 1659 | data = _transform_cupy_array(data) |
| 1660 | return data, feature_names, feature_types |
| 1661 | if _is_dlpack(data): |
| 1662 | return _transform_dlpack(data), feature_names, feature_types |
| 1663 | if _is_list(data) or _is_tuple(data): |
| 1664 | data = np.array(data) |
| 1665 | if _is_np_array_like(data): |
| 1666 | data, _ = _ensure_np_dtype(data, data.dtype) |
| 1667 | return data, feature_names, feature_types |
| 1668 | if is_scipy_csr(data): |
| 1669 | data = transform_scipy_sparse(data, True) |
| 1670 | return data, feature_names, feature_types |
| 1671 | if is_scipy_csc(data): |
| 1672 | data = transform_scipy_sparse(data.tocsr(), True) |
| 1673 | return data, feature_names, feature_types |
| 1674 | if is_scipy_coo(data): |
| 1675 | data = transform_scipy_sparse(data.tocsr(), True) |
| 1676 | return data, feature_names, feature_types |
| 1677 | if _is_polars(data): |
| 1678 | df_pl, feature_names, feature_types = _transform_polars_df( |
| 1679 | data, enable_categorical, feature_names, feature_types |
| 1680 | ) |
| 1681 | return df_pl, feature_names, feature_types |
| 1682 | if _is_pandas_series(data): |
| 1683 | pd = import_pandas() |
| 1684 | |
| 1685 | data = pd.DataFrame(data) |
| 1686 | if _is_arrow(data): |
| 1687 | df_pa, feature_names, feature_types = _transform_arrow_table( |
| 1688 | data, enable_categorical, feature_names, feature_types |
| 1689 | ) |
| 1690 | return df_pa, feature_names, feature_types |
| 1691 | if _is_pandas_df(data): |
| 1692 | df, feature_names, feature_types = _transform_pandas_df( |
| 1693 | data, enable_categorical, feature_names, feature_types |
| 1694 | ) |
| 1695 | return df, feature_names, feature_types |
| 1696 | raise TypeError("Value type is not supported for data iterator:" + str(type(data))) |
| 1697 | |
| 1698 | |
| 1699 | def is_on_cuda(data: Any) -> bool: |
no test coverage detected