File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -97,19 +97,24 @@ def preconditioner(
97
97
klass = None
98
98
if not isinstance (d , sp .csc_matrix ):
99
99
klass = d .__class__
100
- d = sp .csc_matrix (d )
100
+ d_csc = sp .csc_matrix (d )
101
101
elif copy :
102
- d = d .copy ()
102
+ assert isinstance (d , sp .csc_matrix )
103
+ d_csc = d .copy ()
103
104
104
- cond = cast (linearmodels .typing .data .Float64Array , np .sqrt (d .multiply (d ).sum (0 )).A1 )
105
- locs = np .zeros_like (d .indices )
106
- locs [d .indptr [1 :- 1 ]] = 1
105
+ cond = cast (
106
+ linearmodels .typing .data .Float64Array , np .sqrt (d_csc .multiply (d_csc ).sum (0 )).A1
107
+ )
108
+ locs = np .zeros_like (d_csc .indices )
109
+ locs [d_csc .indptr [1 :- 1 ]] = 1
107
110
locs = np .cumsum (locs )
108
- d .data /= np .take (cond , locs )
111
+ d_csc .data /= np .take (cond , locs )
109
112
if klass is not None :
110
- d = klass (d )
113
+ d_out = klass (d_csc )
114
+ else :
115
+ d_out = d_csc
111
116
112
- return d , cond
117
+ return d_out , cond
113
118
114
119
115
120
def dummy_matrix (
You can’t perform that action at this time.
0 commit comments