docstr: Checks that if the metric is almost PSD (i.e. it has some negative
  eigenvalues very close to zero), then components_from_metric will still
  work
docstr_tok: ["Checks","that","if","the","metric","is","almost","PSD","(","i.e",".","it","has","some","negative","eigenvalues","very","close","to","zero",")",",","then","components_from_metric","will","still","work"]
code: def test_almost_psd_dont_raise(self):
      """Checks that if the metric is almost PSD (i.e. it has some negative
      eigenvalues very close to zero), then components_from_metric will still
      work"""
      rng = np.random.RandomState(42)
      D = np.diag([1, 5, 3, 4.2, -1e-20, -2e-20, -1e-20])
      P = ortho_group.rvs(7, random_state=rng)
      M = P.dot(D).dot(P.T)
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
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 14 for calling the TestTransformerMetricConversion obj's underlying member method code with example usage: obj.test_almost_psd_dont_raise() without return types