Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feos-core: updated function and method signatures for pyo3 0.18
  • Loading branch information
g-bauer authored and prehner committed Jan 24, 2023
commit 79ed8e253d6e53e7f8b7e8cc948817097a17b45c
8 changes: 4 additions & 4 deletions feos-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ rustdoc-args = [ "--html-in-header", "./docs-header.html" ]
features = [ "rayon" ]

[dependencies]
quantity = "0.5"
num-dual = { version = "0.5", features = ["linalg"] }
quantity = "0.6"
num-dual = { git = "https://github.com/itt-ustutt/num-dual", features = ["linalg"] }
ndarray = { version = "0.15", features = ["serde"] }
num-traits = "0.2"
thiserror = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
indexmap = "1.8"
conv = "0.3"
numpy = { version = "0.16", optional = true }
pyo3 = { version = "0.16", optional = true }
numpy = { version = "0.18", optional = true }
pyo3 = { version = "0.18", optional = true }
rayon = { version = "1.5", optional = true }

[dev-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion feos-core/src/phase_equilibria/phase_diagram_pure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ use super::{PhaseEquilibrium, SolverOptions};
use crate::equation_of_state::EquationOfState;
use crate::errors::EosResult;
use crate::state::{State, StateVec};
#[cfg(feature = "rayon")]
use crate::EosUnit;
#[cfg(feature = "rayon")]
use ndarray::{Array1, ArrayView1, Axis};
use quantity::si::{SIArray1, SINumber, SIUnit};
#[cfg(feature = "rayon")]
use quantity::si::SIUnit;
use quantity::si::{SIArray1, SINumber};
#[cfg(feature = "rayon")]
use rayon::{prelude::*, ThreadPool};
use std::sync::Arc;
Expand Down
1 change: 0 additions & 1 deletion feos-core/src/python/joback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use pyo3::prelude::*;
/// JobackRecord
#[pyclass(name = "JobackRecord")]
#[derive(Clone)]
#[pyo3(text_signature = "(a, b, c, d, e)")]
pub struct PyJobackRecord(pub JobackRecord);

#[pymethods]
Expand Down
37 changes: 21 additions & 16 deletions feos-core/src/python/parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ macro_rules! impl_binary_record {
/// -------
/// BinaryRecord
#[pyclass(name = "BinaryRecord")]
#[pyo3(text_signature = "(id1, id2, model_record)")]
#[derive(Clone)]
pub struct PyBinaryRecord(pub BinaryRecord<Identifier, $model_record>);

Expand Down Expand Up @@ -284,7 +283,6 @@ macro_rules! impl_binary_record {
/// -------
/// BinarySegmentRecord
#[pyclass(name = "BinarySegmentRecord")]
#[pyo3(text_signature = "(id1, id2, model_record)")]
#[derive(Clone)]
pub struct PyBinarySegmentRecord(pub BinaryRecord<String, f64>);

Expand Down Expand Up @@ -474,7 +472,6 @@ macro_rules! impl_segment_record {
/// -------
/// SegmentRecord
#[staticmethod]
#[pyo3(text_signature = "(path)")]
fn from_json(path: &str) -> Result<Vec<Self>, ParameterError> {
Ok(SegmentRecord::from_json(path)?
.into_iter()
Expand Down Expand Up @@ -548,11 +545,14 @@ macro_rules! impl_parameter {
/// search_option : IdentifierOption, optional, defaults to IdentifierOption.Name
/// Identifier that is used to search binary records.
#[staticmethod]
#[pyo3(text_signature = "(pure_records, binary_records, search_option)")]
#[pyo3(
signature = (pure_records, binary_records=None, search_option=IdentifierOption::Name),
text_signature = "(pure_records, binary_records=None, search_option=None)"
)]
fn from_records(
pure_records: Vec<PyPureRecord>,
binary_records: Option<&PyAny>,
search_option: Option<IdentifierOption>,
search_option: IdentifierOption,
) -> PyResult<Self> {
let prs = pure_records.into_iter().map(|pr| pr.0).collect();
if let Some(binary_records) = binary_records {
Expand All @@ -563,7 +563,7 @@ macro_rules! impl_parameter {
Ok(<$parameter>::binary_matrix_from_records(
&prs,
&brs,
search_option.unwrap_or(IdentifierOption::Name),
search_option,
))
} else {
Err(PyErr::new::<PyTypeError, _>(format!(
Expand All @@ -590,7 +590,6 @@ macro_rules! impl_parameter {
/// pure_record : PureRecord
/// The pure component parameters.
#[staticmethod]
#[pyo3(text_signature = "(pure_record)")]
fn new_pure(pure_record: PyPureRecord) -> Self {
Self(Arc::new(<$parameter>::new_pure(pure_record.0)))
}
Expand All @@ -605,7 +604,7 @@ macro_rules! impl_parameter {
/// binary_record : float or BinaryRecord, optional
/// The binary interaction parameter or binary interaction record.
#[staticmethod]
#[pyo3(text_signature = "(pure_records, binary_record)")]
#[pyo3(text_signature = "(pure_records, binary_record=None)")]
fn new_binary(
pure_records: Vec<PyPureRecord>,
binary_record: Option<&PyAny>,
Expand Down Expand Up @@ -640,18 +639,21 @@ macro_rules! impl_parameter {
/// search_option : IdentifierOption, optional, defaults to IdentifierOption.Name
/// Identifier that is used to search substance.
#[staticmethod]
#[pyo3(text_signature = "(substances, pure_path, binary_path, search_option)")]
#[pyo3(
signature = (substances, pure_path, binary_path=None, search_option=IdentifierOption::Name),
text_signature = "(substances, pure_path, binary_path=None, search_option=IdentifierOption.Name)"
)]
fn from_json(
substances: Vec<&str>,
pure_path: String,
binary_path: Option<String>,
search_option: Option<IdentifierOption>,
search_option: IdentifierOption,
) -> Result<Self, ParameterError> {
Ok(Self(Arc::new(<$parameter>::from_json(
substances,
pure_path,
binary_path,
search_option.unwrap_or(IdentifierOption::Name),
search_option,
)?)))
}

Expand All @@ -667,7 +669,10 @@ macro_rules! impl_parameter {
/// search_option : IdentifierOption, optional, defaults to IdentifierOption.Name
/// Identifier that is used to search substance.
#[staticmethod]
#[pyo3(text_signature = "(input, binary_path=None, search_option='Name')")]
Comment thread
prehner marked this conversation as resolved.
#[pyo3(
signature = (input, binary_path=None, search_option=IdentifierOption::Name),
text_signature = "(input, binary_path=None, search_option=IdentifierOption.Name)"
)]
fn from_multiple_json(
input: Vec<(Vec<&str>, &str)>,
binary_path: Option<&str>,
Expand Down Expand Up @@ -739,21 +744,22 @@ macro_rules! impl_parameter_from_segments {
/// Identifier that is used to search substance.
#[staticmethod]
#[pyo3(
text_signature = "(substances, pure_path, segments_path, binary_path, search_option)"
signature = (substances, pure_path, segments_path, binary_path=None, search_option=IdentifierOption::Name),
text_signature = "(substances, pure_path, segments_path, binary_path=None, search_option=IdentifierOption.Name)"
)]
fn from_json_segments(
substances: Vec<&str>,
pure_path: String,
segments_path: String,
binary_path: Option<String>,
search_option: Option<IdentifierOption>,
search_option: IdentifierOption,
) -> Result<Self, ParameterError> {
Ok(Self(Arc::new(<$parameter>::from_json_segments(
&substances,
pure_path,
segments_path,
binary_path,
search_option.unwrap_or(IdentifierOption::Name),
search_option,
)?)))
}
}
Expand All @@ -767,7 +773,6 @@ macro_rules! impl_json_handling {
impl $py_parameter {
/// Creates record from json string.
#[staticmethod]
#[pyo3(text_signature = "(json)")]
fn from_json_str(json: &str) -> Result<Self, ParameterError> {
Ok(Self(serde_json::from_str(json)?))
}
Expand Down
4 changes: 0 additions & 4 deletions feos-core/src/python/phase_equilibria.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ macro_rules! impl_phase_equilibrium {
/// chemical_potential: SIArray1
/// The new chemical potential
///
#[pyo3(text_signature = "(chemical_potential)")]
fn update_chemical_potential(slf: &PyCell<Self>, chemical_potential: &PySIArray1) -> PyResult<()> {
slf.borrow_mut().0.update_chemical_potential(chemical_potential)?;
Ok(())
Expand All @@ -266,7 +265,6 @@ macro_rules! impl_phase_equilibrium {
/// -------
/// list[PhaseEquilibrium]
#[staticmethod]
#[pyo3(text_signature = "(eos, temperature_or_pressure)")]
fn vle_pure_comps(eos: $py_eos, temperature_or_pressure: PySINumber) -> Vec<Option<Self>> {
PhaseEquilibrium::vle_pure_comps(&eos.0, temperature_or_pressure.into())
.into_iter()
Expand All @@ -288,7 +286,6 @@ macro_rules! impl_phase_equilibrium {
/// -------
/// list[SINumber]
#[staticmethod]
#[pyo3(text_signature = "(eos, temperature)")]
fn vapor_pressure(eos: $py_eos, temperature: PySINumber) -> Vec<Option<PySINumber>> {
PhaseEquilibrium::vapor_pressure(&eos.0, temperature.into())
.into_iter()
Expand All @@ -310,7 +307,6 @@ macro_rules! impl_phase_equilibrium {
/// -------
/// list[SINumber]
#[staticmethod]
#[pyo3(text_signature = "(eos, pressure)")]
fn boiling_temperature(eos: $py_eos, pressure: PySINumber) -> Vec<Option<PySINumber>> {
PhaseEquilibrium::boiling_temperature(&eos.0, pressure.into())
.into_iter()
Expand Down
Loading