Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mb706 committed Jan 14, 2024
1 parent cab9912 commit 8228e0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/ParamSetCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ ParamSetCollection = R6Class("ParamSetCollection", inherit = ParamSet,
# We do this here because we don't want the loop to be aborted early and have half an update.
self$assert(xs)

translate = private$.translation[names(xs), list(original_id, owner_ps_index), on = "id"]
# %??% character(0) in case xs is an empty unnamed list
translate = private$.translation[names(xs) %??% character(0), list(original_id, owner_ps_index), on = "id"]
set(translate, , j = "values", list(xs))
for (xtl in split(translate, by = "owner_ps_index")) {
sets[[xtl$owner_ps_index[[1]]]]$values = set_names(xtl$values, xtl$original_id)
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test_ParamSetCollection.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ test_that("values", {

expect_equal(ps1clone, ps1)
expect_equal(ps2clone, ps2)

# resetting pcs values
pcs$values = list()
expect_list(pcs$values, len = 0)
})

test_that("empty collections", {
Expand Down

0 comments on commit 8228e0f

Please sign in to comment.