Skip to content

Commit

Permalink
fix(core): fix get_params() when using deferreds
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman committed Aug 30, 2024
1 parent f280e86 commit 08deb9d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ibis_ml/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import numpy as np
import pandas as pd
import pyarrow as pa
from ibis.common.deferred import Deferred
from ibis.common.dispatch import lazy_singledispatch

if TYPE_CHECKING:
Expand Down Expand Up @@ -347,7 +348,7 @@ def get_params(self, deep=True) -> dict[str, Any]:
Notes
-----
Copied from [1]_.
Derived from [1]_.
References
----------
Expand All @@ -356,7 +357,12 @@ def get_params(self, deep=True) -> dict[str, Any]:
out = {}
for key in self._get_param_names():
value = getattr(self, key)
if deep and hasattr(value, "get_params") and not isinstance(value, type):
if (
deep
and hasattr(value, "get_params")
# `hasattr()` always returns `True` for deferred objects
and not isinstance(value, (type, Deferred))
):
deep_items = value.get_params().items()
out.update((key + "__" + k, val) for k, val in deep_items)
out[key] = value
Expand Down

0 comments on commit 08deb9d

Please sign in to comment.