Made error message for create_study's direction easier to understand optuna.study#6021
Made error message for create_study's direction easier to understand optuna.study#6021nabenabe0928 merged 7 commits intooptuna:masterfrom
create_study's direction easier to understand optuna.study#6021Conversation
|
For some reason docs/readthedocs.org:optuna now fails. |
3d4ca56 to
b2ba40f
Compare
|
I thought the docs/readthedocs.org:optuna might be failing because I used Sorry for the mess in the history and PR section. In the end I don't know the cause either. |
|
I don't know why, but it didn't seem to pinch this time! |
nzw0301
left a comment
There was a problem hiding this comment.
Yeah, CI jobs sometimes fail due to an external service. Sorry for confusing you.
In terms of PR, could you add a test?
|
I added a test in the form of an extension to Let's change it to create a new function like |
|
@nzw0301 Could you continue to review this PR? |
HideakiImamura
left a comment
There was a problem hiding this comment.
Thanks for the PR. I have several comments. PTAL.
tests/study_tests/test_study.py
Outdated
| assert str(e.value) == ( | ||
| "Please set either 'minimize' or 'maximize' to direction. You can also set the " | ||
| + "corresponding `StudyDirection` member." | ||
| ) |
There was a problem hiding this comment.
IMO, we should not test the exact contents of the error message since it is not a specification, so might be changed later. It would be great to confirm that the error is emitted.
tests/study_tests/test_study.py
Outdated
| assert ( | ||
| str(e.value) | ||
| == "For multi-objective optimization, using `directions` instead of `direction`." | ||
| ) |
tests/study_tests/test_study.py
Outdated
| with pytest.raises(ValueError) as e: | ||
| # Empty `direction` isn't allowed. | ||
| _ = create_study(directions=[]) | ||
| assert str(e.value) == "The number of objectives must be greater than 0." |
tests/study_tests/test_study.py
Outdated
| with pytest.raises(ValueError): | ||
| with pytest.raises(ValueError) as e: | ||
| _ = create_study(direction="minimize", directions=["maximize"]) | ||
| assert str(e.value) == "Specify only one of `direction` and `directions`." |
tests/study_tests/test_study.py
Outdated
| with pytest.raises(ValueError): | ||
| with pytest.raises(ValueError) as e: | ||
| _ = create_study(direction="minimize", directions=[]) | ||
| assert str(e.value) == "Specify only one of `direction` and `directions`." |
|
@HideakiImamura Do you think it is ok for us to ignore it? |
nzw0301
left a comment
There was a problem hiding this comment.
Thanks! The added test looks perfect. Let me leave a minor comment.
optuna.studycreate_study's direction easier to understand optuna.study
Co-authored-by: Kento Nozawa <k_nzw@klis.tsukuba.ac.jp>
nabenabe0928
left a comment
There was a problem hiding this comment.
I think this part should also be modified.
Lines 1258 to 1261 in 896e0ca
Could you, @sinano1107 , please check the comment here as well?
|
@nabenabe0928 |
|
@sinano1107 |
|
@nabenabe0928 |
issue: #5806
Motivation
Users sometimes makes the mistake of passing the list of directions to the direction argument. The error message for this mistake is hard to understand what is the problem.
Using direction instead of directions
Description of the changes
The error message displayed when a list object, is assigned to the direction parameter of create_study has been changed as follows.