Skip to content

Commit

Permalink
reuse len(parts) as n_parts (#3985)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffineis authored Feb 15, 2021
1 parent 1a294c8 commit d74b1be
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python-package/lightgbm/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,16 @@ def _train(
data_parts = _split_to_parts(data=data, is_matrix=True)
label_parts = _split_to_parts(data=label, is_matrix=False)
parts = [{'data': x, 'label': y} for (x, y) in zip(data_parts, label_parts)]
n_parts = len(parts)

if sample_weight is not None:
weight_parts = _split_to_parts(data=sample_weight, is_matrix=False)
for i in range(len(parts)):
for i in range(n_parts):
parts[i]['weight'] = weight_parts[i]

if group is not None:
group_parts = _split_to_parts(data=group, is_matrix=False)
for i in range(len(parts)):
for i in range(n_parts):
parts[i]['group'] = group_parts[i]

# Start computation in the background
Expand Down

0 comments on commit d74b1be

Please sign in to comment.