mlandistest / code

2 stars 0 forks source link

assignment problems for vectors and out-of-range indices [sf#10] #10

Open mlandis opened 10 years ago

mlandis commented 10 years ago

Reported by michaellandis on 2014-07-01 22:25 UTC

RevBayes >            ## Vectors display strange behavior depending on how the variable was RevBayes >            ## initialized.
RevBayes > x<-v()     ## Cannot assign empty vector to x
   Error:   No overloaded function 'v' matches for arguments ( )
   Potentially matching functions are:
   VectorRbPointer<Monitor> function (Monitor , Monitor ...)
   VectorRbPointer<Move> function (Move , Move ...)
   VectorRbPointer<AbstractCharacterData> function (AbstractCharacterData ,
   AbstractCharacterData ...)
   Vector<Natural> function (Natural , Natural ...)
   Vector<Integer> function (Integer , Integer ...)
   Vector<Real> function (Real , Real ...)
   Vector<RealPos> function (RealPos , RealPos ...)
   Vector<Bool> function (Bool , Bool ...)
   Vector<Clade> function (Clade , Clade ...)
   Vector<String> function (String , String ...)
   Vector<TimeTree> function (TimeTree , TimeTree ...)
RevBayes > x<-v(1,2)  ## Can assign new vector to x
RevBayes > x
   [ 1, 2 ]
RevBayes > x[3]<-3    ## Interprets this as assignment of v(NULL,NULL,3), not an append
RevBayes >            ## This might be argued as intended behavior, but is unintuitive.         
RevBayes >            ## (A side note: I cannot find any way to append to vectors...)
RevBayes > x
   Error:   No overloaded function 'v' matches for arguments ( NULL, NULL, Natural )
    Potentially matching functions are:
   VectorRbPointer<Monitor> function (Monitor , Monitor ...)
   VectorRbPointer<Move> function (Move , Move ...)
   VectorRbPointer<AbstractCharacterData> function (AbstractCharacterData ,
   AbstractCharacterData ...)
   Vector<Natural> function (Natural , Natural ...)
   Vector<Integer> function (Integer , Integer ...)
   Vector<Real> function (Real , Real ...)
   Vector<RealPos> function (RealPos , RealPos ...)
   Vector<Bool> function (Bool , Bool ...)
   Vector<Clade> function (Clade , Clade ...)
   Vector<String> function (String , String ...)
   Vector<TimeTree> function (TimeTree , TimeTree ...)
RevBayes > x<-v(1,2)  ## Cannot assign new vector to x
   Error:   No overloaded function 'v' matches for arguments ( NULL, NULL, Natural )
   Potentially matching functions are:
   VectorRbPointer<Monitor> function (Monitor , Monitor ...)
   VectorRbPointer<Move> function (Move , Move ...)
   VectorRbPointer<AbstractCharacterData> function (AbstractCharacterData ,
   AbstractCharacterData ...)
   Vector<Natural> function (Natural , Natural ...)
   Vector<Integer> function (Integer , Integer ...)
   Vector<Real> function (Real , Real ...)
   Vector<RealPos> function (RealPos , RealPos ...)
   Vector<Bool> function (Bool , Bool ...)
   Vector<Clade> function (Clade , Clade ...)
   Vector<String> function (String , String ...)
   Vector<TimeTree> function (TimeTree , TimeTree ...)
RevBayes > x[3]<-4
RevBayes > x[2]<-5
RevBayes > x[1]<-6
RevBayes > x          ## Assigning non-NULL values to x[1] and x[2] restores print
   [ 6, 5, 4 ]
RevBayes > x<-v(1,2)  ## Assign new value to x, no error reported
RevBayes > x          ## New value not reported
   [ 6, 5, 4 ]
RevBayes > y[3] <- 1  ## Let's try a new variable
RevBayes > y          ## Whatever handles the ostream is unhappy with y[1]==y[2]==NULL
   Error:   No overloaded function 'v' matches for arguments ( NULL, NULL, Natural
   )