Skip to content

Commit

Permalink
Merge branch 'master' of github.com:0xdata/h2o
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalohlava committed Feb 17, 2014
2 parents 4175a29 + cc7bd86 commit b06d203
Show file tree
Hide file tree
Showing 9 changed files with 596 additions and 175 deletions.
3 changes: 2 additions & 1 deletion R/h2oRClient-package/R/Algorithms.R
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ h2o.kmeans.FV <- function(data, centers, cols='', iter.max=10, normalize = FALSE
if( missing(data) ) stop('Must specify data')
# if(class(data) != 'H2OParsedData' ) stop('data must be an h2o dataset')
if(!class(data) %in% c("H2OParsedData", "H2OParsedDataVA")) stop("data must be an H2O parsed dataset")
if(h2o.anyFactor(data)) stop("Unimplemented: K-means can only model on numeric data")

if( missing(centers) ) stop('must specify centers')
if(!is.numeric(centers) && !is.integer(centers)) stop('centers must be a positive integer')
Expand Down Expand Up @@ -916,7 +917,7 @@ h2o.confusionMatrix <- function(data, reference) {
y_i <- y
y <- cc[ y ]
}
if( y %in% x ) stop(y, 'is both an explanatory and dependent variable')
if( y %in% x ) stop(paste(y, 'is both an explanatory and dependent variable'))

x_ignore <- setdiff(setdiff( cc, x ), y)
if( length(x_ignore) == 0 ) x_ignore <- ''
Expand Down
15 changes: 5 additions & 10 deletions R/h2oRClient-package/R/ParseImport.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,11 @@ h2o.importFile <- function(object, path, key = "", parse = TRUE, header, sep = "
}

h2o.importFile.VA <- function(object, path, key = "", parse = TRUE, header, sep = "", col.names) {
if(class(object) != "H2OClient") stop("object must be of class H2OClient")
if(!is.character(path)) stop("path must be of class character")
if(nchar(path) == 0) stop("path must be a non-empty string")
if(!is.character(key)) stop("key must be of class character")
if(!is.logical(parse)) stop("parse must be of class logical")

if(missing(key) || nchar(key) == 0)
h2o.importFolder.VA(object, path, pattern = "", key = "", parse, header, sep, col.names = col.names)
else
h2o.importURL.VA(object, paste("file:///", path, sep=""), key, parse, header, sep, col.names = col.names)
h2o.importFolder.VA(object, path, pattern = "", key, parse, header, sep, col.names)
# if(missing(key) || nchar(key) == 0)
# h2o.importFolder.VA(object, path, pattern = "", key = "", parse, header, sep, col.names = col.names)
# else
# h2o.importURL.VA(object, paste("file:///", path, sep=""), key, parse, header, sep, col.names = col.names)
}

h2o.importFile.FV <- function(object, path, key = "", parse = TRUE, header, sep = "", col.names) {
Expand Down
Empty file.
100 changes: 50 additions & 50 deletions R/tests/testdir_munging/exec/runit_opPrecedence.R
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
setwd(normalizePath(dirname(R.utils::commandArgs(asValues=TRUE)$"f")))
source('../../findNSourceUtils.R')

get.eval.result <- function(conn, expr) {
res = h2o.__exec2(conn, expr)
return(new("H2OParsedData", h2o=conn, key=res$dest_key))
}

test.op.precedence <- function(conn) {
a = sample(10)
b = sample(10)
c = sample(10)
A = as.h2o(conn, a, "A")
B = as.h2o(conn, b, "B")
C = as.h2o(conn, c, "C")
s1 = a + b * c
s2 = a - b - c
s3 = a ^ 2 ^ 3
s4 = a == b & c
s5 = a == b + c
s6 = a | b & c

Log.info("Check A + B * C.")
S1 = as.data.frame(get.eval.result(conn, "A + B * C"))
expect_that(all(S1 == s1), equals(T))

Log.info("Check A - B - C.")
S2 = as.data.frame(get.eval.result(conn, "A - B - C"))
expect_that(all(S2 == s2), equals(T))

Log.info("Check A ^ 2 ^ 3.")
S3 = as.data.frame(get.eval.result(conn, "A ^ 2 ^ 3"))
expect_that(all(S3 == s3), equals(T))

Log.info("Check A == B & C.")
S4 = as.data.frame(get.eval.result(conn, "A == B & C"))
expect_that(all(S4 == s4), equals(T))

Log.info("Check A == B + C.")
S5 = as.data.frame(get.eval.result(conn, "A == B + C"))
expect_that(all(S5 == s5), equals(T))

Log.info("Check A | B & C.")
S6 = as.data.frame(get.eval.result(conn, "A | B & C"))
expect_that(all(S6 == s6), equals(T))

testEnd()
}

doTest("Test operator precedence.", test.op.precedence)
setwd(normalizePath(dirname(R.utils::commandArgs(asValues=TRUE)$"f")))
source('../../findNSourceUtils.R')

get.eval.result <- function(conn, expr) {
res = .h2o.__exec2(conn, expr)
return(new("H2OParsedData", h2o=conn, key=res$dest_key))
}

test.op.precedence <- function(conn) {
a = sample(10)
b = sample(10)
c = sample(10)
A = as.h2o(conn, a, "A")
B = as.h2o(conn, b, "B")
C = as.h2o(conn, c, "C")
s1 = a + b * c
s2 = a - b - c
s3 = a ^ 2 ^ 3
s4 = a == b & c
s5 = a == b + c
s6 = a | b & c

Log.info("Check A + B * C.")
S1 = as.data.frame(get.eval.result(conn, "A + B * C"))
expect_that(all(S1 == s1), equals(T))

Log.info("Check A - B - C.")
S2 = as.data.frame(get.eval.result(conn, "A - B - C"))
expect_that(all(S2 == s2), equals(T))

Log.info("Check A ^ 2 ^ 3.")
S3 = as.data.frame(get.eval.result(conn, "A ^ 2 ^ 3"))
expect_that(all(S3 == s3), equals(T))

Log.info("Check A == B & C.")
S4 = as.data.frame(get.eval.result(conn, "A == B & C"))
expect_that(all(S4 == s4), equals(T))

Log.info("Check A == B + C.")
S5 = as.data.frame(get.eval.result(conn, "A == B + C"))
expect_that(all(S5 == s5), equals(T))

Log.info("Check A | B & C.")
S6 = as.data.frame(get.eval.result(conn, "A | B & C"))
expect_that(all(S6 == s6), equals(T))

testEnd()
}

doTest("Test operator precedence.", test.op.precedence)
Loading

0 comments on commit b06d203

Please sign in to comment.