Skip to content

Commit 283fde2

Browse files
authored
Update to PyO3 v0.23 (#262)
1 parent 3b7579c commit 283fde2

File tree

26 files changed

+84
-86
lines changed

26 files changed

+84
-86
lines changed

.github/workflows/documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup python
1616
uses: actions/setup-python@v5
1717
with:
18-
python-version: 3.9
18+
python-version: 3.11
1919
- name: Install pandoc
2020
run: sudo apt-get install -y pandoc
2121
- name: Install python dependencies

.github/workflows/release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.9
14+
python-version: 3.11
1515
- name: Build Wheels
1616
uses: PyO3/maturin-action@v1
1717
with:
@@ -25,12 +25,12 @@ jobs:
2525
path: dist
2626

2727
macos-x86_64:
28-
runs-on: macos-12
28+
runs-on: macos-14
2929
steps:
3030
- uses: actions/checkout@v4
3131
- uses: actions/setup-python@v5
3232
with:
33-
python-version: 3.9
33+
python-version: 3.11
3434
architecture: x64
3535
- name: Build wheels - x86_64
3636
uses: PyO3/maturin-action@v1
@@ -48,7 +48,7 @@ jobs:
4848
- uses: actions/checkout@v4
4949
- uses: actions/setup-python@v5
5050
with:
51-
python-version: 3.9
51+
python-version: 3.11
5252
architecture: arm64
5353
- name: Build wheels - aarch64
5454
uses: PyO3/maturin-action@v1
@@ -69,7 +69,7 @@ jobs:
6969
- uses: actions/checkout@v4
7070
- uses: actions/setup-python@v5
7171
with:
72-
python-version: 3.9
72+
python-version: 3.11
7373
architecture: ${{ matrix.target }}
7474
- name: Build wheels
7575
uses: PyO3/maturin-action@v1
@@ -94,7 +94,7 @@ jobs:
9494
merge-multiple: true
9595
- uses: actions/setup-python@v5
9696
with:
97-
python-version: 3.9
97+
python-version: 3.11
9898
- name: Publish to PyPi
9999
env:
100100
TWINE_USERNAME: __token__

.github/workflows/wheels.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v5
1313
with:
14-
python-version: 3.9
14+
python-version: 3.11
1515
- name: Build Wheels
1616
uses: PyO3/maturin-action@v1
1717
with:
@@ -24,12 +24,12 @@ jobs:
2424
name: wheel-linux-x86_64
2525
path: dist
2626
macos-x86_64:
27-
runs-on: macos-12
27+
runs-on: macos-14
2828
steps:
2929
- uses: actions/checkout@v4
3030
- uses: actions/setup-python@v5
3131
with:
32-
python-version: 3.9
32+
python-version: 3.11
3333
architecture: x64
3434
- name: Build wheels - x86_64
3535
uses: PyO3/maturin-action@v1
@@ -47,7 +47,7 @@ jobs:
4747
- uses: actions/checkout@v4
4848
- uses: actions/setup-python@v5
4949
with:
50-
python-version: 3.9
50+
python-version: 3.11
5151
architecture: arm64
5252
- name: Build wheels - aarch64
5353
uses: PyO3/maturin-action@v1
@@ -65,7 +65,7 @@ jobs:
6565
- uses: actions/checkout@v4
6666
- uses: actions/setup-python@v5
6767
with:
68-
python-version: 3.9
68+
python-version: 3.11
6969
architecture: x64
7070
- name: Build wheels
7171
uses: PyO3/maturin-action@v1

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ members = ["feos-core", "feos-dft", "feos-derive"]
3030
crate-type = ["rlib", "cdylib"]
3131

3232
[dependencies]
33-
quantity = "0.9"
34-
num-dual = "0.10"
33+
quantity = "0.10"
34+
num-dual = "0.11"
3535
feos-core = { version = "0.7", path = "feos-core" }
3636
feos-dft = { version = "0.7", path = "feos-dft", optional = true }
3737
feos-derive = { version = "0.5", path = "feos-derive" }
38-
numpy = { version = "0.22", optional = true }
38+
numpy = { version = "0.23", optional = true }
3939
ndarray = { version = "0.16", features = ["approx"] }
4040
petgraph = { version = "0.6", optional = true }
41-
thiserror = "1.0"
41+
thiserror = "2.0"
4242
conv = "0.3"
4343
num-traits = "0.2"
4444
serde = "1.0"
@@ -50,8 +50,8 @@ itertools = "0.13"
5050
typenum = "1.16"
5151

5252
[dependencies.pyo3]
53-
version = "0.22"
54-
features = ["extension-module", "abi3", "abi3-py37"]
53+
version = "0.23"
54+
features = ["extension-module", "abi3", "abi3-py39"]
5555
optional = true
5656

5757
[dev-dependencies]

feos-core/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ rustdoc-args = ["--html-in-header", "./docs-header.html"]
2626
features = ["rayon"]
2727

2828
[dependencies]
29-
quantity = { version = "0.9", features = ["approx", "ndarray"] }
30-
num-dual = { version = "0.10", features = ["linalg"] }
29+
quantity = { version = "0.10", features = ["approx", "ndarray"] }
30+
num-dual = { version = "0.11", features = ["linalg"] }
3131
ndarray = { version = "0.16", features = ["serde", "approx"] }
3232
nalgebra = "0.33"
3333
num-traits = "0.2"
34-
thiserror = "1.0"
34+
thiserror = "2.0"
3535
serde = { version = "1.0", features = ["derive"] }
3636
serde_json = "1.0"
3737
indexmap = "2.0"
3838
conv = "0.3"
39-
numpy = { version = "0.22", optional = true }
40-
pyo3 = { version = "0.22", features = ["multiple-pymethods"], optional = true }
39+
numpy = { version = "0.23", optional = true }
40+
pyo3 = { version = "0.23", features = ["multiple-pymethods"], optional = true }
4141
rayon = { version = "1.5", optional = true }
4242
typenum = "1.16"
4343
approx = "0.5"

feos-core/src/python/parameter/fragmentation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn fragment_molecule(
113113
smiles: &str,
114114
smarts: Vec<PySmartsRecord>,
115115
) -> PyResult<(Vec<String>, Vec<[usize; 2]>)> {
116-
let chem = py.import_bound("rdkit.Chem")?;
116+
let chem = py.import("rdkit.Chem")?;
117117
let mol = chem.call_method1("MolFromSmiles", (smiles,))?;
118118
let atoms = mol.call_method0("GetNumHeavyAtoms")?.extract::<usize>()?;
119119

@@ -155,7 +155,7 @@ fn fragment_molecule(
155155
.for_each(|(_, m)| m.retain(|m| !(m.len() == 1 && large_segments.contains(&m[0]))));
156156

157157
let bonds = mol.call_method0("GetBonds")?;
158-
let builtins = py.import_bound("builtins")?;
158+
let builtins = py.import("builtins")?;
159159
let bonds = builtins
160160
.call_method1("list", (bonds,))?
161161
.extract::<Vec<Bound<'_, PyAny>>>()?;

feos-core/src/python/parameter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ macro_rules! impl_binary_record {
272272
#[expect(irrefutable_let_patterns)]
273273
fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
274274
Ok(if let Ok(mr) = f64::try_from(self.0.model_record.clone()) {
275-
pyo3::types::PyFloat::new_bound(py, mr).into_any()
275+
pyo3::types::PyFloat::new(py, mr).into_any()
276276
} else {
277277
Bound::new(py, $py_model_record(self.0.model_record.clone()))?.into_any()
278278
})
@@ -744,7 +744,7 @@ macro_rules! impl_parameter {
744744
self.0
745745
.records()
746746
.1
747-
.map(|r| r.mapv(|r| f64::try_from(r).unwrap()).view().to_pyarray_bound(py))
747+
.map(|r| r.mapv(|r| f64::try_from(r).unwrap()).view().to_pyarray(py))
748748
}
749749
}
750750
};

feos-core/src/python/state.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ macro_rules! impl_state {
558558
/// -------
559559
/// numpy.ndarray
560560
fn ln_phi<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
561-
self.0.ln_phi().into_pyarray_bound(py)
561+
self.0.ln_phi().into_pyarray(py)
562562
}
563563

564564
/// Return logarithmic fugacity coefficient of all components treated as
@@ -568,7 +568,7 @@ macro_rules! impl_state {
568568
/// -------
569569
/// numpy.ndarray
570570
fn ln_phi_pure_liquid<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyArray1<f64>>> {
571-
Ok(self.0.ln_phi_pure_liquid()?.into_pyarray_bound(py))
571+
Ok(self.0.ln_phi_pure_liquid()?.into_pyarray(py))
572572
}
573573

574574
/// Return logarithmic symmetric activity coefficient.
@@ -577,7 +577,7 @@ macro_rules! impl_state {
577577
/// -------
578578
/// numpy.ndarray
579579
fn ln_symmetric_activity_coefficient<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyArray1<f64>>> {
580-
Ok(self.0.ln_symmetric_activity_coefficient()?.into_pyarray_bound(py))
580+
Ok(self.0.ln_symmetric_activity_coefficient()?.into_pyarray(py))
581581
}
582582

583583
/// Return Henry's law constant of every solute (x_i=0) for a given solvent (x_i>0).
@@ -650,7 +650,7 @@ macro_rules! impl_state {
650650
/// -------
651651
/// numpy.ndarray
652652
fn thermodynamic_factor<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f64>> {
653-
self.0.thermodynamic_factor().into_pyarray_bound(py)
653+
self.0.thermodynamic_factor().into_pyarray(py)
654654
}
655655

656656
/// Return molar isochoric heat capacity.
@@ -1021,7 +1021,7 @@ macro_rules! impl_state {
10211021
/// -------
10221022
/// numpy.ndarray[Float64]
10231023
fn massfracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
1024-
self.0.massfracs().into_pyarray_bound(py)
1024+
self.0.massfracs().into_pyarray(py)
10251025
}
10261026

10271027
/// Return mass specific Helmholtz energy.
@@ -1168,7 +1168,7 @@ macro_rules! impl_state {
11681168

11691169
#[getter]
11701170
fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
1171-
self.0.molefracs.to_pyarray_bound(py)
1171+
self.0.molefracs.to_pyarray(py)
11721172
}
11731173

11741174
fn _repr_markdown_(&self) -> String {
@@ -1318,7 +1318,7 @@ macro_rules! impl_state {
13181318

13191319
#[getter]
13201320
fn get_compressibility<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1<f64>> {
1321-
StateVec::from(self).compressibility().into_pyarray_bound(py)
1321+
StateVec::from(self).compressibility().into_pyarray(py)
13221322
}
13231323

13241324
#[getter]
@@ -1333,7 +1333,7 @@ macro_rules! impl_state {
13331333

13341334
#[getter]
13351335
fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2<f64>> {
1336-
StateVec::from(self).molefracs().into_pyarray_bound(py)
1336+
StateVec::from(self).molefracs().into_pyarray(py)
13371337
}
13381338

13391339
#[getter]
@@ -1343,7 +1343,7 @@ macro_rules! impl_state {
13431343

13441344
#[getter]
13451345
fn get_massfracs<'py>(&self, py: Python<'py>) -> Option<Bound<'py, PyArray2<f64>>> {
1346-
self.0[0].eos.residual.has_molar_weight().then(|| StateVec::from(self).massfracs().into_pyarray_bound(py))
1346+
self.0[0].eos.residual.has_molar_weight().then(|| StateVec::from(self).massfracs().into_pyarray(py))
13471347
}
13481348

13491349
/// Returns selected properties of a StateVec as dictionary.

feos-core/src/python/user_defined.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ macro_rules! impl_residual {
170170
let py_result = self
171171
.0
172172
.bind(py)
173-
.call_method1("max_density", (moles.to_owned().into_pyarray_bound(py),))
173+
.call_method1("max_density", (moles.to_owned().into_pyarray(py),))
174174
.unwrap();
175175
py_result.extract().unwrap()
176176
})

feos-core/src/state/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub struct StateBuilder<'a, E, const IG: bool> {
7070
initial_temperature: Option<Temperature>,
7171
}
7272

73-
impl<'a, E: Residual> StateBuilder<'a, E, false> {
73+
impl<E: Residual> StateBuilder<'_, E, false> {
7474
/// Create a new `StateBuilder` for the given equation of state.
7575
pub fn new(eos: &Arc<E>) -> Self {
7676
StateBuilder {
@@ -211,7 +211,7 @@ impl<'a, E: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG> {
211211
}
212212
}
213213

214-
impl<'a, E: Residual> StateBuilder<'a, E, false> {
214+
impl<E: Residual> StateBuilder<'_, E, false> {
215215
/// Try to build the state with the given inputs.
216216
pub fn build(self) -> EosResult<State<E>> {
217217
State::new(
@@ -229,7 +229,7 @@ impl<'a, E: Residual> StateBuilder<'a, E, false> {
229229
}
230230
}
231231

232-
impl<'a, E: Residual + IdealGas> StateBuilder<'a, E, true> {
232+
impl<E: Residual + IdealGas> StateBuilder<'_, E, true> {
233233
/// Try to build the state with the given inputs.
234234
pub fn build(self) -> EosResult<State<E>> {
235235
State::new_full(
@@ -251,7 +251,7 @@ impl<'a, E: Residual + IdealGas> StateBuilder<'a, E, true> {
251251
}
252252
}
253253

254-
impl<'a, E, const IG: bool> Clone for StateBuilder<'a, E, IG> {
254+
impl<E, const IG: bool> Clone for StateBuilder<'_, E, IG> {
255255
fn clone(&self) -> Self {
256256
Self {
257257
eos: self.eos.clone(),

0 commit comments

Comments
 (0)