larvaworld.lib.reg.graph ======================== .. py:module:: larvaworld.lib.reg.graph .. autoapi-nested-parse:: Graph/plotting registry for the larvaworld package. This module provides a class for managing and creating plots and graphs. Classes ------- .. autoapisummary:: larvaworld.lib.reg.graph.GraphRegistry Module Contents --------------- .. py:class:: GraphRegistry Registry for managing and creating plots and graphs. Manages graph functions, graphgroups (collections of related plots), and provides methods for batch plot creation during analysis. Attributes: dict: Dictionary of graph functions required_data_dict: Dictionary of required data for each graph function graphgroups: Dictionary of graphgroups, each containing plot specifications Example: >>> graph_reg = GraphRegistry() >>> graph_reg.exists('trajectories') # Check if graph exists >>> plots = graph_reg.run_group('traj') # Run trajectory graphgroup >>> graph_reg.eval_graphgroups(['general', 'endpoint'], save_to='plots/') .. py:attribute:: dict .. py:attribute:: required_data_dict .. py:attribute:: graphgroups .. py:property:: ks :type: larvaworld.lib.util.SuperList Returns a sorted list of the keys of the graph functions. .. py:method:: exists(ID: str) -> bool Checks if a graph function with the given ID exists. .. py:method:: group_exists(gID: str) -> bool Checks if a graphgroup with the given ID exists. .. py:method:: eval_graphgroups(graphgroups: list[str] | dict, save_to: str | None = None, **kws: Any) -> larvaworld.lib.util.AttrDict Evaluates a list of graphgroups. Args: - graphgroups (list): A list of graphgroups to evaluate. - save_to (str, optional): The directory to save the plots to. Defaults to None. - **kws: Additional keyword arguments to pass to the graph functions. Returns: - dict: A dictionary of evaluated graphgroups. .. py:method:: grouplist_to_dict(groups: list | dict) -> larvaworld.lib.util.AttrDict | dict Converts a list of graphgroups to a dictionary. Args: - groups (list): A list of graphgroups to convert. Returns: - dict: A dictionary of graphgroups. .. py:method:: eval_entries(entries: list[dict], **kwargs: Any) -> larvaworld.lib.util.AttrDict Evaluates a list of graph entries. Args: - entries (list): A list of graph entries to evaluate. Returns: - dict: A dictionary of evaluated graph entries. .. py:method:: run(ID: str, **kwargs: Any) -> Any Runs a graph function with the given ID. Args: - ID (str): The ID of the graph function to run. Returns: - plot.Plot: The plot created by the graph function. .. py:method:: run_group(gID: str, **kwargs: Any) -> larvaworld.lib.util.AttrDict Runs a graphgroup with the given ID. Args: - gID (str): The ID of the graphgroup to run. Returns: - dict: A dictionary of plots created by the graphgroup. .. py:method:: entry(ID: str, name: str | None = None, **kwargs: Any) -> dict Creates a graph entry with the given ID and optional name. Args: - ID (str): The ID of the graph function to create an entry for. - name (str, optional): The name of the graph entry. Defaults to None. Returns: - dict: A dictionary containing the key, plotID, and arguments for the graph entry. .. py:method:: model_tables(mIDs: list[str], dIDs: list[str] | None = None, save_to: str | None = None, **kwargs: Any) -> larvaworld.lib.util.AttrDict Creates tables for the given model IDs. Args: - mIDs (list): A list of model IDs to create tables for. - dIDs (list, optional): A list of display IDs to use for the model IDs. Defaults to None. - save_to (str, optional): The directory to save the tables to. Defaults to None. Returns: - dict: A dictionary of tables created for the given model IDs. .. py:method:: model_summaries(mIDs: list[str], save_to: str | None = None, **kwargs: Any) -> dict Creates summary plots for the given model IDs. Args: - mIDs (list): A list of model IDs to create summaries for. - save_to (str, optional): The directory to save the summaries to. Defaults to None. Returns: - dict: A dictionary of summary plots created for the given model IDs. .. py:method:: store_model_graphs(mIDs: list[str], dir: str) -> larvaworld.lib.util.AttrDict Stores model graphs for the given model IDs. Args: - mIDs (list): A list of model IDs to store graphs for. - dir (str): The directory to store the graphs in. Returns: - dict: A dictionary of stored model graphs. .. py:method:: source_graphgroup(source_ID: str, pos: tuple[float, float] | None = None, **kwargs: Any) -> larvaworld.lib.util.AttrDict Creates a graphgroup consisting of plots related to a given food/odor source. Args: - source_ID (str): The ID of the source to create a graphgroup for. - pos (tuple, optional): The position of the source. Defaults to None. Returns: - dict: A dictionary of plot entries for source-related plotting. .. py:method:: get_analysis_graphgroups(exp: str, sources: dict[str, Any], **kwargs: Any) -> larvaworld.lib.util.AttrDict | dict Determines the plots to be created during the analysis of a given experiment/simulation. Args: - exp (str): The experiment that has been completed for which the analysis is requested. The string that defines the type of experiment is associated with one or more graphgroups by their keys. - sources (dict): A dictionary of the IDs and positions of any food/odor sources in the arena. For certain experiments these are needed to create source related plots. Returns: - list: All graphgroups (by their keys) and optionally any single graphs to be created (evaluated) during analysis .. py:method:: build_graphgroups() -> larvaworld.lib.util.AttrDict Creates a dictionary of lists/groups of plots/graphs. Each such group of plots (graphgroup) can be accessed by a key so that all the plots included in the group can be created. The analysis of a given experiment/simulation can be associated with several such graphgroups in the get_analysis_graphgroups method.