Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Hannah Frick <[email protected]>
Co-authored-by: Emil Hvitfeldt <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2024
1 parent 2fcedb9 commit 58025ca
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions R/arguments.R
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ set_mode <- function(object, mode, ...) {
#' for these values (e.g., `quantile_levels = 0.5` is the median).
#' @export
set_mode.model_spec <- function(object, mode, quantile_levels = NULL, ...) {
check_dots_empty()
cls <- class(object)[1]
if (rlang::is_missing(mode)) {
spec_modes <- rlang::env_get(get_model_env(), paste0(cls, "_modes"))
Expand Down
2 changes: 1 addition & 1 deletion R/predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ check_pred_type <- function(object, type, ..., call = rlang::caller_env()) {
"censored regression" = "time",
"quantile regression" = "quantile",
cli::cli_abort(
"{.arg type} should be one of {.val {all_modes}}.",
"{.arg type} should be one of {.or {.val {all_modes}}}.",
call = call
)
)
Expand Down
6 changes: 3 additions & 3 deletions R/predict_quantile.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @keywords internal
#' @rdname other_predict
#' @param quantile_levels A vector of values between zero and one for the
#' quantile to be predicted. If the model has a `"censored regression"` mode,
#' @param quantile_levels A vector of values between 0 and 1 for the
#' quantile to be predicted. If the model has a `"quantile regression"` mode,
#' this value should be `NULL`. For other modes, the default is `(1:9)/10`.
#' @inheritParams predict.model_fit
#' @method predict_quantile model_fit
Expand All @@ -13,7 +13,7 @@ predict_quantile.model_fit <- function(object,
interval = "none",
level = 0.95,
...) {

check_dots_empty()
check_spec_pred_type(object, "quantile")

if (inherits(object$fit, "try-error")) {
Expand Down
2 changes: 1 addition & 1 deletion R/print.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ print_model_spec <- function(x, cls = class(x)[1], desc = get_model_desc(cls), .
print(show_call(x))
}

if ( x$mode == "quantile regression" ) {
if (x$mode == "quantile regression") {
cli::cli_inform("Quantile levels: {x$quantile_levels}.")
}

Expand Down

0 comments on commit 58025ca

Please sign in to comment.