hari_plotter.group module

class hari_plotter.group.Group(images: list[Graph], time=None, model=None)[source]

Bases: object

Represents a group of HariGraph images, allowing for operations like calculating mean graphs, performing clustering, and extracting node values. This facilitates analyzing similarities and differences among a collection of graph-based images, typically used in complex network analysis or similar domains.

images

A list of HariGraph instances representing individual images in the group.

Type:

list[HariGraph]

time

Optional time values associated with each image, used for time-based analyses.

Type:

Optional[list[float]]

model

An optional model associated with the group, which can be used for further analysis or processing.

Type:

Optional[Any]

clusterings

A dictionary to store clustering results with their settings as keys to avoid recomputation.

Type:

dict

_mean_graph

Cached mean graph of the group, calculated when needed to optimize performance.

Type:

Optional[HariGraph]

_nodes

Cached set of nodes present in the mean graph, used to speed up node-related computations.

Type:

Optional[set]

_node_parameters

Cached node parameters from the first image, ensuring consistency across the group.

Type:

Optional[dict]

Common Functions:

Group class provides a dictionary mapping statistical function names (e.g., ‘Mean’, ‘Sum’) to their corresponding numpy function objects, allowing for flexible data aggregation and analysis.

append(image)[source]
calculate_function_of_node_values(parameters: tuple[str], function='Mean', **settings) dict[source]

Calculate the function of mean node values based on parameters, treating ‘Time’ specially.

Parameters:
  • parameters (list[str]) – list of parameter names.

  • function (str) – The name of the function to be applied to the mean values of the nodes, except for ‘Time’.

Returns:

A dictionary containing the results of the function applied to mean node values.

Return type:

dict

calculate_node_values(parameters: tuple[str], **settings) dict[source]

Calculate the node values based on parameters.

Parameters:

parameters (list[str]) – list of parameter names.

Returns:

A dictionary containing mean node values.

Return type:

dict

clustering(**clustering_settings) Clustering[source]
clustering_graph(merge_remaining: bool = False, reinitialize: bool = False, **clustering_settings) Graph[source]
clustering_graph_values(parameters: tuple[str], clustering_settings: tuple, **settings) dict[str, ndarray][source]
common_functions = {'Max': <function max>, 'Mean': <function mean>, 'Median': <function median>, 'Min': <function min>, 'Peak to Peak': <function ptp>, 'Standard Deviation': <function std>, 'Sum': <function sum>, 'Variance': <function var>}
get_clustering(**settings) Clustering[source]
get_mean_graph(**settings) Graph[source]
initialize_mean_graph()[source]
is_clustering_graph_initialized(**clustering_settings) bool[source]
property mean_graph: Graph

Lazily computes or retrieves the cached mean graph of the group. The mean graph is a single HariGraph instance that represents the average structure and attributes of all graphs in the group.

Returns:

The mean graph of the group.

Return type:

HariGraph

mean_time(**settings)[source]
property node_parameters
property nodes: set
static request_to_tuple(request)[source]

Converts a request dictionary or list into a sorted, nested tuple to ensure consistent key representation, especially useful for caching and retrieving results based on unique request settings.

Parameters:

request (Union[dict, list, Any]) – The request to convert, which may include nested dictionaries and lists.

Returns:

A nested tuple representation of the request, providing a hashable and consistent key for caching.

Return type:

tuple