diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 99788f4d4..c05c518dd 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -15,7 +15,7 @@ jobs: - name: Setup python uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Install pandoc run: sudo apt-get install -y pandoc - name: Install python dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87f458f5f..273f12fc3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Build Wheels uses: PyO3/maturin-action@v1 with: @@ -25,12 +25,12 @@ jobs: path: dist macos-x86_64: - runs-on: macos-12 + runs-on: macos-14 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: x64 - name: Build wheels - x86_64 uses: PyO3/maturin-action@v1 @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: arm64 - name: Build wheels - aarch64 uses: PyO3/maturin-action@v1 @@ -69,7 +69,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: ${{ matrix.target }} - name: Build wheels uses: PyO3/maturin-action@v1 @@ -94,7 +94,7 @@ jobs: merge-multiple: true - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Publish to PyPi env: TWINE_USERNAME: __token__ diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 4b35fb355..f31a28132 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 - name: Build Wheels uses: PyO3/maturin-action@v1 with: @@ -24,12 +24,12 @@ jobs: name: wheel-linux-x86_64 path: dist macos-x86_64: - runs-on: macos-12 + runs-on: macos-14 steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: x64 - name: Build wheels - x86_64 uses: PyO3/maturin-action@v1 @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: arm64 - name: Build wheels - aarch64 uses: PyO3/maturin-action@v1 @@ -65,7 +65,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: 3.9 + python-version: 3.11 architecture: x64 - name: Build wheels uses: PyO3/maturin-action@v1 diff --git a/Cargo.toml b/Cargo.toml index 69723af1c..afba6891d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,15 +30,15 @@ members = ["feos-core", "feos-dft", "feos-derive"] crate-type = ["rlib", "cdylib"] [dependencies] -quantity = "0.9" -num-dual = "0.10" +quantity = "0.10" +num-dual = "0.11" feos-core = { version = "0.7", path = "feos-core" } feos-dft = { version = "0.7", path = "feos-dft", optional = true } feos-derive = { version = "0.5", path = "feos-derive" } -numpy = { version = "0.22", optional = true } +numpy = { version = "0.23", optional = true } ndarray = { version = "0.16", features = ["approx"] } petgraph = { version = "0.6", optional = true } -thiserror = "1.0" +thiserror = "2.0" conv = "0.3" num-traits = "0.2" serde = "1.0" @@ -50,8 +50,8 @@ itertools = "0.13" typenum = "1.16" [dependencies.pyo3] -version = "0.22" -features = ["extension-module", "abi3", "abi3-py37"] +version = "0.23" +features = ["extension-module", "abi3", "abi3-py39"] optional = true [dev-dependencies] diff --git a/feos-core/Cargo.toml b/feos-core/Cargo.toml index 709cbc3cf..381aaf969 100644 --- a/feos-core/Cargo.toml +++ b/feos-core/Cargo.toml @@ -26,18 +26,18 @@ rustdoc-args = ["--html-in-header", "./docs-header.html"] features = ["rayon"] [dependencies] -quantity = { version = "0.9", features = ["approx", "ndarray"] } -num-dual = { version = "0.10", features = ["linalg"] } +quantity = { version = "0.10", features = ["approx", "ndarray"] } +num-dual = { version = "0.11", features = ["linalg"] } ndarray = { version = "0.16", features = ["serde", "approx"] } nalgebra = "0.33" num-traits = "0.2" -thiserror = "1.0" +thiserror = "2.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" indexmap = "2.0" conv = "0.3" -numpy = { version = "0.22", optional = true } -pyo3 = { version = "0.22", features = ["multiple-pymethods"], optional = true } +numpy = { version = "0.23", optional = true } +pyo3 = { version = "0.23", features = ["multiple-pymethods"], optional = true } rayon = { version = "1.5", optional = true } typenum = "1.16" approx = "0.5" diff --git a/feos-core/src/python/parameter/fragmentation.rs b/feos-core/src/python/parameter/fragmentation.rs index 90346551b..bdda2fd00 100644 --- a/feos-core/src/python/parameter/fragmentation.rs +++ b/feos-core/src/python/parameter/fragmentation.rs @@ -113,7 +113,7 @@ fn fragment_molecule( smiles: &str, smarts: Vec, ) -> PyResult<(Vec, Vec<[usize; 2]>)> { - let chem = py.import_bound("rdkit.Chem")?; + let chem = py.import("rdkit.Chem")?; let mol = chem.call_method1("MolFromSmiles", (smiles,))?; let atoms = mol.call_method0("GetNumHeavyAtoms")?.extract::()?; @@ -155,7 +155,7 @@ fn fragment_molecule( .for_each(|(_, m)| m.retain(|m| !(m.len() == 1 && large_segments.contains(&m[0])))); let bonds = mol.call_method0("GetBonds")?; - let builtins = py.import_bound("builtins")?; + let builtins = py.import("builtins")?; let bonds = builtins .call_method1("list", (bonds,))? .extract::>>()?; diff --git a/feos-core/src/python/parameter/mod.rs b/feos-core/src/python/parameter/mod.rs index b02d8e15f..fbe4f2960 100644 --- a/feos-core/src/python/parameter/mod.rs +++ b/feos-core/src/python/parameter/mod.rs @@ -272,7 +272,7 @@ macro_rules! impl_binary_record { #[expect(irrefutable_let_patterns)] fn get_model_record<'py>(&self, py: Python<'py>) -> PyResult> { Ok(if let Ok(mr) = f64::try_from(self.0.model_record.clone()) { - pyo3::types::PyFloat::new_bound(py, mr).into_any() + pyo3::types::PyFloat::new(py, mr).into_any() } else { Bound::new(py, $py_model_record(self.0.model_record.clone()))?.into_any() }) @@ -744,7 +744,7 @@ macro_rules! impl_parameter { self.0 .records() .1 - .map(|r| r.mapv(|r| f64::try_from(r).unwrap()).view().to_pyarray_bound(py)) + .map(|r| r.mapv(|r| f64::try_from(r).unwrap()).view().to_pyarray(py)) } } }; diff --git a/feos-core/src/python/state.rs b/feos-core/src/python/state.rs index 35181df19..9bb688fd5 100644 --- a/feos-core/src/python/state.rs +++ b/feos-core/src/python/state.rs @@ -558,7 +558,7 @@ macro_rules! impl_state { /// ------- /// numpy.ndarray fn ln_phi<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - self.0.ln_phi().into_pyarray_bound(py) + self.0.ln_phi().into_pyarray(py) } /// Return logarithmic fugacity coefficient of all components treated as @@ -568,7 +568,7 @@ macro_rules! impl_state { /// ------- /// numpy.ndarray fn ln_phi_pure_liquid<'py>(&self, py: Python<'py>) -> PyResult>> { - Ok(self.0.ln_phi_pure_liquid()?.into_pyarray_bound(py)) + Ok(self.0.ln_phi_pure_liquid()?.into_pyarray(py)) } /// Return logarithmic symmetric activity coefficient. @@ -577,7 +577,7 @@ macro_rules! impl_state { /// ------- /// numpy.ndarray fn ln_symmetric_activity_coefficient<'py>(&self, py: Python<'py>) -> PyResult>> { - Ok(self.0.ln_symmetric_activity_coefficient()?.into_pyarray_bound(py)) + Ok(self.0.ln_symmetric_activity_coefficient()?.into_pyarray(py)) } /// 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 { /// ------- /// numpy.ndarray fn thermodynamic_factor<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2> { - self.0.thermodynamic_factor().into_pyarray_bound(py) + self.0.thermodynamic_factor().into_pyarray(py) } /// Return molar isochoric heat capacity. @@ -1021,7 +1021,7 @@ macro_rules! impl_state { /// ------- /// numpy.ndarray[Float64] fn massfracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - self.0.massfracs().into_pyarray_bound(py) + self.0.massfracs().into_pyarray(py) } /// Return mass specific Helmholtz energy. @@ -1168,7 +1168,7 @@ macro_rules! impl_state { #[getter] fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - self.0.molefracs.to_pyarray_bound(py) + self.0.molefracs.to_pyarray(py) } fn _repr_markdown_(&self) -> String { @@ -1318,7 +1318,7 @@ macro_rules! impl_state { #[getter] fn get_compressibility<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - StateVec::from(self).compressibility().into_pyarray_bound(py) + StateVec::from(self).compressibility().into_pyarray(py) } #[getter] @@ -1333,7 +1333,7 @@ macro_rules! impl_state { #[getter] fn get_molefracs<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2> { - StateVec::from(self).molefracs().into_pyarray_bound(py) + StateVec::from(self).molefracs().into_pyarray(py) } #[getter] @@ -1343,7 +1343,7 @@ macro_rules! impl_state { #[getter] fn get_massfracs<'py>(&self, py: Python<'py>) -> Option>> { - self.0[0].eos.residual.has_molar_weight().then(|| StateVec::from(self).massfracs().into_pyarray_bound(py)) + self.0[0].eos.residual.has_molar_weight().then(|| StateVec::from(self).massfracs().into_pyarray(py)) } /// Returns selected properties of a StateVec as dictionary. diff --git a/feos-core/src/python/user_defined.rs b/feos-core/src/python/user_defined.rs index 414f41fa3..9eba67cb3 100644 --- a/feos-core/src/python/user_defined.rs +++ b/feos-core/src/python/user_defined.rs @@ -170,7 +170,7 @@ macro_rules! impl_residual { let py_result = self .0 .bind(py) - .call_method1("max_density", (moles.to_owned().into_pyarray_bound(py),)) + .call_method1("max_density", (moles.to_owned().into_pyarray(py),)) .unwrap(); py_result.extract().unwrap() }) diff --git a/feos-core/src/state/builder.rs b/feos-core/src/state/builder.rs index c557bc297..5b56e4152 100644 --- a/feos-core/src/state/builder.rs +++ b/feos-core/src/state/builder.rs @@ -70,7 +70,7 @@ pub struct StateBuilder<'a, E, const IG: bool> { initial_temperature: Option, } -impl<'a, E: Residual> StateBuilder<'a, E, false> { +impl StateBuilder<'_, E, false> { /// Create a new `StateBuilder` for the given equation of state. pub fn new(eos: &Arc) -> Self { StateBuilder { @@ -211,7 +211,7 @@ impl<'a, E: Residual + IdealGas, const IG: bool> StateBuilder<'a, E, IG> { } } -impl<'a, E: Residual> StateBuilder<'a, E, false> { +impl StateBuilder<'_, E, false> { /// Try to build the state with the given inputs. pub fn build(self) -> EosResult> { State::new( @@ -229,7 +229,7 @@ impl<'a, E: Residual> StateBuilder<'a, E, false> { } } -impl<'a, E: Residual + IdealGas> StateBuilder<'a, E, true> { +impl StateBuilder<'_, E, true> { /// Try to build the state with the given inputs. pub fn build(self) -> EosResult> { State::new_full( @@ -251,7 +251,7 @@ impl<'a, E: Residual + IdealGas> StateBuilder<'a, E, true> { } } -impl<'a, E, const IG: bool> Clone for StateBuilder<'a, E, IG> { +impl Clone for StateBuilder<'_, E, IG> { fn clone(&self) -> Self { Self { eos: self.eos.clone(), diff --git a/feos-core/src/state/statevec.rs b/feos-core/src/state/statevec.rs index d8bb00961..45f9b7a39 100644 --- a/feos-core/src/state/statevec.rs +++ b/feos-core/src/state/statevec.rs @@ -35,7 +35,7 @@ impl<'a, E> Deref for StateVec<'a, E> { } } -impl<'a, E: Residual> StateVec<'a, E> { +impl StateVec<'_, E> { pub fn temperature(&self) -> Temperature> { Temperature::from_shape_fn(self.0.len(), |i| self.0[i].temperature) } @@ -67,7 +67,7 @@ impl<'a, E: Residual> StateVec<'a, E> { } } -impl<'a, E: Residual + Molarweight> StateVec<'a, E> { +impl StateVec<'_, E> { pub fn mass_density(&self) -> MassDensity> { MassDensity::from_shape_fn(self.0.len(), |i| self.0[i].mass_density()) } @@ -79,7 +79,7 @@ impl<'a, E: Residual + Molarweight> StateVec<'a, E> { } } -impl<'a, E: Residual + IdealGas> StateVec<'a, E> { +impl StateVec<'_, E> { pub fn molar_enthalpy(&self, contributions: Contributions) -> MolarEnergy> { MolarEnergy::from_shape_fn(self.0.len(), |i| self.0[i].molar_enthalpy(contributions)) } @@ -89,7 +89,7 @@ impl<'a, E: Residual + IdealGas> StateVec<'a, E> { } } -impl<'a, E: Residual + Molarweight + IdealGas> StateVec<'a, E> { +impl StateVec<'_, E> { pub fn specific_enthalpy(&self, contributions: Contributions) -> SpecificEnergy> { SpecificEnergy::from_shape_fn(self.0.len(), |i| self.0[i].specific_enthalpy(contributions)) } diff --git a/feos-dft/Cargo.toml b/feos-dft/Cargo.toml index 618574a54..35259c558 100644 --- a/feos-dft/Cargo.toml +++ b/feos-dft/Cargo.toml @@ -20,8 +20,8 @@ rustdoc-args = ["--html-in-header", "./docs-header.html"] features = ["rayon"] [dependencies] -quantity = "0.9" -num-dual = "0.10" +quantity = "0.10" +num-dual = "0.11" feos-core = { version = "0.7", path = "../feos-core" } ndarray = "0.16" nalgebra = "0.33" @@ -32,8 +32,8 @@ libm = "0.2" gauss-quad = { version = "0.2", optional = true } petgraph = "0.6" typenum = "1.16" -numpy = { version = "0.22", optional = true } -pyo3 = { version = "0.22", optional = true } +numpy = { version = "0.23", optional = true } +pyo3 = { version = "0.23", optional = true } [features] default = [] diff --git a/feos-dft/src/python/interface/mod.rs b/feos-dft/src/python/interface/mod.rs index 0519afda8..f866bf729 100644 --- a/feos-dft/src/python/interface/mod.rs +++ b/feos-dft/src/python/interface/mod.rs @@ -143,7 +143,7 @@ macro_rules! impl_planar_interface { /// numpy.ndarray /// fn interfacial_enrichment<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - self.0.interfacial_enrichment().to_pyarray_bound(py) + self.0.interfacial_enrichment().to_pyarray(py) } /// Calculates the interfacial thickness (90-10 number density difference) diff --git a/feos-dft/src/python/interface/surface_tension_diagram.rs b/feos-dft/src/python/interface/surface_tension_diagram.rs index 8ed743a2c..3b292fa8a 100644 --- a/feos-dft/src/python/interface/surface_tension_diagram.rs +++ b/feos-dft/src/python/interface/surface_tension_diagram.rs @@ -90,7 +90,7 @@ macro_rules! impl_surface_tension_diagram { #[getter] pub fn get_interfacial_enrichment<'py>(&self, py: Python<'py>) -> Vec>> { - self.0.interfacial_enrichment().iter().map(|i| i.to_pyarray_bound(py)).collect() + self.0.interfacial_enrichment().iter().map(|i| i.to_pyarray(py)).collect() } #[getter] diff --git a/feos-dft/src/python/profile.rs b/feos-dft/src/python/profile.rs index 15e55d1cd..884ed1b73 100644 --- a/feos-dft/src/python/profile.rs +++ b/feos-dft/src/python/profile.rs @@ -21,7 +21,7 @@ macro_rules! impl_profile { py: Python<'py>, ) -> PyResult<(Bound<'py, $arr2>, Bound<'py, PyArray1>, f64)> { let (res_rho, res_mu, res_norm) = self.0.profile.residual(log)?; - Ok((res_rho.view().to_pyarray_bound(py), res_mu.view().to_pyarray_bound(py), res_norm)) + Ok((res_rho.view().to_pyarray(py), res_mu.view().to_pyarray(py), res_norm)) } /// Solve the profile in-place. A non-default solver can be provided @@ -74,7 +74,7 @@ macro_rules! impl_profile { #[getter] fn get_external_potential<'py>(&self, py: Python<'py>) -> Bound<'py, $py_arr2> { - self.0.profile.external_potential.view().to_pyarray_bound(py) + self.0.profile.external_potential.view().to_pyarray(py) } #[getter] @@ -93,7 +93,7 @@ macro_rules! impl_profile { py: Python<'py>, ) -> PyResult>>> { let n = self.0.profile.weighted_densities()?; - Ok(n.into_iter().map(|n| n.view().to_pyarray_bound(py)).collect()) + Ok(n.into_iter().map(|n| n.view().to_pyarray(py)).collect()) } #[getter] @@ -101,7 +101,7 @@ macro_rules! impl_profile { &self, py: Python<'py>, ) -> PyResult>> { - Ok(self.0.profile.functional_derivative()?.view().to_pyarray_bound(py)) + Ok(self.0.profile.functional_derivative()?.view().to_pyarray(py)) } /// Calculate the entropy density of the inhomogeneous system. diff --git a/feos-dft/src/python/solvation.rs b/feos-dft/src/python/solvation.rs index bea784771..17aa95051 100644 --- a/feos-dft/src/python/solvation.rs +++ b/feos-dft/src/python/solvation.rs @@ -112,7 +112,7 @@ macro_rules! impl_pair_correlation { self.0 .pair_correlation_function .as_ref() - .map(|g| g.view().to_pyarray_bound(py)) + .map(|g| g.view().to_pyarray(py)) } #[getter] diff --git a/feos-dft/src/python/solver.rs b/feos-dft/src/python/solver.rs index ab5f3c1e0..0b51d06fe 100644 --- a/feos-dft/src/python/solver.rs +++ b/feos-dft/src/python/solver.rs @@ -168,7 +168,7 @@ pub struct PyDFTSolverLog(pub DFTSolverLog); impl PyDFTSolverLog { #[getter] fn get_residual<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray1> { - self.0.residual().to_pyarray_bound(py) + self.0.residual().to_pyarray(py) } #[getter] diff --git a/feos-dft/src/weight_functions.rs b/feos-dft/src/weight_functions.rs index 4f4c0665e..37e06a93f 100644 --- a/feos-dft/src/weight_functions.rs +++ b/feos-dft/src/weight_functions.rs @@ -164,10 +164,7 @@ pub enum WeightFunctionShape { DeltaVec, } -/// Defining `type` for information about weight functions based on -/// `WeightFunctionBase`. -// pub type WeightFunctionInfo = WeightFunctionBase, WeightFunction>; - +/// Information about weight functions pub struct WeightFunctionInfo { /// Index of the component that each individual segment belongs to. pub(crate) component_index: Array1, diff --git a/src/estimator/python.rs b/src/estimator/python.rs index 3031f1c24..e2d612454 100644 --- a/src/estimator/python.rs +++ b/src/estimator/python.rs @@ -149,7 +149,7 @@ macro_rules! impl_estimator { loss: PyLoss, py: Python<'py>, ) -> PyResult>> { - Ok(self.0.cost(&eos.0, loss.0)?.view().to_pyarray_bound(py)) + Ok(self.0.cost(&eos.0, loss.0)?.view().to_pyarray(py)) } /// Return the property of interest for each data point @@ -165,7 +165,7 @@ macro_rules! impl_estimator { /// SIArray1 #[pyo3(text_signature = "($self, eos)")] fn predict<'py>(&self, eos: &$py_eos, py: Python<'py>) -> PyResult>> { - Ok(self.0.predict(&eos.0)?.view().to_pyarray_bound(py)) + Ok(self.0.predict(&eos.0)?.view().to_pyarray(py)) } /// Return the relative difference between experimental data @@ -189,7 +189,7 @@ macro_rules! impl_estimator { eos: &$py_eos, py: Python<'py>, ) -> PyResult>> { - Ok(self.0.relative_difference(&eos.0)?.view().to_pyarray_bound(py)) + Ok(self.0.relative_difference(&eos.0)?.view().to_pyarray(py)) } /// Return the mean absolute relative difference. @@ -458,7 +458,7 @@ macro_rules! impl_estimator { /// Return `target` as ``SIArray1``. #[getter] fn get_target<'py>(&self, py: Python<'py>,) -> Bound<'py, PyArray1> { - self.0.target().view().to_pyarray_bound(py) + self.0.target().view().to_pyarray(py) } /// Return number of stored data points. @@ -526,7 +526,7 @@ macro_rules! impl_estimator { /// - and the relative weights as defined in the Estimator object. #[pyo3(text_signature = "($self, eos)")] fn cost<'py>(&self, eos: &$py_eos, py: Python<'py>) -> PyResult>> { - Ok(self.0.cost(&eos.0)?.view().to_pyarray_bound(py)) + Ok(self.0.cost(&eos.0)?.view().to_pyarray(py)) } /// Return the properties as computed by the @@ -546,7 +546,7 @@ macro_rules! impl_estimator { .0 .predict(&eos.0)? .iter() - .map(|d| d.view().to_pyarray_bound(py)) + .map(|d| d.view().to_pyarray(py)) .collect()) } @@ -575,7 +575,7 @@ macro_rules! impl_estimator { .0 .relative_difference(&eos.0)? .iter() - .map(|d| d.view().to_pyarray_bound(py)) + .map(|d| d.view().to_pyarray(py)) .collect()) } @@ -603,7 +603,7 @@ macro_rules! impl_estimator { .0 .mean_absolute_relative_difference(&eos.0)? .view() - .to_pyarray_bound(py)) + .to_pyarray(py)) } /// Return the stored ``DataSet``s. diff --git a/src/gc_pcsaft/python/mod.rs b/src/gc_pcsaft/python/mod.rs index c56339311..8a7fd9ac2 100644 --- a/src/gc_pcsaft/python/mod.rs +++ b/src/gc_pcsaft/python/mod.rs @@ -147,13 +147,13 @@ impl PyGcPcSaftFunctionalParameters { #[getter] fn get_graph(&self, py: Python) -> PyResult { - let fun: Py = PyModule::from_code_bound( + let fun: Py = PyModule::from_code( py, - "def f(s): + c"def f(s): import graphviz return graphviz.Source(s.replace('\\\\\"', ''))", - "", - "", + c"", + c"", )? .getattr("f")? .into(); @@ -162,7 +162,7 @@ impl PyGcPcSaftFunctionalParameters { #[getter] fn get_k_ij<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2> { - self.0.k_ij.view().to_pyarray_bound(py) + self.0.k_ij.view().to_pyarray(py) } fn __repr__(&self) -> PyResult { diff --git a/src/pcsaft/python.rs b/src/pcsaft/python.rs index a9eee6ff7..482cf4490 100644 --- a/src/pcsaft/python.rs +++ b/src/pcsaft/python.rs @@ -203,7 +203,7 @@ impl PyPcSaftParameters { self.0 .binary_records .as_ref() - .map(|br| br.map(|br| br.k_ij).view().to_pyarray_bound(py)) + .map(|br| br.map(|br| br.k_ij).view().to_pyarray(py)) } fn _repr_markdown_(&self) -> String { diff --git a/src/pets/python.rs b/src/pets/python.rs index 5819b50f3..75a32dfbd 100644 --- a/src/pets/python.rs +++ b/src/pets/python.rs @@ -223,7 +223,7 @@ impl PyPetsParameters { #[getter] fn get_k_ij<'py>(&self, py: Python<'py>) -> Option>> { - self.0.k_ij.as_ref().map(|k| k.view().to_pyarray_bound(py)) + self.0.k_ij.as_ref().map(|k| k.view().to_pyarray(py)) } fn _repr_markdown_(&self) -> String { diff --git a/src/python/mod.rs b/src/python/mod.rs index 9ed8a844d..e5f260312 100644 --- a/src/python/mod.rs +++ b/src/python/mod.rs @@ -15,6 +15,7 @@ use crate::uvtheory::python::uvtheory as uvtheory_module; use pyo3::prelude::*; use pyo3::wrap_pymodule; +use std::ffi::CString; mod cubic; mod dippr; @@ -83,8 +84,8 @@ pub fn feos(m: &Bound<'_, PyModule>) -> PyResult<()> { set_path(m, "feos.saftvrmie", "saftvrmie")?; // re-export si_units within feos. Overriding __module__ is required for pickling. - m.py().run_bound( - "\ + m.py().run( + c"\ import sys import si_units sys.modules['feos.si'] = si_units @@ -98,13 +99,14 @@ si_units.Angle.__module__ = 'feos.si' } fn set_path(m: &Bound<'_, PyModule>, path: &str, module: &str) -> PyResult<()> { - m.py().run_bound( - &format!( + m.py().run( + &CString::new(format!( "\ import sys sys.modules['{path}'] = {module} " - ), + )) + .unwrap(), None, Some(&m.dict()), ) diff --git a/src/saftvrmie/python.rs b/src/saftvrmie/python.rs index 69740f9af..91b770c95 100644 --- a/src/saftvrmie/python.rs +++ b/src/saftvrmie/python.rs @@ -255,7 +255,7 @@ impl PySaftVRMieParameters { self.0 .binary_records .as_ref() - .map(|br| br.map(|br| br.k_ij).view().to_pyarray_bound(py)) + .map(|br| br.map(|br| br.k_ij).view().to_pyarray(py)) } fn _repr_markdown_(&self) -> String { diff --git a/src/saftvrqmie/python.rs b/src/saftvrqmie/python.rs index e8196bb14..470fa6198 100644 --- a/src/saftvrqmie/python.rs +++ b/src/saftvrqmie/python.rs @@ -176,12 +176,12 @@ impl_parameter!( impl PySaftVRQMieParameters { #[getter] fn get_k_ij<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2> { - self.0.k_ij.view().to_pyarray_bound(py) + self.0.k_ij.view().to_pyarray(py) } #[getter] fn get_l_ij<'py>(&self, py: Python<'py>) -> Bound<'py, PyArray2> { - self.0.l_ij.view().to_pyarray_bound(py) + self.0.l_ij.view().to_pyarray(py) } /// Calculate effective sigma. @@ -278,7 +278,7 @@ impl PySaftVRQMieParameters { .into_value() }) .view() - .to_pyarray_bound(py)) + .to_pyarray(py)) } /// Generate energy and force tables to be used with LAMMPS' `pair_style table` command. diff --git a/src/uvtheory/eos/wca/hard_sphere.rs b/src/uvtheory/eos/wca/hard_sphere.rs index 90cd9aa04..a6c6fc6b4 100644 --- a/src/uvtheory/eos/wca/hard_sphere.rs +++ b/src/uvtheory/eos/wca/hard_sphere.rs @@ -179,7 +179,6 @@ pub(super) fn dimensionless_length_scale + Copy>( } #[inline] - pub(super) fn packing_fraction_b + Copy>( parameters: &UVTheoryParameters, eta: D,