code: def test_brute_keep(params_lmfit, capsys):
      """TEST 10: using 'keep' argument and check candidates attribute."""
      mini = lmfit.Minimizer(func_lmfit, params_lmfit)
      out = mini.minimize(method="brute")
      assert_equal(len(out.candidates), 50)  # default
  
      out_keep_all = mini.minimize(method="brute", keep="all")
      assert_equal(
          len(out_keep_all.candidates),
          len(out_keep_all.brute_Jout.ravel()),
      )
  
      out_keep10 = mini.minimize(method="brute", keep=10)
      assert_equal(len(out_keep10.candidates), 10)
  
      assert isinstance(out.candidates[0], lmfit.minimizer.Candidate)
      assert isinstance(out.candidates[0].params, lmfit.Parameters)
      assert isinstance(out.candidates[0].score, float)
  
      with pytest.raises(
          ValueError, match=r"'candidate_nmb' should be between"
      ):
          out_keep10.show_candidates(25)
  
      with pytest.raises(
          ValueError, match=r"'candidate_nmb' should be between"
      ):
          out_keep10.show_candidates(0)
  
      out_keep10.show_candidates(5)
      captured = capsys.readouterr()
      assert "Candidate #5" in captured.out
  
      # for coverage and to make sure the 'all' argument works; no assert...
      out_keep10.show_candidates("all")
  
imports: import pickle
  import numpy
  from numpy.testing import assert_allclose, assert_equal
  import pytest
  from scipy import optimize
  import lmfit
label_desc: Use image node_id 13 for calling a global function with example usage: test_brute_keep(params_lmfit, capsys) without return types