pdstools.adm.trees._multi

The MultiTrees collection — multiple snapshots of one config.

Attributes

Classes

MultiTrees

A collection of ADMTreesModel snapshots indexed by timestamp.

Module Contents

logger
class MultiTrees

A collection of ADMTreesModel snapshots indexed by timestamp.

Construct via from_datamart().

trees: dict[str, pdstools.adm.trees._model.ADMTreesModel]
model_name: str | None = None
context_keys: list | None = None
__repr__() str
Return type:

str

__getitem__(index: int | str) pdstools.adm.trees._model.ADMTreesModel

Return the ADMTreesModel at index.

Integer indices select by insertion order; string indices select by snapshot timestamp. Use items() if you need both keys and values together.

Parameters:

index (int | str)

Return type:

pdstools.adm.trees._model.ADMTreesModel

__len__() int
Return type:

int

items()

Iterate (timestamp, model) pairs in insertion order.

values()

Iterate ADMTreesModel instances in insertion order.

keys()

Iterate snapshot timestamps in insertion order.

__iter__()
__add__(other: MultiTrees | pdstools.adm.trees._model.ADMTreesModel) MultiTrees
Parameters:

other (MultiTrees | pdstools.adm.trees._model.ADMTreesModel)

Return type:

MultiTrees

property first: pdstools.adm.trees._model.ADMTreesModel
Return type:

pdstools.adm.trees._model.ADMTreesModel

property last: pdstools.adm.trees._model.ADMTreesModel
Return type:

pdstools.adm.trees._model.ADMTreesModel

classmethod from_datamart(df: polars.DataFrame, n_threads: int = 1, configuration: str | None = None) MultiTrees

Decode every Modeldata blob in df for a single configuration.

Returns one MultiTrees containing one ADMTreesModel per snapshot.

Parameters:
  • df (pl.DataFrame) – Datamart slice. Must contain Modeldata, SnapshotTime and Configuration columns and cover exactly one Configuration. Use from_datamart_grouped() if df spans multiple configurations.

  • n_threads (int) – Worker count for parallel base64+zlib decoding.

  • configuration (str | None) – Optional explicit Configuration name; required if df doesn’t already contain a single Configuration.

Return type:

MultiTrees

classmethod from_datamart_grouped(df: polars.DataFrame, n_threads: int = 1) dict[str, MultiTrees]

Decode every Modeldata blob in df, grouped by Configuration.

Returns a mapping of configuration name to MultiTrees. Use from_datamart() instead when the input has only one configuration.

Parameters:
  • df (polars.DataFrame)

  • n_threads (int)

Return type:

dict[str, MultiTrees]

static _decode_datamart_frame(df: polars.DataFrame, n_threads: int = 1) list[tuple[str, str, pdstools.adm.trees._model.ADMTreesModel]]

Decode every blob in df and return (config, timestamp, model) rows.

Parameters:
  • df (polars.DataFrame)

  • n_threads (int)

Return type:

list[tuple[str, str, pdstools.adm.trees._model.ADMTreesModel]]

compute_over_time(predictor_categorization: collections.abc.Callable | None = None) polars.DataFrame

Return per-tree categorisation counts across snapshots, with a SnapshotTime column per row.

Parameters:

predictor_categorization (collections.abc.Callable | None)

Return type:

polars.DataFrame