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
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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(<dgeMatrix>, "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
Expand Down
2 changes: 1 addition & 1 deletion R/diffnet-class.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion R/misc.r
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-rdiffnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

})
14 changes: 14 additions & 0 deletions tests/testthat/test-struct_equiv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))

})
Loading