Skip to content

Commit

Permalink
Upkeep (#384)
Browse files Browse the repository at this point in the history
* Fix vignette titles

* Enable parallel testing

* Simplify matrixOps definition
  • Loading branch information
hadley authored Nov 23, 2023
1 parent 3d6c6d7 commit d0112a1
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 22 deletions.
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ VignetteBuilder:
knitr
Config/Needs/website: sloop
Config/testthat/edition: 3
Config/testthat/parallel: TRUE
Config/testthat/start-first: external-generic
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ if (getRversion() >= "4.3.0") S3method(matrixOps, S7_object)
if (getRversion() >= "4.3.0") S3method(nameOfClass, S7_class, S7_class_name)
importFrom(stats,setNames)
importFrom(utils,getFromNamespace)
importFrom(utils,globalVariables)
importFrom(utils,hasName)
importFrom(utils,head)
importFrom(utils,packageName)
Expand Down
3 changes: 2 additions & 1 deletion R/S7-package.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## usethis namespace: start
#' @useDynLib S7, .registration = TRUE
#' @importFrom utils globalVariables
#' @importFrom utils head str hasName
#' @useDynLib S7, .registration = TRUE
## usethis namespace: end
NULL
20 changes: 10 additions & 10 deletions R/method-ops.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ Ops.S7_object <- function(e1, e2) {
chooseOpsMethod.S7_object <- function(x, y, mx, my, cl, reverse) TRUE

#' @rawNamespace if (getRversion() >= "4.3.0") S3method(matrixOps, S7_object)
matrixOps.S7_object <- NULL
matrixOps.S7_object <- function(x, y) {
base_matrix_ops[[.Generic]](x, y)
}


on_load_define_matrixOps <- function() {
if (getRversion() >= "4.4.0") {
matrixOps.S7_object <<- function(x, y) {
base_matrix_ops[[.Generic]](x, y)
}
} else {
matrixOps.S7_object <<- function(e1, e2) {
base_matrix_ops[[.Generic]](e1, e2)
}
}
# if (getRversion() >= "4.3.0") {
# } else {
# matrixOps.S7_object <<- function(e1, e2) {
# base_matrix_ops[[.Generic]](e1, e2)
# }
# }
}
1 change: 0 additions & 1 deletion vignettes/classes-objects.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,3 @@ The first argument to `new_object()` should be an object of the `parent` class (
That argument should be followed by one named argument for each property.

There's one drawback of custom constructors that you should be aware of: any subclass will also require a custom constructor.

2 changes: 1 addition & 1 deletion vignettes/generics-methods.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Generics and methods"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{S7 generics and method dispatch}
%\VignetteIndexEntry{Generics and methods}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down
10 changes: 2 additions & 8 deletions vignettes/motivation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ library(S7)
This made it possible to make radical changes but it made it harder to switch from S3 to S4, leading to a general lack of adoption in the R community.
S7 is designed to be drop-in compatible with S3, making it possible to convert existing packages to use S7 instead of S3 with only an hour or two of work.

```{=html}
<!-- -->
```
- At least within Bioconductor, slots are generally thought of as implementation detail that should not be directly accessed by the end-user.
This leads to two problems.
Firstly, implementing an S4 Bioconductor class often also requires a plethora of accessor functions that are a thin wrapper around `@` or `@<-`.
Secondly, users know about `@` and use it to access object internals even though they're not supposed to.
S7 avoids these problems by accepting the fact that R is a data language, and that there's no way to stop users from pulling the data they need out of an object.
To make it possible to change the internal implementation details of an object while preserving existing `@` usage, S7 provides dynamic properties.

- At least within Bioconductor, slots are generally thought of as implementation detail that should not be directly accessed by the end-user. This leads to two problems. Firstly, implementing an S4 Bioconductor class often also requires a plethora of accessor functions that are a thin wrapper around `@` or `@<-`. Secondly, users know about `@` and use it to access object internals even though they're not supposed to. S7 avoids these problems by accepting the fact that R is a data language, and that there's no way to stop users from pulling the data they need out of an object. To make it possible to change the internal implementation details of an object while preserving existing `@` usage, S7 provides dynamic properties.
2 changes: 1 addition & 1 deletion vignettes/packages.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Using S7 in a package"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{packages}
%\VignetteIndexEntry{Using S7 in a package}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down

0 comments on commit d0112a1

Please sign in to comment.