vctrs fix

This commit is contained in:
dr. M.S. (Matthijs) Berends 2024-02-24 18:51:37 +01:00
parent 4aa5413641
commit 35963ca3dc
4 changed files with 22 additions and 20 deletions

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 2.1.1.9007
Version: 2.1.1.9008
Date: 2024-02-24
Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -1,4 +1,4 @@
# AMR 2.1.1.9007
# AMR 2.1.1.9008
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support!)*

View File

@ -34,29 +34,31 @@
# see https://github.com/tidyverse/dplyr/issues/5955 why this is required
# S3: ab_selector
vec_ptype2.ab_selector.default <- function (x, y, ..., x_arg = "", y_arg = "") {
# S3: ab_selector ----
# this does not need a .default method since it's used internally only
vec_ptype2.character.ab_selector <- function(x, y, ...) {
x
}
vec_ptype2.ab_selector.ab_selector <- function(x, y, ...) {
x
vec_ptype2.ab_selector.character <- function(x, y, ...) {
y
}
vec_cast.character.ab_selector <- function(x, to, ...) {
unclass(x)
}
# S3: ab_selector_any_all
vec_ptype2.ab_selector_any_all.default <- function (x, y, ..., x_arg = "", y_arg = "") {
# S3: ab_selector_any_all ----
# this does not need a .default method since it's used internally only
vec_ptype2.logical.ab_selector_any_all <- function(x, y, ...) {
x
}
vec_ptype2.ab_selector_any_all.ab_selector_any_all <- function(x, y, ...) {
x
vec_ptype2.ab_selector_any_all.logical <- function(x, y, ...) {
y
}
vec_cast.logical.ab_selector_any_all <- function(x, to, ...) {
unclass(x)
}
# S3: ab
# S3: ab ----
vec_ptype2.ab.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
@ -70,7 +72,7 @@ vec_cast.ab.character <- function(x, to, ...) {
return_after_integrity_check(x, "antimicrobial drug code", as.character(AMR_env$AB_lookup$ab))
}
# S3: av
# S3: av ----
vec_ptype2.av.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
@ -84,7 +86,7 @@ vec_cast.av.character <- function(x, to, ...) {
return_after_integrity_check(x, "antiviral drug code", as.character(AMR_env$AV_lookup$av))
}
# S3: mo
# S3: mo ----
vec_ptype2.mo.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
@ -99,7 +101,7 @@ vec_cast.mo.character <- function(x, to, ...) {
return_after_integrity_check(x, "microorganism code", as.character(AMR_env$MO_lookup$mo))
}
# S3: disk
# S3: disk ----
vec_ptype2.disk.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
@ -125,7 +127,7 @@ vec_cast.disk.character <- function(x, to, ...) {
as.disk(x)
}
# S3: mic
# S3: mic ----
vec_ptype2.mic.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}
@ -157,7 +159,7 @@ vec_arith.mic <- function(op, x, y, ...) {
vctrs::vec_arith(op, as.double(x), as.double(y))
}
# S3: sir
# S3: sir ----
vec_ptype2.sir.default <- function (x, y, ..., x_arg = "", y_arg = "") {
x
}

View File

@ -133,12 +133,12 @@ if (pkg_is_available("cli")) {
# Support vctrs package for use in e.g. dplyr verbs
# NOTE 2024-02-22 this is the right way - it should be 2 S3 classes in the second argument
# S3: ab_selector
s3_register("vctrs::vec_ptype2", "ab_selector.default")
s3_register("vctrs::vec_ptype2", "ab_selector.ab_selector")
s3_register("vctrs::vec_ptype2", "character.ab_selector")
s3_register("vctrs::vec_ptype2", "ab_selector.character")
s3_register("vctrs::vec_cast", "character.ab_selector")
# S3: ab_selector_any_all
s3_register("vctrs::vec_ptype2", "ab_selector_any_all.default")
s3_register("vctrs::vec_ptype2", "ab_selector_any_all.ab_selector_any_all")
s3_register("vctrs::vec_ptype2", "logical.ab_selector_any_all")
s3_register("vctrs::vec_ptype2", "ab_selector_any_all.logical")
s3_register("vctrs::vec_cast", "logical.ab_selector_any_all")
# S3: ab
s3_register("vctrs::vec_ptype2", "ab.default")