Repository navigation
Conversation
|
| Project | guppylang |
| Branch | codex/array-structure |
| 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%) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## codex/array-queries #2513 +/- ##
=======================================================
- Coverage 93.05% 92.88% -0.17%
=======================================================
Files 167 167
Lines 17221 17302 +81
=======================================================
+ Hits 16025 16071 +46
- Misses 1196 1231 +35 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
ab51bb5 to
30f09e0
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the new array construction and reshaping utilities.
No open issues 🎉
What changed in this PR
Adds safe array construction and reshaping utilities to the standard library, addressing #2480 with consuming operations that support linear elements and borrowed subarray copying.
Changes:
- Adds
concat,appended,split_at,zip,unzip,flatten, andchunks. - Adds
subarraywith runtime start indices, compile-time sizes, and bounds validation. - Adds integration coverage for ordering, empty arrays, linear qubit transfers, and invalid bounds or shapes.
| File | Description |
|---|---|
tests/integration/test_array_structure.py |
Tests concatenation, appending, splitting, and linear transfers. |
tests/integration/test_array_shapes.py |
Tests subarray copying, shape transformations, and validation failures. |
guppylang/src/guppylang/std/array.py |
Implements and documents the new array utilities and validation helpers. |
Review effort: Balanced
Merging this PR will not alter performance1 warning
Comparing Footnotes |
30f09e0 to
2470d11
Compare
|
|
||
| @guppy | ||
| @no_type_check | ||
| def concat[T, n: nat, m: nat]( |
There was a problem hiding this comment.
concat could be used in an __add__ method so we can write xs + ys.
| """Validate a split position before computing its output shape.""" | ||
| if not 0 <= position <= size: | ||
| msg = f"Split position {position} is out of bounds for array of size {size}" | ||
| raise ValueError(msg) |
There was a problem hiding this comment.
This error message (and others) are inconsistent with Guppy error messaging and don't highlight the Guppy source where the error occurred. Implementing this would require a custom call checker so is perhaps beyond the scope of this PR.
2470d11 to
d7494c5
Compare
Add consuming concat, append, split, zip, unzip, flatten, and chunk operations supporting linear elements, plus borrowed subarray copying with runtime starts and compile-time sizes.
Closes #2480