Skip to content

Commit af44dd9

Browse files
Merge pull request #53 from kapsner/master
Fix #52: removing `setorder` due to reproducibility-issues
2 parents cbc3e2b + 766ba97 commit af44dd9

File tree

10 files changed

+39
-14
lines changed

10 files changed

+39
-14
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
.Rproj
21
.Rbuildignore
32
.Rhistory
4-
ParBayesianOptimization.Rproj
53
README.Rmd
64
CRAN-RELEASE
75
.Rproj.user

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Imports: data.table (>= 1.11.8), DiceKriging, stats, foreach, dbscan, lhs, crayo
1414
Suggests: knitr, rmarkdown, xgboost, doParallel, testthat
1515
License: GPL-2
1616
Encoding: UTF-8
17-
RoxygenNote: 7.1.1
17+
RoxygenNote: 7.2.1
1818
VignetteBuilder: knitr
1919
Maintainer: Samuel Wilson <[email protected]>

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import(foreach)
1212
importFrom(DiceKriging,km)
1313
importFrom(crayon,make_style)
1414
importFrom(crayon,red)
15+
importFrom(data.table,".SD")
1516
importFrom(data.table,":=")
1617
importFrom(data.table,.I)
1718
importFrom(data.table,as.data.table)
@@ -23,7 +24,6 @@ importFrom(data.table,rbindlist)
2324
importFrom(data.table,setDT)
2425
importFrom(data.table,setcolorder)
2526
importFrom(data.table,setnames)
26-
importFrom(data.table,setorder)
2727
importFrom(data.table,uniqueN)
2828
importFrom(dbscan,dbscan)
2929
importFrom(ggplot2,aes_string)

ParBayesianOptimization.Rproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Version: 1.0
2+
3+
RestoreWorkspace: Default
4+
SaveWorkspace: Default
5+
AlwaysSaveHistory: Default
6+
7+
EnableCodeIndexing: Yes
8+
UseSpacesForTab: Yes
9+
NumSpacesForTab: 2
10+
Encoding: UTF-8
11+
12+
RnwWeave: Sweave
13+
LaTeX: pdfLaTeX
14+
15+
AutoAppendNewline: Yes
16+
StripTrailingWhitespace: Yes
17+
18+
BuildType: Package
19+
PackageUseDevtools: Yes
20+
PackageInstallArgs: --no-multiarch --with-keep.source
21+
PackageRoxygenize: rd,collate,namespace

R/SmallFuncs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ checkParameters <- function(
160160
if (parallel & (getDoParWorkers() == 1)) stop("parallel is set to TRUE but no back end is registered.\n")
161161
if (!parallel & getDoParWorkers() > 1 & verbose > 0) message("parallel back end is registered, but parallel is set to false. Process will not be run in parallel.")
162162
if (any(!names(otherHalting) %in% c("timeLimit","minUtility"))) stop("otherHalting element not recognized. Must be one of timeLimit and minUtility.")
163-
if (class(bounds) != "list") stop("bounds must be a list of parameter bounds with the same arguments as FUN.")
163+
if (!inherits(x = bounds, what = "list")) stop("bounds must be a list of parameter bounds with the same arguments as FUN.")
164164
if (any(lengths(bounds) != 2)) stop("Not all elements in bounds are length 2.")
165165
if (acqThresh > 1 | acqThresh < 0) stop("acqThresh must be in [0,1]")
166166
if (!is.logical(plotProgress)) stop("plotProgress must be logical")

R/addIterations.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ addIterations <- function(
7070
) {
7171

7272
startT <- Sys.time()
73-
if(class(optObj) != "bayesOpt") stop("optObj must be of class bayesOpt")
73+
if (!inherits(x = optObj, what = "bayesOpt")) stop("optObj must be of class bayesOpt")
7474

7575
# Check the parameters
7676
checkParameters(

R/bayesOpt.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ bayesOpt <- function(
309309

310310
# Make sure everything was returned in the correct format. Any errors here will be passed.
311311
if (any(class(Result) %in% c("simpleError","error","condition"))) return(Result)
312-
if (class(Result) != "list") stop("Object returned from FUN was not a list.")
312+
if (!inherits(x = Result, what = "list")) stop("Object returned from FUN was not a list.")
313313
resLengths <- lengths(Result)
314314
if (!any(names(Result) == "Score")) stop("FUN must return list with element 'Score' at a minimum.")
315315
if (!is.numeric(Result$Score)) stop("Score returned from FUN was not numeric.")

R/changeSaveFile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#' @export
3030
changeSaveFile <- function(optObj,saveFile = NULL) {
3131

32-
if (class(optObj) != "bayesOpt") stop("optObj should be of class bayesOpt.")
32+
if (!inherits(x = optObj, what = "bayesOpt")) stop("optObj should be of class bayesOpt.")
3333

3434
# See if saveFile can be written to.
3535
if (!is.null(saveFile)) {

R/getNextParameters.R

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#' @importFrom dbscan dbscan
2-
#' @importFrom data.table fintersect uniqueN setorder
2+
#' @importFrom data.table fintersect
3+
#' @importFrom data.table uniqueN
4+
#' @importFrom data.table ".SD"
35
getNextParameters <- function(
46
LocalOptims
57
, boundsDT
@@ -15,17 +17,21 @@ getNextParameters <- function(
1517
) {
1618

1719
LocalOptims <- LocalOptims[get("relUtility") >= acqThresh,]
18-
LocalOptims <- LocalOptims[,c(boundsDT$N,"gpUtility"),with=FALSE]
19-
setorder(LocalOptims,-"gpUtility")
20+
LocalOptims <- LocalOptims[
21+
,
22+
.SD,
23+
.SDcols = c(boundsDT$N,"gpUtility")
24+
]
25+
2026
LocalOptims$acqOptimum <- TRUE
2127

2228
# Mark clusters as duplicates if they have already been attempted. Note that
2329
# parameters must match exactly. Whether or not we should eliminate 'close'
2430
# parameters is experimental, and could cause problems as the parameter space
2531
# becomes more fully explored.
2632
LocalOptims$Duplicate <- checkDup(
27-
LocalOptims[,boundsDT$N,with=FALSE]
28-
, scoreSummary[,boundsDT$N,with=FALSE]
33+
LocalOptims[, boundsDT$N, with = FALSE]
34+
, scoreSummary[, boundsDT$N, with = FALSE]
2935
)
3036

3137
# If we already have runNew non-duplicate local optims, use the best of those.

R/updateGP.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ updateGP <- function(optObj,bounds = optObj$bounds,verbose = 1, ...) {
7575
}
7676
)
7777

78-
if (class(sgp) == "stopEarlyMsg") {
78+
if (inherits(x = sgp, what = "stopEarlyMsg")) {
7979
optObj$stopStatus <- sgp
8080
return(optObj)
8181
} else {

0 commit comments

Comments
 (0)