Skip to content

Commit

Permalink
update _using_cv() check
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb committed Dec 17, 2024
1 parent cf12c81 commit a989f5f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python-package/lightgbm/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ class CallbackEnv:


def _using_cv(env: CallbackEnv) -> bool:
return env.__class__.__name__ == "CVBooster"
"""Check if model in callback env is a CVBooster"""
# this string-matching is used instead of isinstance() to avoid a circular import
return env.model.__class__.__name__ == "CVBooster" or any(
c.__name__ == "CVBooster" for c in env.model.__class__.__bases__
)


def _format_eval_result(value: _EvalResultTuple, show_stdv: bool) -> str:
Expand Down

0 comments on commit a989f5f

Please sign in to comment.