示例#1
0
def test_fit_clients() -> None:
    """Test fit_clients."""
    # Prepare
    clients: List[ClientProxy] = [
        FailingCLient("0"),
        SuccessClient("1"),
    ]
    arr = np.array([[1, 2], [3, 4], [5, 6]])
    arr_serialized = ndarray_to_bytes(arr)
    ins: FitIns = FitIns(Parameters(tensors=[arr_serialized], tensor_type=""), {})
    client_instructions = [(c, ins) for c in clients]

    # Execute
    results, failures = fit_clients(client_instructions)

    # Assert
    assert len(results) == 1
    assert len(failures) == 1
    assert results[0][1].num_examples == 1
示例#2
0
 def fit(self, ins: FitIns) -> FitRes:
     arr = np.array([[1, 2], [3, 4], [5, 6]])
     arr_serialized = ndarray_to_bytes(arr)
     return FitRes(Parameters(tensors=[arr_serialized], tensor_type=""), 1, 1, 12.3)