diff --git a/python-package/xgboost/dask.py b/python-package/xgboost/dask.py index 579e4dd4f2b8..0d3eb7cf159f 100644 --- a/python-package/xgboost/dask.py +++ b/python-package/xgboost/dask.py @@ -1551,7 +1551,7 @@ async def _async_wrap_evaluation_matrices( """A switch function for async environment.""" def _dispatch(ref: Optional[DaskDMatrix], **kwargs: Any) -> DaskDMatrix: - if tree_method == "hist" or tree_method == "gpu_hist": + if tree_method in ("hist", "gpu_hist"): return DaskQuantileDMatrix( client=client, ref=ref, max_bin=max_bin, **kwargs ) diff --git a/python-package/xgboost/sklearn.py b/python-package/xgboost/sklearn.py index 9b0188e68817..d820ccc01f87 100644 --- a/python-package/xgboost/sklearn.py +++ b/python-package/xgboost/sklearn.py @@ -910,7 +910,7 @@ def _duplicated(parameter: str) -> None: def _create_dmatrix(self, ref: Optional[DMatrix], **kwargs: Any) -> DMatrix: # Use `QuantileDMatrix` to save memory. - if self.tree_method == "hist" or self.tree_method == "gpu_hist": + if self.tree_method in ("hist", "gpu_hist"): try: return QuantileDMatrix( **kwargs, ref=ref, nthread=self.n_jobs, max_bin=self.max_bin