feat!: Split the pytket extension encoder trait#970
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #970 +/- ##
==========================================
+ Coverage 79.24% 79.68% +0.43%
==========================================
Files 92 95 +3
Lines 11206 11556 +350
Branches 10932 11279 +347
==========================================
+ Hits 8880 9208 +328
- Misses 1707 1717 +10
- Partials 619 631 +12
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
This PR contains breaking changes to the public Rust API. cargo-semver-checks summary |
doug-q
left a comment
There was a problem hiding this comment.
Sorry for the delay, I never submitted the review.
I think it would be could to fix the missing coverage in TypeTranslatorSet
| /// | ||
| /// This is used both during encoding and decoding of pytket operations and | ||
| /// types. | ||
| pub trait TypeTranslator { |
There was a problem hiding this comment.
Unfortunately close name to https://docs.rs/hugr/latest/hugr/types/trait.TypeTransformer.html
There was a problem hiding this comment.
Renamed to PytketTypeTransformer
| params: 0, | ||
| }); | ||
| } | ||
| if let Some(tuple) = sum.as_tuple() { |
| vec![BOOL_EXTENSION_ID] | ||
| } | ||
|
|
||
| fn type_to_pytket(&self, typ: &hugr::types::CustomType) -> Option<RegisterCount> { |
There was a problem hiding this comment.
No coverage.
You don't check the extension. I suppose this is Ok, but I recommend you at least document in the trait that typ is guaranteed to have an extension matching the result of extensions.
Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com>
1f63401 to
d062945
Compare
Splits the `type_to_pytket` method out of the `PytketEmitter` trait implemented by extensions, and into a new `TypeTranslator` trait as we'll use them in the decoder trait too. Adds a `TypeTranslatorSet` used by the encoder/decoder config that caches the translation, since it gets called multiple times with the same types. BREAKING CHANGE: Moved `PytketEmitter::type_to_pytket` to new `TypeTranslator` trait. --------- Co-authored-by: Douglas Wilson <141026920+doug-q@users.noreply.github.com>
## 🙂 New release * `tket2`: 0.12.3 -> `tket` 0.13.0 (New crate name!) * `tket2-hseries`: 0.16.1 -> `tket-qsystem` 0.17.0 (New crate name!) <details><summary><i><b>Changelog</b></i></summary><p> ## `tket` <blockquote> ## [0.13.0](tket2-v0.12.3...tket-v0.13.0) - 2025-07-25 ### New Features - [**breaking] Rename tket2.* HUGR extensions to tket.* ([#988](#988)) - [**breaking] Rename tket2* libs to tket* ([#987](#987)) - [**breaking**] Update to `hugr 0.21` ([#965](#965)) - Add guppy extension with drop operation ([#962](#962)) - [**breaking**] Split the pytket extension encoder trait ([#970](#970)) </blockquote> ## `tket-qsystem` <blockquote> ## [0.17.0](tket2-hseries-v0.16.1...tket-qsystem-v0.17.0) - 2025-07-25 ### New Features - [**breaking] Rename tket2.* HUGR extensions to tket.* ([#988](#988)) - [**breaking] Rename tket2* libs to tket* ([#987](#987)) - [**breaking**] Update to `hugr 0.21` ([#965](#965)) - Add guppy extension with drop operation ([#962](#962)) </blockquote> </p></details> --- This PR was generated by a human.
## 🙂 New release * `tket2`: 0.12.3 -> `tket` 0.13.0 (New crate name!) * `tket2-hseries`: 0.16.1 -> `tket-qsystem` 0.17.0 (New crate name!) <details><summary><i><b>Changelog</b></i></summary><p> ## `tket` <blockquote> ## [0.13.0](tket2-v0.12.3...tket-v0.13.0) - 2025-07-25 ### New Features - [**breaking] Rename tket2.* HUGR extensions to tket.* ([#988](#988)) - [**breaking] Rename tket2* libs to tket* ([#987](#987)) - [**breaking**] Update to `hugr 0.21` ([#965](#965)) - Add guppy extension with drop operation ([#962](#962)) - [**breaking**] Split the pytket extension encoder trait ([#970](#970)) </blockquote> ## `tket-qsystem` <blockquote> ## [0.17.0](tket2-hseries-v0.16.1...tket-qsystem-v0.17.0) - 2025-07-25 ### New Features - [**breaking] Rename tket2.* HUGR extensions to tket.* ([#988](#988)) - [**breaking] Rename tket2* libs to tket* ([#987](#987)) - [**breaking**] Update to `hugr 0.21` ([#965](#965)) - Add guppy extension with drop operation ([#962](#962)) </blockquote> </p></details> --- This PR was generated by a human.
Splits the
type_to_pytketmethod out of thePytketEmittertrait implemented by extensions, and into a newTypeTranslatortrait as we'll use them in the decoder trait too.Adds a
TypeTranslatorSetused by the encoder/decoder config that caches the translation, since it gets called multiple times with the same types.BREAKING CHANGE: Moved
PytketEmitter::type_to_pytketto newTypeTranslatortrait.