From 8803723ebb5790a156eb1400b0496642ae3da42a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 09:27:23 +0000 Subject: [PATCH 1/3] chore(deps): update pyo3 requirement in the pyo3 group Updates the requirements on [pyo3](https://github.com/pyo3/pyo3) to permit the latest version. Updates `pyo3` to 0.21.2 - [Release notes](https://github.com/pyo3/pyo3/releases) - [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md) - [Commits](https://github.com/pyo3/pyo3/compare/v0.21.1...v0.21.2) --- updated-dependencies: - dependency-name: pyo3 dependency-type: direct:production dependency-group: pyo3 ... Signed-off-by: dependabot[bot] --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index a665534..809e33b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,7 +37,7 @@ name = "integration" path = "tests/lib.rs" [workspace.dependencies] -pyo3 = "0.21.1" +pyo3 = "0.22.2" pythonize = "0.21.1" rstest = "0.22.0" serde = "1.0" From 419f24b0e0f38e65b2ae29e9cb565ee75df5789a Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Mon, 12 Aug 2024 10:40:29 +0100 Subject: [PATCH 2/3] Also update pythonize --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 809e33b..f8723e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ path = "tests/lib.rs" [workspace.dependencies] pyo3 = "0.22.2" -pythonize = "0.21.1" +pythonize = "0.22.0" rstest = "0.22.0" serde = "1.0" serde_json = "1.0" From 5a1a944d4a139fa377bd3160843dfdc1f202fda5 Mon Sep 17 00:00:00 2001 From: Agustin Borgna Date: Mon, 12 Aug 2024 10:40:35 +0100 Subject: [PATCH 3/3] Fix deprecation warnings --- src/optype.rs | 16 +--------------- src/pytket.rs | 4 ++-- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/src/optype.rs b/src/optype.rs index 98a3857..851c98c 100644 --- a/src/optype.rs +++ b/src/optype.rs @@ -3,13 +3,11 @@ #[cfg(feature = "pyo3")] use pyo3::prelude::*; -#[cfg(feature = "pyo3")] -use pyo3::{exceptions::PyNotImplementedError, pyclass::CompareOp}; use serde::{Deserialize, Serialize}; use strum::EnumString; /// Operation types in a quantum circuit. -#[cfg_attr(feature = "pyo3", pyclass(name = "RsOpType"))] +#[cfg_attr(feature = "pyo3", pyclass(name = "RsOpType", eq, eq_int))] #[derive(Deserialize, Serialize, Clone, Debug, Default, PartialEq, Eq, Hash, EnumString)] #[non_exhaustive] pub enum OpType { @@ -550,15 +548,3 @@ pub enum OpType { /// [`DiagonalBox`]: crate::opbox::OpBox::DiagonalBox DiagonalBox, } - -#[cfg(feature = "pyo3")] -#[pymethods] -impl OpType { - fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult { - match op { - CompareOp::Eq => Ok(self == other), - CompareOp::Ne => Ok(self != other), - _ => Err(PyNotImplementedError::new_err("Unsupported comparison.")), - } - } -} diff --git a/src/pytket.rs b/src/pytket.rs index 8486248..02a1640 100644 --- a/src/pytket.rs +++ b/src/pytket.rs @@ -2,12 +2,12 @@ use crate::circuit_json::SerialCircuit; use pyo3::prelude::*; -use pythonize::{depythonize_bound, pythonize}; +use pythonize::{depythonize, pythonize}; impl SerialCircuit { /// Create a new `SerialCircuit` from a `pytket.Circuit`. pub fn from_tket1(circ: &Bound) -> PyResult { - let circ = depythonize_bound(circ.call_method0("to_dict").unwrap())?; + let circ = depythonize(&circ.call_method0("to_dict").unwrap())?; Ok(circ) }