Skip to content

Commit

Permalink
Table: _compute_distribution no longer converts X to csc
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Apr 2, 2021
1 parent 496a7d1 commit 17d37fe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Orange/data/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1699,23 +1699,25 @@ def _compute_distributions(self, columns=None):
columns = [self.domain.index(var) for var in columns]

distributions = []
if sp.issparse(self.X):
self.X = self.X.tocsc()
X = self.X
if sp.issparse(X):
X = X.tocsc()


W = self.W.ravel() if self.has_weights() else None

for col in columns:
variable = self.domain[col]

# Select the correct data column from X, Y or metas
if 0 <= col < self.X.shape[1]:
x = self.X[:, col]
if 0 <= col < x.shape[1]:
x = X[:, col]
elif col < 0:
x = self.metas[:, col * (-1) - 1]
if np.issubdtype(x.dtype, np.dtype(object)):
x = x.astype(float)
else:
x = self._Y[:, col - self.X.shape[1]]
x = self._Y[:, col - X.shape[1]]

if variable.is_discrete:
dist, unknowns = bincount(x, weights=W, max_val=len(variable.values) - 1)
Expand Down

0 comments on commit 17d37fe

Please sign in to comment.