code: def test_violin_wrong_features_shape():
      """Checks that DimensionError is raised if the features data matrix
      has an incompatible shape with the shap_values matrix.
      """
      rs = np.random.RandomState(42)
  
      emsg = (
          "The shape of the shap_values matrix does not match the shape of "
          "the provided data matrix. Perhaps the extra column"
      )
      with pytest.raises(DimensionError, match=emsg):
          expln = shap.Explanation(
              values=rs.randn(20, 5),
              data=rs.randn(20, 4),
          )
          shap.plots.violin(expln, show=False)
      # legacy API
      with pytest.raises(DimensionError, match=emsg):
          shap.plots.violin(
              shap_values=rs.randn(20, 5),
              features=rs.randn(20, 4),
              show=False,
          )
  
      emsg = (
          "The shape of the shap_values matrix does not match the shape of "
          "the provided data matrix."
      )
      with pytest.raises(DimensionError, match=emsg):
          expln = shap.Explanation(
              values=rs.randn(20, 5),
              data=rs.randn(20, 1),
          )
          shap.plots.violin(expln, show=False)
      # legacy API
      with pytest.raises(DimensionError, match=emsg):
          shap.plots.violin(
              shap_values=rs.randn(20, 5),
              features=rs.randn(20, 1),
              show=False,
          )
  
file_path: shap/tests/plots/test_violin.py
imports: import matplotlib.pyplot
  import numpy
  import pytest
  import shap
  from shap.utils._exceptions import DimensionError
label_desc: Use image node_id 2 for calling a global function with example usage: test_violin_wrong_features_shape() without return types