Skip to content

docs: Provide docs for array ops, fix bad doc for HugrView::poly_func_type #2021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 2, 2025

Conversation

acl-cqc
Copy link
Contributor

@acl-cqc acl-cqc commented Mar 24, 2025

No description provided.

Copy link

codecov bot commented Mar 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.10%. Comparing base (30c038d) to head (6de4a81).
Report is 21 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2021      +/-   ##
==========================================
- Coverage   83.79%   83.10%   -0.70%     
==========================================
  Files         211      215       +4     
  Lines       39763    40895    +1132     
  Branches    36435    37109     +674     
==========================================
+ Hits        33320    33984     +664     
- Misses       4567     5027     +460     
- Partials     1876     1884       +8     
Flag Coverage Δ
python 85.92% <ø> (-6.15%) ⬇️
rust 82.81% <ø> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

swap,
/// separates leftmost element from the rest of the array.
/// `pop_left<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1,elemty>>`
Copy link
Contributor Author

@acl-cqc acl-cqc Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if SIZE is 0, the u64 will (presumably) wrap, so the result type will be an Option<array<U64_MAX, elemty>> which will be None at runtime.

Given SIZE must be statically known, we could remove the Option:

  • pop_left<0> could return Option of anything we want, or raise error in compute_signature
  • pop_left<1> could return just the element (no Option nor array)
  • pop_left<x> when x>=2 could return the element and rest of array (no Option)

and similarly for pop_right

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a return type you can't write down without a conditional, which is note very nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, yes, OK maybe I've gone too far. See also #1521 though: even if we returned the element and a size-0 array in all cases N>=1, we could still avoid the option by erroring in compute_signature for N==0. A lesser step but a good one?

Which is to say, I'll update/correct #1521 a bit and let's go from there

@acl-cqc acl-cqc changed the title doc: Provide docs for array ops, fix bad doc for HugrMut::poly_func_type doc: Provide docs for array ops, fix bad doc for HugrView::poly_func_type Mar 24, 2025
@acl-cqc acl-cqc changed the title doc: Provide docs for array ops, fix bad doc for HugrView::poly_func_type docs: Provide docs for array ops, fix bad doc for HugrView::poly_func_type Mar 24, 2025
@acl-cqc acl-cqc marked this pull request as ready for review March 24, 2025 11:10
@acl-cqc acl-cqc requested a review from a team as a code owner March 24, 2025 11:10
@acl-cqc acl-cqc requested review from jake-arkinstall and ss2165 and removed request for jake-arkinstall March 24, 2025 11:10
set,
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index index -> either(array, array)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index index -> either(array, array)`
/// exchanges two indices within the array: `swap<size,elemty>: array<size, elemty>, index, index -> either(array, array)`

swap,
/// separates leftmost element from the rest of the array.
/// `pop_left<SIZE><elemty>: array<SIZE, elemty> -> Option<elemty, array<SIZE-1,elemty>>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a return type you can't write down without a conditional, which is note very nice

swap,
/// separates leftmost element from the rest of the array.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention None indicates failure?

@acl-cqc acl-cqc requested a review from ss2165 March 25, 2025 15:38
Copy link
Collaborator

@doug-q doug-q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I think these strings belong in fn description(), but this is surely an improvement so approving.

set,
/// exchanges two indices within the array:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// exchanges two indices within the array:
/// Exchanges two indices within the array:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and I pedantically added "the elements at"

swap,
/// separates leftmost element from the rest of the array:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// separates leftmost element from the rest of the array:
/// Separates leftmost element from the rest of the array:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and added "the" (leftmost element)

pop_left,
/// separates rightmost element from the rest of the array.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// separates rightmost element from the rest of the array.
/// Separates rightmost element from the rest of the array.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and added missing "the"

@acl-cqc acl-cqc enabled auto-merge March 30, 2025 17:27
@acl-cqc acl-cqc disabled auto-merge March 31, 2025 13:14
@acl-cqc acl-cqc enabled auto-merge March 31, 2025 13:14
@acl-cqc acl-cqc requested a review from hugrbot April 2, 2025 09:03
@acl-cqc acl-cqc dismissed hugrbot’s stale review April 2, 2025 09:04

Changes addressed, hugrbot is not responding to request for re-review

@acl-cqc acl-cqc added this pull request to the merge queue Apr 2, 2025
Merged via the queue into main with commit 079585e Apr 2, 2025
25 checks passed
@acl-cqc acl-cqc deleted the acl/doc_array_hugrmut branch April 2, 2025 09:12
@hugrbot hugrbot mentioned this pull request Apr 2, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 2, 2025
## 🤖 New release

* `hugr-model`: 0.18.1 -> 0.19.0 (⚠ API breaking changes)
* `hugr-core`: 0.15.2 -> 0.15.3 ~(⚠ API breaking changes)~
* `hugr-llvm`: 0.15.2 -> 0.15.3 (✓ API compatible changes)
* `hugr-passes`: 0.15.2 -> 0.15.3 (✓ API compatible changes)
* `hugr`: 0.15.2 -> 0.15.3 (✓ API compatible changes)
* `hugr-cli`: 0.15.2 -> 0.15.3 (✓ API compatible changes)

### ⚠ `hugr-model` breaking changes

```text
--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_missing.ron

Failed in:
  enum hugr_model::v0::table::ExtSetPart, previously in file /tmp/.tmpDqJ3X7/hugr-model/src/v0/table/mod.rs:352

--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_variant_added.ron

Failed in:
  variant Term:Func in /tmp/.tmpIpZPlW/hugr/hugr-model/src/v0/table/mod.rs:341

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_variant_missing.ron

Failed in:
  variant Term::ExtSet, previously in file /tmp/.tmpDqJ3X7/hugr-model/src/v0/table/mod.rs:316
  variant Term::ConstFunc, previously in file /tmp/.tmpDqJ3X7/hugr-model/src/v0/table/mod.rs:321
  variant Term::ExtSet, previously in file /tmp/.tmpDqJ3X7/hugr-model/src/v0/ast/mod.rs:237

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing or renamed
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/pub_module_level_const_missing.ron

Failed in:
  CORE_EXT_SET in file /tmp/.tmpDqJ3X7/hugr-model/src/v0/mod.rs:177
```

### ⚠ `hugr-core` breaking changes (⚠️ ignored ⚠️ )

```text
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.40.0/src/lints/enum_variant_added.ron

Failed in:
  variant ImportError:OrderHint in /tmp/.tmpIpZPlW/hugr/hugr-core/src/import.rs:73
```

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.19.0](hugr-model-v0.18.1...hugr-model-v0.19.0)
- 2025-04-02

### New Features

- Python bindings for `hugr-model`.
([#1959](#1959))
- Remove extension sets from `hugr-model`.
([#2031](#2031))
- Packages in `hugr-model` and envelope support.
([#2026](#2026))
- Represent order edges in `hugr-model` as metadata.
([#2027](#2027))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.16.0](hugr-core-v0.15.2...hugr-core-v0.16.0)
- 2025-04-02

### Documentation

- Provide docs for array ops, fix bad doc for HugrView::poly_func_type
([#2021](#2021))

### New Features

- Expand SimpleReplacement API
([#1920](#1920))
- Python bindings for `hugr-model`.
([#1959](#1959))
- ReplaceTypes pass allows replacing extension types and ops
([#1989](#1989))
- Remove extension sets from `hugr-model`.
([#2031](#2031))
- Packages in `hugr-model` and envelope support.
([#2026](#2026))
- Represent order edges in `hugr-model` as metadata.
([#2027](#2027))
- add `build_expect_sum` to allow specific error messages
([#2032](#2032))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.16.0](hugr-llvm-v0.15.2...hugr-llvm-v0.16.0)
- 2025-04-02

### New Features

- *(hugr-llvm)* Add llvm codegen for `arithmetic.float.fpow`
([#2042](#2042))
- *(hugr-llvm)* Emit divmod and mod operations
([#2025](#2025))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.16.0](hugr-passes-v0.15.2...hugr-passes-v0.16.0)
- 2025-04-02

### New Features

- ReplaceTypes pass allows replacing extension types and ops
([#1989](#1989))
- MakeTuple->UnpackTuple elision pass
([#2012](#2012))
- [**breaking**] Extend LowerTypes pass to linearize by inserting
copy/discard ([#2018](#2018))
</blockquote>

## `hugr`

<blockquote>

##
[0.16.0](hugr-v0.15.2...hugr-v0.16.0)
- 2025-04-02

### Documentation

- Provide docs for array ops, fix bad doc for HugrView::poly_func_type
([#2021](#2021))

### New Features

- MakeTuple->UnpackTuple elision pass
([#2012](#2012))
- [**breaking**] Extend LowerTypes pass to linearize by inserting
copy/discard ([#2018](#2018))
- Expand SimpleReplacement API
([#1920](#1920))
- Python bindings for `hugr-model`.
([#1959](#1959))
- ReplaceTypes pass allows replacing extension types and ops
([#1989](#1989))
- Remove extension sets from `hugr-model`.
([#2031](#2031))
- Represent order edges in `hugr-model` as metadata.
([#2027](#2027))
- add `build_expect_sum` to allow specific error messages
([#2032](#2032))
- Packages in `hugr-model` and envelope support.
([#2026](#2026))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.16.0](hugr-cli-v0.15.2...hugr-cli-v0.16.0)
- 2025-04-02

### Documentation

- Add usage info to hugr-cli's rustdocs
([#2044](#2044))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: Agustín Borgna <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants