code: def test_issue_9044(self):
      # https://github.com/scipy/scipy/issues/9044
      # Test the returned `OptimizeResult` contains keys consistent with
      # other solvers.
  
      def callback(x, info):
          assert_("nit" in info)
          assert_("niter" in info)
  
      result = minimize(
          lambda x: x**2,
          [0],
          jac=lambda x: 2 * x,
          hess=lambda x: 2,
          callback=callback,
          method="trust-constr",
      )
      assert_(result.get("success"))
      assert_(result.get("nit", -1) == 1)
  
      # Also check existence of the 'niter' attribute, for backward
      # compatibility
      assert_(result.get("niter", -1) == 1)
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  import pytest
  from scipy.linalg import block_diag
  from scipy.sparse import csc_matrix
  from numpy.testing import TestCase, assert_array_almost_equal, assert_array_less, assert_allclose, assert_
  from pytest import raises
  from scipy.optimize import NonlinearConstraint, LinearConstraint, Bounds, minimize, BFGS, SR1
  from scipy._lib._numpy_compat import suppress_warnings
label_desc: Use image node_id 8 for calling the TestTrustRegionConstr obj's underlying member method code with example usage: obj.test_issue_9044() without return types