Skip to content

Commit

Permalink
Docs fixes (#448)
Browse files Browse the repository at this point in the history
## Description

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

More fixes to documentation.

## TODO

<!-- Notable points that this PR has either accomplished or will
accomplish. -->

- [x] Mention single-field usage in error msg for as_pandas
- [x] Fix return_type docs for archive data method and ArrayStore
retrieve method

## 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`
- [N/A] 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 Jan 24, 2024
1 parent 7ba4c21 commit ed94e0a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
28 changes: 15 additions & 13 deletions ribs/archives/_archive_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,15 +643,18 @@ def data(self, fields=None, return_type="dict"):
"""Retrieves data for all elites in the archive.
Args:
fields (array-like of str): List of fields to include. By default,
all fields will be included (see :attr:`field_list`), with an
additional "index" as the last field ("index" can also be placed
anywhere in this list).
return_type (str): Type of data to return. See below.
fields (str or array-like of str): List of fields to include. By
default, all fields will be included, with an additional "index"
as the last field ("index" can also be placed anywhere in this
list). This can also be a single str indicating a field name.
return_type (str): Type of data to return. See below. Ignored if
``fields`` is a str.
Returns:
The data at the given indices. This can take the following forms,
depending on the ``return_type`` argument:
The data for all entries in the archive. If ``fields`` was a single
str, this will just be an array holding data for the given field.
Otherwise, this data can take the following forms, depending on the
``return_type`` argument:
- ``return_type="dict"``: Dict mapping from the field name to the
field data at the given indices. An example is::
Expand All @@ -675,7 +678,8 @@ def data(self, fields=None, return_type="dict"):
``(objective_arr, measures_arr)``. In this case, the results
from ``retrieve`` could be unpacked as::
objective, measures = archive.data(["objective", "measures"])
objective, measures = archive.data(["objective", "measures"],
return_type="tuple")
Unlike with the ``dict`` return type, duplicate fields will show
up as duplicate entries in the tuple, e.g.,
Expand Down Expand Up @@ -725,11 +729,9 @@ def as_pandas(self, include_solutions=True, include_metadata=False):
# pylint: disable = unused-argument
raise RuntimeError(
"as_pandas has been deprecated. Please use "
"archive.data(..., return_type='pandas') instead. For more "
"info, please see the archive data tutorial: "
# pylint: disable = line-too-long
"https://docs.pyribs.org/en/stable/tutorials/features/archive_data.html"
)
"archive.data(..., return_type='pandas') instead, or consider "
"retrieving individual fields, e.g., "
"objective = archive.data('objective')")

def cqd_score(self,
iterations,
Expand Down
5 changes: 4 additions & 1 deletion ribs/archives/_array_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,10 @@ def retrieve(self, indices, fields=None, return_type="dict"):
``(objective_arr, measures_arr)``. In this case, the results
from ``retrieve`` could be unpacked as::
occupied, (objective, measures) = store.retrieve(...)
occupied, (objective, measures) = store.retrieve(
...,
return_type="tuple",
)
Unlike with the ``dict`` return type, duplicate fields will show
up as duplicate entries in the tuple, e.g.,
Expand Down

0 comments on commit ed94e0a

Please sign in to comment.