Skip to content

more code cleaning/polishing #571

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

Merged
merged 19 commits into from
Jun 7, 2025
Merged

Conversation

till-m
Copy link
Member

@till-m till-m commented Jun 7, 2025

I didn't merge commit upstream changes from #566, hence the messy commit history, but the changes in this PR are fairly small:

  • Refactor test logic
  • fix some type hints that were incorrect
  • fix not using scipy.optimize.NonlinearConstraint when constructing constraints for the target space tests
  • Switch to American English spelling (per Python standards), undoing the colonial throwback from Replace event based logging #557 courtesy of @adrianmolzon

Summary by CodeRabbit

  • Refactor

    • Updated terminology from British to American English for color-related parameters and variables in user-facing logging output.
    • Consolidated multiple acquisition function integration tests into a single parameterized test for improved maintainability and clarity.
    • Replaced a custom constraint model with a standard library constraint in tests for consistency and reliability.
  • Style

    • Corrected keyword argument names in logger tests to match updated parameter naming.

Copy link

coderabbitai bot commented Jun 7, 2025

Walkthrough

The changes update code to use American English spelling for "color" in the logger, replace a custom constraint model with scipy.optimize.NonlinearConstraint in target space tests, and consolidate multiple acquisition function integration tests into a single parameterized test. Type hints are updated for logger parameters, and test argument names are aligned with code changes.

Changes

File(s) Change Summary
bayes_opt/logger.py Renamed all "colour" variables/params to "color"; updated type hints from ParameterConfig to ParamsType.
tests/test_acquisition.py Replaced five separate acquisition function integration tests with a single parameterized test.
tests/test_logger.py Changed _print_step argument from colour to color in the test.
tests/test_target_space.py Replaced ConstraintModel with scipy.optimize.NonlinearConstraint in constraint-related tests.

Poem

In the warren, colors now gleam,
No more "colours" in the stream!
Tests are tidy, grouped with care,
Constraints from SciPy everywhere.
With every hop, our code feels bright,
Rabbits coding through the night! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8211d and 3d7809e.

📒 Files selected for processing (1)
  • tests/test_acquisition.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/test_acquisition.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Python 3.12 - numpy >=2
  • GitHub Check: Python 3.13 - numpy >=2
  • GitHub Check: Python 3.12 - numpy >=1.25,<2
  • GitHub Check: Python 3.10 - numpy >=1.25,<2
  • GitHub Check: Python 3.11 - numpy >=1.25,<2
  • GitHub Check: Python 3.10 - numpy >=2
  • GitHub Check: Python 3.11 - numpy >=2
  • GitHub Check: Python 3.9 - numpy >=2
  • GitHub Check: Python 3.9 - numpy >=1.25,<2
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Jun 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.76%. Comparing base (f6cde7f) to head (3d7809e).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #571   +/-   ##
=======================================
  Coverage   97.76%   97.76%           
=======================================
  Files          10       10           
  Lines        1164     1164           
=======================================
  Hits         1138     1138           
  Misses         26       26           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/test_acquisition.py (1)

429-431: Consider function signature complexity.

While the test consolidation is excellent, the static analysis hints about too many arguments may indicate the function signature is becoming complex. However, this is acceptable for test functions where comprehensive coverage is prioritized.

The current approach with parametrization is preferable to having multiple duplicate test functions.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 429-429: Too many arguments (6/5)

(R0913)


[refactor] 429-429: Too many positional arguments (6/5)

(R0917)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6cde7f and 3e8211d.

📒 Files selected for processing (4)
  • bayes_opt/logger.py (8 hunks)
  • tests/test_acquisition.py (1 hunks)
  • tests/test_logger.py (1 hunks)
  • tests/test_target_space.py (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/test_logger.py (2)
bayes_opt/target_space.py (2)
  • keys (179-186)
  • params_config (189-191)
bayes_opt/bayesian_optimization.py (1)
  • res (166-171)
bayes_opt/logger.py (1)
bayes_opt/target_space.py (2)
  • params_config (189-191)
  • keys (179-186)
🪛 Pylint (3.3.7)
tests/test_acquisition.py

[refactor] 429-429: Too many arguments (6/5)

(R0913)


[refactor] 429-429: Too many positional arguments (6/5)

(R0917)

⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Python 3.12 - numpy >=2
  • GitHub Check: Python 3.13 - numpy >=2
  • GitHub Check: Python 3.9 - numpy >=2
  • GitHub Check: Python 3.10 - numpy >=2
  • GitHub Check: Python 3.9 - numpy >=1.25,<2
  • GitHub Check: Python 3.11 - numpy >=1.25,<2
  • GitHub Check: Python 3.12 - numpy >=1.25,<2
  • GitHub Check: Python 3.10 - numpy >=1.25,<2
  • GitHub Check: Python 3.11 - numpy >=2
🔇 Additional comments (12)
bayes_opt/logger.py (7)

11-11: LGTM! Type import updated correctly.

The import change from ParameterConfig to ParamsType aligns with the type hint corrections throughout the file.


31-33: LGTM! Consistent spelling convention update.

The class attributes have been correctly updated from British English "colour" to American English "color" spelling, maintaining consistency with Python standards.


144-145: LGTM! Parameter and type hint corrections.

Both the type hint update (ParameterConfigParamsType) and parameter name change (colourcolor) are consistent with the overall American English spelling convention changes.


157-162: LGTM! Documentation updated consistently.

The docstring parameter documentation correctly reflects the spelling and type changes.


181-181: LGTM! Implementation updated to use new parameter name.

The string formatting correctly uses the renamed color parameter instead of the old colour.


261-261: LGTM! Type hints consistently updated.

The params_config parameter type hints have been correctly updated to use ParamsType instead of ParameterConfig throughout the file.

Also applies to: 274-274


286-287: LGTM! Variable references updated consistently.

The implementation correctly uses the renamed color class attributes (_color_new_max, _color_regular_message).

tests/test_logger.py (1)

160-160: LGTM! Test parameter updated for consistency.

The parameter name change from colour to color correctly aligns with the corresponding changes in the logger module, ensuring test consistency.

tests/test_target_space.py (2)

5-5: LGTM! Added import for standardized constraint handling.

The import of scipy.optimize.NonlinearConstraint supports the standardization of constraint usage throughout the test suite.


102-102: LGTM! Standardized constraint construction.

The replacement of custom ConstraintModel with scipy.optimize.NonlinearConstraint improves consistency and reduces reliance on custom constraint implementations. The constraint definitions are correctly constructed with appropriate lambda functions and bounds.

Also applies to: 197-197, 231-231, 244-244

tests/test_acquisition.py (2)

409-428: LGTM! Excellent test consolidation with parametrization.

The consolidation of multiple similar integration tests into a single parameterized test reduces code duplication and improves maintainability. The parametrization covers all the essential acquisition functions with appropriate factory functions and configuration.


433-433: LGTM! Parameterized test implementation is clean.

The test implementation correctly uses the parametrized values (acquisition_fn_factory, state_filename, extra_kwargs) to eliminate code duplication while maintaining the same test logic and coverage.

Also applies to: 441-442, 445-445, 451-451, 454-455

@till-m till-m merged commit 793bbf8 into bayesian-optimization:master Jun 7, 2025
15 checks passed
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

Successfully merging this pull request may close these issues.

1 participant