Skip to content

Commit

Permalink
rebase and small stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-thomas committed Nov 24, 2016
1 parent e8f4876 commit d167503
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/infillOptFocus.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ infillOptFocus = function(infill.crit, models, control, par.set, opt.path, desig
}
} else if (isDiscrete(par)) {
# randomly drop a level, which is not val
if (length(par$values) <= 1L) {
if (length(par$values) == 1L) {
return(par)
}
# need to do some magic to handle discrete vectors
if (par$type %nin% c("discretevector", "logicalvector")) {
val.names = names(par$values)
# remove current val from delete options, should work also for NA
val.names = val.names[!sapply(par$values, identical, y=val)] # remember, 'val' can be any type
val.names = val.names[!vlapply(par$values, identical, y=val)] # remember, 'val' can be any type
to.del = sample(val.names, 1)
par$values[[to.del]] = NULL
} else {
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test_infill_opt_focus.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ test_that("complex param space, dependencies, focusing, restarts", {
if(x$disc2 == 'a') tmp3 = log(x$realA) + x$intA^4 + ifelse(x$discA == 'm', 5, 0)
if(x$disc2 == 'b') tmp3 = exp(x$realB) + ifelse(x$discB == 'R', sin(x$realBR), sin(x$realBNR))
if(x$disc2 == "c") tmp3 = 500
assert(is.list(x$discVec))
assert(x$discVec[[1]] %in% c("a", "b", "c"))
assert(x$discScal %in% c("x", "y", "z"))
expect_list(x$discVec)
expect_subset(x$discVec[[1]], c("a", "b", "c"))
expect_subset(x$discScal, c("x", "y", "z"))
tmp1 + tmp2 + tmp3
},
par.set = makeParamSet(
Expand Down

0 comments on commit d167503

Please sign in to comment.