From f0bc5b7a13de146a69f149ed9d1920654004a757 Mon Sep 17 00:00:00 2001 From: Bryon Tjanaka <38124174+btjanaka@users.noreply.github.com> Date: Fri, 29 Nov 2024 16:48:44 -0800 Subject: [PATCH] Clarify errors in scheduler docstrings (#488) ## Description 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 --- HISTORY.md | 1 + ribs/schedulers/_bandit_scheduler.py | 6 +++--- ribs/schedulers/_scheduler.py | 14 +++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f2828d76b..865404e17 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -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 diff --git a/ribs/schedulers/_bandit_scheduler.py b/ribs/schedulers/_bandit_scheduler.py index b35d18584..ac27f92b6 100644 --- a/ribs/schedulers/_bandit_scheduler.py +++ b/ribs/schedulers/_bandit_scheduler.py @@ -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 " + @@ -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. """ diff --git a/ribs/schedulers/_scheduler.py b/ribs/schedulers/_scheduler.py index b973d114c..bc5cec373 100644 --- a/ribs/schedulers/_scheduler.py +++ b/ribs/schedulers/_scheduler.py @@ -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 " + @@ -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 " + @@ -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": @@ -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. """