docstr: ...Test in SVRG that dense and sparse code matches in all possible
  settings
docstr_tok: ["...","Test","in","SVRG","that","dense","and","sparse","code","matches","in","all","possible","settings"]
code: def test_dense_and_sparse_match(self):
      """...Test in SVRG that dense and sparse code matches in all possible
      settings
      """
      variance_reductions = ["last", "rand"]
      rand_types = ["perm", "unif"]
      seed = 123
      tol = 0.0
      max_iter = 50
  
      n_samples = 500
      n_features = 20
  
      # Crazy prox examples
      proxs = [
          ProxTV(strength=1e-2, range=(5, 13), positive=True).astype(
              self.dtype
          ),
          ProxElasticNet(strength=1e-2, ratio=0.9).astype(self.dtype),
          ProxEquality(range=(0, n_features)).astype(self.dtype),
          ProxL1(strength=1e-3, range=(5, 17)).astype(self.dtype),
          ProxL1w(
              strength=1e-3,
              weights=np.arange(5, 17, dtype=np.double),
              range=(5, 17),
          ).astype(self.dtype),
      ]
  
      for intercept in [-1, None]:
          X, y = self.simu_linreg_data(
              dtype=self.dtype,
              interc=intercept,
              n_features=n_features,
              n_samples=n_samples,
          )
  
          fit_intercept = intercept is not None
          (
              model_dense,
              model_spars,
          ) = self.get_dense_and_sparse_linreg_model(
              X, y, dtype=self.dtype, fit_intercept=fit_intercept
          )
          step = 1 / model_spars.get_lip_max()
  
          for variance_reduction, rand_type, prox in product(
              variance_reductions, rand_types, proxs
          ):
              solver_sparse = SVRG(
                  step=step,
                  tol=tol,
                  max_iter=max_iter,
                  verbose=False,
                  variance_reduction=variance_reduction,
                  rand_type=rand_type,
                  seed=seed,
              )
              solver_sparse.set_model(model_spars).set_prox(prox)
  
              solver_dense = SVRG(
                  step=step,
                  tol=tol,
                  max_iter=max_iter,
                  verbose=False,
                  variance_reduction=variance_reduction,
                  rand_type=rand_type,
                  seed=seed,
              )
              solver_dense.set_model(model_dense).set_prox(prox)
  
              solver_sparse.solve()
              solver_dense.solve()
              places = 7
              if self.dtype is "float32":
                  places = 3
              np.testing.assert_array_almost_equal(
                  solver_sparse.solution,
                  solver_dense.solution,
                  decimal=places,
              )
  
imports: import unittest
  from warnings import catch_warnings, simplefilter
  from itertools import product
  import numpy
  from scipy.linalg.special_matrices import toeplitz
  from scipy.sparse import csr_matrix
  from tick.linear_model import ModelLinReg, ModelLogReg, SimuLogReg
  from tick.prox import ProxL1, ProxL1w, ProxTV, ProxEquality, ProxElasticNet
  from tick.solver import SVRG
  from tick.solver.tests import TestSolver
  from tick.solver.build.solver import SVRG_VarianceReductionMethod_Last
  from tick.solver.build.solver import SVRG_VarianceReductionMethod_Average
  from tick.solver.build.solver import SVRG_VarianceReductionMethod_Random
  from tick.solver.build.solver import SVRG_StepType_Fixed
  from tick.solver.build.solver import SVRG_StepType_BarzilaiBorwein
  from tick.simulation import weights_sparse_gauss
label_desc: Use image node_id 8 for calling the SVRGTest obj's underlying member method code with example usage: obj.test_dense_and_sparse_match() without return types