Skip to content

Commit

Permalink
fix doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Nov 18, 2023
1 parent 9549857 commit ee61abb
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/compas_libigl/boundaries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ def trimesh_boundaries(M):
Examples
--------
>>> import compas_libigl as igl
>>> import compas
>>> import compas_libigl
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_off(igl.get('tubemesh.off'))
>>> mesh = Mesh.from_off(compas.get('tubemesh.off'))
>>> mesh.quads_to_triangles()
>>> boundaries = igl.trimesh_boundaries(mesh)
>>> M = mesh.to_vertices_and_faces()
>>> boundaries = compas_libigl.trimesh_boundaries(M)
>>> len(boundaries) == 1
True
"""
Expand Down
8 changes: 5 additions & 3 deletions src/compas_libigl/curvature/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ def trimesh_gaussian_curvature(M):
Examples
--------
>>> import compas_libigl as igl
>>> import compas
>>> import compas_libigl
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_off(igl.get('tubemesh.off'))
>>> mesh = Mesh.from_off(compas.get('tubemesh.off'))
>>> mesh.quads_to_triangles()
>>> curvature = igl.trimesh_curvature(mesh)
>>> M = mesh.to_vertices_and_faces()
>>> curvature = compas_libigl.trimesh_gaussian_curvature(M)
"""
V, F = M
V = np.asarray(V, dtype=np.float64)
Expand Down
1 change: 1 addition & 0 deletions src/compas_libigl/geodistance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def trimesh_geodistance(M, source, method="exact"):
Examples
--------
>>>
"""
V, F = M
V = np.asarray(V, dtype=np.float64)
Expand Down
9 changes: 6 additions & 3 deletions src/compas_libigl/intersections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ def intersection_ray_mesh(ray, M):
Examples
--------
>>> import compas_libigl as igl
>>> import compas
>>> import compas_libigl
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_off(igl.get('tubemesh.off'))
>>> mesh = Mesh.from_off(compas.get('tubemesh.off'))
>>> mesh.quads_to_triangles()
>>> M = mesh.to_vertices_and_faces()
>>> centroid = mesh.centroid()
>>> ray = [centroid[0], centroid[1], 0], [0, 0, 1.0]
>>> hits = igl.intersection_ray_mesh(ray, mesh)
>>> hits = compas_libigl.intersection_ray_mesh(ray, M)
>>> len(hits) == 1
True
To compute the actual intersection point, do
>>> from compas.geometry import add_vectors, scale_vector
>>> point = add_vectors(ray[0], scale_vector(ray[1], hits[0][3]))
"""
Expand Down
8 changes: 5 additions & 3 deletions src/compas_libigl/isolines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ def trimesh_isolines(M, S, N=50):
Examples
--------
>>> import compas_libigl as igl
>>> import compas
>>> import compas_libigl
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_off(igl.get('tubemesh.off'))
>>> mesh = Mesh.from_off(compas.get('tubemesh.off'))
>>> mesh.quads_to_triangles()
>>> M = mesh.to_vertices_and_faces()
>>> scalars = mesh.vertices_attribute('z')
>>> vertices, edges = igl.trimesh_isolines(mesh, scalars, 50)
>>> vertices, edges = compas_libigl.trimesh_isolines(M, scalars, 50)
To convert the vertices and edges to sets of isolines, use :func:`groupsort_isolines`
Expand Down
9 changes: 6 additions & 3 deletions src/compas_libigl/massmatrix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ def trimesh_massmatrix(M):
Examples
--------
>>> import compas_libigl as igl
>>> import compas
>>> import compas_libigl
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_off(igl.get('tubemesh.off'))
>>> mesh = Mesh.from_off(compas.get('tubemesh.off'))
>>> mesh.quads_to_triangles()
>>> mass = igl.trimesh_massmatrix(mesh)
>>> M = mesh.to_vertices_and_faces()
>>> mass = compas_libigl.trimesh_massmatrix(M)
"""
V, F = M
V = np.asarray(V, dtype=np.float64)
Expand Down
2 changes: 0 additions & 2 deletions src/compas_libigl/meshing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ def trimesh_remesh_along_isoline(mesh, scalarfield, scalar):
Examples
--------
>>> import compas_libigl as igl
>>> from compas.datastructures import Mesh
>>>
"""
Expand Down
6 changes: 4 additions & 2 deletions src/compas_libigl/parametrisation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def trimesh_harmonic(M):
>>> mesh = Mesh.from_off(igl.get('camelhead.off'))
>>> mesh_uv = mesh.copy()
>>> mesh_uv.vertices_attribute('z', 0)
>>> uv = igl.trimesh_harmonic(mesh)
>>> M = mesh.to_vertices_and_faces()
>>> uv = igl.trimesh_harmonic(M)
>>> for key in mesh.vertices():
... mesh_uv.vertex_attributes(key, 'xy', uv[key])
...
Expand Down Expand Up @@ -65,7 +66,8 @@ def trimesh_lscm(M):
>>> mesh = Mesh.from_off(igl.get('camelhead.off'))
>>> mesh_uv = mesh.copy()
>>> mesh_uv.vertices_attribute('z', 0)
>>> uv = igl.trimesh_lscm(mesh)
>>> M = mesh.to_vertices_and_faces()
>>> uv = igl.trimesh_lscm(M)
>>> for key in mesh.vertices():
... mesh_uv.vertex_attributes(key, 'xy', uv[key])
...
Expand Down

0 comments on commit ee61abb

Please sign in to comment.