From 9312e2ffa82e9e28212c746d1d4336d309f38710 Mon Sep 17 00:00:00 2001
From: "Pavel N. Krivitsky"
Date: Mon, 7 Oct 2024 15:20:23 +1100
Subject: [PATCH] Rename the ergm_Init_*() calls using rlang names to their
base names, and remove redundant paste() and paste0() calls.
---
R/InitErgmConstraint.R | 6 ++--
R/InitErgmConstraint.hints.R | 2 +-
R/InitErgmProposal.R | 14 ++++----
R/InitErgmReference.R | 2 +-
R/InitErgmTerm.R | 58 ++++++++++++++++-----------------
R/InitErgmTerm.bipartite.R | 12 +++----
R/InitErgmTerm.dgw_sp.R | 2 +-
R/InitErgmTerm.interaction.R | 10 +++---
R/InitErgmTerm.operator.R | 40 +++++++++++------------
R/InitErgmTerm.transitiveties.R | 4 +--
R/InitWtErgmProposal.R | 8 ++---
R/InitWtErgmTerm.R | 2 +-
R/check.ErgmTerm.R | 4 +--
R/ergm.errors.R | 6 ++--
R/get.node.attr.R | 26 +++++++--------
15 files changed, 98 insertions(+), 98 deletions(-)
diff --git a/R/InitErgmConstraint.R b/R/InitErgmConstraint.R
index 04b98d71c..5ec06b664 100644
--- a/R/InitErgmConstraint.R
+++ b/R/InitErgmConstraint.R
@@ -262,7 +262,7 @@ InitErgmConstraint.bd<-function(nw, arglist, ...){
defaultvalues = list(NULL, NA_integer_, NA_integer_, NA_integer_, NA_integer_),
required = c(FALSE, FALSE, FALSE, FALSE, FALSE))
- if(!is.directed(nw) && (!all(is.na(a$minin)) || !all(is.na(a$maxin)))) ergm_Init_abort(sQuote("minin"), " and ", sQuote("maxin"), " cannot be used with undirected networks.")
+ if(!is.directed(nw) && (!all(is.na(a$minin)) || !all(is.na(a$maxin)))) ergm_Init_stop(sQuote("minin"), " and ", sQuote("maxin"), " cannot be used with undirected networks.")
if(all(is.na(a$minout)) && all(is.na(a$minin))) {
constrain <- c("bd","bdmax")
@@ -614,12 +614,12 @@ InitErgmConstraint.Dyads<-function(nw, arglist, ...){
fix <- a$fix; vary <- a$vary
if(is.null(fix) & is.null(vary))
- ergm_Init_abort(paste("Dyads constraint takes at least one argument, either",sQuote("fix"),"or",sQuote("vary"),"or both."))
+ ergm_Init_stop("Dyads constraint takes at least one argument, either ",sQuote("fix")," or ",sQuote("vary")," or both.")
for(f in c(fix, vary)){
f[[3]] <- f[[2]]
f[[2]] <- nw
- if(!is.dyad.independent(f)) ergm_Init_abort(paste("Terms passed to the Dyads constraint must be dyad-independent."))
+ if(!is.dyad.independent(f)) ergm_Init_stop("Terms passed to the Dyads constraint must be dyad-independent.")
}
list(
diff --git a/R/InitErgmConstraint.hints.R b/R/InitErgmConstraint.hints.R
index 8dd5993ff..0f7bed693 100644
--- a/R/InitErgmConstraint.hints.R
+++ b/R/InitErgmConstraint.hints.R
@@ -149,7 +149,7 @@ InitErgmConstraint.strat <- function(nw, arglist, ...) {
pmat <- NVL(pmat, matrix(1, nrow = length(strat_row_levels), ncol = length(strat_col_levels)))
if(NROW(pmat) != length(strat_row_levels) || NCOL(pmat) != length(strat_col_levels)) {
- ergm_Init_abort(sQuote("pmat"), " does not have the correct dimensions for ", sQuote("attr"), ".")
+ ergm_Init_stop(sQuote("pmat"), " does not have the correct dimensions for ", sQuote("attr"), ".")
}
if(!is.bipartite(nw) && !is.directed(nw)) {
diff --git a/R/InitErgmProposal.R b/R/InitErgmProposal.R
index 7adbf3620..bda72bdd2 100644
--- a/R/InitErgmProposal.R
+++ b/R/InitErgmProposal.R
@@ -232,7 +232,7 @@ NULL
InitErgmProposal.CondOutDegree <- function(arguments, nw) {
proposal <- list(name = "CondOutDegree", inputs=NULL)
if (!is.directed(nw)) # Really, this should never trigger, since the InitErgmConstraint function should check.
- ergm_Init_abort("The CondOutDegree proposal function does not work with an",
+ ergm_Init_stop("The CondOutDegree proposal function does not work with an",
"undirected network.")
proposal
}
@@ -247,7 +247,7 @@ NULL
InitErgmProposal.CondInDegree <- function(arguments, nw) {
proposal <- list(name = "CondInDegree", inputs=NULL)
if (!is.directed(nw)) # Really, this should never trigger, since the InitErgmConstraint function should check.
- ergm_Init_abort("The CondInDegree proposal function does not work with an",
+ ergm_Init_stop("The CondInDegree proposal function does not work with an",
"undirected network.")
proposal
}
@@ -263,7 +263,7 @@ NULL
InitErgmProposal.CondB1Degree <- function(arguments, nw) {
proposal <- list(name = "CondB1Degree", inputs=NULL)
if (!is.bipartite(nw)) # Really, this should never trigger, since the InitErgmConstraint function should check.
- ergm_Init_abort("The CondB1Degree proposal function does not work with a non-bipartite network.")
+ ergm_Init_stop("The CondB1Degree proposal function does not work with a non-bipartite network.")
proposal
}
@@ -279,7 +279,7 @@ NULL
InitErgmProposal.CondB2Degree <- function(arguments, nw) {
proposal <- list(name = "CondB2Degree", inputs=NULL)
if (!is.bipartite(nw)) # Really, this should never trigger, since the InitErgmConstraint function should check.
- ergm_Init_abort("The CondB2Degree proposal function does not work with a non-bipartite network.")
+ ergm_Init_stop("The CondB2Degree proposal function does not work with a non-bipartite network.")
proposal
}
@@ -294,7 +294,7 @@ NULL
InitErgmProposal.CondDegreeDist <- function(arguments, nw) {
proposal <- list(name = "CondDegreeDist", inputs=NULL)
if (is.directed(nw)) {
- ergm_Init_warn("Using the 'degreedist' constraint with a directed network ",
+ ergm_Init_warning("Using the 'degreedist' constraint with a directed network ",
"is currently perilous. We recommend that you use 'outdegree' or ",
"'idegrees' instead.")
}
@@ -314,7 +314,7 @@ NULL
InitErgmProposal.CondInDegreeDist <- function(arguments, nw) {
proposal <- list(name = "CondInDegreeDist", inputs=NULL)
if (!is.directed(nw)) {
- ergm_Init_warn("Using the 'idegreedist' constraint with an undirected network ",
+ ergm_Init_warning("Using the 'idegreedist' constraint with an undirected network ",
"is currently perilous. We recommend that you use 'degreedist' ",
" instead.")
}
@@ -334,7 +334,7 @@ NULL
InitErgmProposal.CondOutDegreeDist <- function(arguments, nw) {
proposal <- list(name = "CondOutDegreeDist", inputs=NULL)
if (!is.directed(nw)) {
- ergm_Init_warn("Using the 'odegreedist' constraint with an undirected network n",
+ ergm_Init_warning("Using the 'odegreedist' constraint with an undirected network n",
"is currently perilous. We recommend that you use 'degreedist' ",
" instead.")
}
diff --git a/R/InitErgmReference.R b/R/InitErgmReference.R
index 86b49e11b..933325990 100644
--- a/R/InitErgmReference.R
+++ b/R/InitErgmReference.R
@@ -87,6 +87,6 @@ InitErgmReference.DiscUnif <- function(nw, arglist, a, b, ...){
vartypes = c("numeric", "numeric"),
defaultvalues = list(NULL, NULL),
required = c(TRUE, TRUE))
- if(a$a!=round(a$a) || a$b != round(a$b)) ergm_Init_abort(paste("arguments ", sQuote("a"), "and", sQuote("b"), "must be integers"))
+ if(a$a!=round(a$a) || a$b != round(a$b)) ergm_Init_stop("arguments ", sQuote("a"), " and ", sQuote("b"), "must be integers")
list(name="DiscUnif", arguments=list(a=a$a, b=a$b), init_methods=c("CD","zeros"))
}
diff --git a/R/InitErgmTerm.R b/R/InitErgmTerm.R
index 61668b0c3..cc2c7851f 100644
--- a/R/InitErgmTerm.R
+++ b/R/InitErgmTerm.R
@@ -198,13 +198,13 @@ ergm_edgecov_args <- function(name, nw, a){
# Process the arguments
if(is.network(a$x)){
if(!is.null(a$attrname) && !a$attrname %in% list.edge.attributes(a$x))
- ergm_Init_abort("Specified network ", sQuote(deparse1(attr(a,"exprs")$x)), " does not have an edge attribute ", sQuote(a$attrname), ".")
+ ergm_Init_stop("Specified network ", sQuote(deparse1(attr(a,"exprs")$x)), " does not have an edge attribute ", sQuote(a$attrname), ".")
xm <- as.matrix(a$x, matrix.type="adjacency", a$attrname)
}else if(is.character(a$x)){
xm <- get.network.attribute(nw, a$x)
- if(is.null(xm) || !(is.matrix(xm) || is.network(xm))) ergm_Init_abort("There is no network attribute named ", sQuote(a$x), " or it is not a matrix or a network.")
+ if(is.null(xm) || !(is.matrix(xm) || is.network(xm))) ergm_Init_stop("There is no network attribute named ", sQuote(a$x), " or it is not a matrix or a network.")
if(is.network(xm)){
- if(!is.null(a$attrname) && !a$attrname %in% list.edge.attributes(xm)) ergm_Init_abort("Network at attribute named ", sQuote(a$x), " does not have an edge attribute ", sQuote(a$attrname), ".")
+ if(!is.null(a$attrname) && !a$attrname %in% list.edge.attributes(xm)) ergm_Init_stop("Network at attribute named ", sQuote(a$x), " does not have an edge attribute ", sQuote(a$attrname), ".")
xm <- as.matrix(xm, matrix.type="adjacency", attrname=a$attrname)
name <- paste(name, a$x, sep=".")
}
@@ -232,15 +232,15 @@ LEVELS_BASE1 <- NULL
decay_vs_fixed <- function(a, name, no_curved_attrarg=TRUE){
if(!is.null(a$alpha)){
- ergm_Init_abort("For consistency with ", sQuote("gw*degree"), " terms, in all ", sQuote("gw*sp"), " and ", sQuote("dgw*sp"), " terms the argument ", sQuote("alpha"), " has been renamed to " ,sQuote("decay"), ".")
+ ergm_Init_stop("For consistency with ", sQuote("gw*degree"), " terms, in all ", sQuote("gw*sp"), " and ", sQuote("dgw*sp"), " terms the argument ", sQuote("alpha"), " has been renamed to " ,sQuote("decay"), ".")
}
if(a$fixed){
- if(!attr(a, "missing")["cutoff"]) ergm_Init_warn("When ", sQuote('fixed=TRUE'), " parameter ", sQuote('cutoff'), " has no effect.")
- if(is.null(a$decay)) ergm_Init_abort("Using ", sQuote('fixed=TRUE'), " requires a decay parameter ", sQuote('decay'), ".")
+ if(!attr(a, "missing")["cutoff"]) ergm_Init_warning("When ", sQuote('fixed=TRUE'), " parameter ", sQuote('cutoff'), " has no effect.")
+ if(is.null(a$decay)) ergm_Init_stop("Using ", sQuote('fixed=TRUE'), " requires a decay parameter ", sQuote('decay'), ".")
}else{
- if(!is.null(a$decay)) ergm_Init_warn("When ", sQuote('fixed=FALSE'), " parameter ", sQuote('decay')," has no effect. To specify an initial value for ", sQuote('decay'),", use the ", sQuote('control.ergm()'), " parameter ", sQuote('init='), ".")
- if(no_curved_attrarg && !is.null(NVL(a$attrname,a$attr))) ergm_Init_abort("Using ", sQuote('fixed=FALSE'), " with an attribute is not implemented at this time. Use ", sQuote('fixed=TRUE'), ".")
+ if(!is.null(a$decay)) ergm_Init_warning("When ", sQuote('fixed=FALSE'), " parameter ", sQuote('decay')," has no effect. To specify an initial value for ", sQuote('decay'),", use the ", sQuote('control.ergm()'), " parameter ", sQuote('init='), ".")
+ if(no_curved_attrarg && !is.null(NVL(a$attrname,a$attr))) ergm_Init_stop("Using ", sQuote('fixed=FALSE'), " with an attribute is not implemented at this time. Use ", sQuote('fixed=TRUE'), ".")
}
}
@@ -267,10 +267,10 @@ decay_vs_fixed <- function(a, name, no_curved_attrarg=TRUE){
if(length(to)==1 && length(from)>1) to <- rep(to, length(from))
else if(length(from)==1 && length(to)>1) from <- rep(from, length(to))
- else if(length(from)!=length(to)) ergm_Init_abort("The arguments of term ", sQuote(termname), " must have arguments either of the same length, or one of them must have length 1.")
+ else if(length(from)!=length(to)) ergm_Init_stop("The arguments of term ", sQuote(termname), " must have arguments either of the same length, or one of them must have length 1.")
to <- ifelse(to==Inf, pmax(from, network.size(nw)) + 1, to)
- if(any(from>=to)) ergm_Init_abort("Term ", sQuote(termname), " must have ", sQuote("from"), "<", sQuote("to"), ".")
+ if(any(from>=to)) ergm_Init_stop("Term ", sQuote(termname), " must have ", sQuote("from"), "<", sQuote("to"), ".")
emptynwstats<-NULL
if(!is.null(byarg)) {
@@ -771,7 +771,7 @@ InitErgmTerm.attrcov <- function (nw, arglist, ..., version=packageVersion("ergm
nodecov <- c(match(b1nodecov, b1levels), match(b2nodecov, b2levels))
if(NROW(a$mat) != length(b1levels) || NCOL(a$mat) != length(b2levels)) {
- ergm_Init_abort("mat has wrong dimensions for attr")
+ ergm_Init_stop("mat has wrong dimensions for attr")
}
} else {
nodecov <- ergm_get_vattr(a$attr, nw)
@@ -781,7 +781,7 @@ InitErgmTerm.attrcov <- function (nw, arglist, ..., version=packageVersion("ergm
nodecov <- match(nodecov, levels)
if(NROW(a$mat) != length(levels) || NCOL(a$mat) != length(levels)) {
- ergm_Init_abort("mat has wrong dimensions for attr")
+ ergm_Init_stop("mat has wrong dimensions for attr")
}
}
@@ -1266,7 +1266,7 @@ InitErgmTerm.b1starmix <- function(nw, arglist, ..., version=packageVersion("erg
# Recode to numeric
nodecov <- match(nodecov,u,nomatch=length(u)+1)
if (length(a$k) > 1)
- { ergm_Init_abort("Only a single scalar k may be used with each b1starmix term") }
+ { ergm_Init_stop("Only a single scalar k may be used with each b1starmix term") }
b1namescov <- sort(unique(nodecov[1:nb1]))
b2namescov <- sort(unique(nodecov[(1+nb1):network.size(nw)]))
b1nodecov <- match(nodecov[1:nb1],b1namescov)
@@ -1845,7 +1845,7 @@ InitErgmTerm.b2starmix <- function(nw, arglist, ..., version=packageVersion("erg
# Recode to numeric
nodecov <- match(nodecov,u,nomatch=length(u)+1)
if (length(a$k) > 1)
- { ergm_Init_abort("Only a single scalar k may be used with each b2starmix term") }
+ { ergm_Init_stop("Only a single scalar k may be used with each b2starmix term") }
b1namescov <- sort(unique(nodecov[1:nb1]))
b2namescov <- sort(unique(nodecov[(1+nb1):network.size(nw)]))
b1nodecov <- match(nodecov[1:nb1],b1namescov)
@@ -2176,22 +2176,22 @@ InitErgmTerm.cycle <- function(nw, arglist, ...) {
required = c(TRUE,FALSE))
### Process the arguments
if(any(a$k > network.size(nw))) {
- ergm_Init_warn("cycles of length greater than the network size cannot exist and their statistics will be omitted")
+ ergm_Init_warning("cycles of length greater than the network size cannot exist and their statistics will be omitted")
a$k <- a$k[a$k <= network.size(nw)]
}
if(!is.directed(nw) && any(a$k < 3)) {
- ergm_Init_warn("cycles of length less than 3 cannot exist in an undirected network and their statistics will be omitted")
+ ergm_Init_warning("cycles of length less than 3 cannot exist in an undirected network and their statistics will be omitted")
a$k <- a$k[a$k >= 3]
}
if(any(a$k < 2)) {
- ergm_Init_warn("cycles of length less than 2 cannot exist and their statistics will be omitted")
+ ergm_Init_warning("cycles of length less than 2 cannot exist and their statistics will be omitted")
a$k <- a$k[a$k >= 2]
}
if(is.directed(nw) && a$semi && any(a$k == 2)) {
- ergm_Init_warn("semicycles of length 2 are not currently supported and their statistics will be omitted")
+ ergm_Init_warning("semicycles of length 2 are not currently supported and their statistics will be omitted")
a$k <- a$k[a$k >= 3]
}
@@ -2487,10 +2487,10 @@ InitErgmTerm.diff <- function(nw, arglist, ..., version=packageVersion("ergm"))
sign.action <- match.arg(tolower(a$sign.action), SIGN.ACTIONS)
sign.code <- match(sign.action, SIGN.ACTIONS)
- if(sign.action!="abs" && !is.directed(nw) && !is.bipartite(nw)) ergm_Init_inform(paste("Note that behavior of term diff() on unipartite, undirected networks may be unexpected. See", sQuote("ergmTerm?diff"),"for more information."))
+ if(sign.action!="abs" && !is.directed(nw) && !is.bipartite(nw)) ergm_Init_message("Note that behavior of term ", sQuote("diff()"), " on unipartite, undirected networks may be unexpected. See", sQuote("ergmTerm?diff"),"for more information.")
# 1 and 4 are sign codes that allow negative differences.
- if(sign.code %in% c(1, 4) && a$pow!=round(a$pow)) ergm_Init_abort("In term diff(attr, pow, sign=",a$sign,"), pow must be an integer.")
+ if(sign.code %in% c(1, 4) && a$pow!=round(a$pow)) ergm_Init_stop("In term diff(attr, pow, sign=",a$sign,"), pow must be an integer.")
### Construct the list to return
list(name="diff", #name: required
@@ -2542,7 +2542,7 @@ InitErgmTerm.dyadcov<-function (nw, arglist, ...) {
# DH: Since nw is directed, why are we testing for symmetry here?
if (any(xm[upper.tri(xm)]!=t(xm)[upper.tri(xm)])){
xm[lower.tri(xm)]<-t(xm)[lower.tri(xm)]
- ergm_Init_warn("asymmetric covariate in dyadcov; using upper triangle only")
+ ergm_Init_warning("asymmetric covariate in dyadcov; using upper triangle only")
}
coef.names <- paste(cn, c("mutual","utri","ltri"),sep=".")
}else{
@@ -2932,7 +2932,7 @@ InitErgmTerm.hamming<-function (nw, arglist, ...) {
covm<-as.matrix(a$cov)
}
if (is.null(covm) || !is.matrix(covm) || NCOL(covm)!=3){
- ergm_Init_abort("Improper dyadic covariate passed to hamming()")
+ ergm_Init_stop("Improper dyadic covariate passed to hamming()")
}
emptynwstats <- sum(apply(xm, 1, function(a,b) sum(b[(a[1]==b[,1] & a[2]==b[,2]),3]), covm))
if (is.null(a$defaultweight))
@@ -2990,7 +2990,7 @@ InitErgmTerm.hammingmix<-function (nw, arglist, ..., version=packageVersion("erg
x<-a$x
if (a$contrast) {
- ergm_Init_abort("The 'contrast' argument of the hammingmix term is deprecated. Use 'levels2' instead")
+ ergm_Init_stop("The 'contrast' argument of the hammingmix term is deprecated. Use 'levels2' instead")
}
if(is.network(x)){
xm<-as.edgelist(x)
@@ -3003,7 +3003,7 @@ InitErgmTerm.hammingmix<-function (nw, arglist, ..., version=packageVersion("erg
x<-paste(quote(x))
}
if (is.null(xm) || ncol(xm)!=2){
- ergm_Init_abort("hammingmix() requires an edgelist")
+ ergm_Init_stop("hammingmix() requires an edgelist")
}
nodecov <- ergm_get_vattr(attrarg, nw)
@@ -3435,7 +3435,7 @@ InitErgmTerm.localtriangle<-function (nw, arglist, ...) {
else
xm<-as.matrix(x)
if(!isSymmetric(xm)){
- ergm_Init_warn("localtriangle requires an undirected neighborhood. Using only mutual ties.")
+ ergm_Init_warning("localtriangle requires an undirected neighborhood. Using only mutual ties.")
xm <- pmin(xm[],(t(xm))[])
}
if(!is.null(attrname))
@@ -3722,7 +3722,7 @@ InitErgmTerm.mutual<-function (nw, arglist, ..., version=packageVersion("ergm"))
if (!is.null(a$same)) {
attrarg <- a$same
if (!is.null(a$by))
- ergm_Init_warn("Ignoring 'by' argument to mutual because 'same' exists")
+ ergm_Init_warning("Ignoring 'by' argument to mutual because 'same' exists")
}else{
attrarg <- a$by
}
@@ -4219,7 +4219,7 @@ InitErgmTerm.nodemix<-function (nw, arglist, ..., version=packageVersion("ergm")
### Process the arguments
if (is.bipartite(nw) && is.directed(nw)) {
- ergm_Init_abort("Directed bipartite networks are not currently possible")
+ ergm_Init_stop("Directed bipartite networks are not currently possible")
}
nodecov <- ergm_get_vattr(attrarg, nw)
@@ -4911,7 +4911,7 @@ InitErgmTerm.smalldiff<-function (nw, arglist, ..., version=packageVersion("ergm
cutoff <- a$cutoff
if (length(cutoff)>1)
- ergm_Init_abort("cutoff for smalldiff() must be a scalar.")
+ ergm_Init_stop("cutoff for smalldiff() must be a scalar.")
nodecov <- ergm_get_vattr(attrarg, nw, accept="numeric")
attrname <- attr(nodecov, "name")
@@ -5086,7 +5086,7 @@ InitErgmTerm.threetrail <- function(nw, arglist, ..., version=packageVersion("er
#' @usage
#' # binary: threepath(keep=NULL, levels=NULL)
InitErgmTerm.threepath <- function(nw, arglist, ..., version=packageVersion("ergm")) {
- ergm_Init_warn(paste("This term is inaccurately named and actually refers to a '3-trail' in that it counts repeated vertices: i-j-k-i is a 3-trail but not a 3-path. See", sQuote("ergmTerm?treepath"), "help for more information. This name has been deprecated and will be removed in a future version: if a 3-trail is what you want, use the term 'threetrail'."))
+ ergm_Init_warning("This term is inaccurately named and actually refers to a '3-trail' in that it counts repeated vertices: i-j-k-i is a 3-trail but not a 3-path. See ", sQuote("ergmTerm?treepath"), " help for more information. This name has been deprecated and will be removed in a future version: if a 3-trail is what you want, use the term ", sQuote("threetrail"), ".")
f <- InitErgmTerm.threetrail
f(nw, arglist, ..., version=version)
diff --git a/R/InitErgmTerm.bipartite.R b/R/InitErgmTerm.bipartite.R
index eae54cb66..28828f768 100644
--- a/R/InitErgmTerm.bipartite.R
+++ b/R/InitErgmTerm.bipartite.R
@@ -87,9 +87,9 @@ InitErgmTerm.b1nodematch <- function (nw, arglist, ..., version=packageVersion("
}
### Process the arguments
if (!is.numeric(a$beta) || a$beta>1 || a$beta<0)
- ergm_Init_abort("beta argument to b1nodematch must be between 0 and 1 inclusive.")
+ ergm_Init_stop("beta argument to b1nodematch must be between 0 and 1 inclusive.")
if (!is.numeric(a$alpha) || a$alpha>1 || a$alpha<0)
- ergm_Init_abort("alpha argument to b1nodematch must be between 0 and 1 inclusive.")
+ ergm_Init_stop("alpha argument to b1nodematch must be between 0 and 1 inclusive.")
nodecov <- ergm_get_vattr(attrarg, nw, bip="b1")
attrname <- attr(nodecov, "name")
@@ -117,7 +117,7 @@ InitErgmTerm.b1nodematch <- function (nw, arglist, ..., version=packageVersion("
b2dontmatch <- b2nodecov == (length(v)+1)
b2nodecov[b2dontmatch] <- length(v) + (1:sum(b2dontmatch))
vi <- seq(along = v)
- if (length(vi) < 2) {ergm_Init_abort("byb2attr should have at least two levels")}
+ if (length(vi) < 2) {ergm_Init_stop("byb2attr should have at least two levels")}
} else {b2attrsize <- 0} # to indicate that an b2attr does not exist
@@ -223,9 +223,9 @@ InitErgmTerm.b2nodematch <- function (nw, arglist, ..., version=packageVersion("
}
### Process the arguments
if (!is.numeric(a$beta) || a$beta>1 || a$beta<0)
- ergm_Init_abort("beta argument to b2nodematch must be between 0 and 1 inclusive.")
+ ergm_Init_stop("beta argument to b2nodematch must be between 0 and 1 inclusive.")
if (!is.numeric(a$alpha) || a$alpha>1 || a$alpha<0)
- ergm_Init_abort("alpha argument to b2nodematch must be between 0 and 1 inclusive.")
+ ergm_Init_stop("alpha argument to b2nodematch must be between 0 and 1 inclusive.")
nodecov <- ergm_get_vattr(attrarg, nw, bip="b2")
attrname <- attr(nodecov, "name")
@@ -256,7 +256,7 @@ InitErgmTerm.b2nodematch <- function (nw, arglist, ..., version=packageVersion("
b1nodecov[b1dontmatch] <- length(v) + (1:sum(b1dontmatch))
vi <- seq(along = v)
- if (length(vi) < 2){ergm_Init_abort("byb1attr should have at least two levels")}
+ if (length(vi) < 2){ergm_Init_stop("byb1attr should have at least two levels")}
} else {b1attrsize <- 0} # to indicate that an b1attr does not exist
diff --git a/R/InitErgmTerm.dgw_sp.R b/R/InitErgmTerm.dgw_sp.R
index fa6d4d4c8..2a3fbdcf4 100644
--- a/R/InitErgmTerm.dgw_sp.R
+++ b/R/InitErgmTerm.dgw_sp.R
@@ -154,7 +154,7 @@ SPTYPE_CODE <- c(UTP = 0L, OTP = 1L, ITP = 2L, RTP = 3L, OSP = 4L, ISP = 5L)
## Check that the ultimate result is valid:
if(! type%in%names(SPTYPE_CODE))
- ergm_Init_abort("Illegal value for ", sQuote("type"), "; valid types are:", paste.and(sQuote(names(SPTYPE_CODE))))
+ ergm_Init_stop("Illegal value for ", sQuote("type"), "; valid types are:", paste.and(sQuote(names(SPTYPE_CODE))))
type
}
diff --git a/R/InitErgmTerm.interaction.R b/R/InitErgmTerm.interaction.R
index a1ab86422..ad263e003 100644
--- a/R/InitErgmTerm.interaction.R
+++ b/R/InitErgmTerm.interaction.R
@@ -11,11 +11,11 @@ check_interact_term <- function(m, dependent_action){
msg <- paste0("Change statistic interactions are poorly defined for dyad-dependent terms. Use ", sQuote("interact.dependent"), " term option to set the behavior.")
if(!is.dyad.independent(m))
switch(dependent_action,
- error = ergm_Init_abort(msg, call.=FALSE),
- warning = ergm_Init_warn(msg, immediate.=TRUE, call.=FALSE), # Warn immediately, so the user gets the warning before the MCMC starts.
+ error = ergm_Init_stop(msg, call.=FALSE),
+ warning = ergm_Init_warning(msg, immediate.=TRUE, call.=FALSE), # Warn immediately, so the user gets the warning before the MCMC starts.
message = message(msg))
- if(is.curved(m)) ergm_Init_abort("Interactions are undefined for curved terms at this time.")
+ if(is.curved(m)) ergm_Init_stop("Interactions are undefined for curved terms at this time.")
}
## This will always be passed with two arguments in arglist, which
@@ -46,7 +46,7 @@ check_interact_term <- function(m, dependent_action){
cn <- outer(cn1,cn2,paste,sep=":")
wm <- wrap.ergm_model(m, nw, NULL)
- if(any(wm$offsettheta) || any(wm$offsetmap)) ergm_Init_warn(paste0("The interaction operator does not propagate offset() decorators."))
+ if(any(wm$offsettheta) || any(wm$offsetmap)) ergm_Init_warning("The interaction operator does not propagate offset() decorators.")
c(list(name="interact", coef.names = cn, inputs=inputs, submodel=m, dependence=wm$dependence),
ergm_propagate_ext.encode(m))
@@ -81,7 +81,7 @@ check_interact_term <- function(m, dependent_action){
cn <- c(cn1,cn2,outer(cn1,cn2,paste,sep=":"))
wm <- wrap.ergm_model(m, nw, NULL)
- if(any(wm$offsettheta) || any(wm$offsetmap)) ergm_Init_warn(paste0("The interaction operator does not propagate offset() decorators."))
+ if(any(wm$offsettheta) || any(wm$offsetmap)) ergm_Init_warning("The interaction operator does not propagate offset() decorators.")
c(list(name="main_interact", coef.names = cn, inputs=inputs, submodel=m, dependence=wm$dependence),
ergm_propagate_ext.encode(m))
diff --git a/R/InitErgmTerm.operator.R b/R/InitErgmTerm.operator.R
index c90013e0a..dcb225738 100644
--- a/R/InitErgmTerm.operator.R
+++ b/R/InitErgmTerm.operator.R
@@ -135,7 +135,7 @@ ergm_propagate_ext.encode <- function(submodel) {
ergm_no_ext.encode <- function(submodel) {
has_ext <- !sapply(lapply(submodel$terms, `[[`, "ext.encode"), is.null)
ext_names <- sapply(lapply(submodel$terms[has_ext], `[[`, "call"), deparse, width.cutoff=500)
- if (any(has_ext)) ergm_Init_abort(paste0("This operator term is incompatible with subterms ", paste.and(sQuote(ext_names)), " due to their use of the extended state API. This limitation may be removed in the future."))
+ if (any(has_ext)) ergm_Init_stop("This operator term is incompatible with subterms ", paste.and(sQuote(ext_names)), " due to their use of the extended state API. This limitation may be removed in the future.")
}
## Creates a submodel that does exactly what the model terms passed to
@@ -203,7 +203,7 @@ InitErgmTerm.Label <- function(nw, arglist, ...){
prepend = list(paste0(a$label, cu), paste0(a$label, ca)),
replace =
if(is.curved(m)){
- if(!is.list(a$label) || length(a$label)!=2) ergm_Init_abort("For a curved ERGM, replacement label must be a list of length 2, giving the curved and the canonical names, respectively, with NULL to leave alone.")
+ if(!is.list(a$label) || length(a$label)!=2) ergm_Init_stop("For a curved ERGM, replacement label must be a list of length 2, giving the curved and the canonical names, respectively, with NULL to leave alone.")
list(NVL(a$label[[1]], NA), NVL(a$label[[2]], NA))
}else rep(list(NVL(a$label, cu)), 2),
`(` = list(paste0(a$label,"(",cu,")"), paste0(a$label,"(",ca,")")),
@@ -372,11 +372,11 @@ InitErgmTerm..filter.formula.net <- function(nw, arglist, ...){
m <- ergm_model(a$formula, nw, ..., offset.decorate=FALSE)
ergm_no_ext.encode(m)
- if(!is.dyad.independent(m) || nparam(m)!=1) ergm_Init_abort("The filter test formula must be dyad-independent and have exactly one statistic.")
+ if(!is.dyad.independent(m) || nparam(m)!=1) ergm_Init_stop("The filter test formula must be dyad-independent and have exactly one statistic.")
nw[,] <- FALSE
gs <- summary(m, nw)
- if(gs!=0) ergm_Init_abort("At this time, the filter test term must have the property that its dyadwise components are 0 for 0-valued relations. This limitation may be removed in the future.")
+ if(gs!=0) ergm_Init_stop("At this time, the filter test term must have the property that its dyadwise components are 0 for 0-valued relations. This limitation may be removed in the future.")
c(list(name="_filter_formula_net", submodel=m, iinputs=iinputs, inputs=inputs),
wrap.ergm_model(m, nw, NULL))
@@ -690,7 +690,7 @@ InitErgmTerm.Sum <- function(nw, arglist,...){
curved <- ms[[1]]$etamap$curved
for(i in seq_len(nf-1L)+1L){
m <- ms[[i]]
- if(!identical(curved, m$etamap$curved)) ergm_Init_inform("Model ", i, " in the list appears to be curved, and its mapping differs from that of the first model; the first model's mapping will be used.")
+ if(!identical(curved, m$etamap$curved)) ergm_Init_message("Model ", i, " in the list appears to be curved, and its mapping differs from that of the first model; the first model's mapping will be used.")
}
nstats <- ms %>% map_int(nparam, canonical=TRUE)
@@ -709,9 +709,9 @@ InitErgmTerm.Sum <- function(nw, arglist,...){
nparams <- wl %>% map_int(nrow)
- if(length(curved) && !all(nparams==nstats[1])) ergm_Init_abort("Specified weights produce different number of output statistics different from those expected by the curved effects in Model 1.")
+ if(length(curved) && !all(nparams==nstats[1])) ergm_Init_stop("Specified weights produce different number of output statistics different from those expected by the curved effects in Model 1.")
- if(!all_identical(nparams)) ergm_Init_abort("Specified models and weights appear to differ in lengths of output statistics.")
+ if(!all_identical(nparams)) ergm_Init_stop("Specified models and weights appear to differ in lengths of output statistics.")
nparam <- nparams[1]
inputs <- unlist(wl%>%map(t))
@@ -726,7 +726,7 @@ InitErgmTerm.Sum <- function(nw, arglist,...){
cn.asis <- inherits(cn, "AsIs")
cn <- if(length(cn)==1L && nparam>1L) paste0(cn, seq_len(nparam)) else cn
- if(length(cn) != nparam) ergm_Init_abort(paste0(sQuote("label="), " argument for statistics has or results in length ", length(cn), ", should be ", nparam, "."))
+ if(length(cn) != nparam) ergm_Init_stop(sQuote("label="), " argument for statistics has or results in length ", length(cn), ", should be ", nparam, ".")
coef.names <- if(cn.asis) cn else ergm_mk_std_op_namewrap("Sum")(cn)
wms <- lapply(ms, wrap.ergm_model, nw)
@@ -741,7 +741,7 @@ InitErgmTerm.Sum <- function(nw, arglist,...){
pn.asis <- inherits(pn, "AsIs")
pn <- if(length(pn)==1L && ncparam>1L) paste0(pn, seq_len(ncparam)) else pn
- if(length(pn) != ncparam) ergm_Init_abort(paste0(sQuote("label="), " argument for curved parameters has or results in length ", length(pn), ", should be ", ncparam, "."))
+ if(length(pn) != ncparam) ergm_Init_stop(sQuote("label="), " argument for curved parameters has or results in length ", length(pn), ", should be ", ncparam, ".")
names(wms[[1L]]$params) <- if(pn.asis) pn else ergm_mk_std_op_namewrap("Sum")(pn)
}
@@ -766,7 +766,7 @@ InitErgmTerm.Sum <- function(nw, arglist,...){
offset <- wms[[1L]]$offset # then offsets are safe to propagate.
else{
offset <- FALSE
- ergm_Init_warn(paste0("Sum operator does not propagate offset() decorators unless there is only one formula and its statistics are simply scaled."))
+ ergm_Init_warning("Sum operator does not propagate offset() decorators unless there is only one formula and its statistics are simply scaled.")
}
}else offset <- FALSE
@@ -834,16 +834,16 @@ InitErgmTerm.S <- function(nw, arglist, ...){
headsel <- as.integer(headsel)
# TODO: Check if 1-node graphs cause crashes.
- if(length(tailsel)==0 || length(headsel)==0) ergm_Init_abort("Empty subgraph selected.")
+ if(length(tailsel)==0 || length(headsel)==0) ergm_Init_stop("Empty subgraph selected.")
type <- if(is.directed(nw)) "directed" else "undirected"
if(bip){
if(max(tailsel)>bip || min(headsel)<=bip)
- ergm_Init_abort("Invalid vertex subsets selected for a bipartite graph.")
+ ergm_Init_stop("Invalid vertex subsets selected for a bipartite graph.")
type <- "bipartite"
}else{
if(!identical(tailsel,headsel)){ # Rectangular selection: output bipartite.
- if(length(intersect(tailsel,headsel))) ergm_Init_abort("Vertex subsets constructing a bipartite subgraph must have disjoint ranges.")
+ if(length(intersect(tailsel,headsel))) ergm_Init_stop("Vertex subsets constructing a bipartite subgraph must have disjoint ranges.")
type <- "bipartite"
}
}
@@ -924,7 +924,7 @@ InitErgmTerm.Curve <- function(nw, arglist,...){
})
}else a$map
- if(is.null(a$gradient)) ergm_Init_abort(paste0("The ", sQuote("gradient"), " argument must be supplied unless ", sQuote("map"), " is of a special type."))
+ if(is.null(a$gradient)) ergm_Init_stop("The ", sQuote("gradient"), " argument must be supplied unless ", sQuote("map"), " is of a special type.")
gradient <-
if(is.matrix(a$gradient)) function(...) a$gradient
@@ -948,13 +948,13 @@ InitErgmTerm.Curve <- function(nw, arglist,...){
# Make sure the output dimensions are correct.
test.param <- (deInf(minpar) + deInf(maxpar))/2
test.map <- emap(test.param, p, a$cov)
- if(length(test.map)!=p) ergm_Init_abort(paste0("Model expects ", p, " parameters, but the map function returned a vector of length ", length(test.map), "."))
+ if(length(test.map)!=p) ergm_Init_stop("Model expects ", p, " parameters, but the map function returned a vector of length ", length(test.map), ".")
test.gradient <- gradient(test.param, p, a$cov)
- if(!identical(dim(test.gradient),c(q,p))) ergm_Init_abort(paste0("Mapping of ", q, " to ", p, " parameters expected, but the gradient function returned an object with dimension (", paste0(dim(test.gradient), collapse=","), ")."))
+ if(!identical(dim(test.gradient),c(q,p))) ergm_Init_stop("Mapping of ", q, " to ", p, " parameters expected, but the gradient function returned an object with dimension (", paste0(dim(test.gradient), collapse=","), ").")
wm <- wrap.ergm_model(m, nw)
- if(any(unlist(map(wm, "offsettheta"))) || any(unlist(map(wm, "offsetmap")))) ergm_Init_warn(paste0("Curve operator does not propagate offset() decorators."))
+ if(any(unlist(map(wm, "offsettheta"))) || any(unlist(map(wm, "offsetmap")))) ergm_Init_warning("Curve operator does not propagate ", sQuote("offset()"), " decorators.")
if(is.curved(m)){
wm$map <- function(x, n, ...) wm$map(emap(x, n, ...)) # Composition.
@@ -1194,8 +1194,8 @@ InitErgmTerm.Prod <- function(nw, arglist, ..., env=baseenv()){
#' @concept operator
InitErgmTerm.For <- function(nw, arglist, ...){
counters <- names(arglist)
- if(length(i <- which(counters=="")) != 1) ergm_Init_abort("Exactly one argument (the model formula) must be unnamed.")
- if(length(loops <- arglist[-i]) < 1) ergm_Init_abort("At least one counter must be provided.")
+ if(length(i <- which(counters=="")) != 1) ergm_Init_stop("Exactly one argument (the model formula) must be unnamed.")
+ if(length(loops <- arglist[-i]) < 1) ergm_Init_stop("At least one counter must be provided.")
loops <- map(loops,
function(l){
@@ -1209,7 +1209,7 @@ InitErgmTerm.For <- function(nw, arglist, ...){
})
valid <- loops %>% map_lgl(is.vector)
- if(!all(valid)) ergm_Init_abort("Loop variable(s) ", paste.and(sQuote(names(loops)[!valid])), " does not contain a valid sequence.")
+ if(!all(valid)) ergm_Init_stop("Loop variable(s) ", paste.and(sQuote(names(loops)[!valid])), " does not contain a valid sequence.")
terms <- list_rhs.formula(arglist[[i]])
diff --git a/R/InitErgmTerm.transitiveties.R b/R/InitErgmTerm.transitiveties.R
index 14e99a342..f67a9545f 100644
--- a/R/InitErgmTerm.transitiveties.R
+++ b/R/InitErgmTerm.transitiveties.R
@@ -49,7 +49,7 @@ InitErgmTerm.transitiveties<-function (nw, arglist, ..., version=packageVersion(
attrarg <- a$attr
levels <- a$levels
}
- if (a$diff) ergm_Init_abort("diff=TRUE is not currently implemented in transitiveties")
+ if (a$diff) ergm_Init_stop("diff=TRUE is not currently implemented in transitiveties")
diff <- a$diff
if(!is.null(attrarg)) {
@@ -113,7 +113,7 @@ InitErgmTerm.cyclicalties<-function (nw, arglist, ..., version=packageVersion("e
attrarg <- a$attr
levels <- a$levels
}
- if (a$diff) ergm_Init_abort("diff=TRUE is not currently implemented in cyclicalties")
+ if (a$diff) ergm_Init_stop("diff=TRUE is not currently implemented in cyclicalties")
diff <- a$diff
if(!is.null(attrarg)) {
diff --git a/R/InitWtErgmProposal.R b/R/InitWtErgmProposal.R
index 2be5f81d2..15bd128a9 100644
--- a/R/InitWtErgmProposal.R
+++ b/R/InitWtErgmProposal.R
@@ -28,7 +28,7 @@ NULL
InitWtErgmProposal.DiscUnif <- function(arguments, nw) {
a <- NVL(arguments$reference$arguments$a, -Inf)
b <- NVL(arguments$reference$arguments$b, Inf)
- if(!is.finite(a) || !is.finite(b)) ergm_Init_abort('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
+ if(!is.finite(a) || !is.finite(b)) ergm_Init_stop('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
proposal <- list(name = "DiscUnif", inputs=c(a,b))
proposal
}
@@ -56,7 +56,7 @@ NULL
InitWtErgmProposal.DiscUnifNonObserved <- function(arguments, nw) {
a <- NVL(arguments$reference$arguments$a, -Inf)
b <- NVL(arguments$reference$arguments$b, Inf)
- if(!is.finite(a) || !is.finite(b)) ergm_Init_abort('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
+ if(!is.finite(a) || !is.finite(b)) ergm_Init_stop('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
proposal <- list(name = "DiscUnifNonObserved", inputs=c(a,b,to_ergm_Cdouble(is.na(nw))))
proposal
}
@@ -70,7 +70,7 @@ NULL
InitWtErgmProposal.Unif <- function(arguments, nw) {
a <- NVL(arguments$reference$arguments$a, -Inf)
b <- NVL(arguments$reference$arguments$b, Inf)
- if(!is.finite(a) || !is.finite(b)) ergm_Init_abort('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
+ if(!is.finite(a) || !is.finite(b)) ergm_Init_stop('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
proposal <- list(name = "Unif", inputs=c(a,b))
proposal
}
@@ -84,7 +84,7 @@ NULL
InitWtErgmProposal.UnifNonObserved <- function(arguments, nw) {
a <- NVL(arguments$reference$arguments$a, -Inf)
b <- NVL(arguments$reference$arguments$b, Inf)
- if(!is.finite(a) || !is.finite(b)) ergm_Init_abort('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
+ if(!is.finite(a) || !is.finite(b)) ergm_Init_stop('Uniform reference measures that are not bounded are not implemented at this time. Specifiy a and b to be finite.')
proposal <- list(name = "UnifNonObserved", inputs=c(a,b,to_ergm_Cdouble(is.na(nw))))
proposal
}
diff --git a/R/InitWtErgmTerm.R b/R/InitWtErgmTerm.R
index 14355f56f..01e5023ba 100644
--- a/R/InitWtErgmTerm.R
+++ b/R/InitWtErgmTerm.R
@@ -365,7 +365,7 @@ InitWtErgmTerm.ininterval<-function(nw, arglist, ...) {
OPENSPECS = c('()', '(]', '[)', '[]')
if(is(open, "character")){
- if(! open%in%OPENSPECS) ergm_Init_abort("Interval openness specification via a string must be ", paste.and(OPENSPECS,'"','"',"or"),".")
+ if(! open%in%OPENSPECS) ergm_Init_stop("Interval openness specification via a string must be ", paste.and(OPENSPECS,'"','"',"or"),".")
open <- c(substr(open,1,1)=="(",
substr(open,2,2)==")")
}
diff --git a/R/check.ErgmTerm.R b/R/check.ErgmTerm.R
index 236777212..10f3b6f6c 100644
--- a/R/check.ErgmTerm.R
+++ b/R/check.ErgmTerm.R
@@ -110,7 +110,7 @@ check.ErgmTerm <- function(nw, arglist, directed=NULL, bipartite=NULL, nonnegati
message <- "networks with negative dyad weights"
}
if (!is.null(message)) {
- ergm_Init_abort("Term may not be used with ",message,".")
+ ergm_Init_stop("Term may not be used with ",message,".")
}
# Construct a dummy function that copies all its arguments into a
@@ -149,7 +149,7 @@ check.ErgmTerm <- function(nw, arglist, directed=NULL, bipartite=NULL, nonnegati
if(!is.na(vartypes[m]) && nchar(vartypes[m]) &&
!(is.null(val) && !required[[m]] && is.null(defaultvalues[[m]])) &&
all(sapply(types, function(vartype) !is(val, vartype))))
- ergm_Init_abort(sQuote(name), " argument is not of any of the expected types: ", paste.and(sQuote(types), con="or"), ".")
+ ergm_Init_stop(sQuote(name), " argument is not of any of the expected types: ", paste.and(sQuote(types), con="or"), ".")
# Check deprecation (but only if passed explicitly)
if(!miss){
diff --git a/R/ergm.errors.R b/R/ergm.errors.R
index d6ac8ef39..daab0f982 100644
--- a/R/ergm.errors.R
+++ b/R/ergm.errors.R
@@ -22,7 +22,7 @@
#' different defaults.
#'
#' @note At this time, the \CRANpkg{rlang} analogues
-#' `ergm_Init_abort()`, `ergm_Init_warn()`, and `ergm_Init_inform()`
+#' `ergm_Init_stop()`, `ergm_Init_warning()`, and `ergm_Init_message()`
#' all concatenate their arguments like their base \R
#' counterparts. This may change in the future, and if you wish to
#' retain their old behavior, please switch to their base \R
@@ -79,7 +79,7 @@ ergm_Init_message <- function(..., default.loc=NULL){
#' @describeIn ergm-errors A helper function that evaluates the
#' specified expression in the caller's environment, passing any
-#' errors to [ergm_Init_abort()].
+#' errors to [ergm_Init_stop()].
#' @param expr Expression to be evaluated (in the caller's
#' environment).
#' @seealso [try()], [tryCatch()]
@@ -87,7 +87,7 @@ ergm_Init_message <- function(..., default.loc=NULL){
ergm_Init_try <- function(expr){
expr <- substitute(expr)
tryCatch(eval(expr, parent.frame(1)),
- error = function(e) ergm_Init_abort(e$message))
+ error = function(e) ergm_Init_stop(e$message))
}
format_traceback <- function(x){
diff --git a/R/get.node.attr.R b/R/get.node.attr.R
index 5418e2abc..a127d79c5 100644
--- a/R/get.node.attr.R
+++ b/R/get.node.attr.R
@@ -387,7 +387,7 @@ ergm_get_vattr <- function(object, nw, accept="character", bip=c("n","b1","b2","
switch(multiple,
paste = apply(a, 1, paste, collapse="."),
matrix = a,
- stop = ergm_Init_abort("This term does not accept multiple vertex attributes or matrix vertex attribute functions."))
+ stop = ergm_Init_stop("This term does not accept multiple vertex attributes or matrix vertex attribute functions."))
else c(a),
name = name)
}
@@ -403,19 +403,19 @@ ergm_get_vattr <- function(object, nw, accept="character", bip=c("n","b1","b2","
a <- a[a!=0]
if(all(a>0)) return(a)
- if(!is.null(nrow(a))) ergm_Init_abort("Subtractive (negative) index matrices are not supported at this time.")
+ if(!is.null(nrow(a))) ergm_Init_stop("Subtractive (negative) index matrices are not supported at this time.")
# Now it's negative indices.
l <- switch(bip,
n=seq_len(network.size(nw)),
b1=seq_len(nw%n%"bipartite"),
b2=seq_len(network.size(nw)-nw%n%"bipartite")+nw%n%"bipartite")
if(bip=="b2" && any(-a > nw%n%"bipartite")) a <- a + nw%n%"bipartite"
- if(!all(-a%in%seq_along(l))) ergm_Init_warn("Vertex index is out of bound.")
+ if(!all(-a%in%seq_along(l))) ergm_Init_warning("Vertex index is out of bound.")
structure(l[a], name=name)
}else{
rep_len_warn <- function(x, length.out){
- if(length.out%%NVL(nrow(x), length(x))) ergm_Init_warn("Network size or bipartite group size is not a multiple of the length of vertex attributes.")
+ if(length.out%%NVL(nrow(x), length(x))) ergm_Init_warning("Network size or bipartite group size is not a multiple of the length of vertex attributes.")
if(is.null(nrow(x))) rep_len(x, length.out) else apply(x, 2, rep_len, length.out)
}
@@ -458,11 +458,11 @@ ergm_get_vattr <- function(object, nw, accept="character", bip=c("n","b1","b2","
positive = x>0,
index = is.logical(x) || (all(round(x)==x) && (all(x>0) || all(x<0))))
- if(!OK) ergm_Init_abort("Attribute ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "is not ", ACCNAME[[accept]], " vector as required.")
- if(any(is.na(x))) ergm_Init_abort("Attribute ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "has missing data, which is not currently supported by ergm.")
+ if(!OK) ergm_Init_stop("Attribute ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "is not ", ACCNAME[[accept]], " vector as required.")
+ if(any(is.na(x))) ergm_Init_stop("Attribute ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "has missing data, which is not currently supported by ergm.")
if(is.matrix(x) && !is.null(cn <- colnames(x))){
if(any(cn=="")){
- ergm_Init_warn("Attribute specification ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "is a matrix with some column names set and others not; you may need to set them manually. See example(nodal_attributes) for more information.")
+ ergm_Init_warning("Attribute specification ", NVL3(xspec, paste0(sQuote(paste(deparse(.),collapse="\n")), " ")), "is a matrix with some column names set and others not; you may need to set them manually. See example(nodal_attributes) for more information.")
colnames(x) <- NULL
}
}
@@ -493,7 +493,7 @@ ergm_get_vattr.character <- function(object, nw, accept="character", bip=c("n","
missing_attr <- setdiff(object, list.vertex.attributes(nw))
if(length(missing_attr)){
- ergm_Init_abort(paste.and(sQuote(missing_attr)), " is/are not valid nodal attribute(s).")
+ ergm_Init_stop(paste.and(sQuote(missing_attr)), " is/are not valid nodal attribute(s).")
}
object %>% map(~nw%v%.) %>% set_names(object) %>% .handle_multiple(multiple=multiple) %>%
@@ -617,16 +617,16 @@ ergm_attr_levels.matrix <- function(object, attr, nw, levels=sort(unique(attr)),
sel <- switch(mode(object),
logical = { # Binary matrix
- if(any(dim(object)!=c(nol,nil))) ergm_Init_abort("Level combination selection binary matrix should have dimension ", nol, " by ", nil, " but has dimension ", nrow(object), " by ", ncol(object), ".") # Check dimension.
+ if(any(dim(object)!=c(nol,nil))) ergm_Init_stop("Level combination selection binary matrix should have dimension ", nol, " by ", nil, " but has dimension ", nrow(object), " by ", ncol(object), ".") # Check dimension.
if(!is.directed(nw) && !is.bipartite(nw) && identical(ol,il)) object <- object | t(object) # Symmetrize, if appropriate.
object
},
numeric = { # Two-column index matrix
- if(ncol(object)!=2) ergm_Init_abort("Level combination selection two-column index matrix should have two columns but has ", ncol(object), ".")
+ if(ncol(object)!=2) ergm_Init_stop("Level combination selection two-column index matrix should have two columns but has ", ncol(object), ".")
if(!is.directed(nw) && !is.bipartite(nw) && identical(ol,il)) object <- rbind(object, object[,2:1,drop=FALSE]) # Symmetrize, if appropriate.
object
},
- ergm_Init_abort("Level combination selection matrix must be either numeric or logical.")
+ ergm_Init_stop("Level combination selection matrix must be either numeric or logical.")
)
sel <- m[sel] %>% keep(`!=`,0L) %>% sort %>% unique
@@ -675,9 +675,9 @@ rank_cut <- function(x, n, tie_action = c("warning", "error"), top = FALSE){
tie_action <- match.arg(tie_action)
msg <- paste0("Levels ", paste.and(sQuote(names(x)[s1!=s2])), " are tied.")
switch(tie_action,
- error = ergm_Init_abort(msg, " Specify explicitly."),
+ error = ergm_Init_stop(msg, " Specify explicitly."),
warning = {
- ergm_Init_warn(msg, " Using the order given.")
+ ergm_Init_warning(msg, " Using the order given.")
which(ordrank(rank(x, ties.method="first")) <= n)
})
}