docstr: Checks that a non PSD matrix (i.e. with negative eigenvalues) will
  raise an error when passed to components_from_metric
docstr_tok: ["Checks","that","a","non","PSD","matrix","(","i.e",".","with","negative","eigenvalues",")","will","raise","an","error","when","passed","to","components_from_metric"]
code: def test_non_psd_raises(self):
      """Checks that a non PSD matrix (i.e. with negative eigenvalues) will
      raise an error when passed to components_from_metric"""
      rng = np.random.RandomState(42)
      D = np.diag([1, 5, 3, 4.2, -4, -2, 1])
      P = ortho_group.rvs(7, random_state=rng)
      M = P.dot(D).dot(P.T)
      msg = "Matrix is not positive semidefinite (PSD)."
      with pytest.raises(NonPSDError) as raised_error:
          components_from_metric(M)
      assert str(raised_error.value) == msg
      with pytest.raises(NonPSDError) as raised_error:
          components_from_metric(D)
      assert str(raised_error.value) == msg
  
imports: import unittest
  import numpy
  import pytest
  from scipy.stats import ortho_group
  from sklearn.datasets import load_iris
  from numpy.testing import assert_array_almost_equal, assert_allclose
  from metric_learn.sklearn_shims import ignore_warnings
  from metric_learn import LMNN, NCA, LFDA, Covariance, MLKR, LSML_Supervised, ITML_Supervised, SDML_Supervised, RCA_Supervised
  from metric_learn._util import components_from_metric
  from metric_learn.exceptions import NonPSDError
label_desc: Use image node_id 13 for calling the TestTransformerMetricConversion obj's underlying member method code with example usage: obj.test_non_psd_raises() without return types