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

fix: Fix generic array functions #630

Merged
merged 8 commits into from
Nov 14, 2024
Merged

fix: Fix generic array functions #630

merged 8 commits into from
Nov 14, 2024

Conversation

mark-koch
Copy link
Collaborator

See #629 for context.

This PR changes the lowering of classical arrays to use the same Option trick that we use for linear arrays. This fixes #629 in the short-term. Longer-term we should do #628 to address the problem properly

@mark-koch mark-koch requested a review from a team as a code owner November 7, 2024 10:37
@mark-koch mark-koch requested review from doug-q and removed request for a team November 7, 2024 10:37
Comment on lines 273 to 274
# See https://github.com/CQCL/guppylang/issues/631
raise GuppyError("Array results are currently disabled", value)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The change in this PR breaks array results. We could emit code to unwrap the array elements, but imo it's now worth it since this will be undone once we do #628.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it breaks array results because those ops take an Array<N,f64>, not a Array<N,Option<f64>>.

This is certainly a shame, but the lowering isn't done so it's surely tolerable.

I am not sure enough of exactly what 628 will entail to be confident that that it will be undone then.

Your could emit HUGR that converted an Array<N,Option<_>> -> Array<N,_>. That would be better I think.

I am with things as is, up to you.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 54.54545% with 5 lines in your changes missing coverage. Please review.

Project coverage is 91.68%. Comparing base (263d527) to head (a81e3f1).

Files with missing lines Patch % Lines
guppylang/prelude/_internal/checker.py 0.00% 3 Missing ⚠️
guppylang/prelude/_internal/compiler/array.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           feat/generic-defs     #630      +/-   ##
=====================================================
- Coverage              91.83%   91.68%   -0.15%     
=====================================================
  Files                     60       60              
  Lines                   6465     6470       +5     
=====================================================
- Hits                    5937     5932       -5     
- Misses                   528      538      +10     

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

Comment on lines 273 to 274
# See https://github.com/CQCL/guppylang/issues/631
raise GuppyError("Array results are currently disabled", value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it breaks array results because those ops take an Array<N,f64>, not a Array<N,Option<f64>>.

This is certainly a shame, but the lowering isn't done so it's surely tolerable.

I am not sure enough of exactly what 628 will entail to be confident that that it will be undone then.

Your could emit HUGR that converted an Array<N,Option<_>> -> Array<N,_>. That would be better I think.

I am with things as is, up to you.

Base automatically changed from feat/generic-defs to main November 14, 2024 10:20
@mark-koch mark-koch added this pull request to the merge queue Nov 14, 2024
Merged via the queue into main with commit f4e5655 Nov 14, 2024
3 checks passed
@mark-koch mark-koch deleted the fix/generic-array branch November 14, 2024 10:32
github-merge-queue bot pushed a commit that referenced this pull request Nov 15, 2024
🤖 I have created a release *beep* *boop*
---


## [0.13.1](v0.13.0...v0.13.1)
(2024-11-15)


### Features

* Generic function definitions
([#618](#618))
([7519b90](7519b90)),
closes [#522](#522)
* mem_swap function for swapping two inout values
([#653](#653))
([89e10a5](89e10a5))


### Bug Fixes

* Fix generic array functions
([#630](#630))
([f4e5655](f4e5655))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants