Skip to content

Commit

Permalink
move more text_signature to #[new]
Browse files Browse the repository at this point in the history
  • Loading branch information
prehner committed Oct 20, 2023
1 parent 9d03c8d commit 50a3a35
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion feos-core/src/python/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ macro_rules! impl_state {
/// When the state cannot be created using the combination of input.
#[pyclass(name = "State")]
#[derive(Clone)]
#[pyo3(text_signature = "(eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, molar_enthalpy=None, molar_entropy=None, molar_internal_energy=None, density_initialization=None, initial_temperature=None)")]
pub struct PyState(pub State<$eos>);

#[pymethods]
impl PyState {
#[new]
#[pyo3(text_signature = "(eos, temperature=None, volume=None, density=None, partial_density=None, total_moles=None, moles=None, molefracs=None, pressure=None, molar_enthalpy=None, molar_entropy=None, molar_internal_energy=None, density_initialization=None, initial_temperature=None)")]
pub fn new(
eos: $py_eos,
temperature: Option<PySINumber>,
Expand Down
1 change: 0 additions & 1 deletion feos-dft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(clippy::suspicious_operation_groupings)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::new_ret_no_self)]
#![allow(deprecated)]

pub mod adsorption;
mod convolver;
Expand Down
6 changes: 3 additions & 3 deletions feos-dft/src/python/adsorption/pore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ macro_rules! impl_pore {
/// Pore1D
///
#[pyclass(name = "Pore1D")]
#[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")]
pub struct PyPore1D(Pore1D);

#[pyclass(name = "PoreProfile1D")]
Expand All @@ -33,6 +32,7 @@ macro_rules! impl_pore {
#[pymethods]
impl PyPore1D {
#[new]
#[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")]
fn new(
geometry: Geometry,
pore_size: PySINumber,
Expand Down Expand Up @@ -135,7 +135,6 @@ macro_rules! impl_pore {
}

#[pyclass(name = "Pore2D")]
#[pyo3(text_signature = "(geometry, pore_size, potential, n_grid=None, potential_cutoff=None)")]
pub struct PyPore2D(Pore2D);

#[pyclass(name = "PoreProfile2D")]
Expand All @@ -146,6 +145,7 @@ macro_rules! impl_pore {
#[pymethods]
impl PyPore2D {
#[new]
#[pyo3(text_signature = "(system_size, angle, n_grid)")]
fn new(
system_size: [PySINumber; 2],
angle: PyAngle,
Expand Down Expand Up @@ -245,7 +245,6 @@ macro_rules! impl_pore {
/// Pore3D
///
#[pyclass(name = "Pore3D")]
#[pyo3(text_signature = "(system_size, angles, n_grid, coordinates, sigma_ss, epsilon_k_ss, potential_cutoff=None, cutoff_radius=None)")]
pub struct PyPore3D(Pore3D);

#[pyclass(name = "PoreProfile3D")]
Expand All @@ -256,6 +255,7 @@ macro_rules! impl_pore {
#[pymethods]
impl PyPore3D {
#[new]
#[pyo3(text_signature = "(system_size, n_grid, coordinates, sigma_ss, epsilon_k_ss, angles=None, potential_cutoff=None, cutoff_radius=None)")]
fn new(
system_size: [PySINumber; 3],
n_grid: [usize; 3],
Expand Down
2 changes: 1 addition & 1 deletion feos-dft/src/python/interface/surface_tension_diagram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ macro_rules! impl_surface_tension_diagram {
/// SurfaceTensionDiagram
///
#[pyclass(name = "SurfaceTensionDiagram")]
#[pyo3(text_signature = "(dia, init_densities=None, n_grid=None, l_grid=None, critical_temperature=None, fix_equimolar_surface=None, solver=None)")]
pub struct PySurfaceTensionDiagram(SurfaceTensionDiagram<$func>);

#[pymethods]
impl PySurfaceTensionDiagram {
#[new]
#[pyo3(text_signature = "(dia, init_densities=None, n_grid=None, l_grid=None, critical_temperature=None, fix_equimolar_surface=None, solver=None)")]
pub fn isotherm(
dia: Vec<PyPhaseEquilibrium>,
init_densities: Option<bool>,
Expand Down
2 changes: 1 addition & 1 deletion feos-dft/src/python/solvation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ macro_rules! impl_solvation_profile {
/// SolvationProfile
///
#[pyclass(name = "SolvationProfile")]
#[pyo3(text_signature = "(bulk, n_grid, coordinates, sigma, epsilon_k, system_size=None, cutoff_radius=None, potential_cutoff=None)")]
pub struct PySolvationProfile(SolvationProfile<$func>);

impl_3d_profile!(PySolvationProfile, get_x, get_y, get_z);

#[pymethods]
impl PySolvationProfile {
#[new]
#[pyo3(text_signature = "(bulk, n_grid, coordinates, sigma, epsilon_k, system_size=None, cutoff_radius=None, potential_cutoff=None)")]
fn new(
bulk: &PyState,
n_grid: [usize; 3],
Expand Down
2 changes: 1 addition & 1 deletion feos-dft/src/python/solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ use quantity::python::PySIArray1;
/// DFTSolver
#[pyclass(name = "DFTSolver")]
#[derive(Clone)]
#[pyo3(text_signature = "(verbosity=None)")]
pub struct PyDFTSolver(pub DFTSolver);

#[pymethods]
impl PyDFTSolver {
#[new]
#[pyo3(text_signature = "(verbosity=None)")]
fn new(verbosity: Option<Verbosity>) -> Self {
Self(DFTSolver::new(verbosity))
}
Expand Down
2 changes: 1 addition & 1 deletion src/estimator/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,12 +485,12 @@ macro_rules! impl_estimator {
/// -------
/// Estimator
#[pyclass(name = "Estimator")]
#[pyo3(text_signature = "(data, weights, losses)")]
pub struct PyEstimator(Estimator<$eos>);

#[pymethods]
impl PyEstimator {
#[new]
#[pyo3(text_signature = "(data, weights, losses)")]
fn new(data: Vec<PyDataSet>, weights: Vec<f64>, losses: Vec<PyLoss>) -> Self {
Self(Estimator::new(
data.iter().map(|d| d.0.clone()).collect(),
Expand Down
6 changes: 4 additions & 2 deletions src/gc_pcsaft/python/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ use std::sync::Arc;
mod micelles;

#[pyclass(name = "GcPcSaftRecord")]
#[pyo3(text_signature = "(m, sigma, epsilon_k, mu=None, association_record=None, psi_dft=None)")]
#[derive(Clone)]
pub struct PyGcPcSaftRecord(GcPcSaftRecord);

#[pymethods]
impl PyGcPcSaftRecord {
#[pyo3(signature = (m, sigma, epsilon_k, mu=None, association_record=None, psi_dft=None))]
#[new]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, mu=None, association_record=None, psi_dft=None)",
signature = (m, sigma, epsilon_k, mu=None, association_record=None, psi_dft=None)
)]
fn new(
m: f64,
sigma: f64,
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#![warn(clippy::all)]
#![allow(clippy::too_many_arguments)]
#![allow(deprecated)]

#[cfg(feature = "dft")]
mod dft;
Expand Down
6 changes: 3 additions & 3 deletions src/pcsaft/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ use std::sync::Arc;
/// thermal_conductivity : List[float], optional
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
#[pyclass(name = "PcSaftRecord")]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, mu=None, q=None, kappa_ab=None, epsilon_k_ab=None, na=None, nb=None, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
#[derive(Clone)]
pub struct PyPcSaftRecord(PcSaftRecord);

#[pymethods]
impl PyPcSaftRecord {
#[new]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, mu=None, q=None, kappa_ab=None, epsilon_k_ab=None, na=None, nb=None, nc=None, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
fn new(
m: f64,
sigma: f64,
Expand Down
6 changes: 3 additions & 3 deletions src/pets/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use std::sync::Arc;

/// Create a set of PeTS parameters from records.
#[pyclass(name = "PetsRecord")]
#[pyo3(
text_signature = "(sigma, epsilon_k, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
#[derive(Clone)]
pub struct PyPetsRecord(PetsRecord);

#[pymethods]
impl PyPetsRecord {
#[new]
#[pyo3(
text_signature = "(sigma, epsilon_k, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
fn new(
sigma: f64,
epsilon_k: f64,
Expand Down
8 changes: 4 additions & 4 deletions src/saftvrqmie/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ use std::sync::Arc;
/// thermal_conductivity : List[float], optional
/// Entropy-scaling parameters for thermal_conductivity. Defaults to `None`.
#[pyclass(name = "SaftVRQMieRecord")]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, lr, la, fh, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
#[derive(Clone)]
pub struct PySaftVRQMieRecord(SaftVRQMieRecord);

#[pymethods]
impl PySaftVRQMieRecord {
#[new]
#[pyo3(
text_signature = "(m, sigma, epsilon_k, lr, la, fh, viscosity=None, diffusion=None, thermal_conductivity=None)"
)]
fn new(
m: f64,
sigma: f64,
Expand Down Expand Up @@ -122,13 +122,13 @@ impl PySaftVRQMieRecord {

/// Create a binary record from k_ij and l_ij values.
#[pyclass(name = "SaftVRQMieBinaryRecord")]
#[pyo3(text_signature = "(k_ij, l_ij)")]
#[derive(Clone)]
pub struct PySaftVRQMieBinaryRecord(SaftVRQMieBinaryRecord);

#[pymethods]
impl PySaftVRQMieBinaryRecord {
#[new]
#[pyo3(text_signature = "(k_ij, l_ij)")]
fn new(k_ij: f64, l_ij: f64) -> Self {
Self(SaftVRQMieBinaryRecord { k_ij, l_ij })
}
Expand Down
2 changes: 1 addition & 1 deletion src/uvtheory/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ struct PyNoRecord(NoRecord);

/// Create a set of UV Theory parameters from records.
#[pyclass(name = "UVRecord")]
#[pyo3(text_signature = "(rep, att, sigma, epsilon_k)")]
#[derive(Clone)]
pub struct PyUVRecord(UVRecord);

#[pymethods]
impl PyUVRecord {
#[new]
#[pyo3(text_signature = "(rep, att, sigma, epsilon_k)")]
fn new(rep: f64, att: f64, sigma: f64, epsilon_k: f64) -> Self {
Self(UVRecord::new(rep, att, sigma, epsilon_k))
}
Expand Down

0 comments on commit 50a3a35

Please sign in to comment.