src/estimagic/optimization/get_algorithm.py
def _algorithm_with_logging_template(
    criterion_and_derivative,
    x,
    step_id,
    algorithm,
    logging,
    db_kwargs,
):
    """Wrapped algorithm that logs its status.

    Args:
        criterion_and_derivative (callable): Version of the
            ``internal_criterion_and_derivative_template`` all arguments except for
            ``x``, ``task`` and ``fixed_log_data`` have been partialled in.
        x (np.ndarray): Parameter vector.
        step_id (int): Internal id of the optimization step.
        logging (bool): Whether logging is used.
        algorithm (callable): The internal algorithm where all argument except for
            ``x`` and ``criterion_and_derivative`` are already partialled in.
        db_kwargs (dict): Dict with the entries "database", "path" and "fast_logging"


    Returns:
        dict: Same result as internal algorithm.

    """

    if logging:
        step_id = int(step_id)
        update_row(
            data={"status": "running"},
            rowid=step_id,
            table_name="steps",
            **db_kwargs,
        )

    func = partial(criterion_and_derivative, fixed_log_data={"step": step_id})
    res = algorithm(func, x)

    if logging:
        update_row(
            data={"status": "complete"},
            rowid=step_id,
            table_name="steps",
            **db_kwargs,
        )

    return res
Wrapped algorithm that logs its status.

    Args:
        criterion_and_derivative (callable): Version of the
            ``internal_criterion_and_derivative_template`` all arguments except for
            ``x``, ``task`` and ``fixed_log_data`` have been partialled in.
        x (np.ndarray): Parameter vector.
        step_id (int): Internal id of the optimization step.
        logging (bool): Whether logging is used.
        algorithm (callable): The internal algorithm where all argument except for
            ``x`` and ``criterion_and_derivative`` are already partialled in.
        db_kwargs (dict): Dict with the entries "database", "path" and "fast_logging"


    Returns:
        dict: Same result as internal algorithm.

    
Wrapped algorithm that logs its status.
Wrapped algorithm that logs its status .
def _algorithm_with_logging_template(
    criterion_and_derivative,
    x,
    step_id,
    algorithm,
    logging,
    db_kwargs,
):
    if logging:
        step_id = int(step_id)
        update_row(
            data={"status": "running"},
            rowid=step_id,
            table_name="steps",
            **db_kwargs,
        )
    func = partial(criterion_and_derivative, fixed_log_data={"step": step_id})
    res = algorithm(func, x)
    if logging:
        update_row(
            data={"status": "complete"},
            rowid=step_id,
            table_name="steps",
            **db_kwargs,
        )
    return res
def _algorithm_with_logging_template ( criterion_and_derivative , x , step_id , algorithm , logging , db_kwargs , ) : if logging : step_id = int ( step_id ) update_row ( data = { "status" : "running" } , rowid = step_id , table_name = "steps" , ** db_kwargs , ) func = partial ( criterion_and_derivative , fixed_log_data = { "step" : step_id } ) res = algorithm ( func , x ) if logging : update_row ( data = { "status" : "complete" } , rowid = step_id , table_name = "steps" , ** db_kwargs , ) return res
Wrapped algorithm that logs its status.
Wrapped algorithm that logs its status .
"""Wrapped algorithm that logs its status.

    Args:
        criterion_and_derivative (callable): Version of the
            ``internal_criterion_and_derivative_template`` all arguments except for
            ``x``, ``task`` and ``fixed_log_data`` have been partialled in.
        x (np.ndarray): Parameter vector.
        step_id (int): Internal id of the optimization step.
        logging (bool): Whether logging is used.
        algorithm (callable): The internal algorithm where all argument except for
            ``x`` and ``criterion_and_derivative`` are already partialled in.
        db_kwargs (dict): Dict with the entries "database", "path" and "fast_logging"


    Returns:
        dict: Same result as internal algorithm.

    """
Same result as internal algorithm.
Same result as internal algorithm .
dict
criterion_and_derivative
Version of the
``internal_criterion_and_derivative_template`` all arguments except for
``x``, ``task`` and ``fixed_log_data`` have been partialled in.
Version of the ` ` internal_criterion_and_derivative_template ` ` all arguments except for ` ` x ` ` ` ` task ` ` and ` ` fixed_log_data ` ` have been partialled in .
x
None
step_id
Internal id of the optimization step.
Internal id of the optimization step .
algorithm
The internal algorithm where all argument except for
``x`` and ``criterion_and_derivative`` are already partialled in.
The internal algorithm where all argument except for ` ` x ` ` and ` ` criterion_and_derivative ` ` are already partialled in .
logging
Whether logging is used.
Whether logging is used .
db_kwargs
Dict with the entries "database", "path" and "fast_logging"
Dict with the entries " database " " path " and " fast_logging "