[datatable-help] Streamlining unit tests with test_that
Tom Short
tshort.rlists at gmail.com
Wed Dec 1 21:01:27 CET 2010
This is more for Matthew's input. Following up on cedta used within
sys.source'd code, could cedta be changed to only check for a
namespace? According to the following tracker issue, if a package
doesn't have a namespace, it won't drop to using data.frame's anyway.
https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1074&group_id=240&atid=978
How about something like this?
cedta = function() {
# Calling Environment Data Table Aware
te = topenv(parent.frame(2))
!isNamespace(te) ||
getNamespaceName(te) == "data.table" ||
"data.table" %in% names(getNamespaceImports(te))
}
If I do that, I can execute the following:
sys.source("t.R", new.env(parent=.GlobalEnv))
with t.R as follows:
--------------------------
TESTDT = data.table(a=as.integer(c(1,3,4,4,4,4,7)),
b=as.integer(c(5,5,6,6,9,9,2)),
v=1:7)
setkey(TESTDT,a,b)
x <- TESTDT[SJ(4,6), v, mult="first"]
test.data.table()
--------------------------
I'm not sure if this'd break other stuff, though. I haven't tested it
anymore than just doing this.
- Tom
More information about the datatable-help
mailing list