analyzer.postprocessing.grouping

Attributes

Classes

InputTrace

SelectTrace

CaptureGroupTrace

GroupingTrace

TransformStepTrace

GroupTrace

GroupBuilder

Constructs and applies a sequence of operations to filter, group, and

Functions

applyTransform(transform, items)

configureConverter(conv)

Module Contents

analyzer.postprocessing.grouping.logger[source]
analyzer.postprocessing.grouping.ResultSet[source]
analyzer.postprocessing.grouping.T[source]
class analyzer.postprocessing.grouping.InputTrace[source]
count: int = 0[source]
items: list[str][source]
record(items: list[analyzer.utils.structure_tools.ItemWithMeta])[source]
class analyzer.postprocessing.grouping.SelectTrace[source]
pattern: str | None = None[source]
selected_count: int = 0[source]
dropped_count: int = 0[source]
selected_items: list[str][source]
dropped_items: list[str][source]
record(pattern: analyzer.utils.querying.BasePattern, selected: list[analyzer.utils.structure_tools.ItemWithMeta], dropped: list[analyzer.utils.structure_tools.ItemWithMeta])[source]
class analyzer.postprocessing.grouping.CaptureGroupTrace[source]
key: str = ''[source]
count: int = 0[source]
items: list[str][source]
classmethod fromCaptureSet(cs: analyzer.utils.querying.CaptureSet) CaptureGroupTrace[source]
class analyzer.postprocessing.grouping.GroupingTrace[source]
pattern: str | None = None[source]
groups: list[CaptureGroupTrace][source]
record(pattern: analyzer.utils.querying.BasePattern, capture_sets: list[analyzer.utils.querying.CaptureSet])[source]
class analyzer.postprocessing.grouping.TransformStepTrace[source]
name: str = ''[source]
post_count: int = 0[source]
class analyzer.postprocessing.grouping.GroupTrace[source]
input: InputTrace[source]
select: SelectTrace | None = None[source]
grouping: GroupingTrace | None = None[source]
transforms: list[TransformStepTrace][source]
subgroup_traces: list[dict[str, GroupTrace] | list[GroupTrace]][source]
recordInput(items: list[analyzer.utils.structure_tools.ItemWithMeta])[source]
recordSelect(pattern: analyzer.utils.querying.BasePattern, selected: list[analyzer.utils.structure_tools.ItemWithMeta], dropped: list[analyzer.utils.structure_tools.ItemWithMeta])[source]
recordGrouping(pattern: analyzer.utils.querying.BasePattern, capture_sets: list[analyzer.utils.querying.CaptureSet])[source]
recordTransform(transform, total_count: int)[source]
analyzer.postprocessing.grouping.applyTransform(transform, items)[source]
class analyzer.postprocessing.grouping.GroupBuilder[source]

Constructs and applies a sequence of operations to filter, group, and transform collections of items based on their metadata.

Attributes:
group (BasePattern | None): A pattern used to capture and group items.

If provided, items are gathered by the capture groups defined in this pattern.

select (BasePattern | None): A pattern used to filter the initial items.

Only items whose metadata matches this pattern are kept.

subgroups (list[GroupBuilder] | dict[str, GroupBuilder] | None): Nested

group builders to apply recursively to the resulting groups. If a dictionary, the output will be a dictionary with corresponding keys. If a list, the output will be a list of applied results.

transforms (list[Transform] | None): A list of transformation functions

to apply to each formed group.

group: analyzer.utils.querying.BasePattern | None = None[source]
select: analyzer.utils.querying.BasePattern | None = None[source]
subgroups: list[GroupBuilder] | dict[str, GroupBuilder] | None = None[source]
transforms: list[analyzer.postprocessing.transforms.registry.Transform | list[analyzer.postprocessing.transforms.registry.Transform]] | None = None[source]
apply(items, trace: GroupTrace | None = None)[source]

Applies the selection, grouping, transformations, and subgroup operations to the given items.

Args:
items: A list of items (typically objects with metadata) to be

processed.

trace: If provided, populated in-place with a trace of every

decision made during the pipeline.

Returns:

The processed groups. The exact return type depends on the structure of subgroups:

  • If subgroups is None, returns the list of transformed groups.

  • If subgroups is a dict, returns a list of dictionaries containing the subgroup results.

  • If subgroups is a list, returns a list of lists containing the subgroup results.

explain(items) GroupTrace[source]
analyzer.postprocessing.grouping.configureConverter(conv)[source]