Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Dec 25, 2023
1 parent 8d04653 commit 16815e8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
40 changes: 31 additions & 9 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

glicko <- function(unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call('_sport_glicko', PACKAGE = 'sport', unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau)
glicko <- function(
unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call(
"_sport_glicko",
PACKAGE = "sport",
unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight,
init_r, init_rd, init_sigma, kappa, tau
)
}

glicko2 <- function(unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call('_sport_glicko2', PACKAGE = 'sport', unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau)
glicko2 <- function(
unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call(
"_sport_glicko2",
PACKAGE = "sport",
unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight,
init_r, init_rd, init_sigma, kappa, tau
)
}

bbt <- function(unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call('_sport_bbt', PACKAGE = 'sport', unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau)
bbt <- function(
unique_id, id, rank, team, player, r, rd, sigma, share, lambda, weight, init_r, init_rd, init_sigma, kappa, tau) {
.Call(
"_sport_bbt",
PACKAGE = "sport",
unique_id, id, rank, team, player, r, rd, sigma, share, lambda,
weight, init_r, init_rd, init_sigma, kappa, tau
)
}

dbl <- function(unique_id, id_vec, rank_vec, team_vec, MAP, X, cls, R, RD, lambda_vec, weight_vec, kappa) {
.Call('_sport_dbl', PACKAGE = 'sport', unique_id, id_vec, rank_vec, team_vec, MAP, X, cls, R, RD, lambda_vec, weight_vec, kappa)
dbl <- function(
unique_id, id_vec, rank_vec, team_vec, MAP, X, cls, R, RD, lambda_vec, weight_vec, kappa) {
.Call(
"_sport_dbl",
PACKAGE = "sport",
unique_id, id_vec, rank_vec, team_vec, MAP, X, cls, R, RD, lambda_vec, weight_vec, kappa
)
}

1 change: 0 additions & 1 deletion R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#' @name gpheats
NULL


#' Turnament results of Speedway Grand-Prix
#'
#' Actual dataset containing turnament results of all Speedway Grand-Prix events
Expand Down
20 changes: 13 additions & 7 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ is_newdata_consistent <- function(vars, newnames) {

are_variables_in_dataset <- function(vars, data) {
missing_vars <- setdiff(vars, colnames(data))

if (length(missing_vars) > 0) {
stop(
sprintf(
Expand All @@ -32,6 +31,7 @@ are_variables_in_dataset <- function(vars, data) {

return(invisible(TRUE))
}

check_numeric_argument <- function(x, var_name, min = -Inf, max = Inf) {
if (!is.numeric(x)) {
stop(sprintf("Variable %s should be of type numeric.", var_name),
Expand All @@ -50,15 +50,18 @@ check_numeric_argument <- function(x, var_name, min = -Inf, max = Inf) {

check_integer_argument <- function(x, var_name, min = -Inf, max = Inf) {
if (!is.integer(x)) {
stop(sprintf("Variable %s should be of type integer.", var_name),
stop(
sprintf("Variable %s should be of type integer.", var_name),
call. = FALSE
)
} else if (any(!is.finite(x))) {
stop(sprintf("Variable %s contains non-finite values. All elements should be finite.", var_name),
stop(
sprintf("Variable %s contains non-finite values. All elements should be finite.", var_name),
call. = FALSE
)
} else if (any(x < min | x > max)) {
stop(sprintf("All values in variable %s should be in range [%s, %s]", var_name, min, max),
stop(
sprintf("All values in variable %s should be in range [%s, %s]", var_name, min, max),
call. = FALSE
)
}
Expand All @@ -78,15 +81,18 @@ check_string_argument <- function(x, var_name) {

check_single_argument <- function(x, var_name, min = -Inf, max = Inf) {
if (length(x) > 1) {
stop(sprintf("variable %s should be a single value", var_name),
stop(
sprintf("variable %s should be a single value", var_name),
call. = FALSE
)
} else if (is.numeric(x) && x < min) {
stop(sprintf("variable %s should be greater than %s", var_name, min),
stop(
sprintf("variable %s should be greater than %s", var_name, min),
call. = FALSE
)
} else if (is.numeric(x) && x > max) {
stop(sprintf("variable %s should be lower than %s", var_name, max),
stop(
sprintf("variable %s should be lower than %s", var_name, max),
call. = FALSE
)
}
Expand Down

0 comments on commit 16815e8

Please sign in to comment.