From 9c60283333dc30db9578cb48933e3e7007eae938 Mon Sep 17 00:00:00 2001 From: Chong Shen Ng Date: Wed, 6 Nov 2024 11:33:42 +0000 Subject: [PATCH] Update can_cast type --- src/py/flwr/server/strategy/aggregate.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py/flwr/server/strategy/aggregate.py b/src/py/flwr/server/strategy/aggregate.py index 94beacba0087..16a6c1faba96 100644 --- a/src/py/flwr/server/strategy/aggregate.py +++ b/src/py/flwr/server/strategy/aggregate.py @@ -48,12 +48,12 @@ def aggregate_inplace(results: list[tuple[ClientProxy, FitRes]]) -> NDArrays: num_examples_total = sum(fit_res.num_examples for (_, fit_res) in results) # Compute scaling factors for each result - scaling_factors = [ - fit_res.num_examples / num_examples_total for _, fit_res in results - ] + scaling_factors = np.asarray( + [fit_res.num_examples / num_examples_total for _, fit_res in results] + ) def _try_inplace( - x: NDArray, y: Union[NDArray, float], np_binary_op: np.ufunc + x: NDArray, y: Union[NDArray, np.float64], np_binary_op: np.ufunc ) -> NDArray: return ( # type: ignore[no-any-return] np_binary_op(x, y, out=x)