Skip to content

ParamSet Conditions should respect $default #265

@mb706

Description

@mb706

Suppose the following ParamSet:

> ps <- ParamSet$new(list(
  ParamLgl$new("x", default = TRUE),
  ParamLgl$new("y")))
> ps$add_dep("y", "x", CondEqual$new(TRUE))

Here the default = TRUE indicates that, if the parameter x is not given, the whole thing should behave like x is set to TRUE. E.g. x could indicate whether a certain feature is used, and y could then influence the configuration of that feature---y then depends on x being TRUE, since it does not have anything to configure if x is FALSE.

Since the "default" behaviour indicated is that the feature is usually present (everything behaves like x is TRUE) if x is not given at all, it makes sense to just set the y parameter and have the x parameter be "implicitly" TRUE.

This is not what happens, however:

> ps$values <- list(y = TRUE)
Error in (function (xs)  : 
  Assertion on 'xs' failed: The parameter 'y' can only be set if the following condition is met 'x = TRUE'. Instead the parameter value for 'x' is not set at all. Try setting 'x' to a value that satisfies the condition.

The ParamSet$check() function should do an xs = insert_named(self$default, xs) after the if(!isTRUE(ok)) block. What I am describing above should be added as a test; possibly add more tests.

(I believe one of our student assistants could solve this)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions