code: def test_truncated_svd_eq_pca(X_sparse):
      # TruncatedSVD should be equal to PCA on centered data
  
      X_dense = X_sparse.toarray()
  
      X_c = X_dense - X_dense.mean(axis=0)
  
      params = dict(n_components=10, random_state=42)
  
      svd = TruncatedSVD(algorithm="arpack", **params)
      pca = PCA(svd_solver="arpack", **params)
  
      Xt_svd = svd.fit_transform(X_c)
      Xt_pca = pca.fit_transform(X_c)
  
      assert_allclose(Xt_svd, Xt_pca, rtol=1e-9)
      assert_allclose(pca.mean_, 0, atol=1e-9)
      assert_allclose(svd.components_, pca.components_)
  
file_path: scikit-learn/sklearn/decomposition/tests/test_truncated_svd.py
imports: import numpy
  import pytest
  import scipy.sparse
  from sklearn.decomposition import PCA, TruncatedSVD
  from sklearn.utils import check_random_state
  from sklearn.utils._testing import assert_allclose, assert_array_less
label_desc: Use image node_id 12 for calling a global function with example usage: test_truncated_svd_eq_pca(X_sparse) without return types