Skip to content

Commit

Permalink
Fix to array shorthand not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ythevalil-dd committed Sep 26, 2024
1 parent 3d2437b commit 54d95e7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sliceline/slicefinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def _get_slices_masks(self, X):
# self._top_slices_enc.sum(axis=1) is the number of predicate(s) for each top_slices_
slices_masks = (
slice_candidates == self._top_slices_enc.sum(axis=1)
).toarray().astype(int)
).A.astype(int)

return slices_masks

Expand Down Expand Up @@ -376,7 +376,7 @@ def _eval_slice(
) -> np.ndarray:
"""Compute several statistics for all the slices."""
slice_candidates = x_encoded @ slices.T == level
slice_sizes = slice_candidates.sum(axis=0).toarray()[0]
slice_sizes = slice_candidates.sum(axis=0).A[0]
slice_errors = errors @ slice_candidates
max_slice_errors = slice_candidates.T.multiply(errors).max(axis=1).toarray()

Expand All @@ -395,7 +395,7 @@ def _create_and_score_basic_slices(
errors: np.ndarray,
) -> Tuple[sp.csr_matrix, np.ndarray]:
"""Initialise 1-slices, i.e. slices with one predicate."""
slice_sizes = x_encoded.sum(axis=0).toarray()[0]
slice_sizes = x_encoded.sum(axis=0).A[0]
slice_errors = errors @ x_encoded
max_slice_errors = x_encoded.T.multiply(errors).max(axis=1).toarray()[:, 0]

Expand Down Expand Up @@ -478,7 +478,7 @@ def _prune_invalid_self_joins(
for start, end in zip(feature_offset_start, feature_offset_end):
valid_slices_mask = (
valid_slices_mask
* (pair_candidates[:, start:end].sum(axis=1) <= 1).toarray()[:, 0]
* (pair_candidates[:, start:end].sum(axis=1) <= 1).A[:, 0]
)
return (
pair_candidates[valid_slices_mask],
Expand All @@ -505,7 +505,7 @@ def _prepare_deduplication_and_pruning(
i = sub_pair_candidates.argmax(axis=1).T + np.any(
sub_pair_candidates.toarray(), axis=1
)
ids = ids + i.toarray() * np.prod(dom[(j + 1) : dom.shape[0]])
ids = ids + i.A * np.prod(dom[(j + 1) : dom.shape[0]])
return ids

def _get_pair_candidates(
Expand Down

0 comments on commit 54d95e7

Please sign in to comment.