Skip to content

Commit dcebac3

Browse files
committed
stats: convert sparse array to csc before mean compute
1 parent 58e81ab commit dcebac3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Orange/statistics/util.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ def stats(X, weights=None, compute_variance=False):
343343
is_sparse = sp.issparse(X)
344344

345345
if X.size and is_numeric:
346+
if is_sparse:
347+
X = X.tocsc()
346348
if compute_variance:
347349
means, vars = nan_mean_variance_axis(X, axis=0, weights=weights)
348350
else:
@@ -360,7 +362,6 @@ def stats(X, weights=None, compute_variance=False):
360362
X.shape[0] - nans))
361363
elif is_sparse and X.size:
362364
non_zero = np.bincount(X.nonzero()[1], minlength=X.shape[1])
363-
X = X.tocsc()
364365
return np.column_stack((
365366
nanmin(X, axis=0),
366367
nanmax(X, axis=0),

0 commit comments

Comments
 (0)