Skip to content

fix(rag)!: nested fixed axes, tuple-key axes, and record to_ak depth - #76

Merged
d-laub merged 3 commits into
mainfrom
fix-73
Sep 26, 2026
Merged

d-laub merged 3 commits into
mainfrom
fix-73

Conversation

@d-laub

@d-laub d-laub commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

Fixes three Ragged bugs: indexing that silently returned wrong data, and one to_ak() inconsistency. Each fix is its own commit.

#73: fixed axis before two ragged axes

(b, p, ~v, ~w) arrays (gvl 0.43 _FlatWindow.to_ragged()) ignored p in indexing and to_ak().

  • R=2 arrays with more than one leading axis now use the multidim segment gather. Outer offsets are gathered and inner offsets stay global.
  • If every leading axis gets an int key, the result is peeled, so r[i, j] == r[i][j].
  • Numeric R=2 to_ak() wraps fixed leading dims in RegularArray.

#74: tuple keys applied to axis 0 (breaking)

A key after a non-int key went to axis 0 of the intermediate result. For example, rag[:, 0] on (n, ~) returned row 0.

  • Each key now goes to the next output axis, as in NumPy and awkward.
  • Ragged axes accept an int (one element per row) or a step-1 slice (Python semantics, including negative bounds).
  • Trailing axes index the data buffer.
  • Unsupported combinations raise NotImplementedError: stepped slices, fancy keys on a ragged axis (except the first of two ragged axes), and trailing keys on records.

#75: record to_ak() depth (breaking)

Records are now always at the leaf, whatever rag_dim is, so rec.to_ak()[k] == rec[k].to_ak(). This also fixes trailing fixed dims being wrapped twice.

Breaking changes

  • rag[:, k] and similar tuple keys follow NumPy semantics. To get row k, use rag[k].
  • Record to_ak() with one leading axis returns n * var * {a, b} instead of one record of lists per row.

gvl's values[:, t] only indexes leading axes, so it is not affected. No downstream repo calls to_ak() on a record.

Testing

  • tests/test_ragged_nested_fixed_axis.py and tests/test_ragged_tuple_index.py check results against awkward indexing on the same data. They cover packed and gathered offsets, strings, and records.
  • 778 tests pass. Hooks pass (ruff, ruff format, pyrefly, commitizen).
  • Tuple-key overhead is about 0.5 µs (~4%). Single-key paths are unchanged.
  • skills/seqpro/SKILL.md is updated.

Closes #73
Closes #74
Closes #75

🤖 Generated with Claude Code

d-laub and others added 3 commits September 26, 2026 12:13
Indexing and to_ak() on (b, p, ~v, ~w) arrays ignored the fixed p axis.
Route R=2 arrays with rag_dim > 1 through the multidim segment gather,
peel all-int leading keys on R=2, and wrap fixed leading dims in
RegularArray in the numeric R=2 to_ak path.

Closes #73

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Record to_ak() zipped per row (depth_limit=1) when rag_dim <= 1 but at
the leaf when rag_dim > 1, so rec.to_ak()[k] and rec[k].to_ak() could
disagree. Always build leaf-level records, and stop wrapping trailing
fixed dims in RegularArray: they already live in each field's leaf.

BREAKING CHANGE: Ragged record to_ak() for arrays with one leading axis
now returns records at the leaf (e.g. 2 * var * {a, b}) instead of one
record of lists per row.

Closes #75

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A tuple key after a non-int key was applied to axis 0 of the
intermediate result, so rag[:, 0] on (n, ~) returned row 0 instead of
the first element of every row, and keys reaching ragged or trailing
axes after a slice indexed the wrong axis.

Track the output axis each key targets. Leading fixed axes are still
indexed jointly; ragged axes take an int (per-row element) or a step-1
slice (Python semantics, negative bounds included); trailing axes index
the data buffer. Unsupported combinations raise NotImplementedError
instead of returning wrong data. Also vectorize the R=2 inner int-array
gather and drop the now-dead _getitem_inner/_is_full_slice.

BREAKING CHANGE: rag[:, k] and similar tuple keys now follow NumPy and
awkward semantics; code relying on the old axis-0 behavior must index
rows directly (rag[k]).

Closes #74

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codspeed

codspeed Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will degrade performance by 23.03%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 3 regressed benchmarks
✅ 11 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_bench_baseline_ragged_short_alleles 2.8 ms 4.4 ms -36.01%
❌ test_bench_dense_batch 2.7 ms 3.3 ms -18.32%
❌ test_bench_baseline_ragged_cres 6.3 ms 7.3 ms -12.73%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix-73 (ff1f21a) with main (63a8439)

Open in CodSpeed

@d-laub
d-laub merged commit 3a1ffc6 into main Sep 26, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant