Skip to content

Commit

Permalink
Merge branch 'master' into 4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
krivit committed Nov 5, 2024
2 parents 3522774 + 8a08b0f commit 61711ad
Show file tree
Hide file tree
Showing 38 changed files with 446 additions and 263 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
inputs:
config:
description: 'A comma separated list of R-hub platforms to use.'
type: string
default: 'linux,windows,macos'
name:
description: 'Run name. You can leave this empty now.'
type: string
id:
description: 'Unique ID. You can leave this empty now.'
type: string

jobs:

setup:
runs-on: ubuntu-latest
outputs:
containers: ${{ steps.rhub-setup.outputs.containers }}
platforms: ${{ steps.rhub-setup.outputs.platforms }}

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup

linux-containers:
needs: setup
if: ${{ needs.setup.outputs.containers != '[]' }}
runs-on: ubuntu-latest
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.containers) }}
container:
image: ${{ matrix.config.container }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}

other-platforms:
needs: setup
if: ${{ needs.setup.outputs.platforms != '[]' }}
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.label }}
strategy:
fail-fast: false
matrix:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ergm
Version: 4.7.2
Date: 2024-10-12
Version: 4.7.3
Date: 2024-11-05
Title: Fit, Simulate and Diagnose Exponential-Family Models for Networks
Authors@R: c(
person(c("Mark", "S."), "Handcock", role=c("aut"), email="[email protected]"),
Expand Down
9 changes: 4 additions & 5 deletions R/ergm.geodistn.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ ergm.geodistn <- function(edgelist, n=max(edgelist), directed=FALSE) {
# convention, we want nodelist[1]=0 and in general, nodelist[i]=2*r(i)-2,
# where r(i) is the first row in edgelist containing from node i. (If
# there are no edges from node i, just set nodelist[i]=0.)
nodelist<-match(1:n,edgelist[,1],nomatch=1)-1
nodelist<-match(1:n,edgelist[,1],nomatch=1L)-1L

# Now everything is ready. Call the C code.
ans<-.C("full_geodesic_distribution", as.integer(t(edgelist)),
as.integer(n), as.integer(nodelist), as.integer(dim(edgelist)[1]),
colors=integer(n), distances=integer(n), queue=integer(n),
distribution=integer(n), PACKAGE='ergm') $ distribution
ans<-.Call("full_geodesic_distribution", as.integer(t(edgelist)),
as.integer(n), as.integer(nodelist), as.integer(dim(edgelist)[1]),
PACKAGE='ergm')
names(ans)<-c(1:(n-1),"Inf") # length n really means no path exists
ans
}
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ bibentry("Manual", author = structure(list(list(given = c("Mark",
comment = NULL)), class = "person"), title = paste("ergm",
": ", gsub("\n", " ", "Fit, Simulate and Diagnose Exponential-Family Models for Networks",
fixed = TRUE), sep = ""), organization = paste0("The Statnet Project (\\url{",
"https://statnet.org", "})"), year = substr("2024-10-12",
1, 4), note = paste("R package version ", "4.7.2", sep = ""),
"https://statnet.org", "})"), year = substr("2024-11-05",
1, 4), note = paste("R package version ", "4.7.3", sep = ""),
url = paste0("https://CRAN.R-project.org/package=", "ergm"))
# ---- END AUTOGENERATED STATNET CITATION ----

Expand Down
87 changes: 40 additions & 47 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -66,53 +66,7 @@



\section{Changes in version 4.7.2}{

\subsection{NEW FEATURES}{
\itemize{
\item{
\code{\link{ergm.godfather}()} now takes a \code{basis=} argument like \code{\link{ergm}()}, \code{\link{simulate.ergm}()}, and others. Its term options can be passed directly as well.
}
}
}


\subsection{BUG FIXES}{
\itemize{
\item{
Invalid \code{levels2} specification for \code{\link[=mm-ergmTerm]{mm()}} no longer causes memory errors.
}
}
}


\subsection{OTHER USER-VISIBLE CHANGES}{
\itemize{
\item{
\code{\link{ergm_model}()} constructor is now generic, with methods for \code{\link{formula}}, \code{\link[statnet.common]{term_list}}, and \code{\link{ergm_model}}.
}

\item{
\code{\link{is.dyad.independent}()} can now return dyadic-independence information for each term.
}

\item{
\code{\link{control.ergm.godfather}()} has been deprecated, since it is no longer used to pass term options.
}

\item{
R documentation macros \code{\\ergmTerm}, \code{\\ergmConstraint}, \code{\\ergmReference}, \code{\\ergmHint}, and \code{\\ergmProposal}.
}

\item{
Some improvements to the Terms API (see Vignette), particularly in handling of dyadic dependence and auxiliaries.
}
}
}
}


\section{Changes in version 4.7.1}{
\section{Changes in version 4.7.3}{

\subsection{NEW FEATURES}{
\itemize{
Expand All @@ -136,6 +90,9 @@
\item Excessive runtime check now works in terms of free dyad counts rather than network sizes.
}
}
\item{
\code{\link{ergm.godfather}()} now takes a \code{basis=} argument like \code{\link{ergm}()}, \code{\link{simulate.ergm}()}, and others. Its term options can be passed directly as well.
}
}
}

Expand Down Expand Up @@ -189,6 +146,15 @@
\item{
\code{\link[Label-ergmTerm]{Label}()} operator now documents its behavior when the model is curved more clearly.
}
\item{
Invalid \code{levels2} specification for \code{\link[=mm-ergmTerm]{mm()}} no longer causes memory errors.
}
\item{
Valued proposal updater function was not being passed the current edge state.
}
\item{
Undefined behavior warnings flagged by CRAN's \code{clang-asan} have been fixed.
}
}
}
Expand Down Expand Up @@ -239,6 +205,27 @@
\item{
\code{\link{param_names}()} API now allows assignment, and its method for \code{\link{ergm_model}} objects is more explicit about whether canonical or curved parameters are being modified and when.
}
\item{
\code{\link{ergm_model}()} constructor is now generic, with methods for \code{\link{formula}}, \code{\link[statnet.common]{term_list}}, and \code{\link{ergm_model}}.
}
\item{
\code{\link{is.dyad.independent}()} can now return dyadic-independence information for each term.
}
\item{
\code{\link{control.ergm.godfather}()} has been deprecated, since it is no longer used to pass term options.
}
\item{
R documentation macros \code{\\ergmTerm}, \code{\\ergmConstraint}, \code{\\ergmReference}, \code{\\ergmHint}, and \code{\\ergmProposal}.
}
\item{
Some improvements to the Terms API (see Vignette), particularly in handling of dyadic dependence and auxiliaries.
}
\item{
Documentation improvements to extended state and network callback APIs.
}
\item{
The main ERGM vignette is now in HTML.
}
}
}
Expand Down Expand Up @@ -274,6 +261,12 @@
\item{
\code{RLEBDM1D} C API now exports \code{FirstRLEBDM1D()} and \code{LastRLEBDM1D()} macros, providing dyad indices of the first and the last dyad in the RLEBDM, respectively.
}
\item{
\code{ChangeStats()} function has been split into \code{ChangeStatsDo()} and \code{ChangeStatsUndo()}, the latter only called on rejection, which speeds up MCMC and SAN when the proposal has multiple toggles.
}
\item{
\code{setListElement()} now protects the value being stored in the list before assigning it (then unprotects it), preventing potential accidental garbage collection.
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions inst/include/ergm_MHproposal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ typedef struct MHProposalstruct {
SEXP R;
void (*i_func)(struct MHProposalstruct*, Network*);
void (*p_func)(struct MHProposalstruct*, Network*);
void (*u_func)(Vertex tail, Vertex head, struct MHProposalstruct*, Network*, Rboolean);
void (*u_func)(Vertex, Vertex, struct MHProposalstruct*, Network*, Rboolean);
void (*f_func)(struct MHProposalstruct*, Network*);
void (*x_func)(unsigned int type, void *data, struct MHProposalstruct*, Network*);
void (*x_func)(unsigned int, void *, struct MHProposalstruct*, Network*);
Edge ntoggles;
Vertex *toggletail;
Vertex *togglehead;
Expand Down
3 changes: 3 additions & 0 deletions inst/include/ergm_Rutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ static inline SEXP getListElement(SEXP list, const char *str){
}

static inline SEXP setListElement(SEXP list, const char *str, SEXP value){
value = PROTECT(value);
SEXP names = getAttrib(list, R_NamesSymbol);

for (unsigned int i = 0; i < length(list); i++)
if(strcmp(CHAR(STRING_ELT(names, i)), str) == 0) {
SET_VECTOR_ELT(list, i, value);
UNPROTECT(1);
return value;
}
UNPROTECT(1);
error("List does not have element '%s' to set.", str);
return R_NilValue;
}
Expand Down
2 changes: 1 addition & 1 deletion inst/include/ergm_changestat.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef struct ModelTermstruct {
void (*f_func)(struct ModelTermstruct*, Network*);
void (*s_func)(struct ModelTermstruct*, Network*);
SEXP (*w_func)(struct ModelTermstruct*, Network*);
void (*x_func)(unsigned int type, void *data, struct ModelTermstruct*, Network*);
void (*x_func)(unsigned int, void *, struct ModelTermstruct*, Network*);
void (*z_func)(struct ModelTermstruct*, Network*, Rboolean);
double *attrib; /* Ptr to vector of covariates (if necessary; generally unused) */
int *iattrib; /* Ptr to vector of integer covariates (if necessary; generally unused) */
Expand Down
4 changes: 2 additions & 2 deletions inst/include/ergm_dyadgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ DyadGen *DyadGenInitialize(DyadGenType type, void *dyads, void *track_nwp);
DyadGen *DyadGenInitializeR(SEXP pR, void *any_nwp, Rboolean el);
void DyadGenDestroy(DyadGen *gen);

void DyadGenUpdate(Vertex tail, Vertex head, DyadGen *gen, Network *nwp, Rboolean edgestate);
void WtDyadGenUpdate(Vertex tail, Vertex head, double weight, DyadGen *gen, WtNetwork *nwp, double edgestate);
void DyadGenUpdate(Vertex tail, Vertex head, void *gen, Network *nwp, Rboolean edgestate);
void WtDyadGenUpdate(Vertex tail, Vertex head, double weight, void *gen, WtNetwork *nwp, double edgestate);

static inline void DyadGenRandDyad(Vertex *tail, Vertex *head, DyadGen *gen){
switch(gen->type){
Expand Down
6 changes: 3 additions & 3 deletions inst/include/ergm_khash.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ int main() {
*/


#ifndef __AC_KHASH_H
#define __AC_KHASH_H
#ifndef _ERGM_KHASH_H_
#define _ERGM_KHASH_H_

/*!
@header
Expand Down Expand Up @@ -771,4 +771,4 @@ typedef const char *kh_cstr_t;
} \
}

#endif /* __AC_KHASH_H */
#endif /* _ERGM_KHASH_H_ */
6 changes: 3 additions & 3 deletions inst/include/ergm_kvec.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ int main() {
*/

#ifndef _AC_KVEC_H_
#define _AC_KVEC_H_
#ifndef _ERGM_KVEC_H_
#define _ERGM_KVEC_H_

#include <R.h>

Expand All @@ -78,7 +78,7 @@ int main() {
#define kvec_t(type) struct { size_t n, m; type *a; }
#define kv_init(v) ((v).n = (v).m = 0, (v).a = NULL) // Not necessary if the data structure is calloc()ed.
#define kv_blank {.n = 0, .m = 0, .a = NULL}
#define kv_destroy(v) R_Free((v).a)
#define kv_destroy(v) {R_Free((v).a); (v).n = (v).m = 0;}
#define kv_A(v, i) ((v).a[(i)])
#define kv_pop(v) ((v).a[--(v).n])
#define kv_size(v) ((v).n)
Expand Down
2 changes: 2 additions & 0 deletions inst/include/ergm_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ int GetIndexForAttrValue(int value);

/* *** don't forget tail-> head, so this function accepts toggletail first, not togglehead */

void ChangeStatsDo(unsigned int ntoggles, Vertex *tails, Vertex *heads, Network *nwp, Model *m);
void ChangeStatsUndo(unsigned int ntoggles, Vertex *tails, Vertex *heads, Network *nwp, Model *m);
void ChangeStats(unsigned int ntoggles, Vertex *tails, Vertex *heads, Network *nwp, Model *m);
void ChangeStats1(Vertex tail, Vertex head, Network *nwp, Model *m, Rboolean edgestate);
void ZStats(Network *nwp, Model *m, Rboolean skip_s);
Expand Down
Loading

0 comments on commit 61711ad

Please sign in to comment.