Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stringi dependency (fixes #204) #206

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ Suggests:
knitr,
rmarkdown,
testthat,
roxygen2,
stringi
roxygen2
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1
VignetteBuilder: knitr
Expand Down
4 changes: 2 additions & 2 deletions R/ParamSetCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ ParamSetCollection = R6Class("ParamSetCollection", inherit = ParamSet,
assert_list(xs)
self$assert(xs) # make sure everything is valid and feasible
# extract everything before 1st dot
set_ids = stri_split_fixed(names(xs), ".", n = 1L, tokens_only = TRUE)[[1L]]
set_ids = sub("^([^.]+)\\..+", "\\1", names(xs))
xs = split(xs, set_ids) # partition xs into parts wrt to setids
for (s in private$.sets) {
# retrieve sublist for each set, then assign it in set (after removing prefix)
pv = xs[[s$set_id]]
if (is.null(pv))
pv = list()
names(pv) = stri_replace_first_fixed(names(pv), paste0(s$set_id, "."), "")
names(pv) = sub(sprintf("^%s.", s$set_id), "", names(pv))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd probably need to escape regex characters from set_id like this. Maybe use subsr?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special chars are allowed in an id? 😟

s$param_vals = pv
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/helper_zzz.R

This file was deleted.

8 changes: 2 additions & 6 deletions tests/testthat/test_Param.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ test_that("printer works", {
for (p in th_paramset_full()$params) {
info = p$id
s = capture_output(print(p))
expect_true(stri_detect_fixed(s, p$id), info = info)
expect_true(stri_detect_fixed(s, class(p)[1L]), info = info)
expect_true(grepl(p$id, s, fixed = TRUE), info = info)
expect_true(grepl(class(p)[1L], s, fixed = TRUE), info = info)
}
})




6 changes: 3 additions & 3 deletions tests/testthat/test_ParamSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ test_that("ParamSet$print", {
ps = th_paramset_numeric()
expect_output(print(ps), "ParamSet:")
s = capture_output(print(ps))
expect_true(stri_detect_fixed(s, "ParamInt"))
expect_true(stri_detect_fixed(s, "ParamDbl"))
expect_true(grepl("ParamInt", s, fixed = TRUE))
expect_true(grepl("ParamDbl", s, fixed = TRUE))
s = capture_output(print(ps, hide.cols = c("class")))
expect_false(stri_detect_fixed(s, "ParamInt"))
expect_false(grepl("ParamInt", s, fixed = TRUE))

# iterate through more complex PS and check that printer works by at least calling it
ps_list = list(
Expand Down