def format_result(fit):
    """
    Formats a pyDDM fit object into something more useful
    by extracting parameter estimates and the loss function value.
    """
    parameter_names = fit.get_model_parameter_names()
    estimates = [fitted.real for fitted in fit.get_model_parameters()]

    estimate_dict = {
        parameter: estimate for parameter, estimate in zip(parameter_names, estimates)
    }

    lossfun = fit.fitresult.loss
    lossval = fit.fitresult.value()

    return {
        "estimates": estimate_dict,
        "loss": fit.fitresult.value(),
        "lossfun": fit.fitresult.loss,
        "model": fit.name,
        "n_params": None,
    }