[Phylobase-commits] r764 - in pkg: R inst/unitTests man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Mar 23 19:30:03 CET 2010


Author: francois
Date: 2010-03-23 19:30:03 +0100 (Tue, 23 Mar 2010)
New Revision: 764

Added:
   pkg/inst/unitTests/runit.phylobase.options.R
Modified:
   pkg/R/phylobase.options.R
   pkg/man/check.phylo4.Rd
   pkg/man/phylo4-labels.Rd
   pkg/man/phylobase.options.Rd
Log:
clean up doc associated with options, fix bug that prevented modification of options as characters, introduce match.arg on the value of the options, created unit test for phylobase.options

Modified: pkg/R/phylobase.options.R
===================================================================
--- pkg/R/phylobase.options.R	2010-03-23 00:32:08 UTC (rev 763)
+++ pkg/R/phylobase.options.R	2010-03-23 18:30:03 UTC (rev 764)
@@ -1,10 +1,8 @@
+### Modified code from package sm
 phylobase.options <- function (...) {
-    ## code from package sm
     if (nargs() == 0) return(.phylobase.Options)
     current <- .phylobase.Options
-    if (is.character(...))
-        temp <- eval(parse(text = paste(c("list(", ..., ")"))))
-    else temp <- list(...)
+    temp <- list(...)
     if (length(temp) == 1 && is.null(names(temp))) {
         arg <- temp[[1]]
         switch(mode(arg),
@@ -15,8 +13,14 @@
     if (length(temp) == 0) return(current)
     n <- names(temp)
     if (is.null(n)) stop("options must be given by name")
+
+    if (!all(names(temp) %in% names(current)))
+        stop("Option name invalid: ", sQuote(names(temp)))
     changed <- current[n]
     current[n] <- temp
+    current <- lapply(current, function(foo) {
+        foo <- match.arg(foo, c("warn", "fail", "ok"))
+    })
     if (sys.parent() == 0) env <- asNamespace("phylobase") else env <- parent.frame()
     assign(".phylobase.Options", current, envir = env)
     invisible(current)

Added: pkg/inst/unitTests/runit.phylobase.options.R
===================================================================
--- pkg/inst/unitTests/runit.phylobase.options.R	                        (rev 0)
+++ pkg/inst/unitTests/runit.phylobase.options.R	2010-03-23 18:30:03 UTC (rev 764)
@@ -0,0 +1,22 @@
+
+op <- phylobase.options()
+test.phylobase.options <- function() {
+
+    ## test match.arg
+    checkException(phylobase.options(retic="test"))
+    no <- phylobase.options(retic="f")
+    checkIdentical(no$retic, "fail")
+
+    ## test multiple args
+    phylobase.options(op)
+    no <- phylobase.options(retic="f", poly="f")
+    checkIdentical(no$retic, "fail")
+    checkIdentical(no$poly, "fail")
+
+    ## check some failures
+    checkException(phylobase.options(1))
+    checkException(phylobase.options("foobar"="foo"))
+
+}
+
+phylobase.options(op)

Modified: pkg/man/check.phylo4.Rd
===================================================================
--- pkg/man/check.phylo4.Rd	2010-03-23 00:32:08 UTC (rev 763)
+++ pkg/man/check.phylo4.Rd	2010-03-23 18:30:03 UTC (rev 764)
@@ -13,14 +13,6 @@
 }
 \arguments{
   \item{object}{A prospective phylo4 or phylo4d object}
-  \item{warn}{a character vector listing phenomena to warn about:
-    current options are [\code{"poly"} (polytomies),
-    \code{"retic"} (reticulations),
-    \code{"singleton"} ("singleton" nodes, i.e.
-    nodes with a single descendant), \code{"multiroot"}
-    (multiple roots) ]}
-  \item{err}{a character vector listing phenomena to trigger errors:
-    choices as above}
 }
 \value{
   As required by \code{\link[methods]{validObject}}, returns an
@@ -67,7 +59,9 @@
   the \code{\link{phylo4}} constructor and \linkS4class{phylo4} class;
   \code{\link{formatData}},  the \code{\link{phylo4d}} constructor and
   the \linkS4class{phylo4d} class do checks for the data associated with trees.
-  See \code{\link{coerce-methods}} for translation functions.
+  See \code{\link{coerce-methods}} for translation functions and
+  \code{\link{phylobase.options} to change some of the default options
+  of the validator.}
 }
 \author{Ben Bolker, Steven Kembel, Francois Michonneau}
 \keyword{misc}

Modified: pkg/man/phylo4-labels.Rd
===================================================================
--- pkg/man/phylo4-labels.Rd	2010-03-23 00:32:08 UTC (rev 763)
+++ pkg/man/phylo4-labels.Rd	2010-03-23 18:30:03 UTC (rev 764)
@@ -4,6 +4,9 @@
 \alias{labels,phylo4-method}
 \alias{labels<-,phylo4,ANY,ANY,character-method}
 \alias{labels<-,phylo4d,ANY,ANY,character-method}
+\alias{hasDuplicatedLabels}
+\alias{hasDuplicatedLabels-methods}
+\alias{hasDuplicatedLabels,phylo4-method}
 \alias{hasNodeLabels}
 \alias{hasNodeLabels-methods}
 \alias{hasNodeLabels,phylo4-method}

Modified: pkg/man/phylobase.options.Rd
===================================================================
--- pkg/man/phylobase.options.Rd	2010-03-23 00:32:08 UTC (rev 763)
+++ pkg/man/phylobase.options.Rd	2010-03-23 18:30:03 UTC (rev 764)
@@ -6,7 +6,7 @@
   such as singletons, reticulated trees, polytomies, etc. 
 }
 \usage{
-phylobase.options()
+phylobase.options(\dots)
 }
 \arguments{
   \item{\dots}{a list may be given as the only argument, or any number



More information about the Phylobase-commits mailing list