superstats.utils.plotting#

Shared data preparation helpers for plotting functions.

Functions

prepare_plot_data(estimates, targets[, ...])

Resolve dict-or-array estimates/targets into stacked arrays plus display names.

superstats.utils.plotting.prepare_plot_data(estimates, targets, variable_keys=None, variable_names=None)[source]#

Resolve dict-or-array estimates/targets into stacked arrays plus display names.

For dict input, per-key arrays are stacked along a new last axis in the order given by variable_keys (or all keys, by default). For array input, estimates/targets are used as-is and variable_keys is ignored.

Parameters:
estimatesMapping[str, np.ndarray] or np.ndarray

If a dict, per-key arrays sharing the same leading shape, to be stacked into a new last axis. If an array, used directly (already includes the params axis). Must be the same kind (dict or array) as targets.

targetsMapping[str, np.ndarray] or np.ndarray

Same convention as estimates, one fewer axis than estimates in the array case (no sample axis). Must be the same kind (dict or array) as estimates.

variable_keyssequence of str or None, optional, default: None

Which keys to select from estimates/targets when they are dicts, and in what order. By default, all keys, in dict insertion order. Ignored if estimates/targets are arrays.

variable_namessequence of str or None, optional, default: None

Display names for the columns, in the same order as the selected variables. Defaults to variable_keys (if dicts) or param_0, param_1, … (if arrays).

Returns:
estimates_arr, targets_arr, namestuple

Stacked arrays of shape (…, num_params) and a list of display names, one per column.

Raises:
ValueError

If estimates and targets are not both dicts or both arrays, if variable_keys references a key missing from either dict, or if variable_names doesn’t match the number of selected/resolved variables.

Parameters:
Return type:

tuple[ndarray, ndarray, list[str]]