class_docstr: Test ResidualPlot visualizer
class_docstr_tok: ["Test","ResidualPlot","visualizer"]
docstr: Test that ResidualsPlot properly handles an already-fitted model
docstr_tok: ["Test","that","ResidualsPlot","properly","handles","an","already-fitted","model"]
code: def test_residuals_with_fitted(self):
      """
      Test that ResidualsPlot properly handles an already-fitted model
      """
      X, y = load_energy(return_dataset=True).to_numpy()
  
      model = Ridge().fit(X, y)
  
      with mock.patch.object(model, "fit") as mockfit:
          oz = ResidualsPlot(model)
          oz.fit(X, y)
          mockfit.assert_not_called()
  
      with mock.patch.object(model, "fit") as mockfit:
          oz = ResidualsPlot(model, is_fitted=True)
          oz.fit(X, y)
          mockfit.assert_not_called()
  
      with mock.patch.object(model, "fit") as mockfit:
          oz = ResidualsPlot(model, is_fitted=False)
          oz.fit(X, y)
          mockfit.assert_called_once_with(X, y)
  
imports: import sys
  import pytest
  import matplotlib
  import matplotlib.pyplot
  from yellowbrick.datasets import load_energy
  from yellowbrick.exceptions import YellowbrickValueError
  from yellowbrick.regressor.residuals import ResidualsPlot, residuals_plot
  from unittest import mock
  from tests.fixtures import Dataset, Split
  from tests.base import IS_WINDOWS_OR_CONDA, VisualTestCase
  from sklearn.datasets import make_regression
  from sklearn.linear_model import Ridge, Lasso
  from sklearn.neural_network import MLPRegressor
  from sklearn.linear_model import LinearRegression
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import MinMaxScaler
label_desc: Use image node_id 15 for calling the TestResidualsPlot obj's underlying member method code with example usage: obj.test_residuals_with_fitted() without return types