Skip to content

Support object representation of StudyDirection for create_study arguments#2516

Merged
toshihikoyanase merged 4 commits intooptuna:masterfrom
g-votte:study-direction-arg
Mar 25, 2021
Merged

Support object representation of StudyDirection for create_study arguments#2516
toshihikoyanase merged 4 commits intooptuna:masterfrom
g-votte:study-direction-arg

Conversation

@g-votte
Copy link
Copy Markdown
Member

@g-votte g-votte commented Mar 24, 2021

This PR enables to pass StudyDirection objects to the direction/directions argument of optuna.create_study.

Motivation

Supporting StudyDirection objects sometimes simplifies the user’s code especially when the user already has the StudyDirection objects when creating the study, e.g., copying an existing study to new one as follows.

study_src = optuna.load_study(study_name=study_name, storage=storage_url)
study_dist = optuna.create_study(directions=study_src.directions)

for t in study_src.trials:
    study_dist.add_trial(t)

Note that the code above raises an error in the second line without applying this PR, and the user has to convert the direction objects to the string representation.

@github-actions github-actions Bot added the optuna.study Related to the `optuna.study` submodule. This is automatically labeled by github-actions. label Mar 24, 2021
Comment thread optuna/study.py Outdated
@g-votte g-votte marked this pull request as ready for review March 24, 2021 09:57
Copy link
Copy Markdown
Member

@hvy hvy left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM! Left a minor comment but it's mostly a cosmetic.

Comment thread optuna/study.py Outdated
@hvy hvy self-assigned this Mar 24, 2021
@hvy hvy added the feature Change that does not break compatibility, but affects the public interfaces. label Mar 24, 2021
@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 24, 2021

Codecov Report

Merging #2516 (6ee3391) into master (4b2cfc0) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2516      +/-   ##
==========================================
- Coverage   89.80%   89.78%   -0.02%     
==========================================
  Files         135      135              
  Lines       11310    11310              
==========================================
- Hits        10157    10155       -2     
- Misses       1153     1155       +2     
Impacted Files Coverage Δ
optuna/study.py 96.13% <100.00%> (ø)
optuna/integration/botorch.py 97.75% <0.00%> (-0.90%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b2cfc0...6ee3391. Read the comment docs.

Copy link
Copy Markdown
Member

@toshihikoyanase toshihikoyanase left a comment

Choose a reason for hiding this comment

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

Thank you for your PR. This feature definitely improves the usability of optuna.create_study.
The change looks good to me, but I have a small comment on the error message.

Comment thread optuna/study.py Outdated
@toshihikoyanase toshihikoyanase self-assigned this Mar 25, 2021
Copy link
Copy Markdown
Member

@toshihikoyanase toshihikoyanase left a comment

Choose a reason for hiding this comment

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

Thank you for your update. LGTM!

@toshihikoyanase toshihikoyanase merged commit 10c81a6 into optuna:master Mar 25, 2021
@toshihikoyanase toshihikoyanase added this to the v2.7.0 milestone Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Change that does not break compatibility, but affects the public interfaces. optuna.study Related to the `optuna.study` submodule. This is automatically labeled by github-actions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants