@@ -20,7 +20,7 @@ def test_sparse_coef():
2020 clf .coef_ = [1 , 2 , 3 ]
2121
2222 assert_true (sp .isspmatrix (clf .sparse_coef_ ))
23- assert_equal (clf .sparse_coef_ .todense ().tolist ()[0 ], clf .coef_ )
23+ assert_equal (clf .sparse_coef_ .toarray ().tolist ()[0 ], clf .coef_ )
2424
2525
2626def test_normalize_option ():
@@ -168,7 +168,7 @@ def _test_sparse_enet_not_as_toy_dataset(alpha, fit_intercept, positive):
168168 d_clf = ElasticNet (alpha = alpha , l1_ratio = 0.8 , fit_intercept = fit_intercept ,
169169 max_iter = max_iter , tol = 1e-7 , positive = positive ,
170170 warm_start = True )
171- d_clf .fit (X_train .todense (), y_train )
171+ d_clf .fit (X_train .toarray (), y_train )
172172
173173 assert_almost_equal (d_clf .dual_gap_ , 0 , 4 )
174174 assert_greater (d_clf .score (X_test , y_test ), 0.85 )
@@ -207,7 +207,7 @@ def test_sparse_lasso_not_as_toy_dataset():
207207
208208 # check the convergence is the same as the dense version
209209 d_clf = Lasso (alpha = 0.1 , fit_intercept = False , max_iter = max_iter , tol = 1e-7 )
210- d_clf .fit (X_train .todense (), y_train )
210+ d_clf .fit (X_train .toarray (), y_train )
211211 assert_almost_equal (d_clf .dual_gap_ , 0 , 4 )
212212 assert_greater (d_clf .score (X_test , y_test ), 0.85 )
213213
@@ -254,7 +254,7 @@ def test_same_output_sparse_dense_lasso_and_enet_cv():
254254 clfs = ElasticNetCV (max_iter = 100 , cv = 5 , normalize = normalize )
255255 ignore_warnings (clfs .fit )(X , y )
256256 clfd = ElasticNetCV (max_iter = 100 , cv = 5 , normalize = normalize )
257- ignore_warnings (clfd .fit )(X .todense (), y )
257+ ignore_warnings (clfd .fit )(X .toarray (), y )
258258 assert_almost_equal (clfs .alpha_ , clfd .alpha_ , 7 )
259259 assert_almost_equal (clfs .intercept_ , clfd .intercept_ , 7 )
260260 assert_array_almost_equal (clfs .mse_path_ , clfd .mse_path_ )
@@ -263,7 +263,7 @@ def test_same_output_sparse_dense_lasso_and_enet_cv():
263263 clfs = LassoCV (max_iter = 100 , cv = 4 , normalize = normalize )
264264 ignore_warnings (clfs .fit )(X , y )
265265 clfd = LassoCV (max_iter = 100 , cv = 4 , normalize = normalize )
266- ignore_warnings (clfd .fit )(X .todense (), y )
266+ ignore_warnings (clfd .fit )(X .toarray (), y )
267267 assert_almost_equal (clfs .alpha_ , clfd .alpha_ , 7 )
268268 assert_almost_equal (clfs .intercept_ , clfd .intercept_ , 7 )
269269 assert_array_almost_equal (clfs .mse_path_ , clfd .mse_path_ )
0 commit comments