Repository navigation
Conversation
3634583 to
d11fd5c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## codex/array-structure #2515 +/- ##
=========================================================
- Coverage 92.88% 92.76% -0.12%
=========================================================
Files 167 167
Lines 17302 17343 +41
=========================================================
+ Hits 16071 16089 +18
- Misses 1231 1254 +23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| Project | guppylang |
| Branch | codex/array-mutation |
| Testbed | Linux |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold | 59.84 x 1e3(0.00%)Baseline: 59.84 x 1e3 | 60.44 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 4,514.00(0.00%)Baseline: 4,514.00 | 4,559.14 (99.01%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 26.87 x 1e3(0.00%)Baseline: 26.87 x 1e3 | 27.14 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 1,182.00(0.00%)Baseline: 1,182.00 | 1,193.82 (99.01%) |
| tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile | 📈 view plot 🚷 view threshold | 6.70 x 1e3(0.00%)Baseline: 6.70 x 1e3 | 6.77 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 279.00(0.00%)Baseline: 279.00 | 281.79 (99.01%) |
| tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile | 📈 view plot 🚷 view threshold | 9.22 x 1e3(0.00%)Baseline: 9.22 x 1e3 | 9.31 x 1e3 (99.01%) | 📈 view plot 🚷 view threshold | 371.00(0.00%)Baseline: 371.00 | 374.71 (99.01%) |
Merging this PR will not alter performance1 warning
Comparing |
There was a problem hiding this comment.
🟡 Changes recommended
Rotation accepts amounts above the array length despite issue #2481 requiring 0 ≤ k ≤ n, leaving a contract conflict that must be reconciled.
1 open issue
What changed in this PR
Adds array mutation and in-place rotation utilities to the standard library, addressing #2481 while preserving support for linear elements.
Changes:
- Adds
swapandfillmethods, retaining existing swap and reverse operations. - Implements left and right rotations using three reversals, with nonnegative amounts wrapping modulo array length.
- Adds integration tests for mutation results, linear elements, empty arrays, and invalid inputs.
| File | Description |
|---|---|
tests/integration/test_array_mutation.py |
Tests mutations, rotations, linear-element preservation, and error handling. |
guppylang/src/guppylang/std/array.py |
Adds mutation methods, rotation helpers, and API documentation. |
Review effort: Balanced
d11fd5c to
99e52fd
Compare
99e52fd to
6f66c19
Compare
6f66c19 to
a334a0f
Compare

Add array swap and fill methods, plus in-place left and right rotations supporting linear elements. Signed rotation amounts wrap modulo the array length; negative amounts rotate in the opposite direction. Empty arrays are unchanged.
Closes #2481