"git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "296b2a2662a1560c5baa5a0e6ec32cbe290654b9"
Unverified Commit 8f4126d6 authored by James Lamb's avatar James Lamb Committed by GitHub
Browse files

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

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

* list of lists

* use different variable

* use append()
parent a32de359
...@@ -930,7 +930,7 @@ def _predict( ...@@ -930,7 +930,7 @@ def _predict(
num_cols = model.n_features_ + 1 num_cols = model.n_features_ + 1
nrows_per_chunk = data.chunks[0] 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 # need to tell Dask the expected type and shape of individual preds
pred_meta = data._meta pred_meta = data._meta
...@@ -955,14 +955,17 @@ def _predict( ...@@ -955,14 +955,17 @@ def _predict(
# At this point, `out` is a list of lists of delayeds (each of which points to a matrix). # 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. # Concatenate them to return a list of Dask Arrays.
out_arrays: List[dask_Array] = []
for i in range(num_classes): for i in range(num_classes):
out[i] = dask_array_from_delayed( out_arrays.append(
dask_array_from_delayed(
value=delayed(concat_fn)(out[i]), value=delayed(concat_fn)(out[i]),
shape=(data.shape[0], num_cols), shape=(data.shape[0], num_cols),
meta=pred_meta meta=pred_meta
) )
)
return out return out_arrays
data_row = client.compute(data[[0]]).result() data_row = client.compute(data[[0]]).result()
predict_fn = partial( predict_fn = partial(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment