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!: created/discarded_qubits circuit attribute #87

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Nov 5, 2024

pytket 1.7.3 added created/discarded_qubits fields to the circuit serialization, but we never added them here.

BREAKING CHANGE: Made SerialCircuit non exhaustive.

@aborgna-q aborgna-q requested a review from cqc-alec November 5, 2024 14:09
@hugrbot
Copy link
Collaborator

hugrbot commented Nov 5, 2024

This PR contains breaking changes to the public Rust API.
Please deprecate the old API instead (if possible), or mark the PR with a ! to indicate a breaking change.

cargo-semver-checks summary

--- failure struct_marked_non_exhaustive: struct marked #[non_exhaustive] ---

Description:
A public struct has been marked #[non_exhaustive], which will prevent it from being constructed using a struct literal outside of its crate. It previously had no private fields, so a struct literal could be used to construct it outside its crate.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_marked_non_exhaustive.ron

Failed in:
struct SerialCircuit in /home/runner/work/tket-json-rs/tket-json-rs/PR_BRANCH/src/circuit_json.rs:210
struct SerialCircuit in /home/runner/work/tket-json-rs/tket-json-rs/PR_BRANCH/src/circuit_json.rs:210

@aborgna-q aborgna-q changed the title feat: created/discarded_qubits circuit attribute feat!: created/discarded_qubits circuit attribute Nov 5, 2024
Copy link
Collaborator

@cqc-alec cqc-alec left a comment

Choose a reason for hiding this comment

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

Maybe worth making a new issue for the confusing use of Register in this file.

@@ -223,6 +223,12 @@ pub struct SerialCircuit<P = String> {
/// Number of wasm wires in the circuit.
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_ws: Option<u64>,
/// A list of qubits initialized at the start of the circuit.
#[serde(skip_serializing_if = "Option::is_none")]
pub created_qubits: Option<Vec<Register>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a vector of qubits, not a vector of qubit registers. But it seems Register is used in this file to refer to qubits (or bits). The name and description ("A register of locations sharing the same name") perhaps arise from a misunderstanding: qubits can be multi-indexed, so e.g. ["q", [0]] and ["q", [0, 1]] are both serializations of single qubits.

Copy link
Collaborator Author

@aborgna-q aborgna-q Nov 5, 2024

Choose a reason for hiding this comment

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

Yes, the naming there is terrible. I'll open the issue.

Edit: #88

@aborgna-q aborgna-q added this pull request to the merge queue Nov 5, 2024
Merged via the queue into main with commit bd5fcc4 Nov 5, 2024
7 of 10 checks passed
@aborgna-q aborgna-q deleted the ab/created-qubits branch November 5, 2024 14:34
@hugrbot hugrbot mentioned this pull request Oct 25, 2024
github-merge-queue bot pushed a commit that referenced this pull request Nov 13, 2024
## 🤖 New release
* `tket-json-rs`: 0.6.2 -> 0.7.0 (⚠️ API breaking changes)

### ⚠️ `tket-json-rs` breaking changes

```
--- 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.36.0/src/lints/enum_variant_missing.ron

Failed in:
  variant ClassicalExpUnit::Register, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:56

--- failure struct_marked_non_exhaustive: struct marked #[non_exhaustive] ---

Description:
A public struct has been marked #[non_exhaustive], which will prevent it from being constructed using a struct literal outside of its crate. It previously had no private fields, so a struct literal could be used to construct it outside its crate.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#attr-adding-non-exhaustive
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/struct_marked_non_exhaustive.ron

Failed in:
  struct SerialCircuit in /tmp/.tmp7Vjg5L/tket-json-rs/src/circuit_json.rs:202
  struct SerialCircuit in /tmp/.tmp7Vjg5L/tket-json-rs/src/circuit_json.rs:202

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct 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.36.0/src/lints/struct_missing.ron

Failed in:
  struct tket_json_rs::circuit_json::Bitstring, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:35
  struct tket_json_rs::circuit_json::BitRegister, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:25
  struct tket_json_rs::circuit_json::CompositeGate, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:14
  struct tket_json_rs::circuit_json::Register, previously in file /tmp/.tmpgK5lkw/tket-json-rs/src/circuit_json.rs:10
```

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

<blockquote>

### ⚠ BREAKING CHANGES

- Made `SerialCircuit` non exhaustive.
- `Register` renamed to `ElementId`, `Qubit` and `Bit`
- Moved some definitions from `::circuit_json` to `::register`
- Bumped MSRV to rust 1.75
- Renamed `circuit_json::CompositeGate` to `CustomGate`

## 0.7.0 (2024-11-13)

### Features

- [**breaking**] `created/discarded_qubits` circuit attribute
([#87](#87))
- Support classical expressions
([#86](#86))
- [**breaking**] Rename `Register` and cleanup definitions
([#89](#89))
- [**breaking**] Support old `Composite` alias for `CustomGate`
([#91](#91))
</blockquote>


</p></details>

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

---------

Co-authored-by: Agustín Borgna <[email protected]>
@hugrbot hugrbot mentioned this pull request Nov 18, 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.

3 participants