|
27 | 27 | import scipy.sparse
|
28 | 28 |
|
29 | 29 | from .compat import (
|
| 30 | + CFFI_INSTALLED, |
30 | 31 | PANDAS_INSTALLED,
|
31 | 32 | PYARROW_INSTALLED,
|
32 | 33 | arrow_cffi,
|
@@ -1706,8 +1707,8 @@ def __pred_for_pyarrow_table(
|
1706 | 1707 | predict_type: int,
|
1707 | 1708 | ) -> Tuple[np.ndarray, int]:
|
1708 | 1709 | """Predict for a PyArrow table."""
|
1709 |
| - if not PYARROW_INSTALLED: |
1710 |
| - raise LightGBMError("Cannot predict from Arrow without `pyarrow` installed.") |
| 1710 | + if not (PYARROW_INSTALLED and CFFI_INSTALLED): |
| 1711 | + raise LightGBMError("Cannot predict from Arrow without `pyarrow` and `cffi` installed.") |
1711 | 1712 |
|
1712 | 1713 | # Check that the input is valid: we only handle numbers (for now)
|
1713 | 1714 | if not all(arrow_is_integer(t) or arrow_is_floating(t) or arrow_is_boolean(t) for t in table.schema.types):
|
@@ -2186,6 +2187,8 @@ def _lazy_init(
|
2186 | 2187 | elif isinstance(data, np.ndarray):
|
2187 | 2188 | self.__init_from_np2d(data, params_str, ref_dataset)
|
2188 | 2189 | elif _is_pyarrow_table(data):
|
| 2190 | + if not CFFI_INSTALLED: |
| 2191 | + raise LightGBMError("Cannot init dataframe from Arrow without `pyarrow` and `cffi` installed.") |
2189 | 2192 | self.__init_from_pyarrow_table(data, params_str, ref_dataset)
|
2190 | 2193 | elif isinstance(data, list) and len(data) > 0:
|
2191 | 2194 | if _is_list_of_numpy_arrays(data):
|
@@ -2459,8 +2462,8 @@ def __init_from_pyarrow_table(
|
2459 | 2462 | ref_dataset: Optional[_DatasetHandle],
|
2460 | 2463 | ) -> "Dataset":
|
2461 | 2464 | """Initialize data from a PyArrow table."""
|
2462 |
| - if not PYARROW_INSTALLED: |
2463 |
| - raise LightGBMError("Cannot init dataframe from Arrow without `pyarrow` installed.") |
| 2465 | + if not (PYARROW_INSTALLED and CFFI_INSTALLED): |
| 2466 | + raise LightGBMError("Cannot init dataframe from Arrow without `pyarrow` and `cffi` installed.") |
2464 | 2467 |
|
2465 | 2468 | # Check that the input is valid: we only handle numbers (for now)
|
2466 | 2469 | if not all(arrow_is_integer(t) or arrow_is_floating(t) or arrow_is_boolean(t) for t in table.schema.types):
|
|
0 commit comments