Skip to content

Commit

Permalink
[python-package] fix mypy error about missing type hint in dask.py (#…
Browse files Browse the repository at this point in the history
…4840)

* [python-package] fix mypy error about missing type hint in dask.py

* list of lists

* use different variable

* use append()
  • Loading branch information
jameslamb authored Dec 1, 2021
1 parent a32de35 commit 8f4126d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions python-package/lightgbm/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ def _extract(items: List[Any], i: int) -> Any:
num_cols = model.n_features_ + 1

nrows_per_chunk = data.chunks[0]
out = [[] for _ in range(num_classes)]
out: List[List[dask_Array]] = [[] for _ in range(num_classes)]

# need to tell Dask the expected type and shape of individual preds
pred_meta = data._meta
Expand All @@ -955,14 +955,17 @@ def _extract(items: List[Any], i: int) -> Any:

# At this point, `out` is a list of lists of delayeds (each of which points to a matrix).
# Concatenate them to return a list of Dask Arrays.
out_arrays: List[dask_Array] = []
for i in range(num_classes):
out[i] = dask_array_from_delayed(
value=delayed(concat_fn)(out[i]),
shape=(data.shape[0], num_cols),
meta=pred_meta
out_arrays.append(
dask_array_from_delayed(
value=delayed(concat_fn)(out[i]),
shape=(data.shape[0], num_cols),
meta=pred_meta
)
)

return out
return out_arrays

data_row = client.compute(data[[0]]).result()
predict_fn = partial(
Expand Down

0 comments on commit 8f4126d

Please sign in to comment.