R Under development (unstable) (2024-07-01 r86857 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > # File tests/compute.animation_Tests.R in package ndtv, part of the Statnet suite > # of packages for network analysis, http://statnet.org . > # > # This software is distributed under the GPL-3 license. It is free, > # open source, and has the attribution requirements (GPL Section 7) at > # http://statnet.org/attribution > # > # Copyright 2003-2013 Statnet Commons > ####################################################################### > #test some functions for calculating animated layouts and exporting movies. > require(ndtv) Loading required package: ndtv Loading required package: network 'network' 1.18.2 (2023-12-04), part of the Statnet Project * 'news(package="network")' for changes since last version * 'citation("network")' for citation information * 'https://statnet.org' for help, support, and other information Loading required package: networkDynamic 'networkDynamic' 0.11.4 (2023-12-10?), part of the Statnet Project * 'news(package="networkDynamic")' for changes since last version * 'citation("networkDynamic")' for citation information * 'https://statnet.org' for help, support, and other information Loading required package: animation Loading required package: sna Loading required package: statnet.common Attaching package: 'statnet.common' The following objects are masked from 'package:base': attr, order sna: Tools for Social Network Analysis Version 2.7-2 created on 2023-12-05. copyright (c) 2005, Carter T. Butts, University of California-Irvine For citation information, type citation("sna"). Type help(package="sna") to get started. 'ndtv' 0.13.4 (2023-06-30), part of the Statnet Project * 'news(package="ndtv")' for changes since last version * 'citation("ndtv")' for citation information * 'https://statnet.org' for help, support, and other information > require(testthat) Loading required package: testthat > > # hard to write tests since most require a human looking at the output > # most overall tests are included as man examples or in the packae vignette > # this file should be mostly unit tests for functionality > > > # ----- compute.animation ------ > > # does it crash on basic example > data(newcomb) > dynNew <- networkDynamic(network.list=newcomb[1:5]) Neither start or onsets specified, assuming start=0 Onsets and termini not specified, assuming each network in network.list should have a discrete spell of length 1 Argument base.net not specified, using first element of network.list instead Created net.obs.period to describe network Network observation period info: Number of observation spells: 1 Maximal time range observed: 0 until 5 Temporal mode: discrete Time unit: step Suggested time increment: 1 > dyn<-dynNew > slice.par<-list(start=0,end=5,interval=1, aggregate.dur=1,rule='any') > set.seed(123) > compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > > > # modify network argument in place? > if(!all(c("animation.x.active","animation.y.active")%in%list.vertex.attributes(dyn))){ + stop("compute.animation appears to have not correctly modified its argument in place") + } > > # does it store slice.par > par<-get.network.attribute(dyn,'slice.par') > if (!all(names(par)==c("start","end","interval","aggregate.dur","rule" ))){ + stop("compute.animation did not store slice parameters correctly in slice.par") + } > > # does it store animation.x and animation.y > x<-get.vertex.attribute(dyn,"animation.x.active") > y<-get.vertex.attribute(dyn,"animation.y.active") > if(any(is.na(x)) | any(is.na(y))){ + stop('compute.animation did not store animation.x and animation.y vertex attributes') + } > > # does it give same results from same seed > x1 <-get.vertex.attribute.active(dyn,"animation.x",at=1) > set.seed(123) > dyn <-compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > x2 <-get.vertex.attribute.active(dyn,"animation.x",at=1) > if (!all(x1==x2)){ + stop("compute.animation did not generate the same results fromt he same seed") + } > > # does aggregate.dur change results > set.seed(123) > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=1,rule="any") > dyn <-compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > x1 <-get.vertex.attribute.active(dyn,"animation.x",onset=1,terminus=2) > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=2,rule="any") > set.seed(123) > dyn <-compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > x2 <-get.vertex.attribute.active(dyn,"animation.x",onset=1,terminus=2) > if (any(x1==x2)){ + stop("compute.animation did not give different results with a different aggreagate.dur") + } > > # does aggregation rule change results > set.seed(123) > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=2,rule="any") > dyn <-compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > x1 <-get.vertex.attribute.active(dyn,"animation.x",at=1) > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=2,rule="all") > set.seed(123) > dyn <-compute.animation(dyn,slice.par=slice.par,verbose=FALSE) > x2 <-get.vertex.attribute.active(dyn,"animation.x",at=1) > if (any(x1==x2)){ + stop("compute.animation did not give different results with a different aggregation rule") + } > > # does default.dist change results > data(stergm.sim.1) > set.seed(123) > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=1,rule='latest') > stergm.sim.1 <-compute.animation(stergm.sim.1,slice.par=slice.par,verbose=FALSE) > x1 <-get.vertex.attribute.active(stergm.sim.1,"animation.x",at=1) > set.seed(123) > stergm.sim.1 <-compute.animation(stergm.sim.1,slice.par=slice.par,default.dist=100,verbose=FALSE) > x2 <-get.vertex.attribute.active(stergm.sim.1,"animation.x",at=1) > if (any(x1==x2)){ + stop("compute.animation did not give different results with a different default.dist") + } > > > # check with incomplete slice.par > expect_error(compute.animation(stergm.sim.1,slice.par=list()),"the 'slice.par' argument to compute.animation must include") > expect_error(compute.animation(stergm.sim.1,slice.par=list(start=1)),"the 'slice.par' argument to compute.animation must include") > expect_error(compute.animation(stergm.sim.1,slice.par=list(start=1,end=5,interval=1)),"the 'slice.par' argument to compute.animation must include") > > > # does reverse chaining option crash things > dyn<-dynNew > slice.par<-list(start=0,end=2,interval=1, aggregate.dur=1,rule='latest') > compute.animation(dyn,slice.par=slice.par,verbose=FALSE,chain.direction='reverse') > expect_error(compute.animation(dyn,slice.par=slice.par,verbose=FALSE,chain.direction='sideways'), "'arg' should be one of") > > proc.time() user system elapsed 2.43 0.42 2.85