docstr: Test that components_from_metric returns the right result in various
  edge cases
docstr_tok: ["Test","that","components_from_metric","returns","the","right","result","in","various","edge","cases"]
code: def test_components_from_metric_edge_cases(self):
      """Test that components_from_metric returns the right result in various
      edge cases"""
      rng = np.random.RandomState(42)
  
      # an orthonormal matrix useful for creating matrices with given
      # eigenvalues:
      P = ortho_group.rvs(7, random_state=rng)
  
      # matrix with all its coefficients very low (to check that the algorithm
      # does not consider it as a diagonal matrix)(non regression test for
      # https://github.com/scikit-learn-contrib/metric-learn/issues/175)
      M = np.diag([1e-15, 2e-16, 3e-15, 4e-16, 5e-15, 6e-16, 7e-15])
      M = P.dot(M).dot(P.T)
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # diagonal matrix
      M = np.diag(np.abs(rng.randn(5)))
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # low-rank matrix (with zeros)
      M = np.zeros((7, 7))
      small_random = rng.randn(3, 3)
      M[:3, :3] = small_random.T.dot(small_random)
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # low-rank matrix (without necessarily zeros)
      R = np.abs(rng.randn(7, 7))
      M = R.dot(np.diag([1, 5, 3, 2, 0, 0, 0])).dot(R.T)
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # matrix with a determinant still high but which is
      # undefinite w.r.t to numpy standards
      M = np.diag([1e5, 1e5, 1e5, 1e5, 1e5, 1e5, 1e-20])
      M = P.dot(M).dot(P.T)
      assert np.abs(np.linalg.det(M)) > 10
      assert (
          np.linalg.slogdet(M)[1] > 1
      )  # (just to show that the computed
      # determinant is far from null)
      assert np.linalg.matrix_rank(M) < M.shape[0]
      # (just to show that this case is indeed considered by numpy as an
      # indefinite case)
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # matrix with lots of small nonzeros that make a big zero when multiplied
      M = np.diag([1e-3, 1e-3, 1e-3, 1e-3, 1e-3, 1e-3, 1e-3])
      L = components_from_metric(M)
      assert_allclose(L.T.dot(L), M)
  
      # full rank matrix
      M = rng.randn(10, 10)
      M = M.T.dot(M)
      assert np.linalg.matrix_rank(M) == 10
      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 11 for calling the TestTransformerMetricConversion obj's underlying member method code with example usage: obj.test_components_from_metric_edge_cases() without return types