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

Docstring overhaul #457

Merged
merged 15 commits into from
Feb 26, 2024
Merged

Conversation

till-m
Copy link
Member

@till-m till-m commented Jan 24, 2024

Resolves #427 #434

  • Rewrites most docstrings
  • Uses numpydoc
  • Include README.md in the docs
  • Change links in README.md to link preferrably to docs webpage
  • Change github links in README to link to the organization repo
  • Replaces colors with colorama Replace custom colour implementation with colorama colours #434
  • Migrate images from examples/ to static/

till-m and others added 7 commits August 5, 2023 16:10
….py` (bayesian-optimization#435)

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

* minor typo/syntax fixes

* User `or` to separate different possible types
…an-optimization#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]>
…-optimization#445)

* Fixes issue-436: Constrained optimization does not allow duplicate points (bayesian-optimization#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]>
* Improve acq_max seeding of L-BFGS-B optimization (bayesian-optimization#297)

---------

Co-authored-by: ptapping <[email protected]>
* Fixes issue-436: Constrained optimization does not allow duplicate points (bayesian-optimization#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 (bayesian-optimization#297)

* bounds_transformer could bypass global_bounds due to the test logic within _trim function in domain_reduction.py (bayesian-optimization#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]>
@till-m
Copy link
Member Author

till-m commented Jan 24, 2024

It looks like something was messed up in all the merges. I will close this PR for now and have a look when I'm back from* vacation.

@till-m till-m closed this Jan 24, 2024
@till-m till-m reopened this Jan 31, 2024
Copy link

codecov bot commented Jan 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (129caac) 98.47% compared to head (17f1e27) 98.70%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #457      +/-   ##
==========================================
+ Coverage   98.47%   98.70%   +0.22%     
==========================================
  Files           8        8              
  Lines         590      540      -50     
  Branches       90       90              
==========================================
- Hits          581      533      -48     
  Misses          3        3              
+ Partials        6        4       -2     

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

@till-m till-m force-pushed the docstring-overhaul branch from d666e93 to 8ffdb4f Compare January 31, 2024 21:25
@till-m
Copy link
Member Author

till-m commented Jan 31, 2024

looking back now, I think making a big PR on a seperate branch was not a great idea...

Some of the docstring rules imposed by the numpydocs convention are a bit silly imo, but I guess there is an argument to be made for consistency.
Either way, this should hopefully give us a solid base of docstrings to work with. I think we can then refine how the documentation should look in the future.

Copy link
Contributor

@perezed00 perezed00 left a comment

Choose a reason for hiding this comment

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

So far everything I've seen looks good. I took the closest look at domain reduction and target space changes.

@perezed00
Copy link
Contributor

@till-m please re-request my review. My previous approval of all commits was in error.

@till-m till-m requested a review from perezed00 February 1, 2024 20:44
@bwheelz36
Copy link
Collaborator

Nice work @till-m
I won't review all docstrings, but I see you implemented an automatic checker which I think is absolutely the right approach.

  • I'm not familiar with numpy-docs - does it allow for configuration to ignore trivial errors?
  • Will it detect missing docstrings/parameter descriptions in public methods? this is the main thing I'd really like to make sure we nail down.
  • What I have done on other code is use flake8-docstrings and then set it to ignore the largely spurious errors it throws up (things like missing spaces, full stops etc.)

@till-m
Copy link
Member Author

till-m commented Feb 7, 2024

Hey @bwheelz36,

I won't review all docstrings

completely understandable. If possible, could you review the changes to the README?

I'm not familiar with numpy-docs

I think we don't actually need this to check for convention. I will remove it.

Will it detect missing docstrings/parameter descriptions in public methods? this is the main thing I'd really like to make sure we nail down.

It will detect missing docstrings as-is

bayes_opt/bayesian_optimization.py:369 in public method `set_bounds`:
        D102: Missing docstring in public method

I didn't realize, but missing parameters needs to be explicitly enabled. I will enable it. Note that this does not detect missing docstrings of class documentation, or missing parameters in class documentation. This is due to the way __init__ is handled.

does it allow for configuration to ignore trivial errors?

You can additionally ignore errors by passing --add-ignore <error code> in the call. Unfortunately one cannot ignore individual lines (similar to noqa). The tool you sent is actually a wrapper around pydocstyle, so it behaves the same (except it additionally produces a number of linting issues). If we want to additionally add linting rules, we could also do that, though in that case I would suggest to use ruff which has the advantage of being both very comprehensive and very fast. However, if we want to use ruff we should merge #458 into this branch, as it requires the pyproject.toml.

@perezed00
Copy link
Contributor

I took a second look at revisions in domain reduction, target space files, and several other .py files. However, I haven't looked at util.py, logger.py, or constraint.py

Within the files I checked, the suggestions I made were all rather small and generally things look good. Great work on this.

@bwheelz36
Copy link
Collaborator

@till-m - ruff looks really cool. I'm keen to try it out in some projects - but agree right now is not the time or place for this one :-)

@till-m
Copy link
Member Author

till-m commented Feb 20, 2024

From my side, this PR is mostly good to go, except for a review of the README changes. Does anyone else have any other hold-ups?

@@ -1,16 +1,18 @@
<div align="center">
<img src="https://github.com/fmfn/BayesianOptimization/blob/master/examples/func.png"><br><br>
<img src="https://raw.githubusercontent.com/bayesian-optimization/BayesianOptimization/master/static/func.png"><br><br>
Copy link
Collaborator

Choose a reason for hiding this comment

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

if I look at your branch, it appears this image is missing now? can you double check this link still works?

Copy link
Member Author

Choose a reason for hiding this comment

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

Should work after the PR is merged. This link (when pointing to my repo/branch) works: https://raw.githubusercontent.com/till-m/BayesianOptimization/docstring-overhaul/static/func.png

@bwheelz36
Copy link
Collaborator

From my side, this PR is mostly good to go, except for a review of the README changes. Does anyone else have any other hold-ups?

Just took a look at readme - made a few minor suggestions, but looks great to me!

@till-m
Copy link
Member Author

till-m commented Feb 21, 2024

If someone would still like to have a look, please let me know. Otherwise I will merge this early next week.

@till-m till-m merged commit 383cb29 into bayesian-optimization:master Feb 26, 2024
8 checks passed
@till-m
Copy link
Member Author

till-m commented Feb 26, 2024

Thanks everyone for the help! Glad to see this is done -- even if it isn't perfect right now, we can work to make it better in the future! :)

@bwheelz36 looks like the image renders correctly: link

@till-m till-m deleted the docstring-overhaul branch July 20, 2024 09:16
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.

settle on a docstring format and update all docstrings
3 participants