capturegraph.data.containers
#
Vector Module - Vectorized Collection Types#
This module provides types for vectorized operations on collections of objects, enabling NumPy-style broadcasting for attribute access and transforms.
Core Types
-
List[T]: A list subclass that broadcasts attribute access across all elements.
sessions.datereturns a List of each session's date. -
Dict[V]: A dict subclass with attribute-style access (
d.fooinstead ofd["foo"]). Keys must be strings. -
zip(**kwargs): Combines multiple Lists with NumPy-style broadcasting. Returns a List of Dicts for row-wise processing.
-
MissingType: A null object for safe chaining. Absorbs all attribute access instead of raising AttributeError. Always carries a reason for debugging.
Example
import capturegraph.data as cg
sessions = cg.List([session1, session2, session3])
# Vectorized attribute access
ratings = sessions.tastiness_rating # → List([5, 4, 3])
# Projection to dict subset
subset = sessions["date", "store"] # → List of Dicts
# Apply function with .map()
names = sessions.date.map(lambda d: f"{d:%Y%m%d}.heic")
# Combine multiple Lists with zip
paths = cg.zip(dir=base, name=names).map(lambda r: r.dir / r.name)
# Safe chaining - returns MissingType instead of AttributeError
result = sessions.nonexistent.also_missing # → MissingType(...)
Modules:
| Name | Description |
|---|---|
dict |
Dict - Dictionary with Attribute Access |
list |
List - Vectorized Collection Operations |
missing |
MissingType - Null Object for Safe Chaining |
utilities |
Utilities for working with containers. |