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

Replace custom colour implementation, add docs for logger.py, util.py #435

Merged
merged 3 commits into from
Aug 5, 2023

Conversation

till-m
Copy link
Member

@till-m till-m commented Jul 10, 2023

cf. #427 #434

Also contains fixes for some code smells reported by pylint.

NB: This PR is not against master, but against a separate branch.

@till-m till-m changed the title Replace custom colour implementation, add docs for logger.py, utilpy Replace custom colour implementation, add docs for logger.py, util.py Jul 10, 2023
@till-m till-m requested review from fmfn and bwheelz36 July 13, 2023 08:02
@till-m
Copy link
Member Author

till-m commented Jul 13, 2023

@leandrobbraga a review of yours would also be appreciated, if you have the time.


Parameters
----------
event : str
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a string or an Events object? By looking at the code it is comparing event == Events.OPTIMIZATION_START, which implies that it is an Events object.

Copy link
Member Author

Choose a reason for hiding this comment

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

These Events.OPTIMIZATION_START etc. are properties of the events classed with assigned string values optimization:start etc. I thought about going for Event as type, but that is technically not correct. Maybe it would be good to define Events as a proper Enum but I wouldn't do that in this PR.

Comment on lines +271 to 281
Parameters
----------
event : str
One of the values associated with `Events.OPTIMIZATION_START`,
`Events.OPTIMIZATION_STEP` or `Events.OPTIMIZATION_END`.

instance : bayesian_optimization.BayesianOptimization
The instance associated with the step.

"""
if event == Events.OPTIMIZATION_STEP:
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here, it seems that we expect event to be of Events type

Comment on lines +112 to +114
if x:
x_ = 'T'
elif x == False:
else:
Copy link
Contributor

@leandrobbraga leandrobbraga Jul 20, 2023

Choose a reason for hiding this comment

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

These two codes have different behavior, it seems that the old one was intently done with if / elif.

>>> x = "false"
>>> if x:
...    print("got 'true'!")
... else:
...    print("got 'false'!)
...
got 'true'!

But it can be as surprising as this:

>>> x = 0
>>> if x:
...    print("got 'true'!")
... else:
...    print("got 'false'!)
...
got 'false'!

Or even

>>> x = []
>>> if x:
...    print("got 'true'!")
... else:
...    print("got 'false'!)
...
got 'false'!

In the previous code it would ignore anything that's not a boolean

Copy link
Member Author

Choose a reason for hiding this comment

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

it seems that the old one was intently done with if / elif

I think you're giving me too much credit here 🙃

I do see how this could potentially print something wrong if called with the wrong argument type. What do you think would be the best way to handle this case?

@till-m till-m merged commit 201c6b2 into bayesian-optimization:docstring-overhaul Aug 5, 2023
till-m added a commit that referenced this pull request Feb 26, 2024
* Replace custom colour implementation, add docs for `logger.py`, `util.py` (#435)

* Replace custom colour implementation, add docs for `logger.py`, `util.py`

* minor typo/syntax fixes

* User `or` to separate different possible types

* Update docs & linting for `constraints.py`, `target_space.py` (#440)

* Run tests on any PR

* Update docs, linting

* Update bayes_opt/constraint.py

Co-authored-by: Leandro Braga <[email protected]>

* Rename mislabelled parameters

---------

Co-authored-by: Leandro Braga <[email protected]>

* Update various docstrings, add workflow to check docstrings (#445)

* Fixes issue-436: Constrained optimization does not allow duplicate points (#437)

* Update docs of `bayesian_optimization.py` and `observer.py`.

* Fix minor style issue in module docstring

* Update docs of `__init__.py` and `events.py`.

* Fix minor style issue in class docstring

* Add workflow to check docstrings

* Update bayes_opt/bayesian_optimization.py

Co-authored-by: Leandro Braga <[email protected]>

---------

Co-authored-by: YoungJae Bae <[email protected]>
Co-authored-by: Leandro Braga <[email protected]>

* Pydocstyle (#453)

* Improve acq_max seeding of L-BFGS-B optimization (#297)

---------

Co-authored-by: ptapping <[email protected]>

* Domain reduction, Sphinx docs (#455)

* Fixes issue-436: Constrained optimization does not allow duplicate points (#437)

* Update docs of `bayesian_optimization.py` and `observer.py`.

* Fix minor style issue in module docstring

* Update docs of `__init__.py` and `events.py`.

* Fix minor style issue in class docstring

* Add workflow to check docstrings

* Update bayes_opt/bayesian_optimization.py

Co-authored-by: Leandro Braga <[email protected]>

* Improve acq_max seeding of L-BFGS-B optimization (#297)

* bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py (#441)

* Update trim bounds in domain_reduction.py

Previously, when the new upper limit was less than the original lower limit, the new_bounds could bypass the global_bounds.

* Update test_seq_domain_red.py

Added test cases to catch an error when both bounds of new_bounds exceeded the global_bounds

* Update domain_reduction.py

_trim function now avoids an error when both bounds for a given parameter in new_bounds exceed the global_bounds

* Update domain_reduction.py comments

* fixed English in domain_reduction.py

* use numpy to sort bounds,  boundary exceeded warn.

* simple sort test added

* domain_red windows target_space to global_bounds

Added windowing function to improve the convergence of optimizers that use domain_reduction. Improved comments and documentation.

* target_space.max respects bounds; SDRT warnings

* Remove unused function.

This function was used to prototype a solution. It should not have been pushed and can be removed.

* Updated target_space.py docstrings

* Update tests/test_target_space.py

Co-authored-by: till-m <[email protected]>

* Added pbound warnings, updated various tests.

* updated line spacing for consistency and style

* added pbound test condition

---------

Co-authored-by: till-m <[email protected]>

* DomainReduction docs, docstyle

* Add missing doc dependency

---------

Co-authored-by: YoungJae Bae <[email protected]>
Co-authored-by: Leandro Braga <[email protected]>
Co-authored-by: ptapping <[email protected]>
Co-authored-by: Edgar <[email protected]>

* Small fixes, minor cosmetic changes

* Add some more docs to target space and constraint, cosmetic changes

* Remove duplicate code snippet

* Remove numpydoc + adjust "*" formatting accordingly

* Explicitly add D417, adjust code accordingly

* Adjust `TargetSpace.probe()` behaviour to be in line with docstring.

* Update bayes_opt/target_space.py

Co-authored-by: Edgar <[email protected]>

* Update README.md

---------

Co-authored-by: Leandro Braga <[email protected]>
Co-authored-by: YoungJae Bae <[email protected]>
Co-authored-by: ptapping <[email protected]>
Co-authored-by: Edgar <[email protected]>
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.

2 participants