Skip to content

Commit 718259a

Browse files
author
miranov25
committed
AliasDataFrame: Add support for __getattr__ access to subframes and chained aliases
- Enable dot-access syntax (e.g. adf.track.pt, adf.track.collision.z) - Automatically resolve and evaluate subframe aliases recursively - Preserve subframe metadata in ROOT and Parquet exports - Update unit tests to validate __getattr__ and nested access - Update documentation (AliasDataFrame.md) with realistic subframe usage example
1 parent 3753500 commit 718259a

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

UTILS/dfextensions/AliasDataFrame.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@ adf.materialize_alias("pt")
2727
Reference a subframe (e.g. per-cluster frame linked to a per-track frame):
2828

2929
```python
30-
adf_clusters.register_subframe("T", adf_tracks, index_columns=["track_index"])
31-
adf_clusters.add_alias("dX", "mX - T.mX")
32-
adf_clusters.materialize_alias("dX")
30+
adf_clusters.register_subframe("track", adf_tracks, index_columns="track_index")
31+
adf_tracks.register_subframe("collision", adf_collisions, index_columns="collision_index")
32+
33+
adf_clusters.add_alias("dX", "mX - track.mX")
34+
adf_clusters.add_alias("vertexZ", "track.collision.z")
3335
```
3436

35-
Under the hood, this performs a join using `track_index` between clusters and tracks, rewrites `T.mX` to the joined column, and evaluates in that context.
37+
Under the hood, this performs joins using index columns such as `track_index` and `collision_index`, rewrites dotted expressions like `track.mX` and `track.collision.z` to joined columns, and evaluates in that context.
38+
39+
For example, in ALICE data:
40+
41+
- clusters reference tracks: `cluster → track`
42+
- tracks reference collisions: `track → collision`
43+
- V0s reference two tracks: `v0 → track1`, `v0 → track2`
44+
45+
These relations can be declared using `register_subframe()` and used symbolically in aliases.
3646

3747
### ✅ Dependency Graph & Cycle Detection
3848

@@ -50,6 +60,15 @@ adf.plot_alias_dependencies()
5060
adf.add_alias("scale", "1.5", dtype=np.float32, is_constant=True)
5161
```
5262

63+
### ✅ Attribute Access for Aliases and Subframes
64+
65+
Access aliases and subframe members with convenient dot notation:
66+
67+
```python
68+
adf.cutHighPt # equivalent to adf["cutHighPt"]
69+
adf.track.pt # evaluates pt from registered subframe "track"
70+
```
71+
5372
---
5473

5574
## 💾 Persistence
@@ -91,6 +110,7 @@ Tests included for:
91110
* Constant and hierarchical aliasing
92111
* Partial materialization
93112
* Subframe joins on index columns
113+
* Chained access via `adf.attr` and `adf.subframe.alias`
94114
* Persistence round-trips for `.parquet` and `.root`
95115
* Error detection: cycles, invalid expressions, undefined symbols
96116

@@ -161,20 +181,20 @@ It brings the clarity of a computation graph to structured table analysis — a
161181

162182
* [ ] Secure expression parser (no raw `eval`)
163183
* [ ] Aliased column caching / invalidation strategy
164-
* [ ] Inter-subframe join strategies (e.g., key-based, 1\:n)
184+
* [ ] Inter-subframe join strategies (e.g., key-based, 1: n)
165185
* [ ] Jupyter widget or CLI tool for alias graph exploration
166186
* [ ] Broadcasting-aware joins or 2D index support
167187

168188
---
169189

170190
## 🧑‍🔬 Designed for...
171191

172-
* Physics workflows (e.g. ALICE clusters ↔ tracks ↔ collisions)
192+
* Physics workflows (e.g. ALICE Physics analysis V0 ↔ tracks ↔ collisions)
173193
* Symbolic calibration / correction workflows
174194
* Structured data exports with traceable metadata
175195

176196
---
177197

178-
**Author:** \[You]
198+
**Author:** Marian Ivanov
179199

180200
MIT License

0 commit comments

Comments
 (0)