Skip to content

Commit

Permalink
match exact prob.name and algo.name
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed Mar 9, 2017
1 parent 0edccaa commit 5fe0759
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
@@ -1,4 +1,6 @@
# batchtools 0.9.3
* `findExperiments()` now matches exact string (instead of substrings) for matches using `prob.name` and `algo.name`.
For substring search, use `prob.pattern` or `algo.pattern`, respectively.

# batchtools 0.9.2

Expand Down
8 changes: 4 additions & 4 deletions R/findJobs.R
Expand Up @@ -54,13 +54,13 @@ findJobs = function(expr, ids = NULL, reg = getDefaultRegistry()) {
#' @export
#' @rdname findJobs
#' @param prob.name [\code{character}]\cr
#' Fixed string to match problem names.
#' Exact name of the problem (no substring matching).
#' If not provided, all problems are matched.
#' @param prob.pattern [\code{character}]\cr
#' Regular expression pattern to match problem names.
#' If not provided, all problems are matched.
#' @param algo.name [\code{character}]\cr
#' Fixed string to match algorithm names.
#' Exact name of the problem (no substring matching).
#' If not provided, all algorithms are matched.
#' @param algo.pattern [\code{character}]\cr
#' Regular expression pattern to match algorithm names.
Expand All @@ -82,7 +82,7 @@ findExperiments = function(prob.name = NA_character_, prob.pattern = NA_characte

if (!is.na(prob.name)) {
problem = NULL
tab = tab[stri_detect_fixed(problem, prob.name)]
tab = tab[problem == prob.name]
}

if (!is.na(prob.pattern)) {
Expand All @@ -92,7 +92,7 @@ findExperiments = function(prob.name = NA_character_, prob.pattern = NA_characte

if (!is.na(algo.name)) {
algorithm = NULL
tab = tab[stri_detect_fixed(algorithm, algo.name)]
tab = tab[algorithm == algo.name]
}

if (!is.na(algo.pattern)) {
Expand Down
14 changes: 13 additions & 1 deletion tests/testthat/test_findJobs.R
Expand Up @@ -113,6 +113,9 @@ test_that("findExperiments", {
tab = findExperiments(reg = reg, prob.pattern = "2$")
expect_data_table(tab, nrow = 30, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, prob.pattern = "p1", algo.pattern = "a1", repls = 3:4)
expect_data_table(tab, nrow = 12, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, prob.pattern = c("^p"))
expect_data_table(tab, nrow = 90, ncol = 1, key = "job.id")

Expand All @@ -137,7 +140,16 @@ test_that("findExperiments", {
tab = findExperiments(reg = reg, algo.pattern = "a.")
expect_data_table(tab, nrow = 90, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, algo.name = "a.")
tab = findExperiments(reg = reg, prob.name = "p")
expect_data_table(tab, nrow = 0, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, algo.name = "a")
expect_data_table(tab, nrow = 0, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, prob.name = "xxx")
expect_data_table(tab, nrow = 0, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, algo.name = "xxx")
expect_data_table(tab, nrow = 0, ncol = 1, key = "job.id")

tab = findExperiments(reg = reg, repls = 1:2)
Expand Down

0 comments on commit 5fe0759

Please sign in to comment.