diff --git a/R/assert.R b/R/assert.R index a7a47b6..132f173 100644 --- a/R/assert.R +++ b/R/assert.R @@ -35,12 +35,7 @@ validate <- function(expr) { #' @return Invisibly returns `NULL`. #' @family validation methods #' @author N. Frerebeau -#' @name check-package -#' @rdname check-package -NULL - #' @export -#' @rdname check-package assert_package <- function(x, ask = TRUE) { ok <- vapply(X = x, FUN = requireNamespace, FUN.VALUE = logical(1), quietly = TRUE) @@ -73,7 +68,7 @@ assert_package <- function(x, ask = TRUE) { } #' @export -#' @rdname check-package +#' @rdname assert_package needs <- assert_package # Types ======================================================================== @@ -87,12 +82,7 @@ needs <- assert_package #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-type -#' @rdname check-type -NULL - #' @export -#' @rdname check-type assert_type <- function(x, expected) { arg <- deparse(substitute(x)) predicate <- switch( @@ -115,7 +105,7 @@ assert_type <- function(x, expected) { } #' @export -#' @rdname check-type +#' @rdname assert_type assert_scalar <- function(x, expected) { arg <- deparse(substitute(x)) predicate <- switch( @@ -138,7 +128,7 @@ assert_scalar <- function(x, expected) { } #' @export -#' @rdname check-type +#' @rdname assert_type assert_function <- function(x) { arg <- deparse(substitute(x)) if (!is.function(x)) { @@ -149,7 +139,7 @@ assert_function <- function(x) { } # Attributes =================================================================== -#' Check Object Attributes +#' Check Object Length/Dimensions #' #' @param x An object to be checked. #' @param expected An appropriate expected value. @@ -158,34 +148,7 @@ assert_function <- function(x) { #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-attribute -#' @rdname check-attribute -NULL - #' @export -#' @rdname check-attribute -assert_empty <- function(x) { - arg <- deparse(substitute(x)) - if (!is_empty(x)) { - msg <- sprintf("%s must be empty.", sQuote(arg)) - throw_error("error_bad_dimensions", msg) - } - invisible(x) -} - -#' @export -#' @rdname check-attribute -assert_filled <- function(x) { - arg <- deparse(substitute(x)) - if (is_empty(x)) { - msg <- sprintf("%s must not be empty.", sQuote(arg)) - throw_error("error_bad_dimensions", msg) - } - invisible(x) -} - -#' @export -#' @rdname check-attribute assert_length <- function(x, expected, empty = FALSE) { arg <- deparse(substitute(x)) if (!(empty & is_empty(x)) && !has_length(x, n = expected)) { @@ -197,7 +160,7 @@ assert_length <- function(x, expected, empty = FALSE) { } #' @export -#' @rdname check-attribute +#' @rdname assert_length assert_lengths <- function(x, expected) { arg <- deparse(substitute(x)) n <- lengths(x) @@ -211,7 +174,29 @@ assert_lengths <- function(x, expected) { } #' @export -#' @rdname check-attribute +#' @rdname assert_length +assert_empty <- function(x) { + arg <- deparse(substitute(x)) + if (!is_empty(x)) { + msg <- sprintf("%s must be empty.", sQuote(arg)) + throw_error("error_bad_dimensions", msg) + } + invisible(x) +} + +#' @export +#' @rdname assert_length +assert_filled <- function(x) { + arg <- deparse(substitute(x)) + if (is_empty(x)) { + msg <- sprintf("%s must not be empty.", sQuote(arg)) + throw_error("error_bad_dimensions", msg) + } + invisible(x) +} + +#' @export +#' @rdname assert_length assert_dimensions <- function(x, expected) { arg <- deparse(substitute(x)) n <- dim(x) @@ -224,8 +209,15 @@ assert_dimensions <- function(x, expected) { invisible(x) } +#' Check Object Names +#' +#' @param x An object to be checked. +#' @param expected An appropriate expected value. +#' @return +#' Throws an error, if any, and returns `x` invisibly otherwise. +#' @author N. Frerebeau +#' @family validation methods #' @export -#' @rdname check-attribute assert_names <- function(x, expected) { arg <- deparse(substitute(x)) if (!has_names(x, names = expected)) { @@ -241,7 +233,7 @@ assert_names <- function(x, expected) { } #' @export -#' @rdname check-attribute +#' @rdname assert_names assert_dimnames <- function(x, expected) { arg <- deparse(substitute(x)) if (!identical(dimnames(x), expected)) { @@ -252,7 +244,7 @@ assert_dimnames <- function(x, expected) { } #' @export -#' @rdname check-attribute +#' @rdname assert_names assert_rownames <- function(x, expected) { arg <- deparse(substitute(x)) if (!identical(rownames(x), expected)) { @@ -263,7 +255,7 @@ assert_rownames <- function(x, expected) { } #' @export -#' @rdname check-attribute +#' @rdname assert_names assert_colnames <- function(x, expected) { arg <- deparse(substitute(x)) if (!identical(colnames(x), expected)) { @@ -284,12 +276,12 @@ assert_colnames <- function(x, expected) { #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-data -#' @rdname check-data +#' @name assert_data +#' @rdname assert_data NULL #' @export -#' @rdname check-data +#' @rdname assert_data assert_missing <- function(x) { arg <- deparse(substitute(x)) n <- sum(is.na(x)) @@ -302,7 +294,7 @@ assert_missing <- function(x) { } #' @export -#' @rdname check-data +#' @rdname assert_data assert_infinite <- function(x) { arg <- deparse(substitute(x)) n <- sum(is.infinite(x)) @@ -315,7 +307,7 @@ assert_infinite <- function(x) { } #' @export -#' @rdname check-data +#' @rdname assert_data assert_unique <- function(x) { arg <- deparse(substitute(x)) if (has_duplicates(x)) { @@ -336,12 +328,12 @@ assert_unique <- function(x) { #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-numeric -#' @rdname check-numeric +#' @name assert_numeric +#' @rdname assert_numeric NULL #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_count <- function(x, na.rm = FALSE, ...) { arg <- deparse(substitute(x)) if (!all(is_whole(x, ...), na.rm = na.rm)) { @@ -352,11 +344,11 @@ assert_count <- function(x, na.rm = FALSE, ...) { } #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_whole <- assert_count #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_positive <- function(x, na.rm = FALSE, ...) { arg <- deparse(substitute(x)) if (!all(is_positive(x, ...), na.rm = na.rm)) { @@ -367,7 +359,7 @@ assert_positive <- function(x, na.rm = FALSE, ...) { } #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_negative <- function(x, na.rm = FALSE, ...) { arg <- deparse(substitute(x)) if (!all(is_negative(x, ...), na.rm = na.rm)) { @@ -378,7 +370,7 @@ assert_negative <- function(x, na.rm = FALSE, ...) { } #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_odd <- function(x, na.rm = FALSE, ...) { arg <- deparse(substitute(x)) if (!all(is_odd(x, ...), na.rm = na.rm)) { @@ -389,7 +381,7 @@ assert_odd <- function(x, na.rm = FALSE, ...) { } #' @export -#' @rdname check-numeric +#' @rdname assert_numeric assert_even <- function(x, na.rm = FALSE, ...) { arg <- deparse(substitute(x)) if (!all(is_even(x, ...), na.rm = na.rm)) { @@ -407,12 +399,7 @@ assert_even <- function(x, na.rm = FALSE, ...) { #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-numeric-trend -#' @rdname check-numeric-trend -NULL - #' @export -#' @rdname check-numeric-trend assert_constant <- function(x, ...) { arg <- deparse(substitute(x)) if (!is_constant(x, ...)) { @@ -423,7 +410,7 @@ assert_constant <- function(x, ...) { } #' @export -#' @rdname check-numeric-trend +#' @rdname assert_constant assert_decreasing <- function(x, ...) { arg <- deparse(substitute(x)) if (!is_decreasing(x, ...)) { @@ -434,7 +421,7 @@ assert_decreasing <- function(x, ...) { } #' @export -#' @rdname check-numeric-trend +#' @rdname assert_constant assert_increasing <- function(x, ...) { arg <- deparse(substitute(x)) if (!is_increasing(x, ...)) { @@ -452,12 +439,7 @@ assert_increasing <- function(x, ...) { #' Throws an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-numeric-comparison -#' @rdname check-numeric-comparison -NULL - #' @export -#' @rdname check-numeric-comparison assert_lower <- function(x, y, ...) { arg_x <- deparse(substitute(x)) arg_y <- deparse(substitute(y)) @@ -469,7 +451,7 @@ assert_lower <- function(x, y, ...) { } #' @export -#' @rdname check-numeric-comparison +#' @rdname assert_lower assert_greater <- function(x, y, ...) { arg_x <- deparse(substitute(x)) arg_y <- deparse(substitute(y)) @@ -487,28 +469,23 @@ assert_greater <- function(x, y, ...) { #' @return Throw an error, if any, and returns `x` invisibly otherwise. #' @author N. Frerebeau #' @family validation methods -#' @name check-matrix -#' @rdname check-matrix -NULL - #' @export -#' @rdname check-matrix -assert_symmetric <- function(x) { +assert_square <- function(x) { arg <- deparse(substitute(x)) - if (!is_symmetric(x)) { - msg <- sprintf("%s must be a symmetric matrix.", sQuote(arg)) + if (!is_square(x)) { + k <- paste0(dim(x), collapse = " x ") + msg <- sprintf("%s must be a square matrix, not %s.", sQuote(arg), k) throw_error("error_bad_matrix", msg) } invisible(x) } #' @export -#' @rdname check-matrix -assert_square <- function(x) { +#' @rdname assert_square +assert_symmetric <- function(x) { arg <- deparse(substitute(x)) - if (!is_square(x)) { - k <- paste0(dim(x), collapse = " x ") - msg <- sprintf("%s must be a sqaure matrix, not %s.", sQuote(arg), k) + if (!is_symmetric(x)) { + msg <- sprintf("%s must be a symmetric matrix.", sQuote(arg)) throw_error("error_bad_matrix", msg) } invisible(x) @@ -522,13 +499,8 @@ assert_square <- function(x) { # @return Throw an error, if any. # @author N. Frerebeau # @family validation methods -# @name check-graph -# @rdname check-graph # @keywords internal -NULL - # @export -# @rdname check-graph # assert_dag <- function(x) { # arg <- deparse(substitute(x)) # if (!is_dag(x)) { diff --git a/R/predicates.R b/R/predicates.R index 83ceca3..7b869c5 100644 --- a/R/predicates.R +++ b/R/predicates.R @@ -40,6 +40,13 @@ NULL has_length <- function(x, n = NULL) { if (is.null(n)) length(x) > 0 else length(x) == n } +#' @export +#' @rdname predicate-utils +is_empty <- function(x) { + if (!is.null(dim(x))) nrow(x) == 0 || ncol(x) == 0 + else length(x) == 0 +} + #' @export #' @rdname predicate-utils has_names <- function(x, names = NULL) { @@ -49,11 +56,7 @@ has_names <- function(x, names = NULL) { identical(names(x), names) } } -#' @export -#' @rdname predicate-utils -has_duplicates <- function(x) { - any(duplicated(x)) -} + #' @export #' @rdname predicate-utils has_missing <- function(x) { @@ -64,17 +67,18 @@ has_missing <- function(x) { has_infinite <- function(x) { any(is.infinite(x)) } -#' @export -#' @rdname predicate-utils -is_empty <- function(x) { - any((dim(x) %||% length(x)) == 0) -} + #' @export #' @rdname predicate-utils is_unique <- function(x, na.rm = FALSE) { if (na.rm) x <- stats::na.omit(x) length(unique(x)) == 1 } +#' @export +#' @rdname predicate-utils +has_duplicates <- function(x) { + any(duplicated(x)) +} # Type ========================================================================= #' Type Predicates @@ -149,47 +153,47 @@ is_message <- function(x) { #' @param x An object to be tested. #' @return A [`logical`] scalar. #' @family predicates -#' @name predicate-scalar -#' @rdname predicate-scalar +#' @name is_scalar +#' @rdname is_scalar NULL #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_list <- function(x) { is_list(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_atomic <- function(x) { is_atomic(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_vector <- function(x) { is_vector(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_numeric <- function(x) { is_numeric(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_integer <- function(x) { is_integer(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_double <- function(x) { is_double(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_character <- function(x) { is_character(x) && length(x) == 1 } #' @export -#' @rdname predicate-scalar +#' @rdname is_scalar is_scalar_logical <- function(x) { is_logical(x) && length(x) == 1 } @@ -338,13 +342,8 @@ is_symmetric <- function(x) { # Kahn, A. B. (1962). Topological sorting of large networks. *Communications # of the ACM*, 5(11), p. 558-562. \doi{10.1145/368996.369025}. # @family predicates -# @name predicate-graph -# @rdname predicate-graph # @keywords internal -NULL - # @export -# @rdname predicate-graph # is_dag <- function(x) { # # Get edges # G <- matrix2edges(x) diff --git a/man/check-numeric-trend.Rd b/man/assert_constant.Rd similarity index 70% rename from man/check-numeric-trend.Rd rename to man/assert_constant.Rd index a94ff9f..9b2a862 100644 --- a/man/check-numeric-trend.Rd +++ b/man/assert_constant.Rd @@ -1,7 +1,6 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-numeric-trend} -\alias{check-numeric-trend} +\name{assert_constant} \alias{assert_constant} \alias{assert_decreasing} \alias{assert_increasing} @@ -26,13 +25,14 @@ Check Numeric Trend } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-data.Rd b/man/assert_data.Rd similarity index 72% rename from man/check-data.Rd rename to man/assert_data.Rd index 2cf57cc..90213e6 100644 --- a/man/check-data.Rd +++ b/man/assert_data.Rd @@ -1,7 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-data} -\alias{check-data} +\name{assert_data} +\alias{assert_data} \alias{assert_missing} \alias{assert_infinite} \alias{assert_unique} @@ -28,13 +28,14 @@ missing (\code{NA}, \code{NaN}) or infinite (\code{Inf}) value. } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-attribute.Rd b/man/assert_length.Rd similarity index 58% rename from man/check-attribute.Rd rename to man/assert_length.Rd index d6e5390..4b26b0d 100644 --- a/man/check-attribute.Rd +++ b/man/assert_length.Rd @@ -1,35 +1,22 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-attribute} -\alias{check-attribute} -\alias{assert_empty} -\alias{assert_filled} +\name{assert_length} \alias{assert_length} \alias{assert_lengths} +\alias{assert_empty} +\alias{assert_filled} \alias{assert_dimensions} -\alias{assert_names} -\alias{assert_dimnames} -\alias{assert_rownames} -\alias{assert_colnames} -\title{Check Object Attributes} +\title{Check Object Length/Dimensions} \usage{ -assert_empty(x) - -assert_filled(x) - assert_length(x, expected, empty = FALSE) assert_lengths(x, expected) -assert_dimensions(x, expected) - -assert_names(x, expected) - -assert_dimnames(x, expected) +assert_empty(x) -assert_rownames(x, expected) +assert_filled(x) -assert_colnames(x, expected) +assert_dimensions(x, expected) } \arguments{ \item{x}{An object to be checked.} @@ -42,17 +29,18 @@ assert_colnames(x, expected) Throws an error, if any, and returns \code{x} invisibly otherwise. } \description{ -Check Object Attributes +Check Object Length/Dimensions } \seealso{ Other validation methods: -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-numeric-comparison.Rd b/man/assert_lower.Rd similarity index 68% rename from man/check-numeric-comparison.Rd rename to man/assert_lower.Rd index 6bfbd60..bddbf43 100644 --- a/man/check-numeric-comparison.Rd +++ b/man/assert_lower.Rd @@ -1,7 +1,6 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-numeric-comparison} -\alias{check-numeric-comparison} +\name{assert_lower} \alias{assert_lower} \alias{assert_greater} \title{Check Numeric Relations} @@ -23,13 +22,14 @@ Check Numeric Relations } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/assert_names.Rd b/man/assert_names.Rd new file mode 100644 index 0000000..9ce3c00 --- /dev/null +++ b/man/assert_names.Rd @@ -0,0 +1,44 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/assert.R +\name{assert_names} +\alias{assert_names} +\alias{assert_dimnames} +\alias{assert_rownames} +\alias{assert_colnames} +\title{Check Object Names} +\usage{ +assert_names(x, expected) + +assert_dimnames(x, expected) + +assert_rownames(x, expected) + +assert_colnames(x, expected) +} +\arguments{ +\item{x}{An object to be checked.} + +\item{expected}{An appropriate expected value.} +} +\value{ +Throws an error, if any, and returns \code{x} invisibly otherwise. +} +\description{ +Check Object Names +} +\seealso{ +Other validation methods: +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, +\code{\link{validate}()} +} +\author{ +N. Frerebeau +} +\concept{validation methods} diff --git a/man/check-numeric.Rd b/man/assert_numeric.Rd similarity index 76% rename from man/check-numeric.Rd rename to man/assert_numeric.Rd index e968085..37a4528 100644 --- a/man/check-numeric.Rd +++ b/man/assert_numeric.Rd @@ -1,7 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-numeric} -\alias{check-numeric} +\name{assert_numeric} +\alias{assert_numeric} \alias{assert_count} \alias{assert_whole} \alias{assert_positive} @@ -38,13 +38,14 @@ Check Numeric Values } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-package.Rd b/man/assert_package.Rd similarity index 79% rename from man/check-package.Rd rename to man/assert_package.Rd index 69d8bef..0b20d48 100644 --- a/man/check-package.Rd +++ b/man/assert_package.Rd @@ -1,7 +1,6 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-package} -\alias{check-package} +\name{assert_package} \alias{assert_package} \alias{needs} \title{Check the Availability of a Package} @@ -33,13 +32,14 @@ the user will be asked to install the packages. } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-matrix.Rd b/man/assert_square.Rd similarity index 64% rename from man/check-matrix.Rd rename to man/assert_square.Rd index 825fb91..ace3be2 100644 --- a/man/check-matrix.Rd +++ b/man/assert_square.Rd @@ -1,14 +1,13 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-matrix} -\alias{check-matrix} -\alias{assert_symmetric} +\name{assert_square} \alias{assert_square} +\alias{assert_symmetric} \title{Check Matrix} \usage{ -assert_symmetric(x) - assert_square(x) + +assert_symmetric(x) } \arguments{ \item{x}{A \code{\link{matrix}} to be checked.} @@ -21,13 +20,14 @@ Check Matrix } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_type}()}, \code{\link{validate}()} } \author{ diff --git a/man/check-type.Rd b/man/assert_type.Rd similarity index 74% rename from man/check-type.Rd rename to man/assert_type.Rd index 27ed4ea..9d8c9ae 100644 --- a/man/check-type.Rd +++ b/man/assert_type.Rd @@ -1,7 +1,6 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/assert.R -\name{check-type} -\alias{check-type} +\name{assert_type} \alias{assert_type} \alias{assert_scalar} \alias{assert_function} @@ -28,13 +27,14 @@ Check Data Types } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, \code{\link{validate}()} } \author{ diff --git a/man/predicate-scalar.Rd b/man/is_scalar.Rd similarity index 94% rename from man/predicate-scalar.Rd rename to man/is_scalar.Rd index 013902f..6343966 100644 --- a/man/predicate-scalar.Rd +++ b/man/is_scalar.Rd @@ -1,7 +1,7 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/predicates.R -\name{predicate-scalar} -\alias{predicate-scalar} +\name{is_scalar} +\alias{is_scalar} \alias{is_scalar_list} \alias{is_scalar_atomic} \alias{is_scalar_vector} diff --git a/man/predicate-matrix.Rd b/man/predicate-matrix.Rd index b46f3c1..0119787 100644 --- a/man/predicate-matrix.Rd +++ b/man/predicate-matrix.Rd @@ -24,8 +24,8 @@ A \code{\link{logical}} scalar. } \seealso{ Other predicates: +\code{\link{is_scalar}}, \code{\link{predicate-numeric}}, -\code{\link{predicate-scalar}}, \code{\link{predicate-trend}}, \code{\link{predicate-type}}, \code{\link{predicate-utils}} diff --git a/man/predicate-numeric.Rd b/man/predicate-numeric.Rd index e58bd7d..4ac8790 100644 --- a/man/predicate-numeric.Rd +++ b/man/predicate-numeric.Rd @@ -46,8 +46,8 @@ Check numeric objects: } \seealso{ Other predicates: +\code{\link{is_scalar}}, \code{\link{predicate-matrix}}, -\code{\link{predicate-scalar}}, \code{\link{predicate-trend}}, \code{\link{predicate-type}}, \code{\link{predicate-utils}} diff --git a/man/predicate-trend.Rd b/man/predicate-trend.Rd index 18752c2..24c8fad 100644 --- a/man/predicate-trend.Rd +++ b/man/predicate-trend.Rd @@ -42,9 +42,9 @@ is monotonically increasing or decreasing, respectively. } \seealso{ Other predicates: +\code{\link{is_scalar}}, \code{\link{predicate-matrix}}, \code{\link{predicate-numeric}}, -\code{\link{predicate-scalar}}, \code{\link{predicate-type}}, \code{\link{predicate-utils}} } diff --git a/man/predicate-type.Rd b/man/predicate-type.Rd index 16c498e..4b7bedd 100644 --- a/man/predicate-type.Rd +++ b/man/predicate-type.Rd @@ -48,9 +48,9 @@ Type Predicates } \seealso{ Other predicates: +\code{\link{is_scalar}}, \code{\link{predicate-matrix}}, \code{\link{predicate-numeric}}, -\code{\link{predicate-scalar}}, \code{\link{predicate-trend}}, \code{\link{predicate-utils}} } diff --git a/man/predicate-utils.Rd b/man/predicate-utils.Rd index e1137ea..bdb553a 100644 --- a/man/predicate-utils.Rd +++ b/man/predicate-utils.Rd @@ -3,27 +3,27 @@ \name{predicate-utils} \alias{predicate-utils} \alias{has_length} +\alias{is_empty} \alias{has_names} -\alias{has_duplicates} \alias{has_missing} \alias{has_infinite} -\alias{is_empty} \alias{is_unique} +\alias{has_duplicates} \title{Utility Predicates} \usage{ has_length(x, n = NULL) -has_names(x, names = NULL) +is_empty(x) -has_duplicates(x) +has_names(x, names = NULL) has_missing(x) has_infinite(x) -is_empty(x) - is_unique(x, na.rm = FALSE) + +has_duplicates(x) } \arguments{ \item{x}{A \code{\link{vector}} to be tested.} @@ -53,9 +53,9 @@ or infinite values. } \seealso{ Other predicates: +\code{\link{is_scalar}}, \code{\link{predicate-matrix}}, \code{\link{predicate-numeric}}, -\code{\link{predicate-scalar}}, \code{\link{predicate-trend}}, \code{\link{predicate-type}} } diff --git a/man/validate.Rd b/man/validate.Rd index 7853b0a..350848a 100644 --- a/man/validate.Rd +++ b/man/validate.Rd @@ -17,14 +17,15 @@ Validate a Condition } \seealso{ Other validation methods: -\code{\link{check-attribute}}, -\code{\link{check-data}}, -\code{\link{check-matrix}}, -\code{\link{check-numeric-comparison}}, -\code{\link{check-numeric-trend}}, -\code{\link{check-numeric}}, -\code{\link{check-package}}, -\code{\link{check-type}} +\code{\link{assert_constant}()}, +\code{\link{assert_data}}, +\code{\link{assert_length}()}, +\code{\link{assert_lower}()}, +\code{\link{assert_names}()}, +\code{\link{assert_numeric}}, +\code{\link{assert_package}()}, +\code{\link{assert_square}()}, +\code{\link{assert_type}()} } \author{ N. Frerebeau