Skip to content

Commit

Permalink
Add warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kAIto47802 committed Aug 20, 2024
1 parent aa13810 commit 76e6c64
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion optuna/visualization/_contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any
from typing import Callable
from typing import NamedTuple
import warnings

import numpy as np

Expand Down Expand Up @@ -208,7 +209,13 @@ def _get_contour_subplot(
x_indices = info.xaxis.indices
y_indices = info.yaxis.indices

if len(x_indices) < 2 or len(y_indices) < 2 or len(info.z_values) == 0:
if len(x_indices) < 2 or len(y_indices) < 2:
return go.Contour(), go.Scatter(), go.Scatter()
if len(info.z_values) == 0:
warnings.warn(
f"Contour plot will not be displayed because `{info.xaxis.name}` and "
f"`{info.yaxis.name}` cannot co-exist in `trial.params`."
)
return go.Contour(), go.Scatter(), go.Scatter()

feasible = _PlotValues([], [])
Expand Down

0 comments on commit 76e6c64

Please sign in to comment.