Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Description:
License: MIT + file LICENSE
URL: https://github.com/dynverse/dynutils
BugReports: https://github.com/dynverse/dynutils/issues
RoxygenNote: 7.3.2
Depends:
R (>= 3.0.0)
Imports:
Expand All @@ -48,9 +47,11 @@ Suggests:
hdf5r (>= 1.3.4),
knitr,
rmarkdown,
testthat
testthat (>= 3.0.0)
LinkingTo:
Rcpp
Encoding: UTF-8
VignetteBuilder: knitr
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/roxygen2/version: 8.1.1
130 changes: 77 additions & 53 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -54,60 +54,84 @@ export(tibble_as_list)
export(walkdf)
export(write_h5)
export(write_h5_)
importFrom(Matrix,Matrix)
importFrom(Matrix,sparseMatrix)
importFrom(Matrix,t)
importFrom(Matrix,
Matrix,
sparseMatrix,
t
)
importFrom(Rcpp,evalCpp)
importFrom(assertthat,"%has_name%")
importFrom(assertthat,"on_failure<-")
importFrom(assertthat,assert_that)
importFrom(crayon,bold)
importFrom(crayon,green)
importFrom(crayon,red)
importFrom(assertthat,
"%has_name%",
"on_failure<-",
assert_that
)
importFrom(crayon,
bold,
green,
red
)
importFrom(desc,desc)
importFrom(dplyr,enquo)
importFrom(dplyr,n)
importFrom(dplyr,slice)
importFrom(magrittr,"%$%")
importFrom(magrittr,"%<>%")
importFrom(magrittr,set_colnames)
importFrom(magrittr,set_rownames)
importFrom(methods,as)
importFrom(methods,formalArgs)
importFrom(methods,is)
importFrom(methods,new)
importFrom(proxyC,dist)
importFrom(proxyC,simil)
importFrom(purrr,"%>%")
importFrom(purrr,"%||%")
importFrom(purrr,as_mapper)
importFrom(purrr,discard)
importFrom(purrr,keep)
importFrom(purrr,map)
importFrom(purrr,map2)
importFrom(purrr,map_at)
importFrom(purrr,map_chr)
importFrom(purrr,map_dbl)
importFrom(purrr,map_df)
importFrom(purrr,map_dfc)
importFrom(purrr,map_dfr)
importFrom(purrr,map_if)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(purrr,set_names)
importFrom(purrr,walk)
importFrom(dplyr,
enquo,
n,
slice
)
importFrom(magrittr,
"%$%",
"%<>%",
set_colnames,
set_rownames
)
importFrom(methods,
as,
formalArgs,
is,
new
)
importFrom(proxyC,
dist,
simil
)
importFrom(purrr,
"%>%",
"%||%",
as_mapper,
discard,
keep,
map,
map2,
map_at,
map_chr,
map_dbl,
map_df,
map_dfc,
map_dfr,
map_if,
map_int,
map_lgl,
set_names,
walk
)
importFrom(remotes,install_cran)
importFrom(stats,quantile)
importFrom(stats,runif)
importFrom(stringr,str_detect)
importFrom(stringr,str_match)
importFrom(stringr,str_pad)
importFrom(stringr,str_replace)
importFrom(stringr,str_replace_all)
importFrom(stringr,str_subset)
importFrom(tibble,as_tibble)
importFrom(tibble,lst)
importFrom(tibble,tibble)
importFrom(utils,installed.packages)
importFrom(utils,setRepositories)
importFrom(stats,
quantile,
runif
)
importFrom(stringr,
str_detect,
str_match,
str_pad,
str_replace,
str_replace_all,
str_subset
)
importFrom(tibble,
as_tibble,
lst,
tibble
)
importFrom(utils,
installed.packages,
setRepositories
)
useDynLib(dynutils)
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* BUG FIX `calculate_similarity()`, `calculate_distance()`: Fix Spearman correlations of RsparseMatrix, TsparseMatrix and symmetric inputs (PR #37).

* MINOR CHANGE: Update to roxygen2 8.1.1 and testthat 3rd edition (PR #38).

# dynutils 1.0.12

* DOCUMENTATION: Fix roxygen docs (PR #36).
Expand Down
5 changes: 1 addition & 4 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,4 @@
#'
#' @useDynLib dynutils
#' @importFrom Rcpp evalCpp
#'
#' @docType package
#' @name dynutils
NULL
"_PACKAGE"
5 changes: 3 additions & 2 deletions man/dynutils.Rd → man/dynutils-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions tests/testthat/test-add_class.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing add_class")

test_that("Test add_class", {
add1 <- add_class(list(1), "banana")
expect_equal(class(add1), c("banana", "list"))
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-assertions.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("test-assertions")

test_that("is_single_numeric works", {
expect_true(is_single_numeric(23))
expect_true(is_single_numeric(182L))
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-calculate_distance.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing calculate_distance")

check_output <- function(x, y, o, e) {
expect_equal(nrow(o), nrow(x))
expect_equal(rownames(o), rownames(x))
Expand Down Expand Up @@ -75,7 +73,7 @@ test_that("calculate_distance returns correct solutions", {
calculate_distance(x, y, method = n)[1,1]
})

expect_equivalent(observed, expected)
expect_equal(observed, expected, ignore_attr = TRUE)
})


Expand All @@ -95,7 +93,7 @@ test_that("calculate_similarity returns correct solutions", {
calculate_similarity(x, y, method = n)[1,1]
})

expect_equivalent(observed, expected)
expect_equal(observed, expected, ignore_attr = TRUE)
})


Expand Down Expand Up @@ -188,7 +186,7 @@ test_that("calculate_distance gives the same result for every storage format and

test_that(".as_column_vectors reuses the slots of a CSR matrix for margin 1", {
x <- as(y_any, "RsparseMatrix")
expect_is(x, "dgRMatrix")
expect_s4_class(x, "dgRMatrix")
expect_identical(.as_column_vectors(x, margin = 1), Matrix::t(as(x, "CsparseMatrix")))
expect_identical(.as_column_vectors(x, margin = 2), as(x, "CsparseMatrix"))
})
2 changes: 0 additions & 2 deletions tests/testthat/test-calculate_mean.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Means")

test_that(paste0("calculate_mean"), {
testthat::expect_equal(calculate_arithmetic_mean(0.5, 0.6, 0.7), 0.6)
testthat::expect_equal(calculate_harmonic_mean(0.5, 1, 1), 0.75)
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-check_packages.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing check_packages")

test_that("Test check_packages", {
check <- check_packages(c("dplyr", "dynutils", "jhrveioohvovwhrei", "ijewiojwijoweew"))
expect_equal(check, c(dplyr = TRUE, dynutils = TRUE, jhrveioohvovwhrei = FALSE, ijewiojwijoweew = FALSE))
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-expand_matrix.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing expand_matrix")

test_that("Test expand_matrix", {
mat <- matrix(runif(12), nrow = 3, dimnames = list(letters[1:3], LETTERS[1:4]))
mat2 <- expand_matrix(mat, rownames = letters[1:6], colnames = LETTERS[1:5], fill = 1)
Expand Down
10 changes: 4 additions & 6 deletions tests/testthat/test-extend_with.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing extend_with")

test_that("Test extend_with", {
orig_list <- list(a = 1, b = 2)

Expand All @@ -8,8 +6,8 @@ test_that("Test extend_with", {
list(b = "3", c = list(1))
)

testthat::expect_is(new_list, "extension")
testthat::expect_is(new_list, "list")
testthat::expect_s3_class(new_list, "extension")
testthat::expect_type(new_list, "list")

testthat::expect_equal(length(new_list), 3)
testthat::expect_equal(new_list$a, 1)
Expand All @@ -26,8 +24,8 @@ test_that("Test extend_with with ... functionality", {
c = "10"
)

testthat::expect_is(new_list, "extension2")
testthat::expect_is(new_list, "list")
testthat::expect_s3_class(new_list, "extension2")
testthat::expect_type(new_list, "list")

testthat::expect_equal(length(new_list), 3)
testthat::expect_equal(new_list$a, 1)
Expand Down
65 changes: 32 additions & 33 deletions tests/testthat/test-h5.R
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
context("Testing write_h5 and read_h5")

if (require("hdf5r")) {
test_that("write_h5 and read_h5 works", {
skip_if_not_installed("hdf5r")
obj <- get_h5_test_data()

test_that("write_h5 and read_h5 works", {
file <- tempfile()
on.exit(file.remove(file))
file <- tempfile()
on.exit(file.remove(file))

write_h5(obj, file)
write_h5(obj, file)

obj2 <- read_h5(file)
obj2 <- read_h5(file)

testthat::expect_equivalent(obj2, obj)
})
expect_equal(obj2, obj, ignore_attr = TRUE)
})

test_that("test_h5_installation works", {
expect_true(test_h5_installation())
expect_message(test_h5_installation(detailed = TRUE), "HDF5 test successful")
test_that("test_h5_installation works", {
skip_if_not_installed("hdf5r")

expect_output(expect_error(test_h5_installation_write(detailed = TRUE, obj = list(x = print))))
expect_output(expect_error(test_h5_installation_read(detailed = TRUE, file = tempfile())))
expect_output(expect_error(test_h5_installation_equal(detailed = TRUE, obj = 1, obj2 = 2)))
})
expect_true(test_h5_installation())
expect_message(test_h5_installation(detailed = TRUE), "HDF5 test successful")

test_that("is_sparse works", {
expect_false(is_sparse(matrix(c(1:10))))
expect_output(expect_error(test_h5_installation_write(detailed = TRUE, obj = list(x = print))))
expect_output(expect_error(test_h5_installation_read(detailed = TRUE, file = tempfile())))
expect_output(expect_error(test_h5_installation_equal(detailed = TRUE, obj = 1, obj2 = 2)))
})

m <- Matrix::Matrix(matrix(c(1:10)), sparse = FALSE)
expect_false(is_sparse(m))
expect_true(is_sparse(methods::as(m, "CsparseMatrix")))
expect_false(is_sparse(methods::as(m, "denseMatrix")))
})
test_that("is_sparse works", {
expect_false(is_sparse(matrix(c(1:10))))

m <- Matrix::Matrix(matrix(c(1:10)), sparse = FALSE)
expect_false(is_sparse(m))
expect_true(is_sparse(methods::as(m, "CsparseMatrix")))
expect_false(is_sparse(methods::as(m, "denseMatrix")))
})

test_that("errors gracefully", {
file <- tempfile()
on.exit(file.remove(file))
test_that("errors gracefully", {
skip_if_not_installed("hdf5r")

h5file <- hdf5r::H5File$new(file, mode = "w")
h5file[["a"]] <- 1
h5file$close_all()
file <- tempfile()
on.exit(file.remove(file))

expect_error(read_h5(file), regexp = "Object class not found")
})
h5file <- hdf5r::H5File$new(file, mode = "w")
h5file[["a"]] <- 1
h5file$close_all()

}
expect_error(read_h5(file), regexp = "Object class not found")
})
2 changes: 0 additions & 2 deletions tests/testthat/test-inherit_default_params.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing inherit_default_params")

fun1 <- function(a = 10, b = 7) {
runif(a, -b, b)
}
Expand Down
2 changes: 0 additions & 2 deletions tests/testthat/test-mapdf.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
context("Testing mapdf functions")

tib <- tibble(
a = c(1, 2),
b = list(log10, sqrt),
Expand Down
Loading
Loading