diff --git a/ribs/archives/_archive_base.py b/ribs/archives/_archive_base.py index fa8ac6b0d..76722b840 100644 --- a/ribs/archives/_archive_base.py +++ b/ribs/archives/_archive_base.py @@ -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:: @@ -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., @@ -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, diff --git a/ribs/archives/_array_store.py b/ribs/archives/_array_store.py index 6c686246b..5a879d07f 100644 --- a/ribs/archives/_array_store.py +++ b/ribs/archives/_array_store.py @@ -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.,