Skip to content

Commit

Permalink
PUBDEV-1043: broken logic in ifelse for test type of H2OParsedData
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed May 4, 2015
1 parent 34cc860 commit 5cd4f3f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
15 changes: 10 additions & 5 deletions R/h2o-package/R/Classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -1839,11 +1839,16 @@ setMethod("ifelse", signature(test="ANY",yes="H2OParsedData", no="H2OParsedData"
if (is.logical(no)) no <- as.numeric(no)
return(.h2o.__multop2("ifelse", as.numeric(test), yes, no))
}
if (is.atomic(test))
storage.mode(test) <- "logical"
else test <- if (isS4(test))
as(test, "logical")
else as.logical(test)

if( is(test, "H2OParsedData") ) {
if( is.character(yes) ) yes <- deparse(yes)
if( is.character(no) ) no <- deparse(no)
return(.h2o.__multop2("ifelse",test,yes,no))
}

if (is.atomic(test)) storage.mode(test) <- "logical"
else if( isS4(test) ) test <- as(test, "logical")
else test <- as.logical("test")
ans <- test
ok <- !(nas <- is.na(test))
if (any(test[ok]))
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/water/exec/ASTOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -2309,9 +2309,20 @@ static AST parse(Exec2 E, AST tst, boolean EOS) {

Frame frtst=null, frtru= null, frfal= null;
double dtst= 0 , dtru= 0 , dfal= 0 ;
if( env.isAry() ) frfal= env.popAry(); else dfal = env.popDbl(); String kf = env.key();
if( env.isAry() ) frtru= env.popAry(); else dtru = env.popDbl(); String kt = env.key();
if( env.isAry() ) frtst= env.popAry(); else dtst = env.popDbl(); String kq = env.key();
String kf, kt, kq;

if( env.isAry() ) frfal= env.popAry();
else if( env.isDbl() && !env.isStr() ) { dfal = env.popDbl(); }
else if( env.isStr() ) { env.popStr(); dfal=0.0; }
kf = env.key();

if( env.isAry() ) frtru= env.popAry();
else if( env.isDbl() && !env.isStr() ) { dtru = env.popDbl(); }
else if( env.isStr() ) { env.popStr(); dtru=1.0; }
kt = env.key();

if( env.isAry() ) frtst= env.popAry(); else dtst = env.popDbl();
kq = env.key();

// Multi-selection
// Build a doAll frame
Expand Down

0 comments on commit 5cd4f3f

Please sign in to comment.