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

Print function for DiscreteVectorLearnerParam with unknown length is broken #180

Open
mb706 opened this issue Jun 16, 2017 · 8 comments
Open

Comments

@mb706
Copy link
Collaborator

mb706 commented Jun 16, 2017

> x =  makeDiscreteVectorLearnerParam("test", default = list(), values = c("a", "b", "c"), len = NA)
> x
Error in if (par$type == "discretevector" && length(x) != par$len) stopf("Length of x must be %i!",  : 
  missing value where TRUE/FALSE needed
@berndbischl
Copy link
Member

the problem seems to be your default? and should that even be valid?

@berndbischl
Copy link
Member

if you remove the default=list() it works

@mb706
Copy link
Collaborator Author

mb706 commented Jun 16, 2017

So LearnerParams with unknown vector length should not have a default?

@berndbischl
Copy link
Member

this also breaks

x = makeDiscreteVectorLearnerParam("test", default = list("a", "b"), values = c("a", "b", "c"), len = NA)

@berndbischl
Copy link
Member

So LearnerParams with unknown vector length should not have a default?

no, i am not saying this. i was just wondering wether the list() is a valid defaults. surely vecparams can have defaults. i was wondering whether the problems comes from the edge case of a default where the vector is length 0.

but apparantly other defaults have the same problem

@berndbischl
Copy link
Member

berndbischl commented Jun 16, 2017

the method that really breaks in the background is this

> x =  makeDiscreteVectorLearnerParam("test", values = c("a", "b", "c"), len = NA)
> paramValueToString(x, list())
Error in if (par$type == "discretevector" && length(x) != par$len) stopf("Length of x must be %i!",  : 
  missing value where TRUE/FALSE needed
> paramValueToString(x, list("a"))
Error in if (par$type == "discretevector" && length(x) != par$len) stopf("Length of x must be %i!",  : 
  missing value where TRUE/FALSE needed

@mb706
Copy link
Collaborator Author

mb706 commented Jun 16, 2017

Also

> x= makeNumericVectorLearnerParam("test", default = numeric(0), lower = 0, upper = 10, len = NA)
> x
           Type len        Def  Constr Req Tunable Trafo
1 numericvector  NA numeric(0) 0 to 10   -    TRUE     -
Used: train.

works (and I think length 0 vectors should be possible imho).

@berndbischl
Copy link
Member

(and I think length 0 vectors should be possible imho).

i agree. and the problem is as i posted above something else anyway. but of course we can then unit test your case with 0 length too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants