Skip to content

Commit

Permalink
Fix many small formatting errors in the pydocs
Browse files Browse the repository at this point in the history
the params for the functions were not all used, now it's fixed
  • Loading branch information
hugoledoux committed Mar 11, 2024
1 parent 276ff41 commit a872eee
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ impl DT {
///
/// :param attribute: the name (a string) of the attribute
/// :return: an array all the values (including for the removed vertices).
/// The array is empty is the extra attributes doesn't exist.
/// The array is empty if the extra attributes doesn't exist.
///
/// >>> dt = startinpy.DT(extra_attributes=True)
/// >>> dt.insert_one_pt(85000.0, 444003.2, 2.2, intensity=111.1)
Expand Down Expand Up @@ -477,6 +477,7 @@ impl DT {
///
/// >>> v = dt.get_point(4)
/// array([13., 2.0, 11.])
#[pyo3(text_signature = "($self, vi)")]
#[args(vi)]
fn get_point<'py>(
&self,
Expand Down Expand Up @@ -519,6 +520,7 @@ impl DT {
///
/// :param p2: array with [x, y]-coordinates of point to test
/// :return: True if [x,y] is inside the convex hull or on its boundary, False otherwise.
#[pyo3(text_signature = "($self, p2)")]
#[args(x, y)]
fn is_inside_convex_hull(&self, p2: [f64; 2]) -> PyResult<bool> {
let re = self.t.locate(p2[0], p2[1]);
Expand All @@ -534,6 +536,7 @@ impl DT {
/// :param vi: the vertex index
/// :return: True if *vi* is on the boundary of the convex hull, False otherwise.
/// Also False is returned if the vertex doesn't exist in the DT.
#[pyo3(text_signature = "($self, vi)")]
#[args(vi)]
fn is_vertex_convex_hull(&self, vi: usize) -> PyResult<bool> {
Ok(self.t.is_vertex_convex_hull(vi))
Expand All @@ -544,6 +547,7 @@ impl DT {
/// :param vi: the vertex index
/// :return: True if *vi* is labelled as removed, False otherwise.
/// An exception is raised if *vi* doesn't exist.
#[pyo3(text_signature = "($self, vi)")]
#[args(vi)]
fn is_vertex_removed(&self, vi: usize) -> PyResult<bool> {
let re = self.t.is_vertex_removed(vi);
Expand All @@ -566,6 +570,7 @@ impl DT {
/// >>> cp = dt.closest_point([32.1, 66.9])
/// >>> except Exception as e:
/// >>> print(e)
#[pyo3(text_signature = "($self, p2)")]
#[args(x, y)]
fn closest_point(&self, p2: [f64; 2]) -> PyResult<usize> {
let re = self.t.closest_point(p2[0], p2[1]);
Expand Down Expand Up @@ -593,6 +598,7 @@ impl DT {
/// 3 [3 8 2]
/// 4 [3 2 9]
/// 5 [3 9 4]
#[pyo3(text_signature = "($self, vi)")]
#[args(vi)]
fn incident_triangles_to_vertex<'py>(
&self,
Expand Down Expand Up @@ -621,15 +627,16 @@ impl DT {
/// Return the triangles adjacent to Triangle *t*.
/// Exception thrown if vertex index doesn't exist in the DT.
///
/// :param vi: the vertex index
/// :return: an array of 3 triangles (finite and infinite)
/// :param t: the Triangle, an array of 3 vertex indices
/// :return: an array of 3 Triangles (finite and infinite)
///
/// >>> tris = dt.adjacent_triangles_to_triangle([1, 44, 23])
/// >>> for i, t in enumerate(tris):
/// >>> print(i, t)
/// 0 [3 4 6]
/// 1 [3 6 7]
/// 2 [3 7 8]
#[pyo3(text_signature = "($self, t)")]
#[args(t)]
fn adjacent_triangles_to_triangle<'py>(
&self,
Expand Down Expand Up @@ -664,6 +671,7 @@ impl DT {
///
/// :param vi: the vertex index
/// :return: an array of vertex indices (ordered counter-clockwise)
#[pyo3(text_signature = "($self, vi)")]
#[args(vi)]
fn adjacent_vertices_to_vertex<'py>(
&self,
Expand All @@ -685,10 +693,11 @@ impl DT {
/// of its vertices.
/// This doesn't verify wether the triangle exists (use is_valid()).
///
/// :param t: the triangle, an array of 3 vertex indices
/// :param t: the Triangle, an array of 3 vertex indices
/// :return: True if t is finite, False is infinite
///
/// >>> re = dt.is_finite(np.array([11, 162, 666])))
#[pyo3(text_signature = "($self, t)")]
#[args(t)]
fn is_finite(&self, t: Vec<usize>) -> PyResult<bool> {
let tr = startin::Triangle {
Expand All @@ -699,11 +708,12 @@ impl DT {

/// Verify if a triangle exists in the DT.
///
/// :param t: the triangle, an array of 3 vertex indices
/// :param t: the Triangle, an array of 3 vertex indices
/// :return: True if t exists, False otherwise
///
/// >>> dt.is_triangle(np.array([11, 162, 66]))
/// False
#[pyo3(text_signature = "($self, t)")]
#[args(t)]
fn is_triangle(&self, t: Vec<usize>) -> PyResult<bool> {
let tr = startin::Triangle {
Expand All @@ -720,6 +730,8 @@ impl DT {
///
/// >>> tr = dt.locate([34.2, 55.6])
/// array([65, 61, 23], dtype=uint64)
#[pyo3(text_signature = "($self, p2)")]
#[args(p2)]
fn locate<'py>(
&self,
py: Python<'py>,
Expand Down Expand Up @@ -747,13 +759,14 @@ impl DT {
/// 5. **TIN**: linear interpolation in TIN
///
/// :param interpolant: a JSON/dict Python object with a `"method": "IDW"` (or others). IDW has 2 more params: "power" and "radius"
/// :param locations: an array of [x, y] locations where to interpolate
/// :param strict: if the interpolation cannot find a value (because outside convex hull or search radius too small) then strict==True will stop at the first error and return that error. If strict==False then numpy.nan is returned.
/// :param locations: an array of [x, y] locations where the function should interpolate
/// :param strict: (default=False) if the interpolation cannot find a value (because outside convex hull or search radius too small) then strict==True will stop at the first error and return that error. If strict==False then numpy.nan is returned.
/// :return: a numpy array containing all the interpolation values (same order as input array)
///
/// >>> locs = [ [50.0, 41.1], [101.1, 33.2], [80.0, 66.0] ]
/// >>> re = dt.interpolate({"method": "NNI"}, locs)
/// >>> re = dt.interpolate({"method": "IDW", "radius": 20, "power": 2.0}, locs, strict=True)
#[pyo3(text_signature = "($self, interpolant, locations, *, strict=True)")]
#[args(interpolant, locations, strict = false)]
fn interpolate<'py>(
&mut self,
Expand Down Expand Up @@ -904,6 +917,7 @@ impl DT {
/// :return: (nothing)
///
/// >>> dt.write_obj("/home/elvis/myfile.obj")
#[pyo3(text_signature = "($self, path)")]
#[args(path)]
fn write_obj(&self, path: String) -> PyResult<()> {
let re = self.t.write_obj(path.to_string());
Expand All @@ -920,6 +934,7 @@ impl DT {
/// :return: (nothing)
///
/// >>> dt.write_ply("/home/elvis/myfile.ply")
#[pyo3(text_signature = "($self, path)")]
#[args(path)]
fn write_ply(&self, path: String) -> PyResult<()> {
let re = self.t.write_ply(path.to_string());
Expand All @@ -936,6 +951,7 @@ impl DT {
/// :return: (nothing)
///
/// >>> dt.write_geojson("/home/elvis/myfile.geojson")
#[pyo3(text_signature = "($self, path)")]
#[args(path)]
pub fn write_geojson(&self, path: String) -> PyResult<()> {
let mut fc = FeatureCollection {
Expand Down Expand Up @@ -1007,6 +1023,7 @@ impl DT {
/// :return: (nothing)
///
/// >>> dt.write_cityjson("/home/elvis/myfile.city.json")
#[pyo3(text_signature = "($self, path, digits=3)")]
#[args(path, digits = 3)]
fn write_cityjson(&self, path: String, digits: usize) -> PyResult<()> {
let bbox = self.t.get_bbox();
Expand Down Expand Up @@ -1085,6 +1102,7 @@ impl DT {
///
/// >>> dt.vertical_exaggeration(2.0)
/// >>> dt.vertical_exaggeration(0.5)
#[pyo3(text_signature = "($self, factor)")]
#[args(factor)]
fn vertical_exaggeration(&mut self, factor: f64) {
self.t.vertical_exaggeration(factor);
Expand Down

0 comments on commit a872eee

Please sign in to comment.