Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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