# Path: pybobyqa/util.py
# def remove_scaling(x_scaled, scaling_changes):
#     if scaling_changes is None:
#         return x_scaled
#     shift, scale = scaling_changes
#     return shift + x_scaled * scale


import numpy as np
    import pandas as pd
from .util import remove_scaling
        self.data["slow_iter"] = []
        return

    def to_dataframe(self, with_xk=False):
        data_to_save = {}
        for key in self.data:
            if key == "xk" and not with_xk:
                continue  # skip
            data_to_save[key] = self.data[key]
        if HAVE_PANDAS:
            return pd.DataFrame(data_to_save)
        else:
            return data_to_save

    def to_csv(self, filename):
        df = self.to_dataframe()
        df.to_csv(filename)

    def save_info_from_control(self, control, nruns, iter_this_run, save_poisedness=True):
        self.data["iters_total"].append(len(self.data["iters_total"]))
        self.data["nruns"].append(nruns)
        self.data["iter_this_run"].append(iter_this_run)
        # Get what info we can out of a control
        self.data["nf"].append(control.nf)
        self.data["nx"].append(control.nx)
        self.data["delta"].append(control.delta)
        self.data["rho"].append(control.rho)
        # And from a model?
        self.data["npt"].append(control.model.npt())
        x, f, gradmin, hessmin, nsamples = control.model.get_final_results()

# Path: pybobyqa/util.py
# def remove_scaling(x_scaled, scaling_changes):
#     if scaling_changes is None:
#         return x_scaled
#     shift, scale = scaling_changes
#     return shift + x_scaled * scale


# Path: pybobyqa/diagnostic_info.py
import numpy as np
    import pandas as pd
from .util import remove_scaling

        self.data["slow_iter"] = []
        return

    def to_dataframe(self, with_xk=False):
        data_to_save = {}
        for key in self.data:
            if key == "xk" and not with_xk:
                continue  # skip
            data_to_save[key] = self.data[key]
        if HAVE_PANDAS:
            return pd.DataFrame(data_to_save)
        else:
            return data_to_save

    def to_csv(self, filename):
        df = self.to_dataframe()
        df.to_csv(filename)

    def save_info_from_control(self, control, nruns, iter_this_run, save_poisedness=True):
        self.data["iters_total"].append(len(self.data["iters_total"]))
        self.data["nruns"].append(nruns)
        self.data["iter_this_run"].append(iter_this_run)
        # Get what info we can out of a control
        self.data["nf"].append(control.nf)
        self.data["nx"].append(control.nx)
        self.data["delta"].append(control.delta)
        self.data["rho"].append(control.rho)
        # And from a model?
        self.data["npt"].append(control.model.npt())
        x, f, gradmin, hessmin, nsamples = control.model.get_final_results()

        self.data["xk"].append(remove_scaling(x, control.scaling_changes))