Skip to content

Use f-strings in optuna/samplers/_cmaes.py#6331

Merged
not522 merged 4 commits intooptuna:masterfrom
swativdusane:refactor-use-fstrings
Nov 13, 2025
Merged

Use f-strings in optuna/samplers/_cmaes.py#6331
not522 merged 4 commits intooptuna:masterfrom
swativdusane:refactor-use-fstrings

Conversation

@swativdusane
Copy link
Copy Markdown

@swativdusane swativdusane commented Nov 8, 2025

Motivation

Description of the changes

Summary:
This PR refactors parts of optuna/samplers/_cmaes.py to use f-strings for improved readability and consistency.

Changes:

Replaced .format() calls with f-strings.
Used {var_name=} style where applicable for clearer variable output.
Updated _logger.warning calls to use f-strings with intermediate variable (ind_sampler_name).

Copy link
Copy Markdown
Member

@c-bata c-bata 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 pull requests. I have two requests:

  1. Could you write the description?
  2. Please do not replace _deprecated._DEPRECATION_WARNING_TEMPLATE and _INDEPENDENT_SAMPLING_WARNING_TEMPLATE with f-strings.

@swativdusane
Copy link
Copy Markdown
Author

Thank you for your pull requests. I have two requests:

  1. Could you write the description?
  2. Please do not replace _deprecated._DEPRECATION_WARNING_TEMPLATE and _INDEPENDENT_SAMPLING_WARNING_TEMPLATE with f-strings.

Thank you for the feedback!
I have added a detailed description to the PR.
I reverted the earlier replacements and kept _deprecated._DEPRECATION_WARNING_TEMPLATE and _INDEPENDENT_SAMPLING_WARNING_TEMPLATE as they were, following your guidance.

@not522 not522 changed the title Refactor: use f-strings in optuna/samplers/_cmaes.py (first-time cont… Use f-strings in optuna/samplers/_cmaes.py Nov 12, 2025
) -> bool:
intersection_size = len(set(trans._search_space.keys()).intersection(search_space.keys()))
return intersection_size == len(trans._search_space) == len(search_space)
return intersection_size == len(trans._search_space) == len(search_space) No newline at end of file
Copy link
Copy Markdown
Member

@not522 not522 Nov 12, 2025

Choose a reason for hiding this comment

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

Thank you for update! Could you revert the final newline in the file?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you for the feedback! I have restored the final newline at the end of the file. Please let me know if any further changes are needed.

@not522 not522 self-assigned this Nov 12, 2025
Copy link
Copy Markdown
Member

@c-bata c-bata left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you for the update!

@c-bata c-bata removed their assignment Nov 13, 2025
@c-bata c-bata added the code-fix Change that does not change the behavior, such as code refactoring. label Nov 13, 2025
@c-bata c-bata added this to the v4.7.0 milestone Nov 13, 2025
Copy link
Copy Markdown
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

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

LGTM!

@not522 not522 enabled auto-merge November 13, 2025 05:05
@not522 not522 merged commit e7c6f1d into optuna:master Nov 13, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-fix Change that does not change the behavior, such as code refactoring.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants