Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: José Morales <[email protected]>
  • Loading branch information
jameslamb and jmoralez authored Oct 4, 2023
1 parent 4b988a0 commit 56f73b4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions python-package/lightgbm/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def __call__(self, env: CallbackEnv) -> None:
env.model.reset_parameter(new_parameters)
else:
# CVBooster holds a list of Booster objects, each needs to be updated
for i in range(len(env.model.boosters)):
env.model.boosters[i].reset_parameter(new_parameters)
for booster in env.model.boosters:
booster.reset_parameter(new_parameters)
env.params.update(new_parameters)


Expand Down Expand Up @@ -304,9 +304,8 @@ def _is_train_set(self, ds_name: str, eval_name: str, env: CallbackEnv) -> bool:
return True

# for lgb.train(), it's possible to pass the training data via valid_sets with any eval_name
if isinstance(env.model, Booster):
if ds_name == env.model._train_data_name:
return True
if isinstance(env.model, Booster) and ds_name == env.model._train_data_name:
return True

return False

Expand Down

0 comments on commit 56f73b4

Please sign in to comment.