From f1073a28391cc9aa39a79e66874e3ded029866a0 Mon Sep 17 00:00:00 2001 From: Tomasz Kalinowski Date: Tue, 15 Oct 2024 10:47:56 -0400 Subject: [PATCH] revert `class_array` and `class_matrix` --- NAMESPACE | 2 -- R/S3.R | 20 ++++++------- R/S4.R | 4 +-- man/base_s3_classes.Rd | 8 ----- tests/testthat/test-base.R | 60 +++++++++++++++++++------------------- 5 files changed, 42 insertions(+), 52 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 202eb8fd..c0dfa06a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -49,7 +49,6 @@ export(class_POSIXct) export(class_POSIXlt) export(class_POSIXt) export(class_any) -export(class_array) export(class_atomic) export(class_call) export(class_character) @@ -65,7 +64,6 @@ export(class_integer) export(class_language) export(class_list) export(class_logical) -export(class_matrix) export(class_missing) export(class_name) export(class_numeric) diff --git a/R/S3.R b/R/S3.R index 76e86608..89e7bdcf 100644 --- a/R/S3.R +++ b/R/S3.R @@ -252,8 +252,8 @@ validate_formula <- function(self) { #' * `class_Date` for dates. #' * `class_factor` for factors. #' * `class_POSIXct`, `class_POSIXlt` and `class_POSIXt` for date-times. -#' * `class_matrix` for matrices. -#' * `class_array` for arrays. +# * `class_matrix` for matrices. +# * `class_array` for arrays. #' * `class_formula` for formulas. #' @@ -325,10 +325,10 @@ class_data.frame <- new_S3_class("data.frame", validator = validate_data.frame ) -#' @export -#' @rdname base_s3_classes -#' @format NULL -#' @order 3 +# @export +# @rdname base_s3_classes +# @format NULL +# @order 3 class_matrix <- new_S3_class("matrix", constructor = function(.data = logical(), nrow = NULL, ncol = NULL, byrow = FALSE, dimnames = NULL) { nrow <- nrow %||% NROW(.data) @@ -343,10 +343,10 @@ class_matrix <- new_S3_class("matrix", validator = validate_matrix ) -#' @export -#' @rdname base_s3_classes -#' @format NULL -#' @order 3 +# @export +# @rdname base_s3_classes +# @format NULL +# @order 3 class_array <- new_S3_class("array", constructor = function(.data = logical(), dim = base::dim(.data) %||% length(.data), diff --git a/R/S4.R b/R/S4.R index 2b777494..aa4c0375 100644 --- a/R/S4.R +++ b/R/S4.R @@ -85,8 +85,8 @@ S4_basic_classes <- function() { POSIXct = class_POSIXct, POSIXlt = class_POSIXlt, POSIXt = class_POSIXt, - matrix = class_matrix, - array = class_array, + # matrix = class_matrix, + # array = class_array, formula = class_formula ) } diff --git a/man/base_s3_classes.Rd b/man/base_s3_classes.Rd index bf501523..79876c10 100644 --- a/man/base_s3_classes.Rd +++ b/man/base_s3_classes.Rd @@ -9,8 +9,6 @@ \alias{class_POSIXlt} \alias{class_POSIXt} \alias{class_data.frame} -\alias{class_matrix} -\alias{class_array} \alias{class_formula} \title{S7 wrappers for key S3 classes} \usage{ @@ -26,10 +24,6 @@ class_POSIXt class_data.frame -class_matrix - -class_array - class_formula } \description{ @@ -40,8 +34,6 @@ the base packages: \item \code{class_Date} for dates. \item \code{class_factor} for factors. \item \code{class_POSIXct}, \code{class_POSIXlt} and \code{class_POSIXt} for date-times. -\item \code{class_matrix} for matrices. -\item \code{class_array} for arrays. \item \code{class_formula} for formulas. } } diff --git a/tests/testthat/test-base.R b/tests/testthat/test-base.R index e6fbc72c..59763ab0 100644 --- a/tests/testthat/test-base.R +++ b/tests/testthat/test-base.R @@ -250,25 +250,25 @@ test_that("Base S3 classes can be parents", { expect_error(Foo(list(x = 1:3, y = 1:4)), "all variables should have the same length") - expect_no_error({ - Foo := new_class(class_matrix) - Foo(1:4, nrow = 2) - Foo(NA) - Foo(matrix(1:4, nrow = 2)) - }) - - expect_no_error({ - Foo := new_class(class_array) - - Foo(array(1:4, dim = c(2, 2))) - Foo(1:4, dim = c(2, 2)) - - Foo(array(1:24, dim = c(2, 3, 4))) - Foo(1:24, dim = c(2, 3, 4)) - - Foo(array(1)) - Foo(1) - }) + # expect_no_error({ + # Foo := new_class(class_matrix) + # Foo(1:4, nrow = 2) + # Foo(NA) + # Foo(matrix(1:4, nrow = 2)) + # }) + + # expect_no_error({ + # Foo := new_class(class_array) + # + # Foo(array(1:4, dim = c(2, 2))) + # Foo(1:4, dim = c(2, 2)) + # + # Foo(array(1:24, dim = c(2, 3, 4))) + # Foo(1:24, dim = c(2, 3, 4)) + # + # Foo(array(1)) + # Foo(1) + # }) expect_no_error({ Foo := new_class(class_formula) @@ -294,17 +294,17 @@ test_that("Base S3 classes can be properties", { }) expect_error(Foo(x = 1), "@x must be S3, not ") - expect_no_error({ - Foo := new_class(properties = list(x = class_matrix)) - Foo(x = matrix()) - }) - expect_error(Foo(x = 1), "@x must be S3, not ") - - expect_no_error({ - Foo := new_class(properties = list(x = class_array)) - Foo(x = array()) - }) - expect_error(Foo(x = 1), "@x must be S3, not ") + # expect_no_error({ + # Foo := new_class(properties = list(x = class_matrix)) + # Foo(x = matrix()) + # }) + # expect_error(Foo(x = 1), "@x must be S3, not ") + + # expect_no_error({ + # Foo := new_class(properties = list(x = class_array)) + # Foo(x = array()) + # }) + # expect_error(Foo(x = 1), "@x must be S3, not ") expect_no_error({ Foo := new_class(properties = list(x = class_formula))