Skip to content

Commit 287c389

Browse files
committed
combined_network %n% ".combiner" can now be a vector of compatible combiners.
1 parent cf4aa24 commit 287c389

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

R/combine.networks.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ uncombine_network <- function(nw, populate = TRUE) {
218218
#' This is used primarily by developers to provide informative error
219219
#' messages.
220220
#'
221-
#' @param combiner the combiner name (typically `nw %n% ".combiner"`)
221+
#' @param combiner the combiner name (typically the first element of
222+
#' `nw %n% ".combiner"`)
222223
#'
223224
#' @param description a named character vector or list with elements
224225
#' `constructor`, `element`, `elements`, `construct`, `id`, and
@@ -356,11 +357,11 @@ as.networkLite.combined_networks <- function(x, ...){
356357
#' @keywords internal
357358
#' @export
358359
assert_combined_network <- function(nw, combiners, term = TRUE, call = rlang::caller_env()) {
359-
if (!(nw %n% ".combiner" %||% "") %in% combiners) {
360+
if (!any(nw%n%".combiner" %in% combiners)) {
360361
info <- map(combiners, ergm.multi_combiner)
361362
valid <- paste.and(paste0(map_chr(info, "construct"), " constructed by ", sQuote(map_chr(info, "constructor"))),
362363
con = "nor")
363-
msg <- paste0("This network is not a ", valid, " at its top level.")
364+
msg <- paste0("This network is not a ", valid, " (nor compatible) at its top level.")
364365
if (term) ergm_Init_stop(msg)
365366
else abort(msg, call = call)
366367
FALSE

R/multinet.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ as_tibble.combined_networks<-function(x,attrnames=(match.arg(unit)%in%c("vertice
9696

9797
out <- al[attrnames] %>% lapply(simplify_simple, ...) %>% as_tibble()
9898

99-
combiner <- x%n%".combiner"
99+
combiner <- (x%n%".combiner")[1]
100100
if (!is.null(i <- ergm.multi_combiner(combiner)[["id"]])) out[[i]] <- seq_len(nrow(out))
101101
if (!is.null(i <- ergm.multi_combiner(combiner)[["name"]])) out[[i]] <- names(x%n%".snl")
102102

R/print.combined_networks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
.print_combined_networks_info <- function(x, ...){
1212
cat(" Combined ", length(x%n%".snl"), " networks by ",
1313
sQuote(NVL3(x%n%".combiner",
14-
ergm.multi_combiner(.)$combiner,
14+
ergm.multi_combiner(.[1])$combiner,
1515
"combine_networks()")), ":\n", sep = "")
1616
nattrs <- x%n%".snattr"
1717
nids <- format(seq_along(nattrs$n))

0 commit comments

Comments
 (0)