Skip to content

Commit

Permalink
fix stack overflow for display of interlaced cfactors
Browse files Browse the repository at this point in the history
  • Loading branch information
khusmann committed Jun 18, 2024
1 parent 96f7844 commit b769e01
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions R/cfactor.R
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,8 @@ as.cfactor.factor <- function(x, codes = NULL, ordered = is.ordered(x)) {
#' @importFrom generics as.factor
#' @export
as.factor.interlacer_cfactor <- function(x, ...) {
if (is.cfactor(x)) {
attr(attr(x, "levels"), "codes") <- NULL
class(x) <- class(x)[-1]
}
attr(attr(x, "levels"), "codes") <- NULL
class(x) <- discard(class(x), \(v) v == "interlacer_cfactor")
x
}

Expand Down Expand Up @@ -272,7 +270,7 @@ as.codes.interlacer_cfactor <- function(x, ...) {
#' @export
print.interlacer_cfactor <- function(x, ...) {
if (is.latent.cfactor(x)) {
NextMethod()
obj_print(as.factor(x), ...)
} else {
obj_print(x, ...)
}
Expand Down

0 comments on commit b769e01

Please sign in to comment.