Running 'activate_tests.R' [3s]
  Running 'age.at_tests.R' [3s]
  Running 'classTests.R' [2s]
  Running 'converter_tests.R' [169s]
  Running 'get_tests.R' [173s]
  Running 'import_tests.R' [6s]
  Running 'network_tests.R' [5s]
  Running 'pid_tests.R' [155s]
  Running 'query_tests.R' [2s]
  Running 'reconcile.activityTests.R' [4s]
  Running 'tea_tests.R' [3s]
  Running 'utils_tests.R' [176s]
  Running 'when_tests.R' [3s]
Running the tests in 'tests/converter_tests.R' failed.
Complete output:
  > #  Part of the statnet package, http://statnetproject.org
  > #
  > #  This software is distributed under the GPL-3 license.  It is free,
  > #  open source, and has the attribution requirements (GPL Section 7) in
  > #    http://statnetproject.org/attribution
  > #
  > #  Copyright 2013 the statnet development team
  > ######################################################################
  > 
  > #test networkDynamic conversion functionality
  > 
  > require(networkDynamic)
  Loading required package: networkDynamic
  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
  
  
  '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
  
  > require(testthat)
  Loading required package: testthat
  > 
  > 
  > # ------ get.vertex.activity test ------
  > 
  > net<-network.initialize(5)
  > activate.vertices(net,onset=c(1,2,3,-Inf,100),terminus=c(10,20,Inf,30,Inf))
  > activate.vertices(net,at=1000)
  > expect_equal(unlist(get.vertex.activity(net)),c(1,1000,10,1000,2,1000,20,1000,3,Inf,-Inf,1000,30,1000,100,Inf),info='check if spell list has correct elements in get.vertex.activity')
  > 
  > expect_equivalent(get.vertex.activity(net,as.spellList=TRUE),data.frame(onset=c(1,1000,2,1000,3,-Inf,1000,100),terminus=c(10,1000,20,1000,Inf,30,1000,Inf),vertex.id=c(1,1,2,2,3,4,4,5),onset.censored=c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE),terminus.censored=c(FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE),duration=c(9,0,18,0,Inf,Inf,0,Inf)),info="check if get.vertex.activity(spellList) returns correct data")
  > 
  > # check sort order
  > expect_equal(get.vertex.activity(net,as.spellList=TRUE)$vertex.id,c(1,1,2,2,3,4,4,5),info="check sort order of get.vertex.activity vertex.id")
  > 
  > expect_equal(get.vertex.activity(net,as.spellList=TRUE)$onset,c(1,1000,2,1000,3,-Inf,1000,100),info="check sort order of get.vertex.activity onset")
  > expect_equal(get.vertex.activity(net,as.spellList=TRUE)$terminus,c(10,1000,20,1000,Inf,30,1000,Inf),info="check sort order of get.vertex.activity terminus")
  > 
  > expect_equal(get.vertex.activity(network.initialize(0)),list())
  > 
  > 
  > 
  > 
  > # check that net.obs.period triggers censoring
  > nop <- list(observations=list(c(-5,1001)), mode="discrete", time.increment=1,time.unit="step")
  > set.network.attribute(net,'net.obs.period',nop)
  > expect_equivalent(get.vertex.activity(net,as.spellList=TRUE),data.frame(onset=c(1,1000,2,1000,3,-5,1000,100),terminus=c(10,1000,20,1000,1001,30,1000,1001),vertex.id=c(1,1,2,2,3,4,4,5),onset.censored=c(FALSE,FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE),terminus.censored=c(FALSE,FALSE,FALSE,FALSE,TRUE,FALSE,FALSE,TRUE),duration=c(9,0,18,0,998,35,0,901)),info="check that net.obs.period triggers censoring in get.vertex.activity(spellList)")
  > 
  > 
  > # check for bug with no activity #192
  > nd<-network.initialize(2)
  > nd<-add.edges.active(nd,at=1,tail=1,head=2)
  > 
  > expect_equivalent(get.vertex.activity(nd,as.spellList=TRUE),data.frame(onset=c(-Inf,-Inf),terminus=c(Inf,Inf),vertex.id=c(1,2),onset.censored=c(TRUE,TRUE),terminus.censored=c(TRUE,TRUE),duration=c(Inf,Inf)),info="checking with no vertex activity")
  > 
  > # test if activity is missing for an element
  > activate.vertices(nd,onset=1,terminus=2,v=2)
  > expect_equivalent(get.vertex.activity(nd,as.spellList=TRUE),data.frame(onset=c(-Inf,1),terminus=c(Inf,2),vertex.id=c(1,2),onset.censored=c(TRUE,FALSE),terminus.censored=c(TRUE,FALSE),duration=c(Inf,1)),info="test when only some verticies have activity")
  > 
  > # test when default activity set false
  > expect_equivalent(
  +   get.vertex.activity(nd,as.spellList=TRUE,active.default=FALSE),
  +   data.frame(onset=1,terminus=2,vertex.id=2,onset.censored=FALSE,terminus.censored=FALSE,duration=1),info="test when only some verticies have activity and active.default=FALSE")
  > 
  > # test if v specified for spellmatrix
  > nd <- network.initialize(5)
  > activate.vertices(nd,onset=0:4,terminus=1:5)
  > expect_equivalent(
  +  get.vertex.activity(nd,as.spellList=TRUE,v=2:4)[,1:3],
  +  data.frame(onset=1:3,terminus=2:4,vertex.id=2:4),info="test when when v argument specified with spellmatrix")
  > 
  > expect_equivalent(
  +   unlist(get.vertex.activity(nd,,v=2:4)),c(1,2,2,3,3,4)
  +   ,info="test when when v argument specified")
  > 
  > 
  > # test if called with ordinary network
  > expect_equal(unlist(get.vertex.activity(network.initialize(3))),c(-Inf,Inf,-Inf,Inf,-Inf,Inf),info="calling with ordinary network")
  > 
  > # test when called with something else
  > expect_error(get.vertex.activity(list()))
  > 
  > # test with null spell
  > net<- network.initialize(2)
  > deactivate.vertices(net,onset=-Inf,terminus=Inf)
  > expect_equal(sapply(get.vertex.activity(net),is.null),c(TRUE,TRUE),info="testing for null spell")
  > 
  > 
  > #test for active.default behavior
  > expect_equal(get.vertex.activity(network.initialize(1))[[1]],matrix(c(-Inf,Inf),ncol=2),info='check get.vertex.activity active default behavior')
  > 
  > expect_equal(get.vertex.activity(network.initialize(1),active.default=FALSE)[[1]],NA,info='check get.vertex.activity active.default=FALSE behavior')
  > 
  > expect_equal(nrow(get.vertex.activity(network.initialize(0),as.spellList=TRUE)),0)
  > 
  > # test with deleted spell (was failing in v 0.4)
  > net<-network.initialize(3)
  > delete.vertex.activity(net,v=2)
  > expect_equal(get.vertex.activity(net,as.spellList=TRUE)$onset,c(-Inf,-Inf,-Inf))
  > 
  > # test with deactiviate spell (was failing in v 0.4)
  > net<-network.initialize(3)
  > deactivate.vertices(net,v=2)
  > expect_equal(get.vertex.activity(net,as.spellList=TRUE)$onset,c(-Inf,-Inf))
  > expect_equal(nrow(get.vertex.activity(net,as.spellList=TRUE,active.default=FALSE)),0)
  > 
  > 
  > 
  > # --------------- networkDynamic() conversion test -----
  > 
  > # ---- networkDynamic() vertex spells -----
  > vert.spls <-matrix(
  +   c(1,2,1,
  +   2,3,2,
  +   3,4,3,
  +   4,5,4),ncol=3,byrow=TRUE)
  > 
  > nd <-networkDynamic(vertex.spells=vert.spls)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (network.size(nd)!=4){
  +   stop("networkDynamic did not create network of appropriate size from vertex.spells")
  + }
  > if(!all(get.vertex.activity(nd,as.spellList=TRUE)[1:3]==vert.spls)){
  +   stop("networkDynamic did not create network with appropriate vertex.spells from vertex.spells")
  + }
  >    
  > # vertex.spells  impute missing vertex?   
  > vert.spls <-matrix(
  +      c(1,2,1,
  +        2,3,2,
  +        3,4,3,
  +        4,5,9),ncol=3,byrow=TRUE)
  > nd <-networkDynamic(vertex.spells=vert.spls)
  Initializing base.net of size 9 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (network.size(nd)!=9){
  +   stop("networkDynamic did not create network of appropriate imputed size from vertex.spells")
  + }
  >    
  > # vertex.spells  bad spell input
  > vert.spls <-matrix(
  +      c(1,2,1,
  +        5,3,2,  #uh oh, this spell is backwards
  +        3,4,3,
  +        4,5,4),ncol=3,byrow=TRUE)
  > expect_error(
  +   networkDynamic(vertex.spells=vert.spls) #throws error, but doesn't say what line
  + ,"Onset times must precede terminus times in activate.vertices")
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  >    
  > # vertex.spells empty network
  > vert.spls <-matrix(numeric(0),ncol=3,nrow=0)
  > nd<-networkDynamic(vertex.spells=vert.spls)
  Initializing base.net of size 0 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  Warning messages:
  1: In min(x) : no non-missing arguments to min; returning Inf
  2: In max(x) : no non-missing arguments to max; returning -Inf
  > expect_equal(network.size(nd),0,info="checking creating zero vertex network with networkDynamic converter")
  >    
  > #  ---- networkDynamic() edge spells ---------------
  > edge.spls <-matrix(
  +   c(1,2,1,2,
  +     2,3,2,3,
  +     3,4,3,4,
  +     4,5,4,5),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.spells=edge.spls)
  Initializing base.net of size 5 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if(network.edgecount(nd)!=4){
  +   stop("networkDynamic() did not create appropriate number of edges from edge.spells")
  + }
  > if(network.size(nd)!=5){
  +   stop("networkDynamic() did not create appropriate number of vertices from edge.spells")
  + }
  > 
  > # edge spells - 0 edges
  > # this generates 'mysterious' warning
  > # https://statnet.csde.washington.edu/trac/ticket/189
  > net<-network.initialize(5)  #will crash if no vertices
  > edge.spls <-matrix(0,ncol=4,nrow=0,byrow=TRUE)
  > nd <-networkDynamic(base.net=net,edge.spells=edge.spls)
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  Warning messages:
  1: In min(x) : no non-missing arguments to min; returning Inf
  2: In max(x) : no non-missing arguments to max; returning -Inf
  > 
  > 
  > # edge spells - Loops
  > edge.spls <-matrix(
  +   c(1,2,1,1,
  +     1,2,2,2),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.spells=edge.spls)
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 2 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > 
  > # NA values  
  > edge.spls <-matrix(
  +   c(1,2,1,NA,
  +     1,2,"a",2),ncol=4,byrow=TRUE)
  > expect_error(networkDynamic(edge.spells=edge.spls),"must be numeric")
  > 
  > # edge spells - infer network size
  > edge.spls <-matrix(
  +   c(1,2,1,1,
  +     1,2,2,9),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.spells=edge.spls)
  Initializing base.net of size 9 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 2 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if(network.size(nd)!=9){
  +   stop("networkDynamic() did not infer network size from edge ids as expected")
  + }
  > 
  > # network properties from base net preserved
  > net <-network.initialize(5,directed=FALSE,loops=TRUE)
  > edge.spls <-matrix(
  +   c(1,2,1,2,
  +     2,3,2,3,
  +     3,4,3,4,
  +     4,5,4,5),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(base.net=net,edge.spells=edge.spls)
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (is.directed(nd) & !has.loops(nd)){
  +   stop("networkDynamic did not preserve basic network settings from base.net argument")
  + }
  > 
  > # constsruct with both edges and vertices
  > edge.spls <-matrix(
  +   c(1,2,1,2,
  +     2,3,2,3,
  +     3,4,3,4,
  +     4,5,4,5),ncol=4,byrow=TRUE)
  > vert.spls <-matrix(
  +   c(1,2,1,
  +     2,3,2,
  +     3,4,3,
  +     4,5,4),ncol=3,byrow=TRUE)
  > nd<-networkDynamic(vertex.spells=vert.spls, edge.spells=edge.spls)
  Initializing base.net of size 5 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > # inconsistant edges and vertices
  > 
  > 
  > #  ---- networkDynamic() vertex toggles - no base net ---------------
  > vrt.tog <-matrix(
  +   c(1,1,
  +     2,2,
  +     3,2),ncol=2,byrow=TRUE)
  > nd <-networkDynamic(vertex.toggles=vrt.tog)
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if(!all(get.vertex.activity(nd,as.spellList=TRUE)[,1:3]==matrix(c(-Inf,1,1, -Inf,2,2, 3,Inf,2),ncol=3,byrow=TRUE))){
  +   stop("networkDynamic() did not produduce expected output for vertex.toggles ")
  + }
  > 
  > # check the list version with the inf values
  > expect_equal(unlist(get.vertex.activity(nd)),c(-Inf,1,-Inf,3,2,Inf))
  > 
  > # vertex toggles - with base net
  > net <-network.initialize(3)
  > vrt.tog <-matrix(
  +   c(1,1,
  +     2,2,
  +     3,2),ncol=2,byrow=TRUE)
  > nd <-networkDynamic(base.net=net,vertex.toggles=vrt.tog)
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if(!all(get.vertex.activity(nd,as.spellList=TRUE)[,1:3]==matrix(c(-Inf,1,1,
  +                                                                   -Inf,2,2,
  +                                                                   3,Inf,2,
  +                                                                   -Inf,Inf,3),ncol=3,byrow=TRUE))){
  +   stop("networkDynamic() did not produce expected output for vertex.toggles and base.net")
  + }
  > 
  > # check the list version with the inf values
  > expect_equal(unlist(get.vertex.activity(nd)),c(-Inf,1,-Inf,3,2,Inf,-Inf,Inf))
  > 
  > 
  > #  ---- networkDynamic() edge toggles ------------
  > edge.tog <- matrix(
  +   c(1,1,2,
  +     2,2,3,
  +     3,2,3),ncol=3,byrow=TRUE)
  > nd<-networkDynamic(edge.toggles=edge.tog)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if(!all(get.edge.activity(nd,as.spellList=TRUE)[,1:4]==matrix(c(1,Inf,1,2, 2,3,2,3),ncol=4,byrow=TRUE))){
  +   stop("networkDynamic() did not produce expected output for edge.toggles")
  + }
  > expect_equal(unlist(get.edge.activity(nd)),c(1,Inf,2,3))
  > 
  > net<-network.initialize(4)
  > net[3,4]<-1
  > net[1,4]<-1
  > edge.tog <- matrix(
  +   c(1,1,2,
  +     2,2,3,
  +     3,2,3,
  +     0,1,4),ncol=3,byrow=TRUE)
  > nd<-networkDynamic(base.net=net,edge.toggles=edge.tog)
  Edge activity in base.net was ignored
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if(!all(get.edge.activity(nd,as.spellList=TRUE)[,1:4]==matrix(c(-Inf,Inf,3,4, 
  +                                                                 -Inf,0,1,4, 
  +                                                                 1,Inf,1,2, 
  +                                                                 2,3,2,3),ncol=4,byrow=TRUE))){
  +   stop("networkDynamic() did not produce expected output for edge.toggles with base.net")
  + }
  > expect_equal(unlist(get.edge.activity(nd)),c(-Inf,Inf,-Inf,0,1,Inf,2,3))
  > 
  > #  ---- networkDynamic() vertex changes ----------
  > vrt.cng <-matrix(
  +   c(1,1,1,
  +     2,2,1,
  +     3,2,0),ncol=3,byrow=TRUE)
  > nd <-networkDynamic(vertex.changes=vrt.cng)
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if (!all(get.vertex.activity(nd,as.spellList=TRUE)[,1:3]==matrix(c(1,Inf,1,2, 2,3,2,3),ncol=4,byrow=TRUE) )){
  +   stop("networkDynamic() did not produce expected output for vertex.changes argument")
  + }
  > 
  > expect_equal(unlist(get.vertex.activity(nd)),c(1,Inf,2,3))
  > 
  > #  ---- networkDynamic() edge changes -----------
  > edge.cng <-matrix(
  +   c(1,1,2,1,
  +     2,2,3,1,
  +     3,2,3,0),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.changes=edge.cng)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > if (!all(get.edge.activity(nd,as.spellList=TRUE)[,1:4]==matrix(c(1,Inf,1,2, 2,3,2,3),ncol=4,byrow=TRUE))){
  +   stop("networkDynamic() did not produce expected output for edge.changes argument")
  + }
  > 
  > expect_equal(unlist(get.edge.activity(nd)),c(1,Inf,2,3))
  > # check net.obs.period defaults
  > expect_equal((nd%n%'net.obs.period')$'observations'[[1]],c(1,Inf))
  > 
  > # edge changes - activate edge allready active ignored
  > edge.cng <-matrix(
  +   c(2,2,3,1,
  +     3,2,3,1),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.changes=edge.cng)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 2 until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equivalent(as.numeric(get.edge.activity(nd,as.spellList=TRUE)[1:4]),c(2,Inf,2,3))
  > 
  > # check net.obs.period defaults
  > expect_equal((nd%n%'net.obs.period')$'observations'[[1]],c(2,Inf))
  > 
  > 
  > 
  > 
  > #  ---- networkDynamic() list of networks ---------- 
  > #try converting the newcomb panel data (working 9/3)
  > data(newcomb)
  > newDyn <- networkDynamic(network.list=newcomb[1:3])
  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 3 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > #does it pass a consistency check?
  > check <- network.dynamic.check(newDyn) 
  > if (!all(sapply(check, all)))
  +   stop("newcomb network.list conversion did not pass network.dynamic.check")
  > #is the matrix equal to the input matrix
  > for (k in 1:3) {
  +   if (!all(as.sociomatrix(newcomb[[k]]) == as.sociomatrix(network.extract(newDyn,onset=k-1,terminus=k)))){
  +     stop("FAIL: networkDynamic conversion: 1st input matrix does not match crosssection from time 0 to 1 for newcomb example")
  +   }
  + }
  > 
  > # try converting a list that includes different size networks. (working 9/10)
  > # note that beach[[25]] is NA (missing)
  > data(windsurferPanels)
  > beach<-beach[1:7]
  > # should return error
  > dynBeach=NULL
  > expect_error(dynBeach<-networkDynamic(network.list = beach),
  +              "vertex.pid must be specified")
  >                    
  > if (is.network(dynBeach)) stop("did not ask for vertex.pid when network.list have different size networks")
  > 
  > dynBeach<-networkDynamic(network.list=beach, vertex.pid="vertex.names")
  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
  Initialized network of size 57 inferred from number of unique vertex.pids
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 7 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > #data level node indicies are stored as the vertex names
  > expect_equal(get.network.attribute(dynBeach,'vertex.pid'),'vertex.names',info='check vertex.pid name set correctly')
  > 
  > #check if the neighborhood is the same for both.
  > for (i in 1:length(beach)) {
  +   if (!identical(beach[[i]], NA)) {
  +     beach[[i]]<-set.network.attribute(beach[[i]],'vertex.pid','vertex.names')
  +     for (j in network.vertex.names(beach[[i]])) {
  +       ng1 <-get.neighborhood(beach[[i]], v=get.vertex.id(beach[[i]], j))
  +       ng2 <- get.neighborhood.active(dynBeach, onset=i-1, terminus=i, v=get.vertex.id(dynBeach, j))
  +       # the following line is much much slower
  +       #ng2 <-get.neighborhood(network.extract(dynBeach,onset=i-1,terminus=i,retain.all.vertices=T),v=get.vertex.id(dynBeach, j))
  +       # need to check the vertex names, not the ids which are changed when converting to a networkDynamic object
  +       names1 <- sort(network.vertex.names(beach[[i]])[ng1])
  +       names2 <- sort(network.vertex.names(dynBeach)[ng2])
  +       # print these if necessary
  +       # print(paste('============ ', i, '=========='))
  +       # print(names1)
  +       # print(names2)
  +       if (!identical(names1, names2)) {
  +         print(paste("FAIL: networkDynamic(): neigborhoods do not match for variable sized network list example (windsurfers)",
  +                    " at time", i, 'vertex', j))
  +         print(names1)
  +         print(names2)
  +       }
  +     }
  +     
  +   }
  + }
  > 
  > # try a better (but truncated to make test fast) representation that preserves edge times and gaps
  > 
  > data(windsurferPanels)
  > beach<-beach[c(24,26)]
  > dynBeach<-networkDynamic(network.list=beach, vertex.pid="vertex.names",onsets=c(24,26),termini=c(25,27))
  Argument base.net not specified, using first element of network.list instead
  Initialized network of size 30 inferred from number of unique vertex.pids
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 2 
    Maximal time range observed: 24 until 27 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > 
  > # make sure day 25 really is missing
  > if (any(is.active(dynBeach, at=25,v=1:network.size(dynBeach)))){
  +   stop("onsets and termini did not correctly omit day 25 in windsurfer example")
  + }
  > 
  > # check net.obs.period
  > 
  > expect_equal(do.call(rbind,(dynBeach%n%'net.obs.period')$observations),cbind(c(24,26),c(25,27)),info='was net.obs.period created by default by networkDynamic() with onsets and termini did not have expected range')
  > 
  > 
  > 
  > 
  > #  ---- networkDynamic()  network list TEAs -----------
  > 
  > #try a reduced newcomb version that has edge weights
  > newRankDyn <-networkDynamic(network.list=newcomb.rank[1:2],create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Network:  title 
  	Edges:  rank 
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > # check that it matches original
  > expect_equal(as.matrix(network.collapse(newRankDyn,at=0),attrname='rank'),as.matrix(newcomb.rank[[1]],attrname='rank'))
  > expect_equal(as.matrix(network.collapse(newRankDyn,at=1),attrname='rank'),as.matrix(newcomb.rank[[2]],attrname='rank'))
  > 
  > # test vertex TEA from list of odd-sized networks
  > netlist<-list(network.initialize(3),network.initialize(1),network.initialize(2),network.initialize(2))
  > netlist[[1]]<-set.vertex.attribute(netlist[[1]],'id',c('a','b','c'))
  > netlist[[2]]<-set.vertex.attribute(netlist[[2]],'id','b')
  > netlist[[3]]<-set.vertex.attribute(netlist[[3]],'id',c('c','d'))
  > netlist[[4]]<-set.vertex.attribute(netlist[[4]],'id',c('c','d'))
  > netlist[[1]]<-set.vertex.attribute(netlist[[1]],'val',c('a1','b1','c1'))
  > netlist[[2]]<-set.vertex.attribute(netlist[[2]],'val','b2')
  > netlist[[3]]<-set.vertex.attribute(netlist[[3]],'val',c('c3','d3'))
  > dyn<-networkDynamic(network.list=netlist,vertex.pid='id',create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Vertices:  val 
  Argument base.net not specified, using first element of network.list instead
  Initialized network of size 4 inferred from number of unique vertex.pids
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=0),c('a1','b1','c1',NA))
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=1),c(NA,'b2',NA,NA))
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=2),c(NA,NA,'c3','d3'))
  > expect_true(all(is.na(get.vertex.attribute.active(dyn,'val',at=3))))
  > 
  > # test edge TEA from list of odd-sized networks
  > netlist[[1]]<-add.edges(netlist[[1]],tail=1:2,head=2:3)
  > netlist[[3]]<-add.edges(netlist[[3]],tail=1,head=2)
  > netlist[[4]]<-add.edges(netlist[[4]],tail=1,head=2)
  > netlist[[1]]<-set.edge.attribute(netlist[[1]],'eid','ab1',e=1)
  > netlist[[1]]<-set.edge.attribute(netlist[[1]],'eid','bc1',e=2)
  > netlist[[3]]<-set.edge.attribute(netlist[[3]],'eid','cd3',e=1)
  > netlist[[4]]<-set.edge.attribute(netlist[[4]],'eid','cd4',e=1)
  > dyn<-networkDynamic(network.list=netlist,vertex.pid='id',create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Vertices:  val 
  	Edges:  eid 
  Argument base.net not specified, using first element of network.list instead
  Initialized network of size 4 inferred from number of unique vertex.pids
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=0),c("ab1","bc1" ,NA   ))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=1),c(NA,NA ,NA))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=2),c(NA,NA,"cd3"))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=3),c(NA,NA,"cd4"))
  > 
  > # test network TEA from list of odd-sized networks
  > netlist[[1]]<-set.network.attribute(netlist[[1]],'netname','first')
  > netlist[[2]]<-set.network.attribute(netlist[[2]],'netname','second')
  > netlist[[3]]<-set.network.attribute(netlist[[3]],'netname','third')
  > netlist[[4]]<-set.network.attribute(netlist[[4]],'netname','forth')
  > dyn<-networkDynamic(network.list=netlist,vertex.pid='id',create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Network:  netname 
  	Vertices:  val 
  	Edges:  eid 
  Argument base.net not specified, using first element of network.list instead
  Initialized network of size 4 inferred from number of unique vertex.pids
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(unlist(get.network.attribute.active(dyn,'netname',onset=-Inf,terminus=Inf,return.tea=TRUE)[[1]]),c("first",  "second", "third",  "forth"))
  > 
  > 
  > # test TEAs with same size networks, no vertex.pid
  > netlist<-list(network.initialize(4),network.initialize(4),network.initialize(4),network.initialize(4))
  > template<-netlist[[1]]
  > template<-set.vertex.attribute(template,'id',c('a','b','c','d'))
  > netlist[[1]]<-set.vertex.attribute(netlist[[1]],'val',c('a1','b1','c1'),v=1:3)
  > netlist[[2]]<-set.vertex.attribute(netlist[[2]],'val','b2',v=2)
  > netlist[[3]]<-set.vertex.attribute(netlist[[3]],'val',c('c3','d3'),v=3:4)
  > dyn<-networkDynamic(network.list=netlist,base.net=template,create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Vertices:  val 
  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 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(get.vertex.attribute(dyn,'id'),c('a','b','c','d'))
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=0),c('a1','b1','c1',NA))
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=1),c(NA,'b2',NA,NA))
  > expect_equal(get.vertex.attribute.active(dyn,'val',at=2),c(NA,NA,'c3','d3'))
  > expect_true(all(is.na(get.vertex.attribute.active(dyn,'val',at=3))))
  > 
  > # test edge TEA from list of same-sized networks
  > netlist[[1]]<-add.edges(netlist[[1]],tail=1:2,head=2:3)
  > netlist[[3]]<-add.edges(netlist[[3]],tail=3,head=4)
  > netlist[[4]]<-add.edges(netlist[[4]],tail=3,head=4)
  > netlist[[1]]<-set.edge.attribute(netlist[[1]],'eid','ab1',e=1)
  > netlist[[1]]<-set.edge.attribute(netlist[[1]],'eid','bc1',e=2)
  > netlist[[3]]<-set.edge.attribute(netlist[[3]],'eid','cd3',e=1)
  > netlist[[4]]<-set.edge.attribute(netlist[[4]],'eid','cd4',e=1)
  > dyn<-networkDynamic(network.list=netlist,create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Vertices:  val 
  	Edges:  eid 
  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 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=0),c("ab1","bc1" ,NA   ))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=1),c(NA,NA ,NA))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=2),c(NA,NA,"cd3"))
  > expect_equal(get.edge.attribute.active(dyn,'eid',at=3),c(NA,NA,"cd4"))
  > 
  > # test network TEA from list of same-sized networks
  > netlist[[1]]<-set.network.attribute(netlist[[1]],'netname','first')
  > netlist[[2]]<-set.network.attribute(netlist[[2]],'netname','second')
  > netlist[[3]]<-set.network.attribute(netlist[[3]],'netname','third')
  > netlist[[4]]<-set.network.attribute(netlist[[4]],'netname','forth')
  > dyn<-networkDynamic(network.list=netlist,create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Network:  netname 
  	Vertices:  val 
  	Edges:  eid 
  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 4 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equal(unlist(get.network.attribute.active(dyn,'netname',onset=-Inf,terminus=Inf,return.tea=TRUE)[[1]]),c("first",  "second", "third",  "forth"))
  > 
  > 
  > # -------- networkDynamic() edge spell tea tests ---------
  > 
  > # test dyad eid lookup
  > test<-network.initialize(6,loops=TRUE)
  > add.edges(test,tail=1:3,head=2:4)
  > add.edges(test,tail=5,head=5)
  > 
  > # dyads with no edge should return NA
  > expect_equal(networkDynamic:::get.dyads.eids(test,1,1),NA) 
  > # get eids back
  > expect_equal(networkDynamic:::get.dyads.eids(test,1:3,2:4),1:3)
  > # self loops work
  > expect_equal(networkDynamic:::get.dyads.eids(test,5,5),4)  
  > # error if lengths of head and tails differ
  > expect_error(networkDynamic:::get.dyads.eids(test,1,1:3),regexp = 'length of the tails and heads parameters must be the same') 
  > 
  > # test for multiplex throws warning
  > add.edges(test,tail=1,head=2)
  > expect_warning(expect_equal(networkDynamic:::get.dyads.eids(test,1,2),1), regexp = 'only smallest eid returned')
  > 
  > # ok, now test edge eids
  > 
  > 
  > # create an edge spell matrix where the last two columns will be TEA vals
  > testnumbers<-matrix(c(1,2,1,2, 1, 0.5,
  +                       3,4,1,2, 2, 0.1,
  +                       4,5,1,2, 0, 0.1,
  +                       5,7,2,3, 3, -1,
  +                       5,7,3,4, 4, 1.5),ncol=6,byrow=TRUE)
  > 
  > testnet<-networkDynamic(edge.spells=testnumbers,create.TEAs = TRUE,edge.TEA.names = c('value','weight'))
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > 
  > expect_true('value.active'%in%list.edge.attributes(testnet))
  > expect_true('weight.active'%in%list.edge.attributes(testnet))
  > 
  > expect_equal(get.edge.attribute.active(testnet,'value',at=1),c(1,NA,NA))
  > expect_equal(get.edge.attribute.active(testnet,'value',at=4),c(0,NA,NA))
  > expect_equal(get.edge.attribute.active(testnet,'value',at=5),c(NA,3,4))
  > expect_equal(get.edge.attribute.active(testnet,'weight',at=5),c(NA,-1,1.5))
  > 
  > # test for mismatch between number of cols and number of names
  > expect_error(testnet<-networkDynamic(edge.spells=testnumbers,create.TEAs = TRUE,edge.TEA.names = c('value','weight','foo')),regexp = 'edge.TEA.names must match the number of remaining columns in edge')
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  > 
  > # now try with a non-numeric value
  > testletters<-data.frame(onset=c(1,2,5,5),
  +                     terminus=c(2,4,7,7),
  +                         head=c(1,1,2,3),
  +                         tail=c(2,2,3,4),
  +                       value=c('A','B','C','D'),stringsAsFactors=FALSE)
  > testnet<-networkDynamic(edge.spells=testletters,create.TEAs = TRUE,edge.TEA.names = c('value'))
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  valueCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > # careful, these tests fail if character vector in data frame is converted to a factor
  > expect_equal(get.edge.attribute.active(testnet,'value',at=1),c('A',NA,NA))
  > expect_equal(get.edge.attribute.active(testnet,'value',at=2),c('B',NA,NA))
  > expect_equal(get.edge.attribute.active(testnet,'value',at=5),c(NA,'C','D'))
  > 
  > # test guessing col names from data.frame
  > testnet<-networkDynamic(edge.spells=testletters,create.TEAs = TRUE,edge.TEA.names = c('value'))
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  valueCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_true('value.active'%in%list.edge.attributes(testnet))
  > 
  > testnet<-networkDynamic(edge.spells=testletters,create.TEAs = FALSE)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_false('value.active'%in%list.edge.attributes(testnet))
  > 
  > # run test on a smallish realistic dataset
  > vertexData <-read.table(system.file('extdata/cls33_10_16_96_vertices.tsv', 
  +                                     package='networkDynamic'),header=TRUE,stringsAsFactors=FALSE)
  > edgeData <-read.table(system.file('extdata/cls33_10_16_96_edges.tsv', 
  +                                   package='networkDynamic'),header=TRUE,stringsAsFactors=FALSE)
  > classDyn <- networkDynamic(vertex.spells=vertexData[,c(3,4,1)],
  +                              edge.spells=edgeData[,c(3,4,1,2,5,6)],
  +                              create.TEAs=TRUE,edge.TEA.names=c('weight','type'))
  Initializing base.net of size 20 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  weight, typeCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 49 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_equal(c('weight.active','type.active')%in%list.edge.attributes(classDyn),c(TRUE,TRUE))
  > # check that it actually stored some values
  > expect_equal(get.edge.attribute.active(classDyn,'weight',onset=0,terminus=5,rule='earliest'),c(1, 1, 1, 1, 1, 1, 1, 1, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,  0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,  0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2,  0.2, 0.2, 0.2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA))
  > 
  > expect_equal(get.edge.attribute.active(classDyn,'type',onset=0,terminus=5,rule='earliest'),c("social", "social", "sanction", "sanction", "sanction", "sanction",  "task", "task", "task", "task", "task", "task", "task", "task",  "task", "task", "task", "task", "task", "task", "task", "task",  "task", "task", "task", "task", "task", "task", "task", "task",  "task", "task", "task", "task", "task", "task", "task", "task",  "task", "task", "task", "task", "task", "task", "social", "social",  "social", "social", "social", "social", "social", "social", "social",  "social", "social", "social", NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,  NA))
  > 
  > 
  > # check a perverse case with unsorted values
  > testnumbers<-matrix(c(3,4,1,2, 2, 0.1,
  +                       1,2,1,2, 1, 0.5,
  +                       4,5,1,2, 0, 0.1),ncol=6,byrow=TRUE)
  > 
  > testnet<-networkDynamic(edge.spells=testnumbers,create.TEAs = TRUE,edge.TEA.names = c('value','weight'))
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_equal(testnet$mel[[1]]$atl$value.active[[2]], structure(c(1, 3, 4, 2, 4, 5), .Dim = c(3L, 2L)))
  > 
  > # check a perverse case with intersecting values
  > testnumbers<-matrix(c(3,9,1,2, 2, 0.1,
  +                       1,4,1,2, 1, 0.5,
  +                       4,6,1,2, 0, 0.1),ncol=6,byrow=TRUE)
  > 
  > expect_warning(networkDynamic(edge.spells=testnumbers,create.TEAs = TRUE,edge.TEA.names = c('value','weight')),regexp = 'invalid spell matrix for edge TEA')
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Activated TEA edge attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 9 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > 
  > #-------- networkDynamic() vertex spell tea tests ---------
  >   
  > # create an vertex spell matrix where the last two columns will be TEA vals
  > testnumbers<-matrix(c(1,2,1, 1, 0.5,
  +                       3,4,1, 2, 0.1,
  +                       4,5,1, 0, 0.1,
  +                       5,7,2, 3, -1,
  +                       5,7,3, 4, 1.5),ncol=5,byrow=TRUE)
  > 
  > testnet<-networkDynamic(vertex.spells=testnumbers,create.TEAs = TRUE,vertex.TEA.names = c('value','weight'))
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Activated TEA vertex attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > expect_true('value.active'%in%list.vertex.attributes(testnet))
  > expect_true('weight.active'%in%list.vertex.attributes(testnet))
  > 
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=1),c(1,NA,NA))
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=4),c(0,NA,NA))
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=5),c(NA,3,4))
  > expect_equal(get.vertex.attribute.active(testnet,'weight',at=5),c(NA,-1,1.5))
  > 
  > # test for mismatch between number of cols and number of names
  > expect_error(testnet<-networkDynamic(vertex.spells=testnumbers,create.TEAs = TRUE,vertex.TEA.names = c('value','weight','foo')),regexp = 'vertex.TEA.names must match the number of remaining columns in vertex')
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  > 
  > # now try with a non-numeric value
  > testletters<-data.frame(onset=c(1,2,5,5),
  +                         terminus=c(2,4,7,7),
  +                         vid=c(1,1,2,3),
  +                         value=c('A','B','C','D'),stringsAsFactors=FALSE)
  > testnet<-networkDynamic(vertex.spells=testletters,create.TEAs = TRUE,vertex.TEA.names = c('value'))
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Activated TEA vertex attributes:  valueCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > # careful, these tests fail if character vector in data frame is converted to a factor
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=1),c('A',NA,NA))
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=2),c('B',NA,NA))
  > expect_equal(get.vertex.attribute.active(testnet,'value',at=5),c(NA,'C','D'))
  > 
  > # test guessing col names from data.frame
  > testnet<-networkDynamic(vertex.spells=testletters,create.TEAs = TRUE,vertex.TEA.names = c('value'))
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Activated TEA vertex attributes:  valueCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_true('value.active'%in%list.vertex.attributes(testnet))
  > 
  > # make sure it doesn't create if instructed not to
  > testnet<-networkDynamic(vertex.spells=testletters,create.TEAs = FALSE)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 7 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_false('value.active'%in%list.vertex.attributes(testnet))
  > 
  > 
  > # check a perverse case with unsorted values
  > testnumbers<-matrix(c(3,4,1, 2, 0.1,
  +                       1,2,1, 1, 0.5,
  +                       4,5,1, 0, 0.1),ncol=5,byrow=TRUE)
  > 
  > testnet<-networkDynamic(vertex.spells=testnumbers,create.TEAs = TRUE,vertex.TEA.names = c('value','weight'))
  Initializing base.net of size 1 imputed from maximum vertex id in edge records
  Activated TEA vertex attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 5 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_equal(testnet$val[[1]]$value.active[[2]], structure(c(1, 3, 4, 2, 4, 5), .Dim = c(3L, 2L)))
  > 
  > # check a perverse case with intersecting values
  > testnumbers<-matrix(c(3,9,1, 2, 0.1,
  +                       1,4,1, 1, 0.5,
  +                       4,6,1, 0, 0.1),ncol=5,byrow=TRUE)
  > 
  > expect_warning(networkDynamic(vertex.spells=testnumbers,create.TEAs = TRUE,vertex.TEA.names = c('value','weight')),regexp = 'invalid spell matrix for vertex TEA')
  Initializing base.net of size 1 imputed from maximum vertex id in edge records
  Activated TEA vertex attributes:  value, weightCreated net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 9 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > # ----------- as.networkDynamic.data.frame tests -------
  > 
  > # check correct spells printed for edges
  > test <- network.initialize(3)
  > test[1,2]<-1
  > test[2,3]<-1
  > activate.edges(test,onset=1,terminus=2)
  > ref <- matrix(c(1,2,1,2,0,0,1,1, 1,2,2,3,0,0,1,2),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test) == ref)){
  +   stop("unexpected output for edge spells from as.networkDynamic.data.frame") 
  + }
  > 
  > test <- network.initialize(3)
  > test[1,2]<-1
  > test[2,3]<-1
  > activate.edges(test,at=3)
  > ref <- matrix(c(3,3,1,2,0,0,0,1, 3,3,2,3,0,0,0,2),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test) == ref)){
  +   stop("unexpected output for edge spells of zero length from as.networkDynamic.data.frame") 
  + }
  > 
  > # test for missing activity attribute (only set on one edge)
  > test <- network.initialize(3)
  > test[1,2]<-1
  > test[2,3]<-1
  > activate.edges(test,at=3,e=1)
  > as.data.frame(test)
    onset terminus tail head onset.censored terminus.censored duration edge.id
  1     3        3    1    2          FALSE             FALSE        0       1
  2  -Inf      Inf    2    3           TRUE              TRUE      Inf       2
  > tryCatch(
  +   as.data.frame(test), error = function(e){ warning(paste("error in as.networkDynamic.data.frame  for edge with missing activity attribute",e))} )
    onset terminus tail head onset.censored terminus.censored duration edge.id
  1     3        3    1    2          FALSE             FALSE        0       1
  2  -Inf      Inf    2    3           TRUE              TRUE      Inf       2
  > 
  > 
  > #check for duration for funny length spells
  > test <- network.initialize(3)
  > test[1,2]<-1
  > test[2,3]<-1
  > activate.edges(test,at=1,e=1)
  > activate.edges(test,onset=2.7,terminus=5, e=2)
  > ref <- matrix(c(1.0,1,1,2,0,0,0,1, 2.7,5,2,3,0,0,2.3,2),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test) == ref)){
  +   stop("unexpected output for edge spells from as.networkDynamic.data.frame") 
  + }
  > 
  > # check multiple spells per edge
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=1,terminus=2)
  > activate.edges(test,onset=3,terminus=4)
  > ref <- matrix(c(1,2,1,2,0,0,1,1, 3,4,1,2,0,0,1,1),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test) == ref)){
  +   stop("unexpected output for multiple spells per edge for as.networkDynamic.data.frame") 
  + }
  > 
  > # check censoring arguments when passed in
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=-Inf,terminus=10)
  > ref <- matrix(c(5,10,1,2,1,0,5,1),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test,start=5) == ref)){
  +   stop("unexpected output for 'start' left censoring argument from as.networkDynamic.data.frame") 
  + }
  > 
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=0,terminus=Inf)
  > ref <- matrix(c(0,5,1,2,0,1,5,1),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test,end=5) == ref)){
  +   stop("unexpected output for 'end' left censoring argument from as.networkDynamic.data.frame") 
  + }
  > 
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=-Inf,terminus=Inf)
  > ref <- matrix(c(-Inf,Inf,1,2,1,1,Inf, 1),ncol=8,byrow=TRUE)
  > if (!all(as.data.frame(test) == ref)){
  +   warning("unexpected output for as.networkDynamic.data.frame: Inf and -Inf times not treated as censored") 
  + }
  > 
  > # check censoring arguments when set on input object using attr
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=-Inf,terminus=Inf)
  > attr(test,"start")<-5
  > expect_warning(as.data.frame(test),'has been deprecated',info='specifying start and end using attrs deprecated')
  > #skye: this seems to work, but I want to remove the feature in favor of net.obs.period
  > 
  > 
  > # test using net.obs.period
  > test <- network.initialize(3)
  > test[1,2]<-1
  > activate.edges(test,onset=-Inf,terminus=Inf)
  > set.network.attribute(test,'net.obs.period',list(observations=list(c(5,10)),mode='discrete',time.increment=1,time.unit='step'))
  > expect_equivalent(as.numeric(as.data.frame(test)[,1:2]),c(5,10),info='net.obs.list provides censoring info')
  > 
  > 
  > # =============== TESTING networkDynamic ===========================
  > 
  > # working 9/3/2012. Just compare the data frame output with edgetimes
  > # a really crude edgelist example
  > edgetimes <- as.data.frame(matrix( c(1,2,1,2, 1,2,3,4,  2,3,1,3 ),ncol=4,byrow=TRUE))
  > edgetimetest<-networkDynamic(edge.spells = edgetimes)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 3 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > # do the edges and spells match when spit back out?
  > if (!all(as.data.frame(edgetimetest)[,1:4]==edgetimes)){
  +   stop("output spell matrix does not match input for networkDynamic()")
  + }
  > 
  > #does the internal representation match?
  > if( !all(as.vector(edgetimetest$mel[[1]]$atl$active) == c(1,2))){
  +   stop("networkDynamic() gave unexpected internal representation spells")
  + }
  > 
  > 
  > # combining multiple spells (should combine the spells for edge between v1 and v2)
  > edgetimes <- as.data.frame(matrix( c(1,2,1,2, 2,3,1,2,  1,2,3,4 ),ncol=4,byrow=TRUE))
  > edgetimetest<-networkDynamic(edge.spells = edgetimes)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 3 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (!all(as.data.frame(edgetimetest)[,1:4]==matrix(c(1,3,1,2, 1,2,3,4),ncol=4,byrow=TRUE))){
  +   stop("output spell matrix did not merge input spells as expected for networkDynamic()")
  + }
  > 
  > 
  > # with censoring
  > # Skye:  why does input of Inf mean that it is right censored?
  > edgetimes <- as.data.frame(matrix( c(1,Inf,1,2, 2,3,2,3),ncol=4,byrow=TRUE))
  > edgetimetest<-networkDynamic(edge.spells = edgetimes)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until Inf 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (!all(as.data.frame(edgetimetest)[,1:4]==edgetimes)){
  +   stop("output spell matrix did not merge input spells as expected for networkDynamic()")
  + }
  > 
  > # with missing node (should fill in the missing node)
  > edgetimes <- as.data.frame(matrix( c(1,2,1,2, 2,4,1,2,  1,2,1,4 ),ncol=4,byrow=TRUE))
  > edgetimetest<-networkDynamic(edge.spells = edgetimes)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 4 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > if (network.size(edgetimetest)!=4){
  +   stop("networkDynamic() did not create network with implied size of 4")
  + }
  > 
  > 
  > # create with vertex and edge dynamics specified
  > nodetimes <-as.data.frame(matrix( c(1,1,2,1, 2,2,3,2,  3,3,4,3 ),ncol=4,byrow=TRUE))
  > edgetimes <- as.data.frame(matrix( c(1,2,1,2, 2,4,1,2,  1,2,1,4 ),ncol=4,byrow=TRUE))
  > nd<-networkDynamic(vertex.spells=nodetimes,edge.spells=edgetimes)
  Initializing base.net of size 4 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 4 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > 
  > # check for net.obs.period
  > expect_equal((nd%n%'net.obs.period')$observations[[1]],c(1,4),info='net.obs.period created by default by networkDynamic(vertex.spells,edge.spells) did not have expected range')
  > 
  > # ---- networkDynamic changes conversion ----
  > #[time,tail,head,direction]
  > echange<-matrix( c(1,1,2,1, 
  +                    2,1,2,0,
  +                    2,2,3,1,
  +                    3,1,3,0),ncol=4,byrow=TRUE)
  > 
  > nd<-networkDynamic(edge.changes=echange)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > # the expected output
  > spls<-data.frame(onset=c(1,2,-Inf),terminus=c(2,Inf,3),tail=c(1,2,1),head=c(2,3,3),onset.censored=c(FALSE,FALSE,TRUE),terminus.censored=c(FALSE,TRUE,FALSE),duration=c(1,Inf,Inf),edge.id=c(1,2,3))
  > 
  > # check that spells constructed correctly from edge.changes
  > expect_equivalent(as.data.frame(nd),spls,info='comparing networkDynamic(edge.changes) to resulting spell list')
  > 
  > # check net.obs.period construction
  > expect_equal((nd%n%'net.obs.period')$observations[[1]],c(-Inf,Inf),info='net.obs.period created by default by networkDynamic(edge.changes) did not have expected range')
  > 
  > expect_equal((nd%n%'net.obs.period')$mode,'discrete',info='net.obs.period created by default by networkDynamic(edge.changes) did not have expected mode')
  > 
  > # [time,vertex.id,direction,red_herring]
  > vchange<-matrix( c(1,1,1, 
  +                    2,1,0,
  +                    2,2,1,
  +                    3,3,0),ncol=3,byrow=TRUE)
  > 
  > nd<-networkDynamic(vertex.changes=vchange)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equivalent(get.vertex.activity(nd,as.spellList=TRUE),data.frame(onset=c(1,2,-Inf),terminus=c(2,Inf,3),vertex.id=c(1,2,3),onset.censored=c(FALSE,FALSE,TRUE),terminus.censored=c(FALSE,TRUE,FALSE),duration=c(1,Inf,Inf)),info='networkDynamic(vertex.change) did not give expected spell list result')
  > 
  > 
  > # [time,vertex.id,direction,red_herring]
  > # checks for internal bug in column name assignments
  > vchange<-matrix( c(1,1,1,5, 
  +                    2,1,0,6,
  +                    2,2,1,7,
  +                    3,3,0,8),ncol=4,byrow=TRUE)
  > nd<-networkDynamic(vertex.changes=vchange)
  Initializing base.net of size 3 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_equivalent(get.vertex.activity(nd,as.spellList=TRUE),data.frame(onset=c(1,2,-Inf),terminus=c(2,Inf,3),vertex.id=c(1,2,3),onset.censored=c(FALSE,FALSE,TRUE),terminus.censored=c(FALSE,TRUE,FALSE),duration=c(1,Inf,Inf)),info='networkDynamic(vertex.change) did not give expected spell list result')
  > 
  > 
  > # ----- networkDynamic network.list conversion ----
  > 
  > # does it create a dynamic network
  > d1 <- network.initialize(3)
  > d1[1,2]<-1
  > d2 <- network.initialize(3)
  > d2[1,2]<-1
  > d2[2,3]<-1
  > d3 <- network.initialize(3)
  > d3[3,1]<-1
  > 
  > # default timing
  > ddyn <- networkDynamic(network.list = list(d1,d2,d3))
  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 3 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > if(!is.networkDynamic(ddyn)){
  +   stop("as.networkDynamic.list didn't create a dynamic network from ")
  + }
  > 
  > # check that correct spells with unit lengths were created
  > ref <- matrix(c(0,2,1,2,0,0,2, 1,2,2,3,0,0,1, 2,3,3,1,0,0,1),ncol=7,byrow=TRUE)
  > if (!all(as.data.frame(ddyn)[,1:7]==ref)){
  +   stop("correct unit length spells were not created for list input networks in networkDynamic()")
  + }
  > 
  > # check that default net.obs.period created
  > expect_equal((ddyn%n%'net.obs.period')$observations[[1]],c(0,3),info='was net.obs.period created by default by networkDynamic() did not have expected range')
  > 
  > # does it preserve network attributes of passed in network
  > d1 <- network.initialize(2,directed=F,bipartite=T,multiple=T,loops=T)
  > d2 <- network.initialize(2,directed=F,bipartite=T,multiple=T,loops=T)
  > dlist <- list(d1,d2)
  > ddyn <- networkDynamic(network.list = dlist)
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > if (is.directed(ddyn) != FALSE){
  +   stop("'directed' argument if initial network in list not respected in dynamic version")
  + }
  > if (is.bipartite(ddyn) != TRUE){
  +   stop("'bipartite' argument if initial network in list not respected in dynamic version")
  + }
  > if (is.multiplex(ddyn) != TRUE){
  +   stop("'multiple' argument if initial network in list not respected in dynamic version")
  + }
  > if (has.loops(ddyn) != TRUE){
  +   stop("'loops' argument if initial network in list not respected in dynamic version")
  + }
  > 
  > 
  > # does it warn if network attributes of passed in networks do not match
  > # working 9/10
  > d1 <- network.initialize(2,directed=F)
  > d2 <- network.initialize(2,directed=T)
  > dlist <- list(d1,d2)
  > expect_warning(networkDynamic(network.list = dlist), "have different network properties",info="different network attributes in network.list did not result in a warning")
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > # are vertex attributes included?
  > d1 <- network.initialize(2)
  > d2 <- network.initialize(2)
  > dbase<-network.initialize(2)
  > set.vertex.attribute(dbase,"test","one")
  > set.network.attribute(dbase,'another',"two")
  > dlist <- list(d1,d2)
  > dnet<-networkDynamic(base.net=dbase,network.list = dlist)
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > expect_true('test'%in%list.vertex.attributes(dnet),info="vertex attributes from base.net network not copied by networkDynamic()")
  > 
  > expect_true('another'%in%list.network.attributes(dnet),info="user specified network attributes from base.net network not copied by networkDynamic()")
  > 
  > dlist[[1]]<-set.vertex.attribute(dlist[[1]],"test","one")
  > dlist[[1]]<-set.network.attribute(dlist[[1]],'another',"two")
  > dnet<-networkDynamic(network.list = dlist)
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_true('test'%in%list.vertex.attributes(dnet),info="vertex attributes from first item of network list network not copied by networkDynamic()")
  > 
  > expect_true('another'%in%list.network.attributes(dnet),info="user specified network attributes from base.net network not copied by networkDynamic()")
  > 
  > dnet<-networkDynamic(network.list = dlist,create.TEAs=TRUE)
  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
  Dynamic attributes (TEAs) will be created for the following attributes of the networks on network.list:
  	Network:  another 
  	Vertices:  test 
  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 2 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > expect_true('test.active'%in%list.vertex.attributes(dnet),info="vertex attributes from first item of network list network not copied as TEA by networkDynamic()")
  > 
  > expect_true('another.active'%in%list.network.attributes(dnet),info="user specified network attributes from base.net network not copied as TEA by networkDynamic()")
  > 
  > 
  > # are edge attributes included
  > 
  > # specify net.obs.period
  > d1 <- network.initialize(3)
  > d1[1,2]<-1
  > d2 <- network.initialize(3)
  > d2[1,2]<-1
  > d2[2,3]<-1
  > d3 <- network.initialize(3)
  > d3[3,1]<-1
  > nop = list(observations=list(c(3,5)), mode="discrete", time.increment=1,time.unit="step")
  > ddyn <- networkDynamic(network.list = list(d1,d2,d3), net.obs.period=nop)
  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: 3 until 5 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > expect_false(is.null(ddyn%n%'net.obs.period'),info="net.obs.period argument in input to networkDynamic reproduced in output")
  > 
  > 
  > 
  > # check for error when edge spell list has only one row issue #190
  > edge.spls <-matrix( c(1,2,1,2),ncol=4,byrow=TRUE)
  > nd <-networkDynamic(edge.spells=edge.spls)
  Initializing base.net of size 2 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 1 until 2 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > expect_equivalent(as.matrix(get.edge.activity(nd,as.spellList=TRUE)[,1:4]),edge.spls,info="check when edge spell list has only one row")
  > 
  > 
  > # check for char data in input tables edge spells
  > net <-network.initialize(4)
  > edgetimes <- as.data.frame( list(c("1",1,2),c(2,2,3),c(1,3,1),c(2,4,3)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.spells = edgetimes),"the onset time column of the edge.spells argument to networkDynamic must be numeric",info="testing non-numeric input to networkDynamic edgespells onset")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,"2",3),c(1,3,1),c(2,4,3)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.spells = edgetimes),"the terminus time column of the edge.spells argument to networkDynamic must be numeric",info="testing non-numeric input to networkDynamic edgespells terminus")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,2,3),c(1,"3",1),c(2,4,3)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.spells = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edgespells terminus")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,2,3),c(1,3,1),c(2,4,"3")))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.spells = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edgespells terminus")
  > 
  > # check for char data in input tables edge toggles
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,"2",3),c(1,0,1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.toggles = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edge.toggles tail")
  > 
  > edgetimes <- as.data.frame( list(c(1,"1",2),c(2,2,3),c(1,0,1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.toggles = edgetimes),"must be numeric",info="testing non-numeric input to networkDynamic edge.toggles time")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,2,3),c(1,"0",1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.toggles = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edge.toggles head")
  > 
  > 
  > # check for char data in input tables edge changes
  > edgetimes <- as.data.frame( list(c(1,"1",2),c(2,2,3),c(2,4,3),c(1,0,1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.changes = edgetimes),"must be numeric",info="testing non-numeric input to networkDynamic edge.changes time")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,2,"3"),c(2,4,3),c(1,0,1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.changes = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edge.changes tail")
  > 
  > edgetimes <- as.data.frame( list(c(1,1,2),c(2,2,3),c(2,4,"3"),c(1,0,1)))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.changes = edgetimes),"must be a numeric",info="testing non-numeric input to networkDynamic edge.changes head")
  > 
  > edgetimes <- as.data.frame(list(c(1,1,2),c(2,2,3),c(2,4,3),c(1,0,"1")))
  > expect_error(edgetimetest<-networkDynamic(base.net=net,edge.changes = edgetimes),"must be numeric",info="testing non-numeric input to networkDynamic edge.changes direction")
  > 
  > 
  > # check for char data in input tables vertex toggles
  > 
  > verttimes <- as.data.frame(list(c(1,"1",2),c(1,2,3)))
  > expect_error(networkDynamic(base.net=net,vertex.toggles = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.toggles time")
  > 
  > verttimes <- as.data.frame(list(c(1,1,2),c(1,2,"3")))
  > expect_error(networkDynamic(base.net=net,vertex.toggles = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.toggles vertex.id")
  > 
  > # check for char data in input tables vertex spells
  > verttimes <- as.data.frame(list(c(1,"1",2),c(1,1,2),c(1,2,3)))
  > expect_error(networkDynamic(base.net=net,vertex.spells = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.spells onset")
  > 
  > verttimes <- as.data.frame(list(c(1,1,2),c(1,"1",2),c(1,2,3)))
  > expect_error(networkDynamic(base.net=net,vertex.spells = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.spells terminus")
  > 
  > verttimes <- as.data.frame(list(c(1,1,2),c(1,1,2),c(1,2,"3")))
  > expect_error(networkDynamic(base.net=net,vertex.spells = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.spells vertex.id")
  > 
  > # check for char data in input tables vertex changes
  > 
  > verttimes <- as.data.frame(list(c(1,"1",2),c(1,1,2),c(1,0,1)))
  > expect_error(networkDynamic(base.net=net,vertex.changes = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.changes time")
  > 
  > verttimes <- as.data.frame(list(c(1,1,2),c(1,"1",2),c(1,0,1)))
  > expect_error(networkDynamic(base.net=net,vertex.changes = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.changes vertex.id")
  > 
  > verttimes <- as.data.frame(list(c(1,1,2),c(1,1,2),c(1,0,"1")))
  > expect_error(networkDynamic(base.net=net,vertex.changes = verttimes),"be numeric",info="testing non-numeric input to networkDynamic vertex.changes direction")
  > 
  > # network list with network size 0
  > 
  > expect_equal(network.size(networkDynamic(network.list=list(network.initialize(0)))),0)
  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 1 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > 
  > # check for edge.spells plus base.net with pre-existing edges bug #556
  > test<-network.initialize(3)
  > test[1,2]<-1
  > networkDynamic(base.net=test,edge.spells=matrix(c(0,1,1,2),ncol=4))
  Edge activity in base.net was ignored
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 1 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  NetworkDynamic properties:
    distinct change times: 2 
    maximal time range: 0 until  1 
  
  Includes optional net.obs.period attribute:
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 0 until 1 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  
   Network attributes:
    vertices = 3 
    directed = TRUE 
    hyper = FALSE 
    loops = FALSE 
    multiple = FALSE 
    bipartite = FALSE 
    net.obs.period: (not shown)
    total edges= 1 
      missing edges= 0 
      non-missing edges= 1 
  
   Vertex attribute names: 
      vertex.names 
  
   Edge attribute names: 
      active 
  > 
  > 
  > # =============== TESTING as.data.frame.networkDynamic ====
  > message('testing as.data.frame.networkDynamic\n')
  testing as.data.frame.networkDynamic
  
  > #lets try passing in a noncensored and duration, see if we get the same things back
  > edgetimes <- as.data.frame(matrix( c(1,2,1,2,0,0, 3,5,1,2,0,0,1,2,3,4,0,0, 3,4,2,4,0,0 ),ncol=6,byrow=TRUE))
  > colnames(edgetimes)<-c("onset","terminus","tail","head","onset.censored","terminus.censored")
  > testnet <- network.initialize(4)
  > add.edges.active(testnet,onset=1,terminus=2,tail=1,head=2)
  > add.edges.active(testnet,onset=1,terminus=2,tail=3,head=4)
  > activate.edges(testnet,onset=3,terminus=5,e=get.edgeIDs(testnet, v=1,alter=2))
  > add.edges.active(testnet,onset=3,terminus=4,tail=2,head=4)
  > # these should match
  > if (!all(as.data.frame(testnet)[,1:6] == edgetimes)){
  +   stop("FAIL: output data.frame from as.data.frame.networkDynamic did not match input")
  + }
  > 
  > #check column names
  > if(!all(names(as.data.frame(testnet))==c("onset","terminus","tail","head","onset.censored","terminus.censored","duration","edge.id"))){
  +   stop("Unexpected column names returned by as.data.frame.networkDynamic")
  +   
  + }
  > 
  > # censoring should set the appropriate start or end to Inf
  > # skye: Is this the behavior we want for as.data.frame?
  > edgetimes <- as.data.frame(matrix( c(0,2,1,2,1,0,2, 3,5,1,2,0,0,2,  1,2,3,4,0,0,1, 3,6,2,4,0,1,3 ),ncol=7,byrow=TRUE))
  > colnames(edgetimes)<-c("onset","terminus","tail","head","onset.censored","terminus.censored","duration")
  > testnet <- network.initialize(4)
  > add.edges.active(testnet,onset=-Inf,terminus=2,tail=1,head=2)
  > add.edges.active(testnet,onset=1,terminus=2,tail=3,head=4)
  > activate.edges(testnet,onset=3,terminus=5,e=get.edgeIDs(testnet, v=1,alter=2))
  > add.edges.active(testnet,onset=3,terminus=Inf,tail=2,head=4)
  > 
  > # these should match
  > if(!all(as.data.frame(testnet,start=0,end=6)[-8]==edgetimes)){
  +   stop("as.data.frame.networkDynamic gave unexpected censored spell matrix output")
  + }
  > 
  > # check censoring for non-Inf edges when start and end are set narrower
  > tel<-matrix(c(40,  72,  10, 4,
  +          214, 247, 1,  11,  
  +          224, 256, 7,10),ncol=4,byrow=TRUE)
  > test<-networkDynamic(edge.spells=tel) 
  Initializing base.net of size 11 imputed from maximum vertex id in edge records
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 40 until 256 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > result<-as.data.frame(test,start=50,end=60)
  > expect_equal(nrow(result),1)
  > expect_equal(as.numeric(result[,1:4]),c(50,60,10,4))
  > expect_equal(as.logical(result[,5:6]),c(TRUE,TRUE))
  > 
  > 
  > 
  > # properly handle edges with no spell activity
  > test <- network.initialize(3)
  > test[1,2]<-1
  > test[2,3]<-1
  > activate.edges(test,at=3,e=1)
  > temp = as.data.frame(test,active.default=FALSE)
  > if (!all(temp == c(3,3,1,2,F,F,0,1))) stop('did not handle edges without spell activity')
  > 
  > expect_equivalent(as.data.frame(test,active.default=TRUE),
  + data.frame(onset=c(3,-Inf),terminus=c(3,Inf),
  +           tail=c(1,2),head=c(2,3),onset.censored=c(FALSE,TRUE),
  +            terminus.censored=c(FALSE,TRUE),duration=c(0,Inf),edge.id=c(1,2)),
  +                   info="test active.default=TRUE for edge with no spell")
  > 
  > 
  > # properly handle nD object with no edges at all
  > # active default means it should still return two edges
  > net <-network.initialize(3)
  > activate.vertices(net, onset=1, terminus=Inf)
  > temp<-as.data.frame(net)
  > 
  > if (nrow(temp) != 0) {
  +   stop("as.data.frame.networkDynamic() did not handle an object without any edge activity")
  + }
  > 
  > # check for crash with network size 0
  > expect_equal(nrow(get.edge.activity(network.initialize(0),as.spellList=TRUE)),0)
  > 
  > # check active.default
  > net<-network.initialize(3)
  > add.edges(net,tail=1:3,head=c(2,3,1))
  > expect_equal(get.edge.activity(net,as.spellList=TRUE)$onset,c(-Inf,-Inf,-Inf))
  > expect_equal(nrow(get.edge.activity(net,as.spellList=TRUE,active.default=FALSE)),0)
  > 
  > # check for 'null' spell
  > net<-network.initialize(3)
  > add.edges(net,tail=1:3,head=c(2,3,1))
  > deactivate.edges(net,e=2)
  > spls<-as.data.frame(net,as.spellList=TRUE)
  > expect_equal(spls$onset,c(-Inf,-Inf),info='check for null spell and active.default')
  > expect_equal(spls$terminus,c(Inf,Inf),info='check for null spell and active.default')
  > expect_equal(spls$edge.id,c(1,3),info='check for null spell and active.default')
  > 
  > expect_equal(nrow(as.data.frame(net,as.spellList=TRUE,active.default=FALSE)),0,info='check for null spell and active.default=FALSE')
  > 
  > # check for multiplex case
  > 
  > nd <-network.initialize(2,multiple=TRUE)
  > add.edges.active(nd,onset=12,terminus=12.1,tail=1,head=2)
  > add.edges.active(nd,onset=12,terminus=12.5,tail=1,head=2)
  > as.data.frame(nd)
    onset terminus tail head onset.censored terminus.censored duration edge.id
  1    12     12.1    1    2          FALSE             FALSE      0.1       1
  2    12     12.5    1    2          FALSE             FALSE      0.5       2
  > expect_equal(nrow(as.data.frame(nd)),2,info="test as.data.frame with multiplex network")
  > 
  > # check for correct sort ordering  by onset,terminus, edge.id
  > m<-matrix(c(10,11,1,2,  12,13,1,2, 5,6,2,3, 12,13,2,3, 12,12.5,1,3  ),ncol=4,byrow=TRUE)
  > nd<-networkDynamic(network.initialize(3,multiple=TRUE),edge.spells=m)
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 5 until 13 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > # add in an edge to test multiplex case
  > add.edges.active(nd,onset=12,terminus=12.1,tail=1,head=3)
  > ndmat<-as.data.frame(nd)
  > expect_equal(ndmat$onset,c(5,12,10,12,12,12),info='check as.data.frame.networkDynamic onset sorting')
  > expect_equal(ndmat$terminus,c(6,13,11,13,12.5,12.1),info='check as.data.frame.networkDynamic terminus sorting')
  > expect_equal(ndmat$edge.id,c(1,1,2,2,3,4),info='check as.data.frame.networkDynamic edge.id sorting')
  > 
  > # check that e argument removes appropriate edges' spells
  > ndmat<-as.data.frame(nd,e=c(1,4))
  > expect_equal(ndmat$edge.id,c(1,1,4),info='check that e argument removes edge spells from as.data.frame.networkDynamic')
  > 
  > # check for behavior with deleted edges
  > m<-matrix(c(10,11,1,2,  12,13,1,2, 5,6,2,3, 12,13,2,3, 12,12.5,1,3  ),ncol=4,byrow=TRUE)
  > nd<-networkDynamic(network.initialize(3,multiple=TRUE),edge.spells=m)
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: 5 until 13 
    Temporal mode: continuous 
    Time unit: unknown 
    Suggested time increment: NA 
  > # add in an edge to test multiplex case
  > add.edges.active(nd,onset=12,terminus=12.1,tail=1,head=3)
  > delete.edges(nd,eid=2)
  > ndmat<-as.data.frame(nd)
  > expect_equal(ndmat$edge.id,c(1,1,3,4),info='check that deleted edge doesnt cause problem for as.data.frame.networkDynamic')
  > 
  > # check for appropriate exclusion of terminating edges
  > test<-network.initialize(3)
  > add.edges.active(test,tail=c(1,2,3),head=c(2,3,1),onset=c(0,1,2),terminus=c(1,2,3))
  > # first edge should be excluded because it lies entirly outside query range
  > # second edge could be excluded because it terminates at onset of query range
  > expect_equal(as.data.frame(test,start=2,end=3)$edge.id,3)
  > # also check for appropriate inclusion at other boundry
  > expect_equal(as.data.frame(test,start=1,end=2)$edge.id,2)
  > 
  > # and for at spell query
  > test<-network.initialize(3)
  > add.edges.active(test,tail=c(1,2,3,3),head=c(2,3,1,1),onset=c(0,1,2,1),terminus=c(1,2,3,1))
  > expect_equal(as.data.frame(test,start=1,end=1)$edge.id,c(2,4))
  > 
  > 
  > # ----- get.edge.activity ----
  > # some of this is not tested becaue it actually calls as.data.frame internally
  > 
  > # check subsetting with e argument
  > net<-network.initialize(5)
  > add.edges.active(net,tail=1:4,head=2:5,onset=1:4,terminus=2:5)
  > expect_equal(unlist(get.edge.activity(net)),c(1,2,2,3,3,4,4,5))
  > 
  > expect_equivalent( get.edge.activity(net,as.spellList=TRUE,e=2:3),
  +                     data.frame(onset=2:3,terminus=3:4,tail=2:3,head=3:4,
  +                     onset.censored=c(FALSE,FALSE),terminus.censored=c(FALSE,FALSE),
  +                                duration=c(1,1),edge.id=2:3) ,
  +                    info="test edge activity subsetting with e")
  > 
  > expect_equal(unlist(get.edge.activity(net,e=2:3)),c(2,3,3,4))
  > 
  > 
  > expect_equal(get.edge.activity(network.initialize(0)),list())
  > 
  > # test with ordinary net and default activity
  > net<-network.initialize(3)
  > add.edges(net,c(1,2,3),c(2,3,1))
  > 
  > expect_equal(sapply(get.edge.activity(net,active.default=FALSE),is.null),
  +              c(TRUE,TRUE,TRUE),info='check get.edge.activity with ordinary net and active.default=FALSE')
  > 
  > expect_equal(unlist(get.edge.activity(net,active.default=TRUE)),
  +              c(-Inf,Inf,-Inf,Inf,-Inf,Inf),info='check get.edge.activity with ordinary net and active.default=TRUE')
  > 
  > # can it distinguish from deleted edges?
  > 
  > delete.edges(net,e=2)
  > spls<-get.edge.activity(net,active.default=TRUE)
  > expect_true(is.null(spls[[2]]),info='check get.edge.activity with ordinary net and active.default=TRUE distinguish deleted edge')
  > expect_equal(spls[[3]],matrix(c(-Inf,Inf),ncol=2),info='check get.edge.activity with ordinary net and active.default=TRUE distinguish deleted edge')
  > 
  > # test `null` spell
  > net<-network.initialize(3)
  > add.edges(net,c(1,2,3),c(2,3,1))
  > deactivate.edges(net,e=2)
  > expect_equal(sapply(get.edge.activity(net,active.default=FALSE),is.null),
  +              c(TRUE,TRUE,TRUE),info='check get.edge.activity with ordinary net and null spell active.default=FALSE')
  > 
  > spls<-get.edge.activity(net,active.default=TRUE)
  > expect_true(is.null(spls[[2]]),info='check get.edge.activity with ordinary net and active.default=TRUE distinguish deleted edge')
  > expect_equal(spls[[3]],matrix(c(-Inf,Inf),ncol=2),info='check get.edge.activity with ordinary net and active.default=TRUE and null spell')
  > 
  > # check that it doesn't censor by default with net.obs.period
  > net<-network.initialize(2)
  > add.edges.active(net,tail=1,head=2,onset=-Inf,terminus=Inf)
  > net%n%'net.obs.period'<-list(observations=list(c(0,100)),mode="discrete", time.increment=1,time.unit="step")
  > expect_equal(as.numeric(get.edge.activity(net,as.spellList=TRUE)[1:2]),c(-Inf,Inf))
  > 
  > 
  > 
  > 
  > # ------- networkDynamic from toggles (function used by TERGM) ------------
  > 
  > test <- network.initialize(3)
  > test[1,3]<-1
  > tog <- matrix(c(1,1,2, 1,2,3, 2,1,2, 4,1,3, 4,1,2), ncol=3, byrow=TRUE)
  > net<-networkDynamic(base.net=test,edge.toggles=tog)
  Edge activity in base.net was ignored
  Created net.obs.period to describe network
   Network observation period info:
    Number of observation spells: 1 
    Maximal time range observed: -Inf until Inf 
    Temporal mode: discrete 
    Time unit: step 
    Suggested time increment: 1 
  > spells <-as.data.frame(net)[1:6]
  > # first spell should be onset censored because edge was in original net
  > # all edges in original net are considered active before toggles
  > if (!all(spells[1,]==c(-Inf,4,1,3,1,0))){
  +   stop("networkDynamic() did not record initial toggle correctly")
  + }
  > # 2nd spell toggles twice
  > if (!all(spells[2,]==c(1,2,1,2,0,0))){
  +   stop("networkDynamic() did not record double toggle correctly")
  + }
  > if (!all(spells[4,]==c(1,Inf,2,3,0,1)) | !all(spells[3,]==c(4,Inf,1,2,0,1))){
  +   stop("networkDynamic() did not record toggles correctly")
  + }
  > 
  > # check for net.obs.period
  > expect_equal((net%n%'net.obs.period')$observations[[1]],c(-Inf,Inf),info='net.obs.period created by default by networkDynamic(edge.toggles) did not have expected range')
  > 
  > expect_equal((net%n%'net.obs.period')$mode,'discrete',info='net.obs.period created by default by networkDynamic(edge.toggles) did not have expected mode')
  > 
  > 
  > 
  > 
  > # ==================== TESTING duration.matrix
  > # this function is used internally by as.networkDynamic.network() and should not be called by user
  > net <-network.initialize(3)
  > net[1,2]<-1;
  > net[2,3]<-1;
  > net[1,3]<-1;
  > # toggle list: time, tail, head
  > tog<-matrix(c(1,1,2, 1,2,3, 2,1,2, 4,1,3, 4,1,2), ncol=3, byrow=TRUE)
  > # we expect this matrix
  > ref <- matrix(c(0,1,1,2,1,0,1, 0,1,2,3,1,0,1, 0,4,1,3,1,0,4, 2,4,1,2,0,0,2),ncol=7,byrow=TRUE)
  > if (!all(networkDynamic:::duration.matrix(net, changes=tog, start=0, end=5)==ref)){
  +   stop("duration.matrix returned an unexpected spell list for its input toggles")
  + }
  > # testing start and end
  > ref1 <- matrix(c(1,1,1,2,1,0,0, 1,1,2,3,1,0,0, 1,4,1,3,1,0,3, 2,4,1,2,0,0,2),ncol=7,byrow=TRUE)
  > if (!all(networkDynamic:::duration.matrix(net, changes=tog, start=1, end=5)==ref1)){
  +   stop("duration.matrix returned an unexpected spell list for its input toggles")
  + }
  > # testing start and end
  > ref2 <- matrix(c(0,1,1,2,1,0,1, 0,1,2,3,1,0,1, 0,4,1,3,1,0,4, 2,4,1,2,0,0,2),ncol=7,byrow=TRUE)
  > if (!all(networkDynamic:::duration.matrix(net, changes=tog, start=0, end=8)==ref2)){
  +   stop("duration.matrix returned an unexpected spell list for its input toggles")
  + }
  > 
  > networkDynamic:::duration.matrix(network.initialize(0),changes=tog,start=0,end=1)
    start end tail head left.censored right.censored duration
  1     1   1    1    2         FALSE           TRUE        0
  2     1   1    2    3         FALSE           TRUE        0
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
    10.57    0.84   11.42 
Running the tests in 'tests/get_tests.R' failed.
Complete output:
  > ########################################################################
  > # This file contains the testing suite for the "get" methods, i.e.:
  > #      get.edgeIDs.active
  > #      get.edges.active
  > #      get.neighborhood.active     
  > #      get.change.times
  > #########################################################################
  > 
  > require(networkDynamic)
  Loading required package: networkDynamic
  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
  
  
  '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
  
  > require(testthat)
  Loading required package: testthat
  > 
  > #---------------- GET.CHANGE.TIMES TESTS ------------------------
  > # Notes:
  > #  -- minimal level of testing done here. sorry -- alc 6/28/12
  > #-------------------------------------------------------------------
  > 
  > cat("testing get.change.times ... ")
  testing get.change.times ... > 
  > # a case with no change times
  > data(flo)
  > net1 = network(flo)
  > t1 = get.change.times(net1)
  > a1 = (length(t1) == 0)
  > 
  > # a case with only edge change times
  > activate.edges(net1, onset=1:20, terminus=101:120)
  > t2 = get.change.times(net1, edge.activity=F)
  > t3 = get.change.times(net1)
  > a2 = (length(t2) == 0)
  > a3 = all(t3==c(1:20, 101:120))
  > 
  > # a case with only vertex change times
  > net2 = network(flo)
  > activate.vertices(net2, at=seq(2,32,2))
  > t4 = get.change.times(net2, vertex.activity=F)
  > t5 = get.change.times(net2)
  > a4 = (length(t4) == 0)
  > a5 = all(t5 == seq(2,32,2))
  > 
  > # a case with both types of change times
  > activate.edges(net2, at=60:99)
  > t6 = get.change.times(net2, vertex.activity = F)
  > t7 = get.change.times(net2, edge.activity = F)
  > t8 = get.change.times(net2)
  > a6 = all(t6 == 60:99)
  > a7 = all(t7 == seq(2,32,2))
  > a8 = all(t8 == c(seq(2,32,2), 60:99))
  > 
  > # a case with infinity
  > deactivate.edges(net1)
  > activate.edges(net2)
  > t9 = get.change.times(net1)
  > t10 = get.change.times(net2)
  > t11 = get.change.times(net1, ignore.inf=F)
  > t12 = get.change.times(net2, ignore.inf=F)
  > a9 = (length(t9) == 0)
  > a10 = all(t10 == seq(2,32,2))
  > a11 = length(t11)==0
  > a12 = all(t12 == c(-Inf,seq(2,32,2),Inf))
  > a.tests = paste("a", seq(1,12), sep="")
  > a.results= sapply(a.tests, function(x){eval(parse(text=x))})
  > if(any(!a.results)){
  +   bad.tests = paste("a", which(!a.results), sep="", collapse=" ")
  +   stop(paste("get.change.times is returning incorrect times in tests",
  +              bad.tests))
  + }
  > 
  > 
  > # test when called on a nD with no edge times
  > 
  > # test vertex attributes stuff
  > net<-network.initialize(5)
  > activate.vertex.attribute(net,"number","one",onset=0,terminus=2)
  > activate.vertex.attribute(net,"number","two",onset=3,terminus=4)
  > activate.vertex.attribute(net,"number","three",onset=5,terminus=6)
  > 
  > expect_equal(get.change.times(net),c(0,2,3,4,5,6))
  > expect_equal(get.change.times(net,vertex.attribute.activity=FALSE),numeric(0))
  > 
  > # test if only some vertices have attribute
  > net<-network.initialize(5)
  > activate.vertex.attribute(net,"number","one",onset=0,terminus=2,v=1:2)
  > expect_equal(get.change.times(net),c(0,2),info="checking if only some vertices have activity attribute")
  > 
  > # test edge attribute stuff
  > net<-network.initialize(5)
  > net[1,2]<-1
  > activate.edge.attribute(net,"number","one",onset=0,terminus=2)
  > activate.edge.attribute(net,"number","two",onset=3,terminus=4)
  > activate.edge.attribute(net,"number","three",onset=5,terminus=6)
  > 
  > expect_equal(get.change.times(net),c(0,2,3,4,5,6),info='check edge attribute activity activity')
  > expect_equal(get.change.times(net,edge.attribute.activity=FALSE),numeric(0),info='ignore check edge attribute activity')
  > 
  > # test if only some edges have attributes
  > net<-network.initialize(5)
  > net[1,2]<-1
  > net[2,3]<-1
  > activate.edge.attribute(net,"number","one",onset=0,terminus=2,e=2)
  > expect_equal(get.change.times(net),c(0,2),info='check if only some edges have activity attribute')
  > 
  > # test with deleted edge
  > delete.edges(net,eid=1)
  > expect_equal(get.change.times(net),c(0,2),info='check if some edges deleted')
  > 
  > # test network attribute stuff
  > net<-network.initialize(5)
  > activate.network.attribute(net,"number","one",onset=0,terminus=2)
  > activate.network.attribute(net,"number","two",onset=3,terminus=4)
  > activate.network.attribute(net,"number","three",onset=5,terminus=6)
  > 
  > expect_equal(get.change.times(net),c(0,2,3,4,5,6),info='check network attribute activity activity')
  > expect_equal(get.change.times(net,network.attribute.activity=FALSE),numeric(0),info='ignore check network attribute activity')
  > 
  > # check if null spell
  > net<-network.initialize(2)
  > deactivate.vertices(net,onset=-Inf,terminus=Inf)
  > expect_equal(get.change.times(net,ignore.inf=FALSE),numeric(0),info="check for null spell")
  > 
  > expect_equal(get.change.times(network.initialize(0)),numeric(0))
  > 
  > cat("ok\n")
  ok
  > 
  > 
  > #---------------- GET.EDGEIDS.ACTIVE TESTS ------------------------
  > # Notes:
  > #  --this function is basicallly 2 lines, which call functions that
  > #    are well tested (get.edgeIDs by time, is.active by me), thus
  > #    the testing here is quite minimal
  > #-------------------------------------------------------------------
  > 
  > cat("testing get.edgeIDs.active ... ")
  testing get.edgeIDs.active ... > anet <- network.initialize(100)
  > set.seed(10)
  > heads <- sample(100, 150, replace=TRUE)
  > set.seed(25)
  > tails <- sample(100, 150, replace=TRUE)
  > add.edges(anet, tails, heads)
  > 
  > anet.copy <-anet
  > 
  > 
  > # only checking a few simple cases
  > iov = as.matrix(anet, matrix.type="edgelist")[1:8,]
  > activate.edges(anet, c(-Inf, -Inf,  10, 10, 10),
  +                      c( Inf,   20, Inf, 20, 10), e=2:6)
  > activate.edges(anet, 10, 20, e=7)
  > activate.edges(anet, 20, 30, e=7)
  > activate.edges(anet, 30, 30, e=7)
  > activate.edges(anet, 40, 50, e=7)
  > deactivate.edges(anet, e=8)
  > spells = lapply(lapply(anet$mel[1:8],"[[","atl"),"[[","active")
  > 
  > # point queries that should return an empty vectors
  > b1 = length(get.edgeIDs.active(anet, iov[4,1], at=-Inf, active.default=F))==0    # at -Inf
  > b2 = length(get.edgeIDs.active(anet, iov[5,1], at=Inf, active.default=F))==0     # at Inf
  > b3 = length(get.edgeIDs.active(anet, iov[5,1], at=20, active.default=F))==0      # at b
  > b4 = length(get.edgeIDs.active(anet, iov[3,1], at=30, active.default=F))==0      # at H
  > 
  > # point queries that should return non-empty vectors
  > b5 = get.edgeIDs.active(anet, iov[3,1], at=-Inf, active.default=F)==3  # at -Inf
  > b6 = get.edgeIDs.active(anet, iov[4,1], at=Inf, active.default=F)==4   # at Inf
  > b7 = get.edgeIDs.active(anet, iov[5,1], at=10, active.default=F)==5    # at a
  > b8 = get.edgeIDs.active(anet, iov[7,1], at=30, active.default=F)==7    # at b
  > 
  > # interval queries that should return empty vectors
  > b9 = length(get.edgeIDs.active(anet, iov[3,1], Inf, Inf, active.default=F))==0   # over (Inf,Inf)
  > b10 = length(get.edgeIDs.active(anet, iov[8,1], -Inf, Inf, active.default=F))==0  # over (-Inf,Inf)
  > b11 = length(get.edgeIDs.active(anet, iov[3,1], 30, Inf, active.default=F))==0    # over (H,Inf)
  > b12 = length(get.edgeIDs.active(anet, iov[4,1], -Inf, 0, active.default=F))==0    # over (-Inf, L)
  > b13 = length(get.edgeIDs.active(anet, iov[5,1], 0, 5, active.default=F))==0       # over (L1,L2)
  > b14 = length(get.edgeIDs.active(anet, iov[5,1], 0, 15, active.default=F, rule="all"))==0   # over (L,M)  
  > b15 = length(get.edgeIDs.active(anet, iov[7,1], 0, 60, active.default=F, rule="all"))==0   # over (L,H)
  > b16 = length(get.edgeIDs.active(anet, iov[7,1], 45, 55, active.default=F, rule="all"))==0  # over (M, H)
  > b17 = length(get.edgeIDs.active(anet, iov[6,1], 15, 20, active.default=F))==0     # over (H1, H2)      
  > 
  > # interval queries that should return non-empty vectors
  > b18 = min(get.edgeIDs.active(anet, iov[1,1], -Inf, Inf, active.default=T))==1  # over null
  > b19 = get.edgeIDs.active(anet, iov[2,1], -Inf, Inf, active.default=F)==2  # over (-Inf,Inf)
  > b20 = get.edgeIDs.active(anet, iov[4,1], 10, Inf, active.default=F)==4    # over (a,Inf)
  > b21 = get.edgeIDs.active(anet, iov[3,1], -Inf, 20, active.default=F)==3   # over (-Inf, b)
  > b22 = get.edgeIDs.active(anet, iov[5,1], 10, 20, active.default=F)==5     # over (a,b)
  > b23 = get.edgeIDs.active(anet, iov[6,1], 10, 10, active.default=F)==6     # over (a,a)
  > b24 = get.edgeIDs.active(anet, iov[4,1], 0, 15, active.default=F)==4      # over (L,M)  
  > b25 = get.edgeIDs.active(anet, iov[7,1], 0, 60, active.default=F)==7      # over (L,H)
  > b26 = get.edgeIDs.active(anet, iov[5,1], 15, 18, active.default=F)==5     # over (M1, M2)
  > b27 = get.edgeIDs.active(anet, iov[7,1], 45, 60, active.default=F)==7     # over (M, H)
  > 
  > b.tests = paste("b", seq(1,27), sep="")
  > b.results= sapply(b.tests, function(x){eval(parse(text=x))})
  > if(any(!b.results)){
  +   bad.tests = paste("b", which(!b.results), sep="", collapse=" ")
  +   stop(paste("get.edgeIDs.active is returning incorrect edge IDs in tests",
  +              bad.tests))
  + }
  > 
  > 
  > # some other tests that Zack has written                   
  > # Test case check that given onset all get.edges.active reproduces get.edges.active
  > a1 <-activate.edges(anet,onset=0,terminus=3)
  > v<-1:100
  > c1=all(sapply(v,function(x){identical(get.edgeIDs.active(a1,x,at=1),get.edgeIDs(a1,x))}))
  > # same as above, but check alter functionality, alters present
  > c2=all(sapply(v,function(x)
  + 	{
  + 	all(sapply(which(a1[1,]==1),function(y){identical(get.edgeIDs.active(a1,x,at=1,alter=y),get.edgeIDs(a1,x,alter=y))}))
  + 	}))
  > # alters not present
  > c3=all(sapply(v,function(x)
  + 	{
  + 	all(sapply(which(a1[1,]!=1),function(y){identical(get.edgeIDs.active(a1,x,at=1,alter=y),get.edgeIDs(a1,x,alter=y))}))
  + 	}))
  > # Check that only empty cases are identical 
  > c4=all(sapply(v,function(x){identical(get.edgeIDs.active(a1,x,at=-1),get.edgeIDs(a1,x))})
  +   ==sapply(v,function(x){length(get.edgeIDs(a1,x))==0}))
  > 
  > c.tests = paste("c", seq(1,4), sep="")
  > c.results= sapply(c.tests, function(x){eval(parse(text=x))})
  > if(any(!c.results)){
  +   bad.tests = paste("c", which(!b.results), sep="", collapse=" ")
  +   stop(paste("get.edgeIDs.active is returning incorrect edge IDs in tests",
  +              bad.tests))
  + }
  > 
  > 
  > 
  > 
  > #---------------- GET.EDGES.ACTIVE TESTS ------------------------
  > # Notes:
  > #  --this function is nearly identical to get.edgeIDs.active,
  > #    so we do even less testing here.
  > #-------------------------------------------------------------------
  > 
  > cat("testing get.edges.active ... ")
  testing get.edges.active ... > 
  > ## Zack's tests
  > # within interval
  > b1=all(sapply(v,function(x){identical(get.edges(a1,x),get.edges.active(a1,v=x,at=1))}))
  > # outside interval, should only be same on empty cases
  > b2=all(sapply(v,function(x){identical(get.edges(a1,x),get.edges.active(a1,v=x,at=-1))})
  +   ==
  +   sapply(v,function(x){length(get.edges(a1,x))==0}))
  > ## skye's tests
  > net <-network.initialize(5)
  > net[1,2]<-1;
  > net[2,3]<-1;
  > net <-activate.edges(net,onset=1,terminus=Inf,e=1)
  > net <-activate.edges(net,onset=2,terminus=3,e=2)
  > b3=length(get.edges.active(net,v=2,at=1))== 0
  > b4=length(get.edges.active(net,v=2,at=2, neighborhood="combined"))== 2
  > 
  > b.tests = paste("b", seq(1,4), sep="")
  > b.results= sapply(b.tests, function(x){eval(parse(text=x))})
  > if(any(!b.results)){
  +   bad.tests = paste("b", which(!b.results), sep="", collapse=" ")
  +   stop(paste("get.edges.active is returning incorrect edges in tests",
  +              bad.tests))
  + }
  > 
  > get.edges.active(network.initialize(0),v=1,at=1)
  list()
  > 
  > cat("ok\n")
  ok
  > 
  > 
  > 
  > #---------------- GET.NEIGHBORHOOD.ACTIVE TESTS ------------------------
  > # Notes:
  > #  --this function largely relies on 'get.edges.active', so rather than
  > #    test an extensive set of inputs, I'm white-box testing each of
  > #    the branches in the main "if" loop
  > #-------------------------------------------------------------------
  > 
  > cat("testing get.neighborhood.active ... ")
  testing get.neighborhood.active ... > 
  > # branch 1: undirected network
  > data(flo)
  > net1 <- network(flo, directed=FALSE)
  > el1 <- as.matrix(net1, matrix.type="edgelist")
  > activate.edges(net1, 10, 20, e=seq(2,20,2))
  > activate.edges(net1, 10, 10, e=seq(1,19,2))
  > n1 = get.neighborhood.active(net1, v=9, 10, 20, rule="all")
  > n2 = get.neighborhood.active(net1, v=9, at=10)
  > b1 = all(n1==c(2,3,13,16))
  > b2 = all(n2==c(1,2,3,13,14,16))
  > 
  > # branch 2: undirected network with loops
  > #  um, I can't get network to accept a network with self loops
  > 
  > # branch 3:  undirected network, no neighborhood
  > n3 = get.neighborhood.active(net1, v=12, at=10)
  > b3 = length(n3) == 0
  > 
  > # branch 4:  directed network, out neighborhood
  > net2 <- network(flo)
  > el2 <- as.matrix(net2, matrix.type="edgelist")
  > activate.edges(net2, -Inf, 20, e=seq(2,40,2))
  > activate.edges(net2, 20, 20, e=seq(1,39,2))
  > n4 = get.neighborhood.active(net2, v=15, 10, 20, type="out")
  > n5 = get.neighborhood.active(net2, v=15, at=20, type="out")
  > b4 = all(n4==c(5,11,13))
  > b5 = (n5==4)
  > 
  > # branch 5:  directed network, no out neighborhood
  > n6 = get.neighborhood.active(net2, v=1, 10, 20, type="out")
  > n7 = get.neighborhood.active(net2, v=15, 30, 40, type="out")
  > b6 = length(n6)==0
  > b7 = length(n7)==0
  > 
  > # branch 6:  directed network, in neighborhood
  > net3 <- network(flo)
  > activate.edges(net3, 10, Inf, e=seq(2,40,2))
  > activate.edges(net3, 10, 20, e=seq(1,39,2))
  > n8 = get.neighborhood.active(net3, v=9, 10, 20, type="in")
  > n9 = get.neighborhood.active(net3, v=9, 10, 30, type="in", rule="all")
  > b8 = all(n8==c(1,2,3,13,14,16))
  > b9 = all(n9==c(2,13,16))
  > 
  > # branch 7:  directed network, no in neighborhood
  > n10 = get.neighborhood.active(net3, v=12, 10, 20, type="in")
  > n11 = get.neighborhood.active(net3, v=9, -10, -5, type="in")
  > b10 = length(n10)==0
  > b11 = length(n11)==0
  > 
  > # branch 8:  directed network, combined neighborhood, having in and out ties
  > net4 <- network(flo)
  > activate.edges(net4, at=10, e=seq(2,40,2))
  > activate.edges(net4, at=20, e=seq(1,39,2))
  > n12 = get.neighborhood.active(net4, v=7, 10, 30, type="combined")
  > n13 = get.neighborhood.active(net4, v=7, at=20, type="combined")
  > b12 = all(n12==c(2,4,8,16))
  > b13 = all(n13==c(2,4,16))
  > 
  > # branch 9:  directed network, combined neighborhood, having only in ties
  > net5 <- network(flo)
  > net5[15,] = 0   # remove all out edges from node 15
  > el5 <- as.matrix(net5, matrix.type="edgelist")
  > activate.edges(net5, e=seq(2,36,2))
  > n14 = get.neighborhood.active(net5, v=15, -Inf, Inf, type="combined")
  > n15 = get.neighborhood.active(net5, v=15, -Inf, Inf, type="combined", active.default=F)
  > b14 = all(n14==c(4,5,11,13))
  > b15 = all(n15==c(4,11))
  > 
  > # branch 10:  directed network, combined neighborhood, having only out ties
  > net6 <- network(flo)
  > net6[,14] = 0   # remove all in edges to node 14
  > el6 <- as.matrix(net6, matrix.type="edgelist")
  > activate.edges(net6, e=23)
  > deactivate.edges(net6, e=25)
  > n16 = get.neighborhood.active(net6, v=14, at=6, type="combined")
  > b16 = (n16==9)
  > 
  > # branch 11:  directed network, combined neighborhood, but no in or out ties
  > n17 = get.neighborhood.active(net5, v=12, at=6, type="combined")
  > b17 = length(n17)==0
  > 
  > b.tests = paste("b", seq(1,17), sep="")
  > b.results= sapply(b.tests, function(x){eval(parse(text=x))})
  > if(any(!b.results)){
  +   bad.tests = paste("b", which(!b.results), sep="", collapse=" ")
  +   stop(paste("get.neighborhood.active is returning wrong neighborhood in tests",
  +              bad.tests))
  + }
  > 
  > 
  > # Zack's tests (adjusted a touch)
  > # within interval
  > net7 <- network(flo)
  > activate.edges(net7, 1,2)
  > v = 1:network.size(net7)
  > c1=all(sapply(v,function(x){identical(sort(get.neighborhood(net7,x)),get.neighborhood.active(net7,v=x,at=1))}))
  > # outside interval
  > c2=all(sapply(v,function(x){length(get.neighborhood.active(net7,v=x,at=-1))==0}))
  > #c2=all(sapply(v,function(x){
  > #              nc<-get.neighborhood(a1,x)
  > #              nd<-get.neighborhood.active(a1,v=x,at=-1)
  > #              identical(nc[order(nc)],nd[order(nd)])})
  > #        ==
  > #       sapply(v,function(x){length(get.edges(a1,x))==0}))
  > 
  > c.tests = paste("c", seq(1,2), sep="")
  > c.results= sapply(c.tests, function(x){eval(parse(text=x))})
  > if(any(!c.results)){
  +   bad.tests = paste("c", which(!c.results), sep="", collapse=" ")
  +   stop(paste("get.neighborhood.active is returning wrong neighborhood in tests",
  +              bad.tests))
  + }
  > 
  > expect_equal(get.neighborhood.active(network.initialize(0),v=1),integer(0))
  > 
  > cat("ok\n")
  ok
  > 
  > proc.time()
     user  system elapsed 
     3.46    0.25    3.73 
Running the tests in 'tests/pid_tests.R' failed.
Complete output:
  > #  Part of the statnet package, http://statnetproject.org
  > #
  > #  This software is distributed under the GPL-3 license.  It is free,
  > #  open source, and has the attribution requirements (GPL Section 7) in
  > #    http://statnetproject.org/attribution
  > #
  > #  Copyright 2013 the statnet development team
  > ######################################################################
  > 
  > require(networkDynamic)
  Loading required package: networkDynamic
  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
  
  
  '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
  
  > require(testthat)
  Loading required package: testthat
  > 
  > #Create a network with three edges
  > m<-matrix(0,3,3)
  > m[1,2]<-1; m[2,3]<-1; m[3,1]<-1
  > g<-network(m)
  > 
  > #Create a matrix of values corresponding to edges
  > mm<-m
  > mm[1,2]<-7; mm[2,3]<-4; mm[3,1]<-2
  > 
  > #Assign some attributes
  > set.edge.attribute(g,"myeval",3:5)
  > set.edge.value(g,"myeval2",mm)
  > set.network.attribute(g,"mygval","boo")
  > set.vertex.attribute(g,"myvval",letters[1:3])
  > network.vertex.names(g) <- LETTERS[1:10]
  > 
  > set.network.attribute(g, 'vertex.pid', 'vertex.names')
  > 
  > 
  > # check if some pid missing
  > 
  > #------ get.vertex.id checks ------
  > 
  > expect_equal(get.vertex.id(g, 'A'),1)
  > expect_equal(get.vertex.id(g, 'B'),2)
  > # returns NA if not found
  > expect_true(is.na(get.vertex.id(g, 'D')))
  > 
  > # check multiple works
  > expect_equal(get.vertex.id(g, c('B','C','D')),c(2,3,NA))
  > 
  > expect_error(get.vertex.id(network.initialize(5),"does not have a 'vertex.pid' attribute"))
  > 
  > expect_error(get.vertex.id(network.initialize(0),"does not have a 'vertex.pid' attribute"))
  > 
  > 
  > #------- get.vertex.pid checks ---
  > 
  > expect_equal(get.vertex.pid(g, 2),'B')
  > # returns NA if not found
  > expect_true(is.na(get.vertex.pid(g, 5)))
  > 
  > # multiple works
  > expect_equal(get.vertex.pid(g,c(2,3,4)),c("B","C",NA))
  > 
  > # check when no vertex pid speced
  > expect_error(get.vertex.pid(network.initialize(5),"does not have a 'vertex.pid' attribute"))
  > 
  > expect_error(get.vertex.pid(network.initialize(0),"does not have a 'vertex.pid' attribute"))
  > 
  > 
  > # ---------- add.vertices  checks -----
  > 
  > # test calling original function, direct assignment
  > net <- as.networkDynamic(network.initialize(1))
  > net <-add.vertices(net,nv=3)
  > expect_equal(network.size(net),4,info='add.vertices direct assignment')
  > 
  > # test calling original function, modify inplace
  > net <- as.networkDynamic(network.initialize(1))
  > add.vertices(net,nv=3)
  > expect_equal(network.size(net),4,info='add.vertices modify in place')
  > 
  > 
  > net <- as.networkDynamic(network.initialize(1))
  > set.network.attribute(net,'vertex.pid','data_id')
  > set.vertex.attribute(net,'data_id','one')
  > 
  > # adding wrong number of ids gives error
  > expect_error(add.vertices(net,4,vertex.pid=c('two','three','four')), info='does not match number of new vertices')
  > 
  > # adding duplicate ids gives error
  > 
  > expect_error(add.vertices(net,4,vertex.pid=c('two','three','three','three')), info='vertex.pid values must be unique')
  > 
  > # error did not modify network
  > expect_equal(network.size(net),1)
  > 
  > # adding correctly 
  > add.vertices(net,4,vertex.pid=c('two','three','four','five'))
  > expect_equal(network.size(net),5, info='add.vertices check verts added')
  > expect_equal(net%v%'data_id',c("one","two","three","four","five" ),info='add.vertices added vertex.pids')
  > 
  > # adding with no specified pid
  > add.vertices(net,3)
  > expect_equal(anyDuplicated(get.vertex.attribute(net,'data_id')),0)
  > 
  > # adding with pid disabled
  > net<-as.networkDynamic(network.initialize(3))
  > set.network.attribute(net,'vertex.pid',NULL)
  > expect_equal(network.size(add.vertices(net,3)),6)
  > 
  > # adding to net of size 0
  > 
  > expect_equal(network.size(add.vertices(network.initialize(0),1)),1)
  > 
  > # ------------ add.edges checks ----
  > 
  > # no pid defined, modify in place
  > nd<-as.networkDynamic(network.initialize(3))
  > add.edges(nd,tail=1:3,head=c(2,3,1))
  > expect_equal(network.edgecount(nd),3)
  > 
  > # direct assignement
  > nd<-as.networkDynamic(network.initialize(3))
  > nd2<-add.edges(nd,tail=1:3,head=c(2,3,1))
  > expect_equal(network.edgecount(nd2),3)
  > 
  > # pid defined
  > nd<-as.networkDynamic(network.initialize(3))
  > set.network.attribute(nd,'edge.pid','myFavoriteId')
  > add.edges(nd,tail=1:3,head=c(2,3,1))
  > expect_true(nd%n%'edge.pid'=='myFavoriteId')
  > expect_equal(length(get.edge.attribute(nd,'myFavoriteId')),3,info='check add.edges created pids for edges')
  > expect_true('myFavoriteId'%in%list.edge.attributes(nd),info='check add.edges created edge.pid with correct name')
  > 
  > # adding to net with edges, and passing 
  > nd<-as.networkDynamic(network.initialize(3))
  > add.edges(nd,tail=1:3,head=c(2,3,1))
  > set.network.attribute(nd,'edge.pid','edge.pid')
  > set.edge.attribute(nd,'edge.pid',c("A","B","C"))
  > add.edges(nd,tail=3,head=1,edge.pid="D")
  > add.edges(nd,tail=3,head=2)
  > 
  > expect_equal(length(get.edge.attribute(nd,'edge.pid')),5)
  > expect_equal(get.edge.attribute(nd,'edge.pid')[1:4],LETTERS[1:4])
  >              
  > # ------------ add.edge checks ----
  >              
  > # no pid defined, modify in place
  > nd<-as.networkDynamic(network.initialize(3))
  > add.edge(nd,tail=1,head=2)
  > expect_equal(network.edgecount(nd),1)
  >              
  > # direct assignement
  > nd<-as.networkDynamic(network.initialize(3))
  > nd2<-add.edge(nd,tail=1,head=2)
  > expect_equal(network.edgecount(nd2),1)
  >              
  > # pid defined
  > nd<-as.networkDynamic(network.initialize(3))
  > set.network.attribute(nd,'edge.pid','myFavoriteId')
  > add.edge(nd,tail=1,head=2)
  > expect_true(nd%n%'edge.pid'=='myFavoriteId')
  > expect_equal(length(get.edge.attribute(nd,'myFavoriteId')),1,info='check add.edge created pids for edges')
  > expect_true('myFavoriteId'%in%list.edge.attributes(nd),info='check add.edge created edge.pid with correct name')
  >              
  > # adding to net with edges, and passing 
  > nd<-as.networkDynamic(network.initialize(3))
  > add.edges(nd,tail=1:3,head=c(2,3,1))
  > set.network.attribute(nd,'edge.pid','edge.pid')
  > set.edge.attribute(nd,'edge.pid',c("A","B","C"))
  > add.edge(nd,tail=3,head=1,edge.pid="D")
  > add.edge(nd,tail=3,head=2)
  >              
  > expect_equal(length(get.edge.attribute(nd,'edge.pid')),5)
  > expect_equal(get.edge.attribute(nd,'edge.pid')[1:4],LETTERS[1:4])             
  >              
  >              
  > # check error for non-unique
  > nd<-as.networkDynamic(network.initialize(3))
  > set.network.attribute(nd,'edge.pid','edge.pid')
  > expect_error(add.edge(nd,tail=1,head=2,edge.pid=c("A","A","A")), 'Only one edge.pid can be specified')   
  >              
  > # check for errror from existign non-unique
  > nd<-as.networkDynamic(network.initialize(3))
  > set.network.attribute(nd,'edge.pid','edge.pid')  
  > add.edges(nd,tail=1:3,head=c(2,3,1))
  > set.edge.attribute(nd,'edge.pid',"A")             
  > expect_error(add.edge(nd,tail=3,head=1,edge.pid="B"),"edge.pid attribute must be specified and unique for each edge")
  >              
  >              
  > 
  > # ---- intitialize.pids ----
  > 
  > test<-as.networkDynamic(network.initialize(30))
  > add.edges(test,1:29,2:30)
  > initialize.pids(test)
  > expect_equal(anyDuplicated(get.vertex.attribute(test,'vertex.pid')),0)
  > expect_equal(anyDuplicated(get.edge.attribute(test,'edge.pid')),0)
  > 
  > initialize.pids(network.initialize(0))
  > 
  > # ----- get.edge.id ----------------
  > net<-as.networkDynamic(network.initialize(5))
  > add.edges(net,1:4,2:5)
  > set.edge.attribute(net,'data_id',LETTERS[1:4])
  > set.network.attribute(net,'edge.pid','data_id')
  > expect_equal(get.edge.id(net,c("B","D")),c(2,4))
  > 
  > # error if not defined
  > expect_error(get.edge.id(network.initialize(4)),"does not have an 'edge.pid' attribute")
  > 
  > # NA if not existing
  > 
  > expect_true(is.na(get.edge.id(net,"L")))
  > 
  > # ----- get.edge.pid -----
  > expect_equal(get.edge.pid(net,c(1,4)),c("A","D"))
  > 
  > # NA if out of range
  > expect_true(identical(get.edge.pid(net,c(4,5)),c("D",NA)))
  > 
  > # error if not defined
  > expect_error(get.edge.pid(network.initialize(4)),"does not have an 'edge.pid' attribute")
  > 
  > expect_error(get.edge.pid(network.initialize(0)),"does not have an 'edge.pid' attribute")
  >              
  >              
  > 
  > 
  > #----- edge.pid.check  checks ---------
  > nd <-as.networkDynamic(network.initialize(5))
  > add.edges(nd,1:4,2:5)
  > set.edge.attribute(nd,"myId",LETTERS[1:4])
  > set.network.attribute(nd,'edge.pid','myId')
  > 
  > expect_true(edge.pid.check(nd))
  > 
  > # missing
  > delete.edge.attribute(nd,"myId")
  > expect_error(edge.pid.check(nd),'Missing edge.pids')
  > 
  > # partially missing
  > set.edge.attribute(nd,"myId",LETTERS[1:3],e=1:3)
  > expect_error(edge.pid.check(nd),'must be specified and unique')
  > 
  > 
  > # not unique
  > set.edge.attribute(nd,"myId","a")
  > expect_error(edge.pid.check(nd),'must be specified and unique')
  > 
  > # not defined
  > expect_warning(edge.pid.check(network.initialize(2)),"does not have an 'edge.pid' attribute")
  > 
  > expect_warning(edge.pid.check(network.initialize(0)),"does not have an 'edge.pid' attribute")
  > 
  > 
  > 
  > # ----- vertex.pid.check checks ------
  > nd <-as.networkDynamic(network.initialize(5))
  > set.vertex.attribute(nd,"myId",LETTERS[1:5])
  > set.network.attribute(nd,'vertex.pid','myId')
  > expect_true(vertex.pid.check(nd),info='checking correctly formatted edge.pid')
  > 
  > nd <-as.networkDynamic(network.initialize(5))
  > set.vertex.attribute(nd,"myId",LETTERS[1:4],v=1:4)
  > set.network.attribute(nd,'vertex.pid','myId')
  > expect_error(vertex.pid.check(nd),info='error for mis-formatted vertex.pid')
  > 
  > expect_warning(vertex.pid.check(network.initialize(3)),"does not have a 'vertex.pid' attribute")
  > 
  > expect_warning(vertex.pid.check(network.initialize(0)),"does not have a 'vertex.pid' attribute")
  > 
  > # ------- extraction check ----
  > nd <-as.networkDynamic(network.initialize(5))
  > set.vertex.attribute(nd,"myId",LETTERS[1:5])
  > set.network.attribute(nd,'vertex.pid','myId')
  > activate.vertices(nd,onset=c(1,2,3,4,5),terminus=c(3,4,5,6,7))
  > n3<-network.extract(nd,at=3)
  > expect_equal(get.vertex.attribute(n3,'myId'),c("B","C"))
  > expect_equal(get.vertex.id(n3,c("A","B","C")),c(NA,1,2))
  > 
  > 
  > # find vertex corresponding to extracted vertex
  > haystack<-network.initialize(30)
  > activate.vertices(haystack,v=10:20)
  > # hide a needle somewhere in the haystack
  > set.vertex.attribute(haystack,'needle',TRUE,v=10)
  > initialize.pids(haystack)
  > # some hay is removed over time ...
  > newstack<-network.extract(haystack,at=100,active.default=FALSE)
  > # we find the needle!
  > needleId <-which(get.vertex.attribute(newstack,'needle'))
  > 
  > # which vertex is the corresponding one in original stack?
  > oldId<-get.vertex.id(haystack,get.vertex.pid(newstack,needleId))
  > 
  > expect_true(get.vertex.attribute(haystack,'needle')[oldId],info="find vertex corresponding to extracted vertex")
  > 
  > 
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     3.32    0.48    3.78 
Running the tests in 'tests/utils_tests.R' failed.
Complete output:
  > # tests for utilities functions
  > require(networkDynamic)
  Loading required package: networkDynamic
  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
  
  
  '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
  
  > require(testthat)
  Loading required package: testthat
  > # ------- test for adjust.activity -----
  > 
  > test<-network.initialize(3)
  > activate.vertices(test,onset=0,terminus=3,v=1:2)
  > add.edges.active(test,tail=1:2,head=2:3,onset=0,terminus=3)
  > add.edge(test,tail=3,head=1)
  > activate.vertex.attribute(test,'fruit','apple',v=1:2,onset=0,terminus=3)
  > activate.edge.attribute(test,'veggie','carrot',e=1:2,onset=0,terminus=3)
  > activate.network.attribute(test,'meat','pork',onset=0,terminus=3)
  > test%n%'net.obs.period'<-list(observations=list(c(0,1),c(1,2),c(2,3)),mode="discrete", time.increment=1,time.unit="step")
  > 
  > # test offset and return value
  > test2<-adjust.activity(test,offset=5)
  > 
  > expect_equal(test2$val[[1]]$active,matrix(c(5,8),ncol=2))
  > expect_equal(test2$val[[3]]$active,NULL)
  > expect_equal(test2$mel[[1]]$atl$active,matrix(c(5,8),ncol=2))
  > expect_equal(test2$mel[[3]]$atl$active,NULL)
  > expect_equal(test2$val[[1]]$'fruit.active'[[2]],matrix(c(5,8),ncol=2))
  > expect_equal(test2$val[[3]]$'fruit.active'[[2]],NULL)
  > expect_equal(test2$mel[[1]]$atl$'veggie.active'[[2]],matrix(c(5,8),ncol=2))
  > expect_equal(test2$mel[[3]]$atl$'veggie.active'[[2]],NULL)
  > expect_equal(test2$gal$'meat.active'[[2]],matrix(c(5,8),ncol=2))
  > expect_equal(unlist((test2%n%'net.obs.period')$observations),c(5,6,6,7,7,8))
  > expect_equal((test2%n%'net.obs.period')$time.increment,1)
  > 
  > # test factor and modify-in-place
  > adjust.activity(test,factor=.5)
  > 
  > expect_equal(test$val[[1]]$active,matrix(c(2.5,4),ncol=2))
  > expect_equal(test$val[[3]]$active,NULL)
  > expect_equal(test$mel[[1]]$atl$active,matrix(c(2.5,4),ncol=2))
  > expect_equal(test$mel[[3]]$atl$active,NULL)
  > expect_equal(test$val[[1]]$'fruit.active'[[2]],matrix(c(2.5,4),ncol=2))
  > expect_equal(test$val[[3]]$'fruit.active'[[2]],NULL)
  > expect_equal(test$mel[[1]]$atl$'veggie.active'[[2]],matrix(c(2.5,4),ncol=2))
  > expect_equal(test$mel[[3]]$atl$'veggie.active'[[2]],NULL)
  > expect_equal(test$mel[[1]]$atl$'veggie.active'[[2]],matrix(c(2.5,4),ncol=2))
  > expect_equal(unlist((test%n%'net.obs.period')$observations),c(2.5,3,3,3.5,3.5,4))
  > expect_equal((test%n%'net.obs.period')$time.increment,0.5)
  > 
  > # ---- test for add.vertices.active -----
  > net<-network.initialize(3)
  > # test for adding zero vertices
  > add.vertices.active(net,nv=0)
  > expect_equal(network.size(net),3)
  > expect_true(is.networkDynamic(net))
  > 
  > add.vertices.active(net,nv=2, onset=1,terminus=2)
  > expect_equal(network.size(net),5)
  > expect_true(is.networkDynamic(net))
  > expect_equal(unlist(get.vertex.activity(net,as.spellList=TRUE)[4:5,1:2]),c(1,1,2,2),check.names=FALSE)
  > 
  > 
  > # ---- tests for get.dyads.active ----
  > test_that("get.dyads.active works",{
  +   
  +   expect_error( get.dyads.active(network.initialize(3,hyper=TRUE),at=1),regexp="does not currently support hypergraphic",info="error on hyper")
  +   expect_equal( nrow(get.dyads.active(network.initialize(0),at=1)),0,info="network size zero case")
  +   expect_equal( nrow(get.dyads.active(network.initialize(3),at=1)),0,info="zero edges case")
  +   
  +   test<-network.initialize(5)
  +   add.edges.active(test,tail=1,head=2,onset=0,terminus=1)
  +   add.edges.active(test,tail=2,head=3,onset=1,terminus=2)
  +   add.edges.active(test,tail=3,head=4,onset=1,terminus=3)
  +   activate.edges(test,e=1,onset=2,terminus=3)
  +   as.data.frame(test)
  +   expect_equal(get.dyads.active(test,at=0),rbind(1:2))
  +   expect_equal(get.dyads.active(test,at=1),cbind(2:3,3:4))
  +   expect_equal(get.dyads.active(test,onset=0,terminus=4),rbind(1:2,2:3,3:4))
  +   
  +   # test with no (default) dynamics
  +   test2<-network.initialize(3)
  +   test2[1,2]<-1
  +   expect_equal(get.dyads.active(test2,onset=0,terminus=4),rbind(1:2))
  +   # test active default
  +   expect_equal(get.dyads.active(test2,onset=0,terminus=4,active.default=FALSE),cbind(list(),list()), info='test active default arg')
  +   
  +   # deleted edges
  +   test2<-network.initialize(3)
  +   test2[1,2]<-1
  +   test2[2,3]<-1
  +   test2[3,1]<-1
  +   delete.edges(test2,eid=2)
  +   expect_equal(get.dyads.active(test2,at=1),rbind(1:2,c(3,1)),info='deleted edge case')
  +   
  + })
  Test passed 🥳
  > 
  > test_that("conversions between network, networkLite, and networkDynamic behave as expected", {
  +   library(networkLite)
  + 
  +   m <- matrix(rbinom(20*20, 1, 1/10), nrow = 20, ncol = 20)
  +   m[lower.tri(m, diag = TRUE)] <- FALSE
  +   el <- which(m > 0, arr.ind = TRUE)
  +   el <- el[order(el[,1], el[,2]),,drop=FALSE]
  +   attr(el, "n") <- 20
  + 
  +   nw <- network(el, directed = FALSE, bipartite = FALSE, matrix.type = "edgelist")
  +   nwL <- as.networkLite(nw)
  +   nwLD <- as.networkDynamic(nwL)
  +   nwD <- as.networkDynamic(nw)
  +   nwDL <- as.networkLite(nwD)
  +   expect_identical(nwD, nwLD)
  +   expect_identical(nwDL, nwL)
  + 
  +   nwL <- networkLite(el)
  +   nw <- to_network_networkLite(nwL)
  +   nwD <- as.networkDynamic(nw)
  +   nwLD <- as.networkDynamic(nwL)
  +   nwDL <- as.networkLite(nwD)
  +   expect_identical(nwD, nwLD)
  +   expect_identical(nwDL, nwL)
  + })
  Test passed 😸
  > 
  > proc.time()
     user  system elapsed 
     3.14    0.39    3.51