awkward-array
关于在Python中使用Awkward Array 2.0锯齿数组和记录的指南。在构建或调试`awkward`工作流时使用,包括使用`ak.zip`构建记录,使用`ak.with_field`添加字段,过滤/聚合,组合数学(`ak.cartesian`/`ak.combinations`),`argmin`/`argmax`切片,展平,排序,以及NumPy互操作或常见的Awkward陷阱。
📖 中文导读:关于在Python中使用Awkward Array 2.0锯齿数组和记录的指南。在构建或调试`awkward`工作流时使用,包括使用`ak.zip`构建记录,使用`ak.with_field`添加字段,过滤/聚合,组合数学(`ak.cartesian`/`ak.combinations`),`argmin`/`argmax`切片,展平,排序,以及NumPy互操作或常见的Awkward陷阱。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。
name: awkward-array
description: Guidance for working with Awkward Array 2.0 jagged arrays and records in Python. Use when building or debugging awkward workflows, including record construction with ak.zip, adding fields with ak.with_field, filtering/aggregation, combinatorics (ak.cartesian/ak.combinations), argmin/argmax slicing, flattening, sorting, and NumPy interop or common Awkward pitfalls.
Awkward Array
Overview
Use this skill to apply Awkward 2.0 best practices for jagged arrays, especially in HEP-style event data models. Keep guidance lean in this file and load reference notes only when needed.
Core workflow
- Build an event data model (records) with
ak.zip. - Filter early at the event level.
- Perform combinatorics or derived calculations.
- Add derived fields back into the record with
ak.with_field. - Repeat until the final values are present in the EDM.
Reference guide
Load only the reference files that matches the task:
references/best-practices.md: use when setting overall approach or reminding about Awkward 2.0 usage and axes.references/records.md: use when building records or adding fields.references/filtering-aggregation.md: use for boolean masking,ak.sum/ak.count/ak.num, and axis guidance.references/sorting.md: use forak.sort.references/combinatorics.md: use for pairings or n-way combinations (ak.cartesian,ak.combinations).references/argmin-argmax.md: use when selecting min/max elements in jagged lists.references/flattening.md: use forak.flattenbehavior and axis rules.references/numpy-interop.md: use when mixing NumPy operations with Awkward arrays.references/pitfalls.md: use for common API mistakes and missing functions.references/awkward-files.md: use for file I/O patterns (read/write) with Awkward arrays.
Constraints
- Use Awkward 2.0 APIs and syntax only.
- Avoid
axis=Noneunless the function explicitly supports it. - Ensure
awkwardis listed as a dependency in the active environment (venv pluspyproject.tomlorrequirements.txt).