From 47b97ee187f8616172d9d5283cdc8ce6bdfcc5e1 Mon Sep 17 00:00:00 2001 From: Dani Bodor Date: Tue, 31 Oct 2023 16:00:02 +0100 Subject: [PATCH] add internal attributes of `QueryCollection` to its init and comment in docstring. also fix docstring typos in process method --- deeprank2/query.py | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/deeprank2/query.py b/deeprank2/query.py index 566a8f7b0..bcc089114 100644 --- a/deeprank2/query.py +++ b/deeprank2/query.py @@ -377,15 +377,29 @@ def _build_helper(self) -> Graph: class QueryCollection: - """Represents the collection of data queries. + """Represents the collection of data queries that will be processed. + The class attributes are set either while adding queries to the + collection (`_queries` and `_ids_count`), or when processing the collection + (`_cpu_count`, `_prefix`, and `_grid_settings`). + + Attributes: + _queries (list[:class:`Query`]): The `Query` objects in the collection. + _ids_count (dict[str, int]): The original `query_id` and the repeat number for this id. + This is used to rename the `query_id` to ensure that there are no duplicate ids. + _prefix, _cpu_count, and _grid_settings: See docstring for `QueryCollection.process`. + + Note: Queries can be saved as a dictionary to easily navigate through their data, using `QueryCollection.export_dict()`. """ def __init__(self): - self._queries = [] - self._ids_count = {} + self._queries: list[Query] = [] + self._ids_count: dict[str, int] = {} + self._prefix: str | None = None + self._cpu_count: int | None = None + self._grid_settings: GridSettings | None = None def add( self, @@ -475,8 +489,8 @@ def process( # pylint: disable=too-many-arguments, too-many-locals, dangerous-de """Render queries into graphs (and optionally grids). Args: - prefix (str None, optional): prefix for naming the output files. Defaults to "processed-queries". - feature_modules (list[ModuleType] | list[str] | Literal ['all'], optional): feature module or list of feature modules + prefix (str | None, optional): Prefix for naming the output files. Defaults to "processed-queries". + feature_modules (list[ModuleType] | list[str] | Literal ['all'], optional): Feature module or list of feature modules used to generate features (given as string or as an imported module). Each module must implement the :py:func:`add_features` function, and all feature modules must exist inside `deeprank2.features` folder. If set to 'all', all available modules in `deeprank2.features` are used to generate the features. @@ -485,7 +499,7 @@ def process( # pylint: disable=too-many-arguments, too-many-locals, dangerous-de the number of CPUs available to the system. Defaults to None, which takes all available cpu cores. combine_output (bool, optional): - if `True` (default): all processes are combined into a single HDF5 file. + If `True` (default): all processes are combined into a single HDF5 file. If `False`: separate HDF5 files are created for each process (i.e. for each CPU used). grid_settings (:class:`GridSettings` | None, optional): If valid together with `grid_map_method`, the grid data will be stored as well. Defaults to None.