Skip to content
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

feat!: Add more list operations #1474

Merged
merged 3 commits into from
Aug 30, 2024
Merged

feat!: Add more list operations #1474

merged 3 commits into from
Aug 30, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Aug 27, 2024

Closes #1467.

Blocked by #1469

BREAKING CHANGE: ListOp::pop now returns an option.

@aborgna-q aborgna-q requested a review from a team as a code owner August 27, 2024 15:21
@aborgna-q aborgna-q requested review from zrho and removed request for a team August 27, 2024 15:21
Base automatically changed from ab/refactor-list-ext to main August 27, 2024 16:15
Copy link

codecov bot commented Aug 27, 2024

Codecov Report

Attention: Patch coverage is 72.29730% with 41 lines in your changes missing coverage. Please review.

Project coverage is 87.18%. Comparing base (9698420) to head (68f6225).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
hugr-passes/src/const_fold/test.rs 0.00% 28 Missing ⚠️
hugr-core/src/hugr/rewrite/replace.rs 0.00% 7 Missing ⚠️
...r-core/src/std_extensions/collections/list_fold.rs 90.76% 0 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1474      +/-   ##
==========================================
- Coverage   87.95%   87.18%   -0.77%     
==========================================
  Files         125      125              
  Lines       21116    21222     +106     
  Branches    18272    18380     +108     
==========================================
- Hits        18572    18503      -69     
- Misses       1760     1945     +185     
+ Partials      784      774      -10     
Flag Coverage Δ
python 92.54% <ø> (-0.01%) ⬇️
rust 86.36% <72.29%> (-0.88%) ⬇️

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.

@aborgna-q aborgna-q added this to the hugr-rs 0.12 / hugr-py 0.8 milestone Aug 28, 2024
hugr-core/src/std_extensions/collections.rs Outdated Show resolved Hide resolved
hugr-core/src/std_extensions/collections.rs Outdated Show resolved Hide resolved
hugr-core/src/std_extensions/collections.rs Outdated Show resolved Hide resolved
@aborgna-q aborgna-q removed this from the hugr-rs 0.12 / hugr-py 0.8 milestone Aug 28, 2024
@aborgna-q
Copy link
Collaborator Author

I removed all panicking operations, as they can be defined from checked ones (with an if and a standalone panic).

I also reduced the set of operations to a core one. This gets rid of the equality checks problem.

I moved the option/result definitions to it's own PR (#1481). I'll rebase on top of it.

@aborgna-q aborgna-q changed the base branch from main to ab/option-result August 29, 2024 11:25
@aborgna-q aborgna-q force-pushed the ab/list-ops branch 2 times, most recently from 980ce59 to 7ba766a Compare August 29, 2024 12:20
@aborgna-q aborgna-q changed the title feat: Add more list operations feat!: Add more list operations Aug 29, 2024
@aborgna-q aborgna-q requested a review from zrho August 29, 2024 12:38
@ss2165
Copy link
Member

ss2165 commented Aug 29, 2024

regarding panicking, how about adding a generic unwrap: forall R, E. [R, E] -> R function to the guppy prelude? Maybe guppy needs better Sum support first?

Base automatically changed from ab/option-result to main August 29, 2024 15:46
@aborgna-q
Copy link
Collaborator Author

aborgna-q commented Aug 29, 2024

It seems I'll actually need an unwrap to fix this test in hugr.

#[test]
#[cfg_attr(
feature = "extension_inference",
ignore = "inference fails for test graph, it shouldn't"
)]
fn test_list_ops() -> Result<(), Box<dyn std::error::Error>> {

(It was skipped due to some inference error, but it works now).

I'd prefer to skip it temporarily, and add the unwrap in a separate PR.

Or do you think it should be exclusively a guppy definition?

@ss2165 ss2165 requested review from ss2165 and removed request for zrho August 30, 2024 08:54
Copy link
Member

@ss2165 ss2165 left a comment

Choose a reason for hiding this comment

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

:shipit:

@aborgna-q aborgna-q added this pull request to the merge queue Aug 30, 2024
Merged via the queue into main with commit 037005f Aug 30, 2024
20 of 21 checks passed
@aborgna-q aborgna-q deleted the ab/list-ops branch August 30, 2024 09:02
github-merge-queue bot pushed a commit that referenced this pull request Aug 30, 2024
## 🤖 New release
* `hugr`: 0.11.0 -> 0.12.0
* `hugr-core`: 0.8.0 -> 0.9.0
* `hugr-passes`: 0.7.0 -> 0.8.0
* `hugr-cli`: 0.4.0 -> 0.5.0

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

## `hugr`
<blockquote>

## 0.12.0 (2024-08-30)

### Features

- [**breaking**] Disallow opaque ops during validation
([#1431](#1431))
- [**breaking**] Add collections to serialized standard extensions
([#1452](#1452))
- [**breaking**] Variadic logic ops now binary
([#1451](#1451))
- [**breaking**] Int operations other than widen/narrow have only one
width arg ([#1455](#1455))
- Add a `FuncTypeBase::io` method
([#1458](#1458))
- Add missing ops ([#1463](#1463))
- [**breaking**] Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` to
prelude ([#1475](#1475))
- `Option` / `Result` helpers
([#1481](#1481))
- [**breaking**] Add more list operations
([#1474](#1474))
- [**breaking**] Move int conversions to `conversions` ext, add to/from
usize ([#1490](#1490))
- Fill out array ops ([#1491](#1491))

### Refactor

- [**breaking**] Bring the collections ext in line with other extension
defs ([#1469](#1469))
- [**breaking**] Make Either::Right the "success" case
([#1489](#1489))
- [**breaking**] Flatten `CustomOp` in to `OpType`
([#1429](#1429))

### Testing

- Add serialization benchmarks
([#1439](#1439))
</blockquote>

## `hugr-core`
<blockquote>

## 0.9.0 (2024-08-30)

### Features

- [**breaking**] Disallow opaque ops during validation
([#1431](#1431))
- [**breaking**] Add collections to serialized standard extensions
([#1452](#1452))
- [**breaking**] Variadic logic ops now binary
([#1451](#1451))
- [**breaking**] Int operations other than widen/narrow have only one
width arg ([#1455](#1455))
- Add a `FuncTypeBase::io` method
([#1458](#1458))
- Add missing ops ([#1463](#1463))
- [**breaking**] Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` to
prelude ([#1475](#1475))
- `Option` / `Result` helpers
([#1481](#1481))
- [**breaking**] Add more list operations
([#1474](#1474))
- [**breaking**] Move int conversions to `conversions` ext, add to/from
usize ([#1490](#1490))
- Fill out array ops ([#1491](#1491))

### Refactor

- [**breaking**] Flatten `CustomOp` in to `OpType`
([#1429](#1429))
- [**breaking**] Bring the collections ext in line with other extension
defs ([#1469](#1469))
- [**breaking**] Make Either::Right the "success" case
([#1489](#1489))
</blockquote>

## `hugr-passes`
<blockquote>

## 0.8.0 (2024-08-30)

### Features

- [**breaking**] Variadic logic ops now binary
([#1451](#1451))
- [**breaking**] Int operations other than widen/narrow have only one
width arg ([#1455](#1455))
- [**breaking**] Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` to
prelude ([#1475](#1475))
- [**breaking**] Add more list operations
([#1474](#1474))
- [**breaking**] Move int conversions to `conversions` ext, add to/from
usize ([#1490](#1490))

### Refactor

- [**breaking**] Flatten `CustomOp` in to `OpType`
([#1429](#1429))
- [**breaking**] Bring the collections ext in line with other extension
defs ([#1469](#1469))
- [**breaking**] Make Either::Right the "success" case
([#1489](#1489))
</blockquote>

## `hugr-cli`
<blockquote>

## 0.5.0 (2024-08-30)

### Features

- [**breaking**] Add collections to serialized standard extensions
([#1452](#1452))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
github-merge-queue bot pushed a commit that referenced this pull request Aug 30, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](hugr-py-v0.7.0...hugr-py-v0.8.0)
(2024-08-30)


### ⚠ BREAKING CHANGES

* Moved `itobool`/`ifrombool`/`itostring_{u,s}` to the conversions
extension.
* Binary sums representing fallible values now use tag `1` for the
successful variant
* **hugr-py:** rename `Custom.name` to `Custom.op_name` and
`Func(Defn/Decl).name` to `f_name` to allow for new `name` method
* `ListOp::pop` now returns an option.
* Moved all builder definitions into the `hugr.build` module. Moved
`node_port` and `render` into the `hugr.hugr` module.
* Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` from core
operations to prelude. Rename `ops::leaf` module to `ops::sum`.
* **hugr-py:** `hugr.serialization` module and `to_serial` methods are
now internal only.
* Renamed `_DfBase` to `DfBase` and `_DefinitionBuilder` to
`DefinitionBuilder`
* `idivmod_checked`, `idivmod`, `idiv`, `idiv_checked`, `imod`, `ishl`,
`ishr`, `irotl`, `irotr` operations now only have one width argument for
all inputs and outputs rather than two.
* HUGRs containing opaque operations that don't point to an extension in
the registry will fail to validate. Use `Package` to pack extensions
with HUGRs for serialisation.
* `CustomOp` removed, `OpType` now contains `ExtensionOp` and `OpaqueOp`
directly. `CustomOpError` renamed to`OpaqueOpError`.

### Features

* `Option` / `Result` helpers
([#1481](#1481))
([9698420](9698420))
* Add missing ops ([#1463](#1463))
([841f450](841f450))
* Add more list operations
([#1474](#1474))
([037005f](037005f))
* Bring in the pure-python renderer from guppy
([#1462](#1462))
([001e66a](001e66a))
* disallow opaque ops during validation
([#1431](#1431))
([fbbb805](fbbb805))
* fill out array ops ([#1491](#1491))
([26ec57a](26ec57a))
* **hugr-py:** pretty printing for ops and types
([#1482](#1482))
([aca403a](aca403a))
* **hugr-py:** use serialized extensions in python
([#1459](#1459))
([a61f4df](a61f4df)),
closes [#1450](#1450)
* int operations other than widen/narrow have only one width arg
([#1455](#1455))
([c39ed15](c39ed15))
* Move `Lift`, `MakeTuple`, `UnpackTuple` and `Lift` to prelude
([#1475](#1475))
([b387505](b387505))
* Move int conversions to `conversions` ext, add to/from usize
([#1490](#1490))
([88913f2](88913f2))


### Bug Fixes

* **hugr-py:** record node children correctly when deserializing
([#1480](#1480))
([331125a](331125a)),
closes [#1479](#1479)
* **py:** Invalid node indexing
([#1457](#1457))
([d6edcd7](d6edcd7))
* schema for array inner types
([#1494](#1494))
([d43cbb2](d43cbb2)),
closes [#1471](#1471)
* Sum value equality. Add unit tests
([#1484](#1484))
([a7b2718](a7b2718))


### Code Refactoring

* flatten `CustomOp` in to `OpType`
([#1429](#1429))
([8e8bba5](8e8bba5))
* **hugr-py:** make serialization (module/methods) private
([#1477](#1477))
([49a5bad](49a5bad))
* Make `_DfBase` and `_DefinitionBuilder` public
([#1461](#1461))
([ea9cca0](ea9cca0))
* Make Either::Right the "success" case
([#1489](#1489))
([8caa572](8caa572))
* Organise the hugr-py modules
([#1460](#1460))
([3ca56f4](3ca56f4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com>
Co-authored-by: Agustin Borgna <agustin.borgna@quantinuum.com>
@hugrbot hugrbot mentioned this pull request Sep 3, 2024
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.

Add more list operations
3 participants