class_docstr: Tests regularization/postprocessing methods.
class_docstr_tok: ["Tests","regularization\/postprocessing","methods","."]
docstr: Test obtaining the closest positive semi-definite matrix using a semi-definite program.
docstr_tok: ["Test","obtaining","the","closest","positive","semi-definite","matrix","using","a","semi-definite","program","."]
code: def test_closest_psd_matrix(
      self, input, fix_diagonal, expected_output
  ):
      """Test obtaining the closest positive semi-definite matrix using a semi-definite program."""
      try:
          import cvxpy as cp
  
          output = kern.closest_psd_matrix(
              input, fix_diagonal=fix_diagonal, feastol=1e-10
          )
      except cp.error.SolverError:
          pytest.skip(
              "The cvxopt solver seems to not be installed on the system."
              "It is the default solver for qml.kernels.closest_psd_matrix"
              " and can be installed via `pip install cvxopt`."
          )
  
      assert np.allclose(output, expected_output, atol=1e-5)
  
imports: import math
  import sys
  from functools import partial
  import pytest
  import numpy
  import pennylane
  import pennylane.kernels
  from pennylane import numpy
label_desc: Use image node_id 5 for calling the TestRegularization obj's underlying member method code with example usage: obj.test_closest_psd_matrix(input, fix_diagonal, expected_output) without return types