code: def test_plot_compare_evokeds():
      """Test plot_compare_evokeds."""
      evoked = _get_epochs().average()
      # test defaults
      figs = plot_compare_evokeds(evoked)
      assert len(figs) == 3
      # test picks, combine, and vlines (1-channel pick also shows sensor inset)
      picks = (
          ["MEG 0113", "mag"]
          + 2 * [["MEG 0113", "MEG 0112"]]
          + [[0, 1]]
      )
      vlines = [[0.1, 0.2], []] + 3 * ["auto"]
      combine = [None, "mean", "std", None, lambda x: np.min(x, axis=1)]
      title = ["MEG 0113", "(mean)", "(std. dev.)", "(GFP)", "MEG 0112"]
      for _p, _v, _c, _t in zip(picks, vlines, combine, title):
          fig = plot_compare_evokeds(
              evoked, picks=_p, vlines=_v, combine=_c
          )
          assert fig[0].axes[0].get_title().endswith(_t)
      # test passing more than one evoked
      red, blue = evoked.copy(), evoked.copy()
      red.comment = red.comment + "*" * 100
      red.data *= 1.5
      blue.data /= 1.5
      evoked_dict = {"aud/l": blue, "aud/r": red, "vis": evoked}
      huge_dict = {f"cond{i}": ev for i, ev in enumerate([evoked] * 11)}
      plot_compare_evokeds(evoked_dict)  # dict
      plot_compare_evokeds(
          [[red, evoked], [blue, evoked]]
      )  # list of lists
      figs = plot_compare_evokeds(
          {"cond": [blue, red, evoked]}
      )  # dict of list
      # test that confidence bands are plausible
      for fig in figs:
          extents = (
              fig.axes[0].collections[0].get_paths()[0].get_extents()
          )
          xlim, ylim = extents.get_points().T
          assert np.allclose(xlim, evoked.times[[0, -1]])
          line = fig.axes[0].lines[0]
          xvals = line.get_xdata()
          assert np.allclose(xvals, evoked.times)
          yvals = line.get_ydata()
          assert (yvals < ylim[1]).all()
          assert (yvals > ylim[0]).all()
      # test plotting eyetracking data
      plt.close(
          "all"
      )  # close the previous figures as to avoid a too many figs warning
      info_tmp = mne.create_info(
          ["pupil_left"], evoked.info["sfreq"], ["pupil"]
      )
      evoked_et = mne.EvokedArray(
          np.ones_like(evoked.times).reshape(1, -1), info_tmp
      )
      figs = plot_compare_evokeds(evoked_et, show_sensors=False)
      assert len(figs) == 1
      # test plotting only invalid channel types
      info_tmp = mne.create_info(["ias"], evoked.info["sfreq"], ["ias"])
      ev_invalid = mne.EvokedArray(
          np.ones_like(evoked.times).reshape(1, -1), info_tmp
      )
      with pytest.raises(RuntimeError, match="No valid"):
          plot_compare_evokeds(ev_invalid, picks="all")
      plt.close("all")
  
      # test other CI args
      def ci_func(array):
          return array.mean(axis=0, keepdims=True) * np.array(
              [[0.5], [1.5]]
          )
  
      ci_types = (None, False, 0.5, ci_func)
      for _ci in ci_types:
          fig = plot_compare_evokeds(
              {"cond": [blue, red, evoked]}, ci=_ci
          )[0]
          if _ci in ci_types[2:]:
              assert np.any(
                  [
                      isinstance(coll, PolyCollection)
                      for coll in fig.axes[0].collections
                  ]
              )
      # make sure we can get a CI even for single conditions
      fig = plot_compare_evokeds(evoked, picks="eeg", ci=ci_func)[0]
      assert np.any(
          [
              isinstance(coll, PolyCollection)
              for coll in fig.axes[0].collections
          ]
      )
  
      with pytest.raises(
          TypeError, match='"ci" must be None, bool, float or'
      ):
          plot_compare_evokeds(evoked, ci="foo")
      # test sensor inset, legend location, and axis inversion & truncation
      plot_compare_evokeds(
          evoked_dict,
          invert_y=True,
          legend="upper left",
          show_sensors="center",
          truncate_xaxis=False,
          truncate_yaxis=False,
      )
      plot_compare_evokeds(
          evoked, ylim=dict(mag=(-50, 50)), truncate_yaxis=True
      )
      plt.close("all")
      # test styles
      plot_compare_evokeds(
          evoked_dict,
          colors=["b", "r", "g"],
          linestyles=[":", "-", "--"],
          split_legend=True,
      )
      style_dict = dict(
          aud=dict(alpha=0.3), vis=dict(linewidth=3, c="k")
      )
      plot_compare_evokeds(
          evoked_dict,
          styles=style_dict,
          colors={"aud/r": "r"},
          linestyles=dict(vis="dotted"),
          ci=False,
      )
      plot_compare_evokeds(evoked_dict, colors=list(range(3)))
      plt.close("all")
      # test colormap
      cmap = _get_cmap("viridis")
      plot_compare_evokeds(
          evoked_dict, cmap=cmap, colors=dict(aud=0.4, vis=0.9)
      )
      plot_compare_evokeds(
          evoked_dict, cmap=cmap, colors=dict(aud=1, vis=2)
      )
      plot_compare_evokeds(
          evoked_dict,
          cmap=("cmap title", "inferno"),
          linestyles=["-", ":", "--"],
      )
      plt.close("all")
      # test combine
      match = "combine must be an instance of None, callable, or str"
      with pytest.raises(TypeError, match=match):
          plot_compare_evokeds(evoked, combine=["mean", "gfp"])
      plt.close("all")
      # test warnings
      with pytest.warns(
          RuntimeWarning, match='in "picks"; cannot combine'
      ):
          plot_compare_evokeds(evoked, picks=[0], combine="median")
      plt.close("all")
      # test errors
      with pytest.raises(
          TypeError, match='"evokeds" must be a dict, list'
      ):
          plot_compare_evokeds("foo")
      with pytest.raises(
          ValueError, match=r'keys in "styles" \(.*\) must '
      ):
          plot_compare_evokeds(
              evoked_dict, styles=dict(foo="foo", bar="bar")
          )
      with pytest.raises(
          ValueError, match="colors in the default color cycle"
      ):
          plot_compare_evokeds(huge_dict, colors=None)
      with pytest.raises(
          TypeError, match='"cmap" is specified, then "colors"'
      ):
          plot_compare_evokeds(
              evoked_dict,
              cmap="Reds",
              colors={"aud/l": "foo", "aud/r": "bar", "vis": "baz"},
          )
      plt.close("all")
      for kwargs in [dict(colors=[0, 1]), dict(linestyles=["-", ":"])]:
          match = r"but there are only \d* (colors|linestyles). Please specify"
          with pytest.raises(ValueError, match=match):
              plot_compare_evokeds(evoked_dict, **kwargs)
      for kwargs in [dict(colors="foo"), dict(linestyles="foo")]:
          match = r'"(colors|linestyles)" must be a dict, list, or None; got '
          with pytest.raises(TypeError, match=match):
              plot_compare_evokeds(evoked_dict, **kwargs)
      for kwargs in [
          dict(colors=dict(foo="f")),
          dict(linestyles=dict(foo="f")),
      ]:
          match = r'If "(colors|linestyles)" is a dict its keys \(.*\) must '
          with pytest.raises(ValueError, match=match):
              plot_compare_evokeds(evoked_dict, **kwargs)
      for kwargs in [dict(legend="foo"), dict(show_sensors="foo")]:
          with pytest.raises(
              ValueError, match="not a legal MPL loc, please"
          ):
              plot_compare_evokeds(evoked_dict, **kwargs)
      with pytest.raises(
          TypeError, match="an instance of list or tuple"
      ):
          plot_compare_evokeds(evoked_dict, vlines="foo")
      with pytest.raises(
          ValueError, match='"truncate_yaxis" must be bool or '
      ):
          plot_compare_evokeds(evoked_dict, truncate_yaxis="foo")
      plt.close("all")
      # test axes='topo'
      figs = plot_compare_evokeds(evoked_dict, axes="topo", legend=True)
      for fig in figs:
          assert len(fig.axes[0].lines) == len(evoked_dict)
      # test with (fake) CSD data
      csd = _get_epochs(
          picks=np.arange(315, 320)
      ).average()  # 5 EEG chs
      for entry in csd.info["chs"]:
          entry["coil_type"] = FIFF.FIFFV_COIL_EEG_CSD
          entry["unit"] = FIFF.FIFF_UNIT_V_M2
      plot_compare_evokeds(csd, picks="csd", axes="topo")
      # old tests
      red.info["chs"][0]["loc"][:2] = 0  # test plotting channel at zero
      (fig,) = plot_compare_evokeds(
          [red, blue],
          picks=[0],
          ci=lambda x: [x.std(axis=0), -x.std(axis=0)],
      )
      # reasonable legend lengths
      leg_texts = [
          t.get_text() for t in fig.axes[0].get_legend().get_texts()
      ]
      assert all(len(lt) < 50 for lt in leg_texts)
      plot_compare_evokeds(
          [list(evoked_dict.values())], picks=[0], ci=_parametric_ci
      )
      # smoke test for tmin >= 0 (from mailing list)
      red.crop(0.01, None)
      assert len(red.times) > 2
      plot_compare_evokeds(red)
      # plot a flat channel
      red.data = np.zeros_like(red.data)
      plot_compare_evokeds(red)
      # smoke test for one time point (not useful but should not fail)
      red.crop(0.02, 0.02)
      assert len(red.times) == 1
      plot_compare_evokeds(red)
      # now that we've cropped `red`:
      with pytest.raises(
          ValueError, match="not contain the same time instants"
      ):
          plot_compare_evokeds(evoked_dict)
      plt.close("all")
  
imports: from pathlib import Path
  import matplotlib.pyplot
  import numpy
  import pytest
  from matplotlib import gridspec
  from matplotlib.collections import PolyCollection
  from matplotlib.colors import same_color
  from mpl_toolkits.axes_grid1.parasite_axes import HostAxes
  from numpy.testing import assert_allclose
  import mne
  from mne import Epochs, compute_covariance, compute_proj_evoked, make_fixed_length_events, read_cov, read_events
  from mne._fiff.constants import FIFF
  from mne.datasets import testing
  from mne.io import read_raw_fif
  from mne.stats.parametric import _parametric_ci
  from mne.utils import catch_logging
  from mne.viz import plot_compare_evokeds, plot_evoked_white
  from mne.viz.utils import _fake_click, _get_cmap
label_desc: Use image node_id 10 for calling a global function with example usage: test_plot_compare_evokeds() and returns: unknown