Repository: scipy/scipy
File: scipy/optimize/_cobyqa_py.py (Python)

Code before:
        Target value for the objective function. The optimization procedure is
        terminated when the objective function value of a feasible point (see
        `feasibility_tol` below) is less than or equal to this target. Default
        is ``-numpy.inf``.
    feasibility_tol : float
        Absolute tolerance for the constraint violation. Default is ``1e-8``.
    initial_tr_radius : float
        Initial trust-region radius. Typically, this value should be in the
        order of one tenth of the greatest expected change to the variables.
        Default is ``1.0``.
    final_tr_radius : float
        Final trust-region radius. It should indicate the accuracy required in
        the final values of the variables. If provided, this option overrides
        the value of `tol` in the `minimize` function. Default is ``1e-6``.
    scale : bool
        Set to True to scale the variables according to the bounds. If True and
        if all the lower and upper bounds are finite, the variables are scaled
        to be within the range :math:`[-1, 1]`. If any of the lower or upper
        bounds is infinite, the variables are not scaled. Default is ``False``.

    References
    ----------
    .. [1] COBYQA
           https://www.cobyqa.com/stable/
    """
    from .._lib.cobyqa import minimize  # import here to avoid circular imports

    _check_unknown_options(unknown_options)
    options = {
        'disp': bool(disp),
        'maxfev': int(maxfev) if maxfev is not None else 500 * len(x0),
        'maxiter': int(maxiter) if maxiter is not None else 1000 * len(x0),
        'target': float(f_target),
        'feasibility_tol': float(feasibility_tol),
        'radius_init': float(initial_tr_radius),
        'radius_final': float(final_tr_radius),
        'scale': bool(scale),
    }
    return minimize(fun, x0, args, bounds, constraints, callback, options)


Review comment (suggestion):
```suggestion
    from .._lib.cobyqa import minimize as _cobqa_minimize # import here to avoid circular imports
```

Code after:
        `feasibility_tol` below) is less than or equal to this target. Default
        is ``-numpy.inf``.
    feasibility_tol : float
        Absolute tolerance for the constraint violation. Default is ``1e-8``.
    initial_tr_radius : float
        Initial trust-region radius. Typically, this value should be in the
        order of one tenth of the greatest expected change to the variables.
        Default is ``1.0``.
    final_tr_radius : float
        Final trust-region radius. It should indicate the accuracy required in
        the final values of the variables. If provided, this option overrides
        the value of `tol` in the `minimize` function. Default is ``1e-6``.
    scale : bool
        Set to True to scale the variables according to the bounds. If True and
        if all the lower and upper bounds are finite, the variables are scaled
        to be within the range :math:`[-1, 1]`. If any of the lower or upper
        bounds is infinite, the variables are not scaled. Default is ``False``.

    References
    ----------
    .. [1] COBYQA
           https://www.cobyqa.com/stable/
    """
    # Import here to avoid circular imports
    from .._external.cobyqa import minimize as _cobyqa_minimize

    _check_unknown_options(unknown_options)
    options = {
        'disp': bool(disp),
        'maxfev': int(maxfev) if maxfev is not None else 500 * len(x0),
        'maxiter': int(maxiter) if maxiter is not None else 1000 * len(x0),
        'target': float(f_target),
        'feasibility_tol': float(feasibility_tol),
        'radius_init': float(initial_tr_radius),
        'radius_final': float(final_tr_radius),
        'scale': bool(scale),
    }
    return _cobyqa_minimize(fun, x0, args, bounds, constraints, callback, options)