"""Collection of tests for :mod:`orion.plotting.backend_plotly`."""
import copy

import numpy
import pandas
import plotly
import pytest

import orion.client
from orion.analysis.partial_dependency_utils import partial_dependency_grid
from orion.core.worker.experiment import Experiment
from orion.plotting.base import (
    lpi,
    parallel_coordinates,
    partial_dependencies,
    rankings,
    regret,
    regrets,
)
from orion.testing import create_experiment
from orion.testing.plotting import (
    assert_lpi_plot,
    assert_parallel_coordinates_plot,
    assert_partial_dependencies_plot,
    assert_rankings_plot,
    assert_regret_plot,
    assert_regrets_plot,
)

config = dict(
    name="experiment-name",
    space={"x": "uniform(0, 200)"},
    metadata={
        "user": "test-user",
        "orion_version": "XYZ",
        "VCS": {
            "type": "git",
            "is_dirty": False,
            "HEAD_sha": "test",
            "active_branch": None,
            "diff_sha": "diff",
        },
    },
    version=1,
    pool_size=1,
    max_trials=10,
    working_dir="",
    algorithms={"random": {"seed": 1}},
    producer={"strategy": "NoParallelStrategy"},
)

trial_config = {
    "experiment": 0,
    "status": "completed",
    "worker": None,
    "start_time": None,
    "end_time": None,
    "heartbeat": None,
    "results": [],
    "params": [],
}


def mock_space(x="uniform(0, 6)", y="uniform(0, 3)", **kwargs):
    """Build a mocked space"""
    mocked_config = copy.deepcopy(config)
    mocked_config["space"] = {"x": x}
    if y is not None:
        mocked_config["space"]["y"] = y
    mocked_config["space"].update(kwargs)
    return mocked_config


def mock_experiment(
    monkeypatch, ids=None, x=None, y=None, z=None, objectives=None, status=None
):
    """Mock experiment to_pandas to return given data (or default one)"""
    if ids is None:
        ids = ["a", "b", "c", "d"]
    if x is None:
        x = [0, 1, 2, 4]
    if y is None:
        y = [3, 2, 0, 1]
    if objectives is None:
        objectives = [0.1, 0.2, 0.3, 0.5]
    if status is None:
        status = ["completed", "completed", "completed", "completed"]

    data = {
        "id": ids,
        "x": x,
        "objective": objectives,
        "status": status,
        "suggested": ids,
    }

    if not isinstance(y, str):
        data["y"] = y
    if z is not None:
        data["z"] = z

    def to_pandas(self, with_evc_tree=False):

        return pandas.DataFrame(data=data)

    monkeypatch.setattr(Experiment, "to_pandas", to_pandas)


def mock_experiment_with_random_to_pandas(monkeypatch, status=None, unbalanced=False):
    def to_pandas(self, with_evc_tree=False):
        if unbalanced:
            N = numpy.random.randint(5, 15)
        elif status is not None:
            N = len(status)
        else:
            N = 10
        ids = numpy.arange(N)
        x = numpy.random.normal(0, 0.1, size=N)
        y = numpy.random.normal(0, 0.1, size=N)
        objectives = numpy.random.normal(0, 0.1, size=N)
        if status is None:
            exp_status = ["completed"] * N
        else:
            exp_status = status

        data = pandas.DataFrame(
            data={
                "id": ids,
                "x": x,
                "y": y,
                "objective": objectives,
                "status": exp_status,
                "suggested": ids,
            }
        )

        return data

    monkeypatch.setattr(Experiment, "to_pandas", to_pandas)


def mock_model():
    """Return a mocked regressor which just predict iterated integers"""

    class Model:
        """Mocked Regressor"""

        def __init__(self):
            self.i = 0

        def predict(self, data):
            """Returns counting of predictions requested."""
            data = numpy.arange(data.shape[0]) + self.i
            self.i += data.shape[0]
            return data  #  + numpy.random.normal(0, self.i, size=data.shape[0])

    return Model()


def mock_train_regressor(monkeypatch, assert_model=None, assert_model_kwargs=None):
    """Mock the train_regressor to return the mocked regressor instead"""

    def train_regressor(model, data, **kwargs):
        """Return the mocked model, and then model argument if requested"""
        if assert_model:
            assert model == assert_model
        if assert_model_kwargs:
            assert kwargs == assert_model_kwargs
        return mock_model()

    monkeypatch.setattr(
        "orion.analysis.partial_dependency_utils.train_regressor", train_regressor
    )


@pytest.mark.usefixtures("version_XYZ")
class TestLPI:
    """Tests the ``lpi()`` method provided by the plotly backend"""

    def test_requires_argument(self):
        """Tests that the experiment data are required."""
        with pytest.raises(ValueError):
            lpi(None)

    def test_returns_plotly_object(self):
        """Tests that the plotly backend returns a plotly object"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self, monkeypatch):
        """Tests the layout of the plot"""
        config = mock_space()
        mock_experiment(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))
            df = experiment.to_pandas()
            assert df["x"].tolist() == [0, 1, 2, 4]
            assert df["y"].tolist() == [3, 2, 0, 1]
            assert df["objective"].tolist() == [0.1, 0.2, 0.3, 0.5]

        assert_lpi_plot(plot, dims=["x", "y"])

    def test_experiment_worker_as_parameter(self, monkeypatch):
        """Tests that ``Experiment`` is a valid parameter"""
        config = mock_space()
        mock_experiment(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            experiment,
            _,
        ):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert_lpi_plot(plot, dims=["x", "y"])

    def test_ignore_uncompleted_statuses(self, monkeypatch):
        """Tests that uncompleted statuses are ignored"""
        config = mock_space()
        mock_experiment(
            monkeypatch,
            ids="abcdefgh",
            x=[0, 0, 0, 1, 0, 2, 0, 3],
            y=[1, 0, 0, 2, 0, 0, 0, 3],
            objectives=[0.1, None, None, 0.2, None, 0.3, None, 0.5],
            status=[
                "completed",
                "new",
                "reserved",
                "completed",
                "broken",
                "completed",
                "interrupted",
                "completed",
            ],
        )
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = lpi(experiment)

        assert_lpi_plot(plot, dims=["x", "y"])

    def test_multidim(self, monkeypatch):
        """Tests that dimensions with shape > 1 are flattened properly"""
        config = mock_space(y="uniform(0, 3, shape=2)")
        mock_experiment(monkeypatch, y=[[3, 3], [2, 3], [1, 2], [0, 3]])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert_lpi_plot(plot, dims=["x", "y[0]", "y[1]"])

    def test_fidelity(self, monkeypatch):
        """Tests that fidelity is supported"""
        config = mock_space(y="fidelity(1, 200, base=3)")
        mock_experiment(monkeypatch, y=[1, 3 ** 2, 1, 3 ** 4])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert_lpi_plot(plot, dims=["x", "y"])

    def test_categorical(self, monkeypatch):
        """Tests that categorical is supported"""
        config = mock_space(y='choices(["a", "b", "c"])')
        mock_experiment(monkeypatch, y=["c", "c", "a", "b"])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert_lpi_plot(plot, dims=["x", "y"])

    def test_categorical_multidim(self, monkeypatch):
        """Tests that multidim categorical is supported"""
        config = mock_space(y='choices(["a", "b", "c"], shape=3)')
        mock_experiment(
            monkeypatch,
            y=[["c", "b", "a"], ["c", "a", "c"], ["a", "b", "a"], ["c", "b", "b"]],
        )

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = lpi(experiment, model_kwargs=dict(random_state=1))

        assert_lpi_plot(plot, dims=["x", "y[0]", "y[1]", "y[2]"])


@pytest.mark.usefixtures("version_XYZ")
class TestParallelCoordinates:
    """Tests the ``parallel_coordinates()`` method provided by the plotly backend"""

    def test_requires_argument(self):
        """Tests that the experiment data are required."""
        with pytest.raises(ValueError):
            parallel_coordinates(None)

    def test_returns_plotly_object(self):
        """Tests that the plotly backend returns a plotly object"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = parallel_coordinates(experiment)

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self):
        """Tests the layout of the plot"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(plot, order=["x", "loss"])

    def test_experiment_worker_as_parameter(self):
        """Tests that ``Experiment`` is a valid parameter"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            experiment,
            _,
        ):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(plot, order=["x", "loss"])

    def test_ignore_uncompleted_statuses(self):
        """Tests that uncompleted statuses are ignored"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(plot, order=["x", "loss"])

    def test_unsupported_order_key(self):
        """Tests that unsupported order keys are rejected"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            with pytest.raises(ValueError):
                parallel_coordinates(experiment, order=["unsupported"])

    def test_order_columns(self):
        """Tests that columns are sorted according to ``order``"""
        multidim_config = copy.deepcopy(config)
        for k in "yzutv":
            multidim_config["space"][k] = "uniform(0, 200)"
        with create_experiment(multidim_config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment, order="vzyx")

        assert_parallel_coordinates_plot(plot, order=["v", "z", "y", "x", "loss"])

    def test_multidim(self):
        """Tests that dimensions with shape > 1 are flattened properly"""
        multidim_config = copy.deepcopy(config)
        multidim_config["space"]["y"] = "uniform(0, 200, shape=4)"
        with create_experiment(multidim_config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(
            plot, order=["x", "y[0]", "y[1]", "y[2]", "y[3]", "loss"]
        )

    def test_fidelity(self):
        """Tests that fidelity is set to first column by default"""
        fidelity_config = copy.deepcopy(config)
        fidelity_config["space"]["z"] = "fidelity(1, 200, base=3)"
        with create_experiment(fidelity_config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(plot, order=["z", "x", "loss"])

    def test_categorical(self):
        """Tests that categorical is supported"""
        categorical_config = copy.deepcopy(config)
        categorical_config["space"]["z"] = 'choices(["a", "b", "c"])'
        with create_experiment(categorical_config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(plot, order=["x", "z", "loss"])

    def test_categorical_multidim(self):
        """Tests that multidim categorical is supported"""
        categorical_config = copy.deepcopy(config)
        categorical_config["space"]["z"] = 'choices(["a", "b", "c"], shape=3)'
        with create_experiment(categorical_config, trial_config) as (_, _, experiment):
            plot = parallel_coordinates(experiment)

        assert_parallel_coordinates_plot(
            plot, order=["x", "z[0]", "z[1]", "z[2]", "loss"]
        )


@pytest.mark.usefixtures("version_XYZ")
class TestPartialDependencies:
    """Tests the ``partial_dependencies()`` method provided by the plotly backend"""

    def test_returns_plotly_object(self, monkeypatch):
        """Tests that the plotly backend returns a plotly object"""
        mock_train_regressor(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self, monkeypatch):
        """Tests the layout of the plot"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )
            df = experiment.to_pandas()
            assert df["x"].tolist() == [0, 1, 2, 4]
            assert df["y"].tolist() == [3, 2, 0, 1]
            assert df["objective"].tolist() == [0.1, 0.2, 0.3, 0.5]

        assert_partial_dependencies_plot(plot, dims=["x", "y"])

    def test_ignore_uncompleted_statuses(self, monkeypatch):
        """Tests that uncompleted statuses are ignored"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(
            monkeypatch,
            ids="abcdefgh",
            x=[0, 0, 0, 1, 0, 2, 0, 3],
            y=[1, 0, 0, 2, 0, 0, 0, 3],
            objectives=[0.1, None, None, 0.2, None, 0.3, None, 0.5],
            status=[
                "completed",
                "new",
                "reserved",
                "completed",
                "broken",
                "completed",
                "interrupted",
                "completed",
            ],
        )
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(experiment, n_grid_points=5)

        assert_partial_dependencies_plot(plot, dims=["x", "y"])

    def test_multidim(self, monkeypatch):
        """Tests that dimensions with shape > 1 are flattened properly"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y="uniform(0, 3, shape=2)")
        mock_experiment(monkeypatch, y=[[3, 3], [2, 3], [1, 2], [0, 3]])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(plot, dims=["x", "y[0]", "y[1]"])

    def test_fidelity(self, monkeypatch):
        """Tests that fidelity is supported"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y="fidelity(1, 200, base=3)")
        mock_experiment(monkeypatch, y=[1, 3 ** 2, 1, 3 ** 4])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(plot, dims=["x", "y"], log_dims=["y"])

    def test_categorical(self, monkeypatch):
        """Tests that categorical is supported"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y='choices(["a", "b", "c"])')
        mock_experiment(monkeypatch, y=["c", "c", "a", "b"])
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        # There is only 3 categories, so test must be adjusted accordingly.
        assert_partial_dependencies_plot(
            plot, dims=["x", "y"], n_grid_points={"x": 5, "y": 3}
        )

    def test_categorical_multidim(self, monkeypatch):
        """Tests that multidim categorical is supported"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y='choices(["a", "b", "c"], shape=3)')
        mock_experiment(
            monkeypatch,
            y=[["c", "b", "a"], ["c", "a", "c"], ["a", "b", "a"], ["c", "b", "b"]],
        )

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(
            plot,
            dims=["x", "y[0]", "y[1]", "y[2]"],
            n_grid_points={"x": 5, "y[0]": 3, "y[1]": 3, "y[2]": 3},
        )

    def test_logarithmic_scales_first(self, monkeypatch):
        """Test that log dims are turn to log scale

        Test first dim specifically because special xaxis name for first dim.
        """
        mock_train_regressor(monkeypatch)
        config = mock_space(x="loguniform(0.001, 1)", z="uniform(0, 1)")
        mock_experiment(monkeypatch, x=[0.001, 0.1, 0.01, 1], z=[0, 0.1, 0.2, 0.5])

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(
            plot, dims=["x", "y", "z"], n_grid_points=5, log_dims=["x"]
        )

    def test_logarithmic_scales_any_dim(self, monkeypatch):
        """Test that log dims are turn to log scale"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y="loguniform(0.001, 1)", z="uniform(0, 1)")
        mock_experiment(monkeypatch, y=[0.001, 0.1, 0.01, 1], z=[0, 0.1, 0.2, 0.5])

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(
            plot, dims=["x", "y", "z"], n_grid_points=5, log_dims=["y"]
        )

    def test_int_logarithmic_scales(self, monkeypatch):
        """Test that int log dims are turn to log scale"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y="loguniform(1, 1000, discrete=True)", z="uniform(0, 1)")
        mock_experiment(monkeypatch, y=[1, 10, 100, 1000], z=[0, 0.1, 0.2, 0.5])

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(
            plot, dims=["x", "y", "z"], n_grid_points=5, log_dims=["y"]
        )

    def test_one_param(self, monkeypatch):
        """Test ploting a space with only 1 dim"""
        mock_train_regressor(monkeypatch)
        config = mock_space(y=None)
        mock_experiment(monkeypatch, y="drop")

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment, n_grid_points=5, model_kwargs=dict(random_state=1)
            )

        assert_partial_dependencies_plot(plot, dims=["x"], n_grid_points=5)

    def test_select_params(self, monkeypatch):
        """Test selecting subset"""
        mock_train_regressor(monkeypatch)
        config = mock_space(z="uniform(0, 1)")
        mock_experiment(monkeypatch, z=[0, 0.1, 0.2, 0.5])

        for params in [["x"], ["x", "y"], ["y", "z"]]:
            with create_experiment(config, trial_config) as (_, _, experiment):
                plot = partial_dependencies(
                    experiment,
                    params=params,
                    n_grid_points=5,
                    model_kwargs=dict(random_state=1),
                )

            assert_partial_dependencies_plot(plot, dims=params, n_grid_points=5)

    def test_custom_smoothing(self, monkeypatch):
        """Test changing smoothing value"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(monkeypatch)

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=5,
                model_kwargs=dict(random_state=1),
                smoothing=1.2,
            )

        with pytest.raises(AssertionError):
            assert_partial_dependencies_plot(plot, dims=["x", "y"], n_grid_points=5)

        assert_partial_dependencies_plot(
            plot, dims=["x", "y"], n_grid_points=5, smoothing=1.2
        )

    def test_custom_n_grid_points(self, monkeypatch):
        """Test changing n_grid_points value"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(monkeypatch)

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=10,
                model_kwargs=dict(random_state=1),
            )

        with pytest.raises(AssertionError):
            assert_partial_dependencies_plot(plot, dims=["x", "y"], n_grid_points=5)

        assert_partial_dependencies_plot(plot, dims=["x", "y"], n_grid_points=10)

    def test_custom_n_samples(self, monkeypatch):
        """Test changing n_samples value"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(monkeypatch)

        PARAMS = ["x", "y"]
        N_SAMPLES = numpy.random.randint(20, 50)

        def mock_partial_dependency_grid(space, model, params, samples, n_points):
            print(samples)
            assert samples.shape == (N_SAMPLES, len(PARAMS))
            return partial_dependency_grid(space, model, params, samples, n_points)

        monkeypatch.setattr(
            "orion.analysis.partial_dependency_utils.partial_dependency_grid",
            mock_partial_dependency_grid,
        )

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=10,
                model_kwargs=dict(random_state=1),
                n_samples=N_SAMPLES,
            )

    def test_custom_colorscale(self, monkeypatch):
        """Test changing colorscale"""
        mock_train_regressor(monkeypatch)
        config = mock_space()
        mock_experiment(monkeypatch)

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=5,
                colorscale="Viridis",
                model_kwargs=dict(random_state=1),
            )

        with pytest.raises(AssertionError):
            assert_partial_dependencies_plot(
                plot, dims=["x", "y"], n_grid_points=5, custom_colorscale=False
            )

        assert_partial_dependencies_plot(
            plot, dims=["x", "y"], n_grid_points=5, custom_colorscale=True
        )

    def test_custom_model(self, monkeypatch):
        """Test changing type of regression model"""
        mock_train_regressor(monkeypatch, assert_model="BaggingRegressor")
        config = mock_space()
        mock_experiment(monkeypatch)

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=5,
                model="BaggingRegressor",
                model_kwargs=dict(random_state=1),
            )

    def test_custom_model_kwargs(self, monkeypatch):
        """Test changing arguments of regression model"""
        mock_train_regressor(monkeypatch, assert_model_kwargs=dict(random_state=1))
        config = mock_space()
        mock_experiment(monkeypatch)

        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = partial_dependencies(
                experiment,
                n_grid_points=5,
                model_kwargs=dict(random_state=1),
            )


@pytest.mark.usefixtures("version_XYZ")
class TestRankings:
    """Tests the ``rankings()`` method provided by the plotly backend"""

    def test_requires_argument(self):
        """Tests that the experiment data are required."""
        with pytest.raises(ValueError):
            rankings(None)

    def test_returns_plotly_object(self, monkeypatch):
        """Tests that the plotly backend returns a plotly object"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings([experiment, experiment])

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self, monkeypatch):
        """Tests the layout of the plot"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings([experiment])

        assert_rankings_plot(plot, [f"{experiment.name}-v{experiment.version}"])

    def test_list_of_experiments(self, monkeypatch):
        """Tests the rankings with list of experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            child = orion.client.create_experiment(
                experiment.name, branching={"branch_to": "child"}
            )

            plot = rankings([experiment, child])

        # Exps are sorted alphabetically by names.
        assert_rankings_plot(
            plot, [f"{exp.name}-v{exp.version}" for exp in [child, experiment]]
        )

    def test_list_of_experiments_name_conflict(self, monkeypatch):
        """Tests the rankings with list of experiments with the same name"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            child = orion.client.create_experiment(
                experiment.name, branching={"branch_to": experiment.name}
            )
            assert child.name == experiment.name
            assert child.version == experiment.version + 1
            plot = rankings([experiment, child])

        # Exps are sorted alphabetically by names.
        assert_rankings_plot(
            plot, [f"{exp.name}-v{exp.version}" for exp in [experiment, child]]
        )

    def test_dict_of_experiments(self, monkeypatch):
        """Tests the rankings with renamed experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings({"exp-1": experiment, "exp-2": experiment})

        assert_rankings_plot(plot, ["exp-1", "exp-2"])

    def test_list_of_dict_of_experiments(self, monkeypatch):
        """Tests the rankings with avg of competitions"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings(
                [{"exp-1": experiment, "exp-2": experiment} for _ in range(10)]
            )

        assert_rankings_plot(plot, ["exp-1", "exp-2"], with_avg=True)

    def test_dict_of_list_of_experiments(self, monkeypatch):
        """Tests the rankings with avg of experiments separated in lists"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings({"exp-1": [experiment] * 10, "exp-2": [experiment] * 10})

        assert_rankings_plot(plot, ["exp-1", "exp-2"], with_avg=True)

    def test_unbalanced_experiments(self, monkeypatch):
        """Tests the regrets with avg of unbalanced experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch, unbalanced=True)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = rankings({"exp-1": [experiment] * 10, "exp-2": [experiment] * 10})

        assert_rankings_plot(plot, ["exp-1", "exp-2"], with_avg=True, balanced=0)

    def test_ignore_uncompleted_statuses(self, monkeypatch):
        """Tests that uncompleted statuses are ignored"""
        mock_experiment_with_random_to_pandas(
            monkeypatch,
            status=[
                "completed",
                "new",
                "reserved",
                "completed",
                "broken",
                "completed",
                "interrupted",
                "completed",
            ],
        )
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = rankings([experiment])

        assert_rankings_plot(
            plot, [f"{experiment.name}-v{experiment.version}"], balanced=4
        )

    def test_unsupported_order_key(self):
        """Tests that unsupported order keys are rejected"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            with pytest.raises(ValueError):
                rankings([experiment], order_by="unsupported")


@pytest.mark.usefixtures("version_XYZ")
class TestRegret:
    """Tests the ``regret()`` method provided by the plotly backend"""

    def test_requires_argument(self):
        """Tests that the experiment data are required."""
        with pytest.raises(ValueError):
            regret(None)

    def test_returns_plotly_object(self):
        """Tests that the plotly backend returns a plotly object"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regret(experiment)

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self):
        """Tests the layout of the plot"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regret(experiment)

        assert_regret_plot(plot)

    def test_experiment_worker_as_parameter(self):
        """Tests that ``Experiment`` is a valid parameter"""
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            experiment,
            _,
        ):
            plot = regret(experiment)

        assert_regret_plot(plot)

    def test_ignore_uncompleted_statuses(self):
        """Tests that uncompleted statuses are ignored"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = regret(experiment)

        assert_regret_plot(plot)

    def test_unsupported_order_key(self):
        """Tests that unsupported order keys are rejected"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            with pytest.raises(ValueError):
                regret(experiment, order_by="unsupported")


@pytest.mark.usefixtures("version_XYZ")
class TestRegrets:
    """Tests the ``regrets()`` method provided by the plotly backend"""

    def test_requires_argument(self):
        """Tests that the experiment data are required."""
        with pytest.raises(ValueError):
            regrets(None)

    def test_returns_plotly_object(self, monkeypatch):
        """Tests that the plotly backend returns a plotly object"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regrets([experiment])

        assert type(plot) is plotly.graph_objects.Figure

    def test_graph_layout(self, monkeypatch):
        """Tests the layout of the plot"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regrets([experiment])

        assert_regrets_plot(plot, [f"{experiment.name}-v{experiment.version}"])

    def test_list_of_experiments(self, monkeypatch):
        """Tests the regrets with list of experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            child = orion.client.create_experiment(
                experiment.name, branching={"branch_to": "child"}
            )

            plot = regrets([experiment, child])

        # Exps are sorted alphabetically by names.
        assert_regrets_plot(
            plot, [f"{exp.name}-v{exp.version}" for exp in [child, experiment]]
        )

    def test_list_of_experiments_name_conflict(self, monkeypatch):
        """Tests the regrets with list of experiments with the same name"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            child = orion.client.create_experiment(
                experiment.name, branching={"branch_to": experiment.name}
            )
            assert child.name == experiment.name
            assert child.version == experiment.version + 1
            plot = regrets([experiment, child])

        # Exps are sorted alphabetically by names.
        assert_regrets_plot(
            plot, [f"{exp.name}-v{exp.version}" for exp in [experiment, child]]
        )

    def test_dict_of_experiments(self, monkeypatch):
        """Tests the regrets with renamed experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regrets({"exp-1": experiment, "exp-2": experiment})

        assert_regrets_plot(plot, ["exp-1", "exp-2"])

    def test_dict_of_list_of_experiments(self, monkeypatch):
        """Tests the regrets with avg of experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regrets({"exp-1": [experiment] * 10, "exp-2": [experiment] * 10})

        assert_regrets_plot(plot, ["exp-1", "exp-2"], with_avg=True)

    def test_unbalanced_experiments(self, monkeypatch):
        """Tests the regrets with avg of unbalanced experiments"""
        mock_experiment_with_random_to_pandas(monkeypatch, unbalanced=True)
        with create_experiment(config, trial_config, ["completed"]) as (
            _,
            _,
            experiment,
        ):
            plot = regrets({"exp-1": [experiment] * 10, "exp-2": [experiment] * 10})

        assert_regrets_plot(plot, ["exp-1", "exp-2"], with_avg=True, balanced=0)

    def test_ignore_uncompleted_statuses(self, monkeypatch):
        """Tests that uncompleted statuses are ignored"""
        mock_experiment_with_random_to_pandas(
            monkeypatch,
            status=[
                "completed",
                "new",
                "reserved",
                "completed",
                "broken",
                "completed",
                "interrupted",
                "completed",
            ],
        )
        with create_experiment(config, trial_config) as (_, _, experiment):
            plot = regrets([experiment])

        assert_regrets_plot(
            plot, [f"{experiment.name}-v{experiment.version}"], balanced=4
        )

    def test_unsupported_order_key(self):
        """Tests that unsupported order keys are rejected"""
        with create_experiment(config, trial_config) as (_, _, experiment):
            with pytest.raises(ValueError):
                regrets([experiment], order_by="unsupported")

[((4561, 4599), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (4584, 4599), False, 'import pytest\n'), ((8907, 8945), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (8930, 8945), False, 'import pytest\n'), ((13187, 13225), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (13210, 13225), False, 'import pytest\n'), ((25473, 25511), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (25496, 25511), False, 'import pytest\n'), ((31021, 31059), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (31044, 31059), False, 'import pytest\n'), ((32808, 32846), 'pytest.mark.usefixtures', 'pytest.mark.usefixtures', (['"""version_XYZ"""'], {}), "('version_XYZ')\n", (32831, 32846), False, 'import pytest\n'), ((1497, 1518), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (1510, 1518), False, 'import copy\n'), ((2470, 2497), 'pandas.DataFrame', 'pandas.DataFrame', ([], {'data': 'data'}), '(data=data)\n', (2486, 2497), False, 'import pandas\n'), ((2869, 2884), 'numpy.arange', 'numpy.arange', (['N'], {}), '(N)\n', (2881, 2884), False, 'import numpy\n'), ((2897, 2932), 'numpy.random.normal', 'numpy.random.normal', (['(0)', '(0.1)'], {'size': 'N'}), '(0, 0.1, size=N)\n', (2916, 2932), False, 'import numpy\n'), ((2945, 2980), 'numpy.random.normal', 'numpy.random.normal', (['(0)', '(0.1)'], {'size': 'N'}), '(0, 0.1, size=N)\n', (2964, 2980), False, 'import numpy\n'), ((3002, 3037), 'numpy.random.normal', 'numpy.random.normal', (['(0)', '(0.1)'], {'size': 'N'}), '(0, 0.1, size=N)\n', (3021, 3037), False, 'import numpy\n'), ((3170, 3289), 'pandas.DataFrame', 'pandas.DataFrame', ([], {'data': "{'id': ids, 'x': x, 'y': y, 'objective': objectives, 'status': exp_status,\n    'suggested': ids}"}), "(data={'id': ids, 'x': x, 'y': y, 'objective': objectives,\n    'status': exp_status, 'suggested': ids})\n", (3186, 3289), False, 'import pandas\n'), ((5806, 5844), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (5821, 5844), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((6255, 6293), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (6270, 6293), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((7061, 7099), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (7076, 7099), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((7501, 7550), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y[0]', 'y[1]']"}), "(plot, dims=['x', 'y[0]', 'y[1]'])\n", (7516, 7550), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((7917, 7955), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (7932, 7955), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((8326, 8364), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (8341, 8364), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((8846, 8903), 'orion.testing.plotting.assert_lpi_plot', 'assert_lpi_plot', (['plot'], {'dims': "['x', 'y[0]', 'y[1]', 'y[2]']"}), "(plot, dims=['x', 'y[0]', 'y[1]', 'y[2]'])\n", (8861, 8903), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((9874, 9933), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'loss']"}), "(plot, order=['x', 'loss'])\n", (9906, 9933), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((10246, 10305), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'loss']"}), "(plot, order=['x', 'loss'])\n", (10278, 10305), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((10550, 10609), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'loss']"}), "(plot, order=['x', 'loss'])\n", (10582, 10609), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((11034, 11055), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (11047, 11055), False, 'import copy\n'), ((11302, 11376), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['v', 'z', 'y', 'x', 'loss']"}), "(plot, order=['v', 'z', 'y', 'x', 'loss'])\n", (11334, 11376), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((11507, 11528), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (11520, 11528), False, 'import copy\n'), ((11742, 11837), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'y[0]', 'y[1]', 'y[2]', 'y[3]', 'loss']"}), "(plot, order=['x', 'y[0]', 'y[1]', 'y[2]',\n    'y[3]', 'loss'])\n", (11774, 11837), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((11980, 12001), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (11993, 12001), False, 'import copy\n'), ((12215, 12279), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['z', 'x', 'loss']"}), "(plot, order=['z', 'x', 'loss'])\n", (12247, 12279), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((12392, 12413), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (12405, 12413), False, 'import copy\n'), ((12633, 12697), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'z', 'loss']"}), "(plot, order=['x', 'z', 'loss'])\n", (12665, 12697), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((12828, 12849), 'copy.deepcopy', 'copy.deepcopy', (['config'], {}), '(config)\n', (12841, 12849), False, 'import copy\n'), ((13078, 13165), 'orion.testing.plotting.assert_parallel_coordinates_plot', 'assert_parallel_coordinates_plot', (['plot'], {'order': "['x', 'z[0]', 'z[1]', 'z[2]', 'loss']"}), "(plot, order=['x', 'z[0]', 'z[1]', 'z[2]',\n    'loss'])\n", (13110, 13165), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((14530, 14585), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (14562, 14585), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((15429, 15484), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']"}), "(plot, dims=['x', 'y'])\n", (15461, 15484), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((15992, 16058), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y[0]', 'y[1]']"}), "(plot, dims=['x', 'y[0]', 'y[1]'])\n", (16024, 16058), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((16531, 16602), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'log_dims': "['y']"}), "(plot, dims=['x', 'y'], log_dims=['y'])\n", (16563, 16602), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((17155, 17246), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': "{'x': 5, 'y': 3}"}), "(plot, dims=['x', 'y'], n_grid_points={'x':\n    5, 'y': 3})\n", (17187, 17246), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((17852, 17987), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y[0]', 'y[1]', 'y[2]']", 'n_grid_points': "{'x': 5, 'y[0]': 3, 'y[1]': 3, 'y[2]': 3}"}), "(plot, dims=['x', 'y[0]', 'y[1]', 'y[2]'],\n    n_grid_points={'x': 5, 'y[0]': 3, 'y[1]': 3, 'y[2]': 3})\n", (17884, 17987), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((18652, 18750), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y', 'z']", 'n_grid_points': '(5)', 'log_dims': "['x']"}), "(plot, dims=['x', 'y', 'z'], n_grid_points=\n    5, log_dims=['x'])\n", (18684, 18750), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((19303, 19401), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y', 'z']", 'n_grid_points': '(5)', 'log_dims': "['y']"}), "(plot, dims=['x', 'y', 'z'], n_grid_points=\n    5, log_dims=['y'])\n", (19335, 19401), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((19965, 20063), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y', 'z']", 'n_grid_points': '(5)', 'log_dims': "['y']"}), "(plot, dims=['x', 'y', 'z'], n_grid_points=\n    5, log_dims=['y'])\n", (19997, 20063), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((20521, 20588), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x']", 'n_grid_points': '(5)'}), "(plot, dims=['x'], n_grid_points=5)\n", (20553, 20588), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((21879, 21970), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(5)', 'smoothing': '(1.2)'}), "(plot, dims=['x', 'y'], n_grid_points=5,\n    smoothing=1.2)\n", (21911, 21970), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((22585, 22658), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(10)'}), "(plot, dims=['x', 'y'], n_grid_points=10)\n", (22617, 22658), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((22912, 22940), 'numpy.random.randint', 'numpy.random.randint', (['(20)', '(50)'], {}), '(20, 50)\n', (22932, 22940), False, 'import numpy\n'), ((24316, 24416), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(5)', 'custom_colorscale': '(True)'}), "(plot, dims=['x', 'y'], n_grid_points=5,\n    custom_colorscale=True)\n", (24348, 24416), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((26541, 26613), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "[f'{experiment.name}-v{experiment.version}']"], {}), "(plot, [f'{experiment.name}-v{experiment.version}'])\n", (26561, 26613), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((27165, 27258), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "[f'{exp.name}-v{exp.version}' for exp in [child, experiment]]"], {}), "(plot, [f'{exp.name}-v{exp.version}' for exp in [child,\n    experiment]])\n", (27185, 27258), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((27976, 28070), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "[f'{exp.name}-v{exp.version}' for exp in [experiment, child]]"], {}), "(plot, [f'{exp.name}-v{exp.version}' for exp in [\n    experiment, child]])\n", (27996, 28070), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((28478, 28524), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "['exp-1', 'exp-2']"], {}), "(plot, ['exp-1', 'exp-2'])\n", (28498, 28524), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((28974, 29035), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "['exp-1', 'exp-2']"], {'with_avg': '(True)'}), "(plot, ['exp-1', 'exp-2'], with_avg=True)\n", (28994, 29035), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((29466, 29527), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "['exp-1', 'exp-2']"], {'with_avg': '(True)'}), "(plot, ['exp-1', 'exp-2'], with_avg=True)\n", (29486, 29527), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((29961, 30034), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "['exp-1', 'exp-2']"], {'with_avg': '(True)', 'balanced': '(0)'}), "(plot, ['exp-1', 'exp-2'], with_avg=True, balanced=0)\n", (29981, 30034), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((30624, 30712), 'orion.testing.plotting.assert_rankings_plot', 'assert_rankings_plot', (['plot', "[f'{experiment.name}-v{experiment.version}']"], {'balanced': '(4)'}), "(plot, [f'{experiment.name}-v{experiment.version}'],\n    balanced=4)\n", (30644, 30712), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((31919, 31943), 'orion.testing.plotting.assert_regret_plot', 'assert_regret_plot', (['plot'], {}), '(plot)\n', (31937, 31943), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((32242, 32266), 'orion.testing.plotting.assert_regret_plot', 'assert_regret_plot', (['plot'], {}), '(plot)\n', (32260, 32266), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((32497, 32521), 'orion.testing.plotting.assert_regret_plot', 'assert_regret_plot', (['plot'], {}), '(plot)\n', (32515, 32521), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((33859, 33930), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "[f'{experiment.name}-v{experiment.version}']"], {}), "(plot, [f'{experiment.name}-v{experiment.version}'])\n", (33878, 33930), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((34480, 34572), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "[f'{exp.name}-v{exp.version}' for exp in [child, experiment]]"], {}), "(plot, [f'{exp.name}-v{exp.version}' for exp in [child,\n    experiment]])\n", (34499, 34572), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((35288, 35381), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "[f'{exp.name}-v{exp.version}' for exp in [experiment, child]]"], {}), "(plot, [f'{exp.name}-v{exp.version}' for exp in [\n    experiment, child]])\n", (35307, 35381), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((35787, 35832), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "['exp-1', 'exp-2']"], {}), "(plot, ['exp-1', 'exp-2'])\n", (35806, 35832), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((36242, 36302), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "['exp-1', 'exp-2']"], {'with_avg': '(True)'}), "(plot, ['exp-1', 'exp-2'], with_avg=True)\n", (36261, 36302), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((36735, 36807), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "['exp-1', 'exp-2']"], {'with_avg': '(True)', 'balanced': '(0)'}), "(plot, ['exp-1', 'exp-2'], with_avg=True, balanced=0)\n", (36754, 36807), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((37396, 37483), 'orion.testing.plotting.assert_regrets_plot', 'assert_regrets_plot', (['plot', "[f'{experiment.name}-v{experiment.version}']"], {'balanced': '(4)'}), "(plot, [f'{experiment.name}-v{experiment.version}'],\n    balanced=4)\n", (37415, 37483), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((2733, 2760), 'numpy.random.randint', 'numpy.random.randint', (['(5)', '(15)'], {}), '(5, 15)\n', (2753, 2760), False, 'import numpy\n'), ((4794, 4819), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (4807, 4819), False, 'import pytest\n'), ((4833, 4842), 'orion.plotting.base.lpi', 'lpi', (['None'], {}), '(None)\n', (4836, 4842), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((4967, 5021), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (4984, 5021), False, 'from orion.testing import create_experiment\n'), ((5390, 5444), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (5407, 5444), False, 'from orion.testing import create_experiment\n'), ((6051, 6105), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (6068, 6105), False, 'from orion.testing import create_experiment\n'), ((6954, 6993), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (6971, 6993), False, 'from orion.testing import create_experiment\n'), ((7036, 7051), 'orion.plotting.base.lpi', 'lpi', (['experiment'], {}), '(experiment)\n', (7039, 7051), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((7359, 7398), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (7376, 7398), False, 'from orion.testing import create_experiment\n'), ((7775, 7814), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (7792, 7814), False, 'from orion.testing import create_experiment\n'), ((8184, 8223), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (8201, 8223), False, 'from orion.testing import create_experiment\n'), ((8704, 8743), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (8721, 8743), False, 'from orion.testing import create_experiment\n'), ((9173, 9198), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (9186, 9198), False, 'import pytest\n'), ((9212, 9238), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['None'], {}), '(None)\n', (9232, 9238), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((9363, 9417), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (9380, 9417), False, 'from orion.testing import create_experiment\n'), ((9507, 9539), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (9527, 9539), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((9688, 9742), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (9705, 9742), False, 'from orion.testing import create_experiment\n'), ((9832, 9864), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (9852, 9864), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((10060, 10114), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (10077, 10114), False, 'from orion.testing import create_experiment\n'), ((10204, 10236), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (10224, 10236), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((10426, 10465), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (10443, 10465), False, 'from orion.testing import create_experiment\n'), ((10508, 10540), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (10528, 10540), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((10727, 10766), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (10744, 10766), False, 'from orion.testing import create_experiment\n'), ((11155, 11203), 'orion.testing.create_experiment', 'create_experiment', (['multidim_config', 'trial_config'], {}), '(multidim_config, trial_config)\n', (11172, 11203), False, 'from orion.testing import create_experiment\n'), ((11246, 11292), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {'order': '"""vzyx"""'}), "(experiment, order='vzyx')\n", (11266, 11292), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((11609, 11657), 'orion.testing.create_experiment', 'create_experiment', (['multidim_config', 'trial_config'], {}), '(multidim_config, trial_config)\n', (11626, 11657), False, 'from orion.testing import create_experiment\n'), ((11700, 11732), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (11720, 11732), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((12082, 12130), 'orion.testing.create_experiment', 'create_experiment', (['fidelity_config', 'trial_config'], {}), '(fidelity_config, trial_config)\n', (12099, 12130), False, 'from orion.testing import create_experiment\n'), ((12173, 12205), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (12193, 12205), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((12497, 12548), 'orion.testing.create_experiment', 'create_experiment', (['categorical_config', 'trial_config'], {}), '(categorical_config, trial_config)\n', (12514, 12548), False, 'from orion.testing import create_experiment\n'), ((12591, 12623), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (12611, 12623), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((12942, 12993), 'orion.testing.create_experiment', 'create_experiment', (['categorical_config', 'trial_config'], {}), '(categorical_config, trial_config)\n', (12959, 12993), False, 'from orion.testing import create_experiment\n'), ((13036, 13068), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {}), '(experiment)\n', (13056, 13068), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((13521, 13575), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (13538, 13575), False, 'from orion.testing import create_experiment\n'), ((14050, 14104), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (14067, 14104), False, 'from orion.testing import create_experiment\n'), ((15288, 15327), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (15305, 15327), False, 'from orion.testing import create_experiment\n'), ((15370, 15419), 'orion.plotting.base.partial_dependencies', 'partial_dependencies', (['experiment'], {'n_grid_points': '(5)'}), '(experiment, n_grid_points=5)\n', (15390, 15419), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((15786, 15825), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (15803, 15825), False, 'from orion.testing import create_experiment\n'), ((16325, 16364), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (16342, 16364), False, 'from orion.testing import create_experiment\n'), ((16873, 16912), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (16890, 16912), False, 'from orion.testing import create_experiment\n'), ((17646, 17685), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (17663, 17685), False, 'from orion.testing import create_experiment\n'), ((18446, 18485), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (18463, 18485), False, 'from orion.testing import create_experiment\n'), ((19097, 19136), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (19114, 19136), False, 'from orion.testing import create_experiment\n'), ((19759, 19798), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (19776, 19798), False, 'from orion.testing import create_experiment\n'), ((20315, 20354), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (20332, 20354), False, 'from orion.testing import create_experiment\n'), ((21192, 21260), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': 'params', 'n_grid_points': '(5)'}), '(plot, dims=params, n_grid_points=5)\n', (21224, 21260), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((21479, 21518), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (21496, 21518), False, 'from orion.testing import create_experiment\n'), ((21754, 21783), 'pytest.raises', 'pytest.raises', (['AssertionError'], {}), '(AssertionError)\n', (21767, 21783), False, 'import pytest\n'), ((21797, 21869), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(5)'}), "(plot, dims=['x', 'y'], n_grid_points=5)\n", (21829, 21869), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((22215, 22254), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (22232, 22254), False, 'from orion.testing import create_experiment\n'), ((22460, 22489), 'pytest.raises', 'pytest.raises', (['AssertionError'], {}), '(AssertionError)\n', (22473, 22489), False, 'import pytest\n'), ((22503, 22575), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(5)'}), "(plot, dims=['x', 'y'], n_grid_points=5)\n", (22535, 22575), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((23132, 23196), 'orion.analysis.partial_dependency_utils.partial_dependency_grid', 'partial_dependency_grid', (['space', 'model', 'params', 'samples', 'n_points'], {}), '(space, model, params, samples, n_points)\n', (23155, 23196), False, 'from orion.analysis.partial_dependency_utils import partial_dependency_grid\n'), ((23372, 23411), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (23389, 23411), False, 'from orion.testing import create_experiment\n'), ((23854, 23893), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (23871, 23893), False, 'from orion.testing import create_experiment\n'), ((24136, 24165), 'pytest.raises', 'pytest.raises', (['AssertionError'], {}), '(AssertionError)\n', (24149, 24165), False, 'import pytest\n'), ((24179, 24280), 'orion.testing.plotting.assert_partial_dependencies_plot', 'assert_partial_dependencies_plot', (['plot'], {'dims': "['x', 'y']", 'n_grid_points': '(5)', 'custom_colorscale': '(False)'}), "(plot, dims=['x', 'y'], n_grid_points=5,\n    custom_colorscale=False)\n", (24211, 24280), False, 'from orion.testing.plotting import assert_lpi_plot, assert_parallel_coordinates_plot, assert_partial_dependencies_plot, assert_rankings_plot, assert_regret_plot, assert_regrets_plot\n'), ((24691, 24730), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (24708, 24730), False, 'from orion.testing import create_experiment\n'), ((25240, 25279), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (25257, 25279), False, 'from orion.testing import create_experiment\n'), ((25716, 25741), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (25729, 25741), False, 'import pytest\n'), ((25755, 25769), 'orion.plotting.base.rankings', 'rankings', (['None'], {}), '(None)\n', (25763, 25769), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((25966, 26020), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (25983, 26020), False, 'from orion.testing import create_experiment\n'), ((26110, 26144), 'orion.plotting.base.rankings', 'rankings', (['[experiment, experiment]'], {}), '([experiment, experiment])\n', (26118, 26144), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((26365, 26419), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (26382, 26419), False, 'from orion.testing import create_experiment\n'), ((26509, 26531), 'orion.plotting.base.rankings', 'rankings', (['[experiment]'], {}), '([experiment])\n', (26517, 26531), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((26798, 26852), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (26815, 26852), False, 'from orion.testing import create_experiment\n'), ((27075, 27104), 'orion.plotting.base.rankings', 'rankings', (['[experiment, child]'], {}), '([experiment, child])\n', (27083, 27104), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((27494, 27548), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (27511, 27548), False, 'from orion.testing import create_experiment\n'), ((27886, 27915), 'orion.plotting.base.rankings', 'rankings', (['[experiment, child]'], {}), '([experiment, child])\n', (27894, 27915), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((28272, 28326), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (28289, 28326), False, 'from orion.testing import create_experiment\n'), ((28416, 28468), 'orion.plotting.base.rankings', 'rankings', (["{'exp-1': experiment, 'exp-2': experiment}"], {}), "({'exp-1': experiment, 'exp-2': experiment})\n", (28424, 28468), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((28717, 28771), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (28734, 28771), False, 'from orion.testing import create_experiment\n'), ((29246, 29300), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (29263, 29300), False, 'from orion.testing import create_experiment\n'), ((29390, 29456), 'orion.plotting.base.rankings', 'rankings', (["{'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10}"], {}), "({'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10})\n", (29398, 29456), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((29741, 29795), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (29758, 29795), False, 'from orion.testing import create_experiment\n'), ((29885, 29951), 'orion.plotting.base.rankings', 'rankings', (["{'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10}"], {}), "({'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10})\n", (29893, 29951), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((30510, 30549), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (30527, 30549), False, 'from orion.testing import create_experiment\n'), ((30592, 30614), 'orion.plotting.base.rankings', 'rankings', (['[experiment]'], {}), '([experiment])\n', (30600, 30614), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((30848, 30887), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (30865, 30887), False, 'from orion.testing import create_experiment\n'), ((31260, 31285), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (31273, 31285), False, 'import pytest\n'), ((31299, 31311), 'orion.plotting.base.regret', 'regret', (['None'], {}), '(None)\n', (31305, 31311), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((31436, 31490), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (31453, 31490), False, 'from orion.testing import create_experiment\n'), ((31580, 31598), 'orion.plotting.base.regret', 'regret', (['experiment'], {}), '(experiment)\n', (31586, 31598), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((31747, 31801), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (31764, 31801), False, 'from orion.testing import create_experiment\n'), ((31891, 31909), 'orion.plotting.base.regret', 'regret', (['experiment'], {}), '(experiment)\n', (31897, 31909), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((32070, 32124), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (32087, 32124), False, 'from orion.testing import create_experiment\n'), ((32214, 32232), 'orion.plotting.base.regret', 'regret', (['experiment'], {}), '(experiment)\n', (32220, 32232), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((32387, 32426), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (32404, 32426), False, 'from orion.testing import create_experiment\n'), ((32469, 32487), 'orion.plotting.base.regret', 'regret', (['experiment'], {}), '(experiment)\n', (32475, 32487), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((32639, 32678), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (32656, 32678), False, 'from orion.testing import create_experiment\n'), ((33049, 33074), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (33062, 33074), False, 'import pytest\n'), ((33088, 33101), 'orion.plotting.base.regrets', 'regrets', (['None'], {}), '(None)\n', (33095, 33101), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((33298, 33352), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (33315, 33352), False, 'from orion.testing import create_experiment\n'), ((33442, 33463), 'orion.plotting.base.regrets', 'regrets', (['[experiment]'], {}), '([experiment])\n', (33449, 33463), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((33684, 33738), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (33701, 33738), False, 'from orion.testing import create_experiment\n'), ((33828, 33849), 'orion.plotting.base.regrets', 'regrets', (['[experiment]'], {}), '([experiment])\n', (33835, 33849), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((34114, 34168), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (34131, 34168), False, 'from orion.testing import create_experiment\n'), ((34391, 34419), 'orion.plotting.base.regrets', 'regrets', (['[experiment, child]'], {}), '([experiment, child])\n', (34398, 34419), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((34807, 34861), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (34824, 34861), False, 'from orion.testing import create_experiment\n'), ((35199, 35227), 'orion.plotting.base.regrets', 'regrets', (['[experiment, child]'], {}), '([experiment, child])\n', (35206, 35227), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((35582, 35636), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (35599, 35636), False, 'from orion.testing import create_experiment\n'), ((35726, 35777), 'orion.plotting.base.regrets', 'regrets', (["{'exp-1': experiment, 'exp-2': experiment}"], {}), "({'exp-1': experiment, 'exp-2': experiment})\n", (35733, 35777), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((36023, 36077), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (36040, 36077), False, 'from orion.testing import create_experiment\n'), ((36167, 36232), 'orion.plotting.base.regrets', 'regrets', (["{'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10}"], {}), "({'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10})\n", (36174, 36232), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((36516, 36570), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config', "['completed']"], {}), "(config, trial_config, ['completed'])\n", (36533, 36570), False, 'from orion.testing import create_experiment\n'), ((36660, 36725), 'orion.plotting.base.regrets', 'regrets', (["{'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10}"], {}), "({'exp-1': [experiment] * 10, 'exp-2': [experiment] * 10})\n", (36667, 36725), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((37283, 37322), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (37300, 37322), False, 'from orion.testing import create_experiment\n'), ((37365, 37386), 'orion.plotting.base.regrets', 'regrets', (['[experiment]'], {}), '([experiment])\n', (37372, 37386), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((37619, 37658), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (37636, 37658), False, 'from orion.testing import create_experiment\n'), ((3809, 3836), 'numpy.arange', 'numpy.arange', (['data.shape[0]'], {}), '(data.shape[0])\n', (3821, 3836), False, 'import numpy\n'), ((10807, 10832), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (10820, 10832), False, 'import pytest\n'), ((10850, 10905), 'orion.plotting.base.parallel_coordinates', 'parallel_coordinates', (['experiment'], {'order': "['unsupported']"}), "(experiment, order=['unsupported'])\n", (10870, 10905), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((20894, 20933), 'orion.testing.create_experiment', 'create_experiment', (['config', 'trial_config'], {}), '(config, trial_config)\n', (20911, 20933), False, 'from orion.testing import create_experiment\n'), ((30928, 30953), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (30941, 30953), False, 'import pytest\n'), ((30971, 31017), 'orion.plotting.base.rankings', 'rankings', (['[experiment]'], {'order_by': '"""unsupported"""'}), "([experiment], order_by='unsupported')\n", (30979, 31017), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((32719, 32744), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (32732, 32744), False, 'import pytest\n'), ((32762, 32804), 'orion.plotting.base.regret', 'regret', (['experiment'], {'order_by': '"""unsupported"""'}), "(experiment, order_by='unsupported')\n", (32768, 32804), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n'), ((37699, 37724), 'pytest.raises', 'pytest.raises', (['ValueError'], {}), '(ValueError)\n', (37712, 37724), False, 'import pytest\n'), ((37742, 37787), 'orion.plotting.base.regrets', 'regrets', (['[experiment]'], {'order_by': '"""unsupported"""'}), "([experiment], order_by='unsupported')\n", (37749, 37787), False, 'from orion.plotting.base import lpi, parallel_coordinates, partial_dependencies, rankings, regret, regrets\n')]