Skip to content

Commit

Permalink
Clarify errors in scheduler docstrings (#488)
Browse files Browse the repository at this point in the history
## Description

<!-- Provide a brief description of the PR's purpose here. -->

Minor clarifications to how the error messages work in the scheduler. In
ask(), we aren't checking if tell() is called; we're just checking if
another ask method was previously called.

## Status

- [x] I have read the guidelines in

[CONTRIBUTING.md](https://github.com/icaros-usc/pyribs/blob/master/CONTRIBUTING.md)
- [x] I have formatted my code using `yapf`
- [x] I have tested my code by running `pytest`
- [x] I have linted my code with `pylint`
- [x] I have added a one-line description of my change to the changelog
in
      `HISTORY.md`
- [x] This PR is ready to go
  • Loading branch information
btjanaka authored Nov 30, 2024
1 parent 0bc3372 commit f0bc5b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Switch from std to var in arm tutorial ({pr}`486`)
- Fix documentation conf for readthedocs deprecations ({pr}`485`)
- Add novelty search with CMA-ES to sphere example ({pr}`478`, {pr}`482`)
- Clarify errors in scheduler docstrings ({pr}`488`)

#### Improvements

Expand Down
6 changes: 3 additions & 3 deletions ribs/schedulers/_bandit_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def ask(self):
(batch_size, dim) array: An array of n solutions to evaluate. Each
row contains a single solution.
Raises:
RuntimeError: This method was called without first calling
:meth:`tell`.
RuntimeError: This method was called immediately after calling an
ask method.
"""
if self._last_called == "ask":
raise RuntimeError("ask cannot be called immediately after " +
Expand Down Expand Up @@ -331,7 +331,7 @@ def tell(self, objective, measures, **fields):
argument should be an array with batch_size as the first
dimension.
Raises:
RuntimeError: This method is called without first calling
RuntimeError: This method was called without first calling
:meth:`ask`.
ValueError: One of the inputs has the wrong shape.
"""
Expand Down
14 changes: 7 additions & 7 deletions ribs/schedulers/_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def ask_dqd(self):
(batch_size, dim) array: An array of n solutions to evaluate. Each
row contains a single solution.
Raises:
RuntimeError: This method was called without first calling
:meth:`tell`.
RuntimeError: This method was called immediately after calling an
ask method.
"""
if self._last_called in ["ask", "ask_dqd"]:
raise RuntimeError("ask_dqd cannot be called immediately after " +
Expand Down Expand Up @@ -185,8 +185,8 @@ def ask(self):
(batch_size, dim) array: An array of n solutions to evaluate. Each
row contains a single solution.
Raises:
RuntimeError: This method was called without first calling
:meth:`tell`.
RuntimeError: This method was called immediately after calling an
ask method.
"""
if self._last_called in ["ask", "ask_dqd"]:
raise RuntimeError("ask cannot be called immediately after " +
Expand Down Expand Up @@ -307,8 +307,8 @@ def tell_dqd(self, objective, measures, jacobian, **fields):
argument should be an array with batch_size as the first
dimension.
Raises:
RuntimeError: This method is called without first calling
:meth:`ask`.
RuntimeError: This method was called without first calling
:meth:`ask_dqd`.
ValueError: One of the inputs has the wrong shape.
"""
if self._last_called != "ask_dqd":
Expand Down Expand Up @@ -362,7 +362,7 @@ def tell(self, objective, measures, **fields):
argument should be an array with batch_size as the first
dimension.
Raises:
RuntimeError: This method is called without first calling
RuntimeError: This method was called without first calling
:meth:`ask`.
ValueError: One of the inputs has the wrong shape.
"""
Expand Down

0 comments on commit f0bc5b7

Please sign in to comment.