diff --git a/CITATION.cff b/CITATION.cff index 7403e33..7b5840a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,7 +3,7 @@ message: 'To cite package "netdiffuseR" in publications use:' type: software license: MIT title: 'netdiffuseR: Analysis of Diffusion and Contagion Processes on Networks' -version: 1.25.0 +version: 1.25.1 doi: 10.32614/CRAN.package.netdiffuseR abstract: 'Empirical statistical analysis, visualization and simulation of diffusion and contagion processes on networks. The package implements algorithms for calculating @@ -69,6 +69,6 @@ references: given-names: Thomas orcid: https://orcid.org/0000-0002-8824-5816 year: '2026' - notes: R package version 1.25.0 + notes: R package version 1.25.1 url: https://github.com/USCCANA/netdiffuseR doi: 10.32614/CRAN.package.netdiffuseR diff --git a/DESCRIPTION b/DESCRIPTION index b87eec5..8dae1db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: netdiffuseR Title: Analysis of Diffusion and Contagion Processes on Networks -Version: 1.25.0 +Version: 1.25.1 Authors@R: c( person("George", "Vega Yon", email="g.vegayon@gmail.com", role=c("aut", "cre"), comment=c(ORCID = "0000-0002-3171-0844", what="Rewrite functions with Rcpp, plus new features") diff --git a/NEWS.md b/NEWS.md index 05b028b..582b04b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,17 @@ +# Changes in netdiffuseR version 1.25.1 (2026-10-21) + +## Bug fixes + +* Multi-behavior simulations with `rdiffnet()` no longer emit a spurious + "Coercing -toa- into integer." warning. `new_diffnet()` now checks the storage + mode of `toa` instead of its class, which failed for integer matrices (#86). + +* `exposure(..., alt.graph = "se")` no longer triggers the deprecated + `as(, "dgCMatrix")` coercion from the **Matrix** package. + `as_dgCMatrix()` now uses the recommended `dMatrix` -> `generalMatrix` -> + `CsparseMatrix` coercion chain (#87). + + # Changes in netdiffuseR version 1.25.0 (2026-03-27) ## User-visible changes diff --git a/R/diffnet-class.r b/R/diffnet-class.r index d92ec8d..35dc67b 100644 --- a/R/diffnet-class.r +++ b/R/diffnet-class.r @@ -623,7 +623,7 @@ new_diffnet <- function( } # Step 2.1: Checking class of TOA and coercing if necessary - if (!inherits(toa, "integer")) { + if (!is.integer(toa)) { warning("Coercing -toa- into integer.") toa[] <- as.integer(toa) diff --git a/R/misc.r b/R/misc.r index 55431c2..50e42f5 100644 --- a/R/misc.r +++ b/R/misc.r @@ -490,7 +490,10 @@ as_spmat <- as_dgCMatrix #' @rdname as_dgCMatrix as_dgCMatrix.default <- function(x, make.dimnames = TRUE, ...) { - ans <- methods::as(x, "dgCMatrix") + ans <- methods::as( + methods::as(methods::as(x, "dMatrix"), "generalMatrix"), + "CsparseMatrix" + ) # Updating row and colnames if necesary if (make.dimnames) diff --git a/tests/testthat/test-rdiffnet.R b/tests/testthat/test-rdiffnet.R index 75c070f..8376744 100644 --- a/tests/testthat/test-rdiffnet.R +++ b/tests/testthat/test-rdiffnet.R @@ -210,3 +210,20 @@ test_that("Disadoption works", { expect_true(all(should_be_ones_or_zeros %in% c(0,1))) }) + +# Multi-behavior simulations should not warn about -toa- coercion (#86) +test_that("Multi-behavior rdiffnet does not coerce toa", { + + set.seed(1231) + expect_silent( + ans <- suppressMessages(rdiffnet( + 200, 10, + seed.p.adopt = list(0.1, 0.15), + seed.nodes = list("random", "random"), + behavior = list("Behavior 1", "Behavior 2") + )) + ) + + expect_true(is.integer(ans$toa)) + +}) diff --git a/tests/testthat/test-struct_equiv.R b/tests/testthat/test-struct_equiv.R index d2e0cef..023d288 100644 --- a/tests/testthat/test-struct_equiv.R +++ b/tests/testthat/test-struct_equiv.R @@ -177,3 +177,17 @@ test_that("transformGraphBy", { expect_equivalent(ans1, ans2) }) + +# SE exposure should not use deprecated Matrix coercions (#87) +test_that("SE exposure avoids deprecated Matrix coercions", { + + # Turning deprecated coercions into errors + old <- options(Matrix.warnDeprecatedCoerce = 2) + on.exit(options(old)) + + set.seed(1231) + diffnet <- rdiffnet(100, 5, seed.graph = "small-world") + + expect_silent(exposure(diffnet, alt.graph = "se", valued = TRUE)) + +})