Skip to content

Commit

Permalink
fix simplify of apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunuuuu committed Jul 6, 2024
1 parent 534ccad commit 6f58260
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions R/Method-apply.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ methods::setMethod(
X_dim <- dim(X)
MARGIN <- as.integer(MARGIN)
if (MARGIN < 1L || MARGIN > length(X_dim)) {
cli::cli_abort(
"{.arg MARGIN} must be >= 1 and <= length(dim(X))"
)
cli::cli_abort("{.arg MARGIN} must be >= 1 and <= length(dim(X))")
}
if (X_dim[[MARGIN]] == 0L) {
## base::apply seems to be doing something like that!
ans <- FUN(X, ...)
ans <- FUN(as.matrix(X), ...)
return(as.vector(ans[0L]))
}
seed <- to_BPCells(X@seed)
Expand Down Expand Up @@ -79,10 +77,10 @@ methods::setMethod(
ans <- do.call(cbind, ans)
colnames(ans) <- nms
}
return(ans)
}
} else {
names(ans) <- nms
}
names(ans) <- nms
ans
}
)

0 comments on commit 6f58260

Please sign in to comment.