Skip to content

Commit

Permalink
use Py<PyAny> instead of Bound in from_pyany (#291)
Browse files Browse the repository at this point in the history
* From_pyany use Py<PyAny> instead of Bound for compatibility

* version
  • Loading branch information
dberthault authored May 3, 2024
1 parent 9cfe47d commit 43ca393
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This changelog track changes to the qoqo_calculator project starting at version 0.6.0

## 1.2.1

* Fixes a compatibility issue for from_pyany with struqture and qoqo.

## 1.2.0

* Update to pyo3 0.21
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions qoqo_calculator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "qoqo_calculator"
version = "1.2.0"
version = "1.2.1"
authors = ["HQS Quantum Simulations <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
Expand All @@ -15,10 +15,10 @@ name = "qoqo_calculator"
crate-type = ["rlib"]

[dependencies]
num-complex = {version= "0.4", features=['serde']}
num-complex = { version = "0.4", features = ['serde'] }
serde = { version = '1.0', features = ["derive"] }
thiserror = "1.0"
schemars = { version = "0.8", optional=true }
schemars = { version = "0.8", optional = true }


[dev-dependencies]
Expand Down
16 changes: 11 additions & 5 deletions qoqo_calculator_pyo3/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
[package]
name = "qoqo_calculator_pyo3"
version = "1.2.0"
version = "1.2.1"
authors = ["HQS Quantum Simulations <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
readme = "README.md"
repository = "https://github.com/HQSquantumsimulations/qoqo_calculator_pyo3"
description = "Python interface to qoqo calculator, the calculator backend of the qoqo quantum computing toolkit by HQS Quantum Simulations"
include = ["src*", "qoqo_calculator_pyo3", "LICENSE", "pyproject.toml", "README.md"]
include = [
"src*",
"qoqo_calculator_pyo3",
"LICENSE",
"pyproject.toml",
"README.md",
]

[lib]
name = "qoqo_calculator_pyo3"
Expand All @@ -16,8 +22,8 @@ crate-type = ["cdylib", "rlib"]

[dependencies]
num-complex = "0.4"
qoqo_calculator = {version="1.2", path="../qoqo_calculator"}
serde = "1.0"
qoqo_calculator = { version = "1.2", path = "../qoqo_calculator" }
serde = "1.0"
thiserror = "1.0"

[dependencies.pyo3]
Expand All @@ -29,4 +35,4 @@ pyo3-build-config = "0.21"

[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
default = ["extension-module"]
10 changes: 6 additions & 4 deletions qoqo_calculator_pyo3/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[project]
name = "qoqo_calculator_pyo3"
version = "1.2.0"
license = {text="Apache-2.0 AND Apache-2.0 with LLVM-exception AND MIT AND Unicode-DFS-2016"}
maintainers = [{name = "HQS Quantum Simulations GmbH", email = "[email protected]"}]
version = "1.2.1"
license = { text = "Apache-2.0 AND Apache-2.0 with LLVM-exception AND MIT AND Unicode-DFS-2016" }
maintainers = [
{ name = "HQS Quantum Simulations GmbH", email = "[email protected]" },
]
requires-python = ">=3.8"

[build-system]
Expand All @@ -25,5 +27,5 @@ docs = [
"myst_parser",
"sphinx_rtd_theme",
"tomli",
"numpy"
"numpy",
]
4 changes: 2 additions & 2 deletions qoqo_calculator_pyo3/qoqo_calculator_pyo3/DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -4660,7 +4660,7 @@ LICENSE-APACHE:


====================================================
qoqo_calculator 1.2.0
qoqo_calculator 1.2.1
https://github.com/HQSquantumsimulations/qoqo_calculator
by HQS Quantum Simulations <[email protected]>
qoqo-calculator is the calculator backend of the qoqo quantum computing toolkit by HQS Quantum Simulations
Expand Down Expand Up @@ -4872,7 +4872,7 @@ LICENSE:


====================================================
qoqo_calculator_pyo3 1.2.0
qoqo_calculator_pyo3 1.2.1
https://github.com/HQSquantumsimulations/qoqo_calculator_pyo3
by HQS Quantum Simulations <[email protected]>
Python interface to qoqo calculator, the calculator backend of the qoqo quantum computing toolkit by HQS Quantum Simulations
Expand Down
9 changes: 6 additions & 3 deletions qoqo_calculator_pyo3/src/calculator_complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,12 @@ impl CalculatorComplexWrapper {
}

impl CalculatorComplexWrapper {
pub fn from_pyany(input: &Bound<PyAny>) -> PyResult<CalculatorComplex> {
convert_into_calculator_complex(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_complex: {err:?}"))
pub fn from_pyany(input: Py<PyAny>) -> PyResult<CalculatorComplex> {
Python::with_gil(|py| -> PyResult<CalculatorComplex> {
let input = input.bind(py);
convert_into_calculator_complex(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_complex: {err:?}"))
})
})
}
}
9 changes: 6 additions & 3 deletions qoqo_calculator_pyo3/src/calculator_float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,12 @@ impl CalculatorFloatWrapper {
}

impl CalculatorFloatWrapper {
pub fn from_pyany(input: &Bound<PyAny>) -> PyResult<CalculatorFloat> {
convert_into_calculator_float(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_float: {err:?}"))
pub fn from_pyany(input: Py<PyAny>) -> PyResult<CalculatorFloat> {
Python::with_gil(|py| -> PyResult<CalculatorFloat> {
let input = input.bind(py);
convert_into_calculator_float(input).map_err(|err| {
PyValueError::new_err(format!("Error in convert_to_calculator_float: {err:?}"))
})
})
}
}

0 comments on commit 43ca393

Please sign in to comment.