Skip to content

Commit

Permalink
tweak the templates
Browse files Browse the repository at this point in the history
  • Loading branch information
moodymudskipper committed Jul 2, 2024
1 parent 3aeb429 commit ba11788
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 9 additions & 4 deletions R/qr.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ opts_qr <- function(constructor = c("qr", "next"), ...) {
}

is_corrupted_qr <- function(x) {
FALSE
# we could go further but here we just check that the high level structure
# makes sense for a "qr" object. We should not check the class here.
!is.list(x) || !all(names(x) %in% c("qr", "rank", "qraux", "pivot"))
}

#' @export
#' @method .cstr_construct.qr qr
.cstr_construct.qr.qr <- function(x, ...) {
# opts <- list(...)$opts$qr %||% opts_qr()
args <- list()
code <- .cstr_apply(args, fun = "qr", ...)
# inverse transformation
inv <- qr.X(x)
args <- list(inv)
# .cstr_apply constructs the code for `inv` and interpolates it into a qr() call
code <- .cstr_apply(args, "qr", ..., new_line = FALSE)
# in case attributes are different than canonical, .cstr_repair_attributes fixes them
.cstr_repair_attributes(
x, code, ...,
idiomatic_class = "qr"
Expand Down
4 changes: 2 additions & 2 deletions R/tbl_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ NULL

#' @export
.cstr_construct.tbl_df.data_frame <- function(x, ...) {
# opts <- list(...)$opts$tbl_df %||% opts_tbl_df()
args <- list()
args <- as.list(x)
code <- .cstr_apply(args, fun = "tibble::data_frame", ...)
.cstr_repair_attributes(
x, code, ...,
ignore = "row.names",
idiomatic_class = c("tbl_df", "tbl", "data.frame")
)
}

0 comments on commit ba11788

Please sign in to comment.