Skip to content

Commit

Permalink
docstring formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Jul 6, 2024
1 parent d7b0a3e commit feec173
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 39 deletions.
7 changes: 3 additions & 4 deletions src/compas/data/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,13 @@ class DataDecoder(json.JSONDecoder):
>>> import json
>>> from compas.data import DataDecoder
>>> with open('point.json', 'r') as f: # doctest: +SKIP
... point = json.load(f, cls=DataDecoder) # doctest: +SKIP
...
>>> with open("point.json", "r") as f: # doctest: +SKIP
... point = json.load(f, cls=DataDecoder) # doctest: +SKIP
Implicit use case.
>>> from compas.data import json_load
>>> point = json_load('point.json') # doctest: +SKIP
>>> point = json_load("point.json") # doctest: +SKIP
"""

Expand Down
9 changes: 5 additions & 4 deletions src/compas/datastructures/assembly/part.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,20 @@ class GeometricFeature(Feature):
>>>
>>> def trim_brep_plane(brep, plane):
... pass
...
>>> def trim_mesh_plane(mesh, plane):
... pass
...
>>> class TrimmingFeature(GeometricFeature):
... OPERATIONS = {Brep: trim_brep_plane, Mesh: trim_mesh_plane}
...
... def __init__(self, trimming_plane):
... super(TrimmingFeature, self).__init__()
... self._geometry = trimming_plane
...
... def apply(self, part):
... part_geometry = part.get_geometry(with_features=True)
... type_ = Brep if isinstance(part_geometry, Brep) else Mesh
... operation = OPERATIONS[type_]
... return operation(part_geometry, self._geometry)
...
>>>
"""
Expand Down Expand Up @@ -87,13 +86,15 @@ class ParametricFeature(Feature):
... def __init__(self, extend_by):
... super(ExtensionFeature, self).__init__()
... self.extend_by = extend_by
...
... def apply(self, part):
... part.length += self._extend_by
...
... def restore(self, part):
... part.length -= self._extend_by
...
... def accumulate(self, other):
... return BeamExtensionFeature(max(self.extend_by, other.extend_by))
...
>>>
"""
Expand Down
5 changes: 1 addition & 4 deletions src/compas/datastructures/cell_network/cell_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ class CellNetwork(Datastructure):
>>> cells = [[0, 1, 2, 3, 4, 5]]
>>> for x, y, z in vertices:
... vertex = cell_network.add_vertex(x=x, y=y, z=z)
...
>>> for face_vertices in faces:
... face = cell_network.add_face(face_vertices)
...
>>> for cell_faces in cells:
... cell = cell_network.add_cell(cell_faces)
...
... cell = cell_network.add_cell(cell_faces)
>>> print(cell_network)
<CellNetwork with 8 vertices, 6 faces, 1 cells, 12 edges>
Expand Down
1 change: 0 additions & 1 deletion src/compas/datastructures/mesh/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,6 @@ def remove_duplicate_vertices(self, precision=None):
36
>>> for x, y, z in mesh.vertices_attributes("xyz", keys=list(mesh.vertices())[:5]):
... mesh.add_vertex(x=x, y=y, z=z)
...
36
37
38
Expand Down
2 changes: 1 addition & 1 deletion src/compas/datastructures/mesh/operations/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def mesh_merge_faces(mesh, faces):
--------
>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_vertices_and_faces([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1, 2, 3]])
>>> mesh = mesh.subdivided(scheme='quad')
>>> mesh = mesh.subdivided(scheme="quad")
>>> mesh_merge_faces(mesh, [1, 2])
5
>>> mesh_merge_faces(mesh, [3, 5])
Expand Down
12 changes: 6 additions & 6 deletions src/compas/geometry/curves/parabola.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ class Parabola(Conic):
Visualize the parabola with the COMPAS viewer.
>>> from compas_viewer import Viewer # doctest: +SKIP
>>> viewer = Viewer() # doctest: +SKIP
>>> viewer.scene.add(line) # doctest: +SKIP
>>> viewer.scene.add(parabola) # doctest: +SKIP
>>> viewer.scene.add(parabola.frame) # doctest: +SKIP
>>> viewer.show() # doctest: +SKIP
>>> from compas_viewer import Viewer # doctest: +SKIP
>>> viewer = Viewer() # doctest: +SKIP
>>> viewer.scene.add(line) # doctest: +SKIP
>>> viewer.scene.add(parabola) # doctest: +SKIP
>>> viewer.scene.add(parabola.frame) # doctest: +SKIP
>>> viewer.show() # doctest: +SKIP
"""

Expand Down
16 changes: 8 additions & 8 deletions src/compas/geometry/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,8 @@ def from_euler_angles(cls, euler_angles, static=True, axes="xyz", point=[0, 0, 0
--------
>>> from compas.tolerance import TOL
>>> ea1 = 1.4, 0.5, 2.3
>>> f = Frame.from_euler_angles(ea1, static=True, axes='xyz')
>>> ea2 = f.euler_angles(static=True, axes='xyz')
>>> f = Frame.from_euler_angles(ea1, static=True, axes="xyz")
>>> ea2 = f.euler_angles(static=True, axes="xyz")
>>> TOL.is_allclose(ea1, ea2)
True
Expand Down Expand Up @@ -555,7 +555,7 @@ def from_plane(cls, plane): # type: (...) -> Frame
--------
>>> from compas.geometry import Plane
>>> from compas.tolerance import TOL
>>> plane = Plane([0,0,0], [0,0,1])
>>> plane = Plane([0, 0, 0], [0, 0, 1])
>>> frame = Frame.from_plane(plane)
>>> TOL.is_allclose(frame.normal, plane.normal)
True
Expand Down Expand Up @@ -676,8 +676,8 @@ def euler_angles(self, static=True, axes="xyz"):
--------
>>> from compas.tolerance import TOL
>>> ea1 = 1.4, 0.5, 2.3
>>> f = Frame.from_euler_angles(ea1, static=True, axes='xyz')
>>> ea2 = f.euler_angles(static=True, axes='xyz')
>>> f = Frame.from_euler_angles(ea1, static=True, axes="xyz")
>>> ea2 = f.euler_angles(static=True, axes="xyz")
>>> TOL.is_allclose(ea1, ea2)
True
Expand Down Expand Up @@ -706,7 +706,7 @@ def to_local_coordinates(self, obj_in_wcf):
--------
>>> from compas.geometry import Point
>>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
>>> pw = Point(2, 2, 2) # point in wcf
>>> pw = Point(2, 2, 2) # point in wcf
>>> pl = frame.to_local_coordinates(pw) # point in frame
>>> print(frame.to_world_coordinates(pl))
Point(x=2.000, y=2.000, z=2.000)
Expand Down Expand Up @@ -738,8 +738,8 @@ def to_world_coordinates(self, obj_in_lcf):
--------
>>> from compas.geometry import Point
>>> frame = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
>>> pl = Point(1.632, -0.090, 0.573) # point in frame
>>> pw = frame.to_world_coordinates(pl) # point in wcf
>>> pl = Point(1.632, -0.090, 0.573) # point in frame
>>> pw = frame.to_world_coordinates(pl) # point in wcf
>>> print(frame.to_local_coordinates(pw))
Point(x=1.632, y=-0.090, z=0.573)
Expand Down
14 changes: 7 additions & 7 deletions src/compas/geometry/intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ class Intersection(object):
Examples
--------
>>> from compas.geometry import Line # doctest: +SKIP
>>> from compas.geometry import Line # doctest: +SKIP
>>> from compas.geometry import Intersection # doctest: +SKIP
>>> a = Line([0, 0, 0], [2, 0, 0]) # doctest: +SKIP
>>> b = Line([1, 0, 0], [1, 1, 0]) # doctest: +SKIP
>>> intersection = Intersection() # doctest: +SKIP
>>> intersection.line_line(a, b) # doctest: +SKIP
>>> intersection.number_of_intersections # doctest: +SKIP
>>> a = Line([0, 0, 0], [2, 0, 0]) # doctest: +SKIP
>>> b = Line([1, 0, 0], [1, 1, 0]) # doctest: +SKIP
>>> intersection = Intersection() # doctest: +SKIP
>>> intersection.line_line(a, b) # doctest: +SKIP
>>> intersection.number_of_intersections # doctest: +SKIP
1
>>> intersection.points[0] # doctest: +SKIP
>>> intersection.points[0] # doctest: +SKIP
Point(1.0, 0.0, z=0.0)
"""
Expand Down
2 changes: 1 addition & 1 deletion src/compas/geometry/point.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Point(Geometry):
>>> print(result)
Point(x=2.000, y=4.000, z=6.000)
>>> result = p1 ** 2
>>> result = p1**2
>>> print(result)
Point(x=1.000, y=4.000, z=9.000)
Expand Down
4 changes: 2 additions & 2 deletions src/compas/geometry/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Scale(Transformation):
>>> point = Point(2, 5, 0)
>>> frame = Frame(point, (1, 0, 0), (0, 1, 0))
>>> points = [point, Point(2, 10, 0)]
>>> S = Scale.from_factors([2.] * 3, frame)
>>> S = Scale.from_factors([2.0] * 3, frame)
>>> points = [p.transformed(S) for p in points]
>>> print(points)
[Point(x=2.000, y=5.000, z=0.000), Point(x=2.000, y=15.000, z=0.000)]
Expand Down Expand Up @@ -88,7 +88,7 @@ def from_factors(cls, factors, frame=None):
>>> point = Point(2, 5, 0)
>>> frame = Frame(point, (1, 0, 0), (0, 1, 0))
>>> points = [point, Point(2, 10, 0)]
>>> S = Scale.from_factors([2.] * 3, frame)
>>> S = Scale.from_factors([2.0] * 3, frame)
>>> points = [p.transformed(S) for p in points]
>>> print(points)
[Point(x=2.000, y=5.000, z=0.000), Point(x=2.000, y=15.000, z=0.000)]
Expand Down
1 change: 0 additions & 1 deletion tests/compas/datastructures/test_hashtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def test_hashtree_from_dict():

tree1 = HashTree.from_dict({"a": {"b": 1, "c": 3}, "d": [1, 2, 3], "e": 2})
tree2 = HashTree.from_dict({"a": {"b": 1, "c": 2}, "d": [1, 2, 3], "f": 2})
diff = tree2.diff(tree1)
Expand Down

0 comments on commit feec173

Please sign in to comment.