code: def test_newton_full_output(self):
      # Test the full_output capability, both when converging and not.
      # Use simple polynomials, to avoid hitting platform dependencies
      # (e.g., exp & trig) in number of iterations
  
      x0 = 3
      expected_counts = [(6, 7), (5, 10), (3, 9)]
  
      for derivs in range(3):
          kwargs = {
              "tol": 1e-6,
              "full_output": True,
          }
          for k, v in [["fprime", self.f1_1], ["fprime2", self.f1_2]][
              :derivs
          ]:
              kwargs[k] = v
  
          x, r = zeros.newton(self.f1, x0, disp=False, **kwargs)
          assert_(r.converged)
          assert_equal(x, r.root)
          assert_equal(
              (r.iterations, r.function_calls), expected_counts[derivs]
          )
          if derivs == 0:
              assert r.function_calls <= r.iterations + 1
          else:
              assert_equal(
                  r.function_calls, (derivs + 1) * r.iterations
              )
  
          # Now repeat, allowing one fewer iteration to force convergence failure
          iters = r.iterations - 1
          x, r = zeros.newton(
              self.f1, x0, maxiter=iters, disp=False, **kwargs
          )
          assert_(not r.converged)
          assert_equal(x, r.root)
          assert_equal(r.iterations, iters)
  
          if derivs == 1:
              # Check that the correct Exception is raised and
              # validate the start of the message.
              with pytest.raises(
                  RuntimeError,
                  match="Failed to converge after %d iterations, value is .*"
                  % (iters),
              ):
                  x, r = zeros.newton(
                      self.f1, x0, maxiter=iters, disp=True, **kwargs
                  )
  
imports: import pytest
  from math import sqrt, exp, sin, cos
  from functools import lru_cache
  from numpy.testing import assert_warns, assert_, assert_allclose, assert_equal, assert_array_equal, suppress_warnings
  import numpy
  from numpy import finfo, power, nan, isclose
  from scipy.optimize import zeros, newton, root_scalar
  from scipy._lib._util import getfullargspec_no_self
  from scipy.optimize._tstutils import get_tests, functions, fstrings
label_desc: Use image node_id 31 for calling the TestBasic obj's underlying member method code with example usage: obj.test_newton_full_output() without return types