From 75a772db76200d41725b8529b7c189df6f322b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Robert?= Date: Fri, 29 Nov 2024 14:07:27 +0100 Subject: [PATCH] Bump pyo3 and numpy versions to 0.22 --- Cargo.toml | 4 ++-- src/geometry.rs | 1 + src/lib.rs | 6 +++++- src/mesh.rs | 10 ++++++++++ src/parallel.rs | 1 + src/remesher.rs | 4 ++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5d5410b..f4738f4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["cdylib"] [dependencies] log = "0.4.22" tucanos = { git = "https://github.com/tucanos/tucanos.git", rev = "252380e" } -numpy = "0.21" -pyo3 = { version = "0.21", features = ["extension-module", "multiple-pymethods"] } +numpy = "0.22" +pyo3 = { version = "0.22", features = ["extension-module", "multiple-pymethods"] } pyo3-log = "0.11" [features] diff --git a/src/geometry.rs b/src/geometry.rs index de1e786..49a2348 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -21,6 +21,7 @@ macro_rules! create_geometry { /// Create a new geometry #[new] #[must_use] + #[pyo3(signature = (mesh, geom=None))] pub fn new( mesh: &$mesh, geom: Option<&$geom>, diff --git a/src/lib.rs b/src/lib.rs index 9365704..47c3503 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,11 @@ mod mesh; mod parallel; mod remesher; use numpy::{PyArray, PyArray1, PyArray2, PyArrayMethods}; -use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python}; +use pyo3::{ + pymodule, + types::{PyModule, PyModuleMethods}, + Bound, PyResult, Python, +}; fn to_numpy_1d(py: Python<'_>, vec: Vec) -> Bound<'_, PyArray1> { PyArray::from_vec_bound(py, vec) diff --git a/src/mesh.rs b/src/mesh.rs index d66817f..6a4ee6e 100644 --- a/src/mesh.rs +++ b/src/mesh.rs @@ -240,6 +240,7 @@ macro_rules! create_mesh { } /// Write a vtk file containing the mesh + #[pyo3(signature = (file_name, vert_data=None, elem_data=None))] pub fn write_vtk(&self, file_name: &str, vert_data : Option>>, @@ -363,6 +364,7 @@ macro_rules! create_mesh { } /// Interpolate a field (scalar or vector) defined at the vertices (P1) to a different mesh using linear interpolation + #[pyo3(signature = (other, arr, tol=None))] pub fn interpolate_linear<'py>( &mut self, py: Python<'py>, @@ -394,6 +396,7 @@ macro_rules! create_mesh { } /// Smooth a field defined at the mesh vertices using a 1st order least-square approximation + #[pyo3(signature = (arr, weight_exp=None))] pub fn smooth<'py>( &self, py: Python<'py>, @@ -417,6 +420,7 @@ macro_rules! create_mesh { } /// Compute the gradient of a field defined at the mesh vertices using a 1st order least-square approximation + #[pyo3(signature = (arr, weight_exp=None))] pub fn compute_gradient<'py>( &self, py: Python<'py>, @@ -446,6 +450,7 @@ macro_rules! create_mesh { /// Compute the hessian of a field defined at the mesh vertices using a 2nd order least-square approximation /// if `weight_exp` is `None`, the vertex has a weight 10, its first order neighbors have /// a weight 1 and the 2nd order neighbors (if used) have a weight of 0.1 + #[pyo3(signature = (arr, weight_exp=None, use_second_order_neighbors=None))] pub fn compute_hessian<'py>( &self, py: Python<'py>, @@ -567,6 +572,7 @@ impl Mesh33 { #[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_lines)] #[classmethod] + #[pyo3(signature = (coords, hexs=None, hex_tags=None, pris=None, pri_tags=None, pyrs=None, pyr_tags=None, tets=None, tet_tags=None, quas=None, qua_tags=None, tris=None, tri_tags=None))] pub fn from_basic_elems( _cls: &Bound<'_, PyType>, coords: PyReadonlyArray2, @@ -734,6 +740,7 @@ impl Mesh33 { /// - if an implied metric is provided, the result is limited to (1/step,step) times the implied metric /// - if a normal size array is not provided, the minimum of the tangential sizes is used. #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (geom, r_h, beta, h_min=None, h_n=None, h_n_tags=None))] pub fn curvature_metric<'py>( &self, py: Python<'py>, @@ -779,6 +786,7 @@ impl Mesh32 { /// Create a Mesh32 from basic elements #[classmethod] #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (coords, quas=None, qua_tags=None, tris=None, tri_tags=None, edgs=None, edg_tags=None))] pub fn from_basic_elems( _cls: &Bound<'_, PyType>, coords: PyReadonlyArray2, @@ -887,6 +895,7 @@ impl Mesh22 { /// Create a Mesh22 from basic elements #[allow(clippy::too_many_arguments)] #[classmethod] + #[pyo3(signature = (coords, quas=None, qua_tags=None, tris=None, tri_tags=None, edgs=None, edg_tags=None))] pub fn from_basic_elems( _cls: &Bound<'_, PyType>, coords: PyReadonlyArray2, @@ -989,6 +998,7 @@ impl Mesh22 { /// - the metric is entended into the volume with gradation beta /// - if a normal size array is not provided, the minimum of the tangential sizes is used. #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (geom, r_h, beta, h_min=None, h_n=None, h_n_tags=None))] pub fn curvature_metric<'py>( &self, py: Python<'py>, diff --git a/src/parallel.rs b/src/parallel.rs index 35d8f36..b986fde 100644 --- a/src/parallel.rs +++ b/src/parallel.rs @@ -69,6 +69,7 @@ macro_rules! create_parallel_remesher { } #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (geometry, m, num_iter=None, two_steps=None, split_max_iter=None, split_min_l_rel=None, split_min_l_abs=None, split_min_q_rel=None, split_min_q_abs=None, collapse_max_iter=None, collapse_max_l_rel=None, collapse_max_l_abs=None, collapse_min_q_rel=None, collapse_min_q_abs=None, swap_max_iter=None, swap_max_l_rel=None, swap_max_l_abs=None, swap_min_l_rel=None, swap_min_l_abs=None, smooth_iter=None, smooth_type=None, smooth_relax=None, smooth_keep_local_minima=None, max_angle=None, debug=None, n_layers=None, n_levels=None, min_verts=None))] pub fn remesh<'py>(&mut self, py: Python<'py>, geometry: &$geom, diff --git a/src/remesher.rs b/src/remesher.rs index 8c42e95..e001945 100644 --- a/src/remesher.rs +++ b/src/remesher.rs @@ -59,6 +59,7 @@ macro_rules! create_remesher { /// Convert a Hessian $H$ to the optimal metric for a Lp norm, i.e. /// $$ m = det(|H|)^{-1/(2p+dim)}|H| $$ #[classmethod] + #[pyo3(signature = (mesh, m, p=None))] pub fn hessian_to_metric<'py>( _cls: &Bound<'_, PyType>, py: Python<'py>, @@ -97,6 +98,7 @@ macro_rules! create_remesher { /// Scale a metric field to reach the desired (ideal) number of elements using min / max bounds on the cell size #[classmethod] #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (mesh, m, h_min, h_max, n_elems, fixed_m=None, implied_m=None, step=None, max_iter=None))] pub fn scale_metric<'py>( _cls: &Bound<'_, PyType>, py: Python<'py>, @@ -340,6 +342,7 @@ macro_rules! create_remesher { #[doc = concat!("Get the mesh as a ", stringify!($mesh))] #[must_use] + #[pyo3(signature = (only_bdy_faces=None))] pub fn to_mesh(&self, only_bdy_faces: Option) -> $mesh { $mesh { mesh: self.remesher.to_mesh(only_bdy_faces.unwrap_or(false)), @@ -402,6 +405,7 @@ macro_rules! create_remesher { /// Perform a remeshing iteration #[allow(clippy::too_many_arguments)] + #[pyo3(signature = (geometry, num_iter=None, two_steps=None, split_max_iter=None, split_min_l_rel=None, split_min_l_abs=None, split_min_q_rel=None, split_min_q_abs=None, collapse_max_iter=None, collapse_max_l_rel=None, collapse_max_l_abs=None, collapse_min_q_rel=None, collapse_min_q_abs=None, swap_max_iter=None, swap_max_l_rel=None, swap_max_l_abs=None, swap_min_l_rel=None, swap_min_l_abs=None, smooth_iter=None, smooth_type=None, smooth_relax=None, smooth_keep_local_minima=None, max_angle=None, debug=None))] pub fn remesh( &mut self, geometry: &$geom,