Skip to content

Commit

Permalink
stats: convert sparse array to csc before mean compute
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Nov 17, 2022
1 parent 58e81ab commit dcebac3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Orange/statistics/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,8 @@ def stats(X, weights=None, compute_variance=False):
is_sparse = sp.issparse(X)

if X.size and is_numeric:
if is_sparse:
X = X.tocsc()
if compute_variance:
means, vars = nan_mean_variance_axis(X, axis=0, weights=weights)
else:
Expand All @@ -360,7 +362,6 @@ def stats(X, weights=None, compute_variance=False):
X.shape[0] - nans))
elif is_sparse and X.size:
non_zero = np.bincount(X.nonzero()[1], minlength=X.shape[1])
X = X.tocsc()
return np.column_stack((
nanmin(X, axis=0),
nanmax(X, axis=0),
Expand Down

0 comments on commit dcebac3

Please sign in to comment.