Skip to content

Commit

Permalink
version 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
rcannood authored and cran-robot committed Sep 20, 2021
1 parent 3781c92 commit d7adc78
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 42 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
@@ -1,7 +1,7 @@
Package: dynutils
Type: Package
Title: Common Functionality for the 'dynverse' Packages
Version: 1.0.7
Version: 1.0.8
Authors@R: c(
person(
"Robrecht",
Expand Down Expand Up @@ -34,10 +34,10 @@ LinkingTo: Rcpp
Encoding: UTF-8
VignetteBuilder: knitr
NeedsCompilation: yes
Packaged: 2021-09-02 08:33:19 UTC; rcannood
Packaged: 2021-09-20 04:00:24 UTC; rcannood
Author: Robrecht Cannoodt [aut, cre] (<https://orcid.org/0000-0003-3641-729X>,
rcannood),
Wouter Saelens [aut] (<https://orcid.org/0000-0002-7114-6248>, zouter)
Maintainer: Robrecht Cannoodt <rcannood@gmail.com>
Repository: CRAN
Date/Publication: 2021-09-04 05:40:02 UTC
Date/Publication: 2021-09-20 04:40:02 UTC
10 changes: 5 additions & 5 deletions MD5
@@ -1,7 +1,7 @@
cfaac4514a25c22522d50186d25d3da0 *DESCRIPTION
8510aa87df9d876cdbe76d51fcfa643a *DESCRIPTION
ef3d9f056adaa322680184035912700f *LICENSE
246edeab46c29b2a202d37070ffd69ba *NAMESPACE
5c9dbde5719e9fb33f6d81c9470867ef *NEWS.md
dc6e839ed9deb7b83a555d3c29010611 *NEWS.md
dcdf2491b0e62a545623862a87d55529 *R/RcppExports.R
6f7fc8ddd74f0326bf2b59a523681cf7 *R/add_class.R
93ee58dfa8e9d0165a0aadbc62cfb01a *R/assertions.R
Expand All @@ -11,7 +11,7 @@ e2b7b0caa56d6a39e5f74f05f1ba7546 *R/check_packages.R
cdbbf9a1f8aea5c2df485b414eed39ad *R/development.R
ebced609202a59d493b476c3aac3fe8d *R/expand_matrix.R
aa0987fdaaa50b3bf720eef589eb9cbe *R/extend_with.R
c589a1bec773c845c2229d0a547c230c *R/h5.R
eccf89678a8a7f364a3addafdd2f7e76 *R/h5.R
56ddd7a01d957f768e214bf3ff7d1286 *R/inherit_default_params.R
54d7dba8e284ec639517ca1e31b66a83 *R/install_packages.R
ad9da1318face1a62868506526ccb6b2 *R/mapdf.R
Expand All @@ -27,7 +27,7 @@ ed5a6e94e1159f1aafdcfc1c82c27d49 *R/spearman_rank_sparse.R
97438e22f9f6789b6c35f75e506e56ab *build/vignette.rds
a60b55d68196751eae1016f1871240de *inst/doc/functionality.R
fd437c3c797311ac07d31ffd0e74d86c *inst/doc/functionality.Rmd
4f7d145fcbf87ea6aa77b79cc43edf02 *inst/doc/functionality.html
826c6d6991bc74aa1e44e9906cb0ae45 *inst/doc/functionality.html
c3db2b03d9fad3aa6837b3f565dfdebd *man/add_class.Rd
6bc340f4659bf12f836063f6dbdd2329 *man/all_in.Rd
b5ac523861808607b014847cb3797765 *man/apply_minmax_scale.Rd
Expand Down Expand Up @@ -72,7 +72,7 @@ e98edf1dd851bb968f099085613e1641 *tests/testthat.R
dbb99d66a04da64c942eeb3d2aad76a4 *tests/testthat/test-check_packages.R
7485242237d66f602ee1126cbe4000c2 *tests/testthat/test-expand_matrix.R
8faa7d5a28c69f65e45e8ff451fc705b *tests/testthat/test-extend_with.R
057e29b12553afd78ba1f7b0ca48a03f *tests/testthat/test-h5.R
ab9e302bf557b200c0a2f78471fac0ca *tests/testthat/test-h5.R
5ce31da95e0ab2cae64f31550e6957c1 *tests/testthat/test-inherit_default_params.R
eb500b1fea1726787b4e1cc25de6caa0 *tests/testthat/test-mapdf.R
900fd5789d675deb11cbb4c5072259e4 *tests/testthat/test-news.R
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
@@ -1,3 +1,7 @@
# dynutils 1.0.8

* BUG FIX unit test: Surround hdf5 unit tests by `if(require(.))`.

# dynutils 1.0.7

* MINOR CHANGE `calculate_distance()`: Convert matrices to CsparseMatrix instead of dgCMatrix.
Expand Down
2 changes: 2 additions & 0 deletions R/h5.R
Expand Up @@ -104,6 +104,7 @@ read_h5_ <- function(file_h5) {
}

.read_h5_vec <- function(file_h5) {
requireNamespace("hdf5r")
# workaround for https://github.com/hhoeflin/hdf5r/issues/118
if (file_h5$dims == 0 && "H5T_STRING" %in% class(file_h5$get_type())) {
character(0)
Expand All @@ -121,6 +122,7 @@ read_h5_ <- function(file_h5) {
}

.write_h5_vec <- function(x, file_h5, name) {
requireNamespace("hdf5r")
# workaround for https://github.com/dynverse/dyno/issues/43
was_logical <- is.logical(x)
if (is.logical(x)) {
Expand Down
8 changes: 4 additions & 4 deletions inst/doc/functionality.html
Expand Up @@ -364,13 +364,13 @@ <h2>Manipulation of vectors</h2>
<div id="random_time_string-generates-a-string-very-likely-to-be-unique" class="section level3">
<h3><code>random_time_string</code>: Generates a string very likely to be unique</h3>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210902_103319__test__syYeN626jT&quot;</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210920_060024__test__syYeN626jT&quot;</span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210902_103319__test__e6MCnXcJM7&quot;</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210920_060024__test__e6MCnXcJM7&quot;</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="fu">random_time_string</span>(<span class="st">&quot;test&quot;</span>)</span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210902_103319__test__9pFJ5mxS3R&quot;</span></span></code></pre></div>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;20210920_060024__test__9pFJ5mxS3R&quot;</span></span></code></pre></div>
</div>
</div>
<div id="tibble-helpers" class="section level2">
Expand Down Expand Up @@ -476,7 +476,7 @@ <h2>File helpers</h2>
<div id="safe_tempdir-create-an-empty-temporary-directory-and-return-its-path" class="section level3">
<h3><code>safe_tempdir</code>: Create an empty temporary directory and return its path</h3>
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a><span class="fu">safe_tempdir</span>(<span class="st">&quot;samson&quot;</span>)</span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;/tmp/RtmpPYnzSd/file3def077bad0e06/samson&quot;</span></span></code></pre></div>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a><span class="co">#&gt; [1] &quot;/tmp/Rtmp2XlScH/file3986444897b83/samson&quot;</span></span></code></pre></div>
</div>
</div>
<div id="assertion-helpers" class="section level2">
Expand Down
62 changes: 32 additions & 30 deletions tests/testthat/test-h5.R
@@ -1,45 +1,47 @@
context("Testing write_h5 and read_h5")

obj <- get_h5_test_data()
if (require("hdf5r")) {
obj <- get_h5_test_data()

test_that("write_h5 and read_h5 works", {
file <- tempfile()
on.exit(file.remove(file))
test_that("write_h5 and read_h5 works", {
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)
})
testthat::expect_equivalent(obj2, obj)
})

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", {
expect_true(test_h5_installation())
expect_message(test_h5_installation(detailed = TRUE), "HDF5 test successful")

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_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)))
})

test_that("is_sparse works", {
expect_false(is_sparse(matrix(c(1:10))))
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, "dgeMatrix")))
})
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, "dgeMatrix")))
})


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

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

expect_error(read_h5(file), regexp = "Object class not found")
})
expect_error(read_h5(file), regexp = "Object class not found")
})

}

0 comments on commit d7adc78

Please sign in to comment.