Skip to content

Commit

Permalink
fix docstring errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Nov 7, 2023
1 parent 58b24e3 commit db5478a
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 78 deletions.
34 changes: 0 additions & 34 deletions src/compas_occ/brep/brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,40 +98,6 @@ class OCCBrep(Brep):
volume : float, read-only
The volume of the regions contained by the Brep.
Examples
--------
Constructors
>>> brep = Brep.from_corners([0, 0, 0], [1, 0, 0], [1, 1, 1], [1, 1, 0])
>>> from compas.geometry import Box
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> vertices, faces = box.to_vertices_and_faces()
>>> polygons = [[vertices[index] for index in face] for face in faces]
>>> brep = Brep.from_polygons(polygons)
>>> from compas.geometry import Box
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> brep = Brep.from_box(box)
>>> from compas.geometry import Box, Sphere
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> sphere = Sphere([1, 1, 1], 0.5)
>>> A = Brep.from_box(box)
>>> B = Brep.from_sphere(sphere)
>>> brep = Brep.from_boolean_union(A, B)
Booleans
>>> from compas.geometry import Box, Sphere
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> sphere = Sphere([1, 1, 1], 0.5)
>>> A = Brep.from_box(box)
>>> B = Brep.from_sphere(sphere)
>>> C = A + B
>>> D = A - B
>>> E = A & B
"""

_occ_shape: TopoDS_Shape
Expand Down
2 changes: 2 additions & 0 deletions src/compas_occ/conversions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from .geometry import compas_circle_to_occ_circle
from .geometry import compas_cone_to_occ_cone
from .geometry import compas_cylinder_to_occ_cylinder
from .geometry import compas_ellipse_to_occ_ellipse
from .geometry import compas_frame_to_occ_ax2
from .geometry import compas_frame_to_occ_ax3
from .geometry import compas_line_to_occ_line
Expand Down Expand Up @@ -63,6 +64,7 @@
"compas_cylinder_from_occ_cylinder",
"compas_cylinder_to_occ_cylinder",
"compas_ellipse_from_occ_ellipse",
"compas_ellipse_to_occ_ellipse",
"compas_frame_from_occ_ax2",
"compas_frame_from_occ_ax3",
"compas_frame_from_occ_location",
Expand Down
40 changes: 20 additions & 20 deletions src/compas_occ/conversions/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def array1_from_points1(points: List[Point]) -> TColgp_Array1OfPnt:
>>> points1 = [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0)]
>>> array1 = array1_from_points1(points1)
>>> array1
>>> array1 # doctest: +ELLIPSIS
<OCC.Core.TColgp.TColgp_Array1OfPnt; ... >
>>> for item in array1:
Expand Down Expand Up @@ -82,7 +82,7 @@ def harray1_from_points1(points: List[Point]) -> TColgp_HArray1OfPnt:
>>> points1 = [Point(0, 0, 0), Point(1, 0, 0), Point(2, 0, 0)]
>>> harray1 = harray1_from_points1(points1)
>>> harray1
>>> harray1 # doctest: +ELLIPSIS
<OCC.Core.TColgp.TColgp_HArray1OfPnt; ... >
>>> for item in harray1:
Expand Down Expand Up @@ -137,9 +137,9 @@ def points1_from_array1(array: TColgp_Array1OfPnt) -> List[Point]:
>>> for point in points1:
... print(point)
...
Point(0.000, 0.000, 0.000)
Point(1.000, 0.000, 0.000)
Point(2.000, 0.000, 0.000)
Point(0.0, 0.0, z=0.0)
Point(1.0, 0.0, z=0.0)
Point(2.0, 0.0, z=0.0)
"""
return [Point(point.X(), point.Y(), point.Z()) for point in array]
Expand Down Expand Up @@ -172,11 +172,11 @@ def array2_from_points2(points: List[List[Point]]) -> TColgp_Array2OfPnt:
... [Point(0, 1, 0), Point(1, 1, 0), Point(2, 1, 0)],
... ]
>>> array2 = array2_from_points2(points2)
>>> array2
>>> array2 # doctest: +ELLIPSIS
<OCC.Core.TColgp.TColgp_Array2OfPnt; ... >
>>> rows = range(array2.LowerRow(), array2.UpperRow() + 1))
>>> cols = range(array2.LowerCol(), array2.UpperCol() + 1))
>>> rows = range(array2.LowerRow(), array2.UpperRow() + 1)
>>> cols = range(array2.LowerCol(), array2.UpperCol() + 1)
>>> for i, j in product(rows, cols):
... value = array2.Value(i, j)
... x = value.X()
Expand All @@ -185,10 +185,10 @@ def array2_from_points2(points: List[List[Point]]) -> TColgp_Array2OfPnt:
... print(x, y, z)
...
0.0 0.0 0.0
1.0 0.0 0.0
2.0 0.0 0.0
0.0 1.0 0.0
1.0 0.0 0.0
1.0 1.0 0.0
2.0 0.0 0.0
2.0 1.0 0.0
"""
Expand Down Expand Up @@ -236,12 +236,12 @@ def points2_from_array2(array: TColgp_Array2OfPnt) -> List[List[Point]]:
>>> for i, j in product(range(len(points2)), range(len(points2[0]))):
... print(points2[i][j])
...
Point(0.000, 0.000, 0.000)
Point(1.000, 0.000, 0.000)
Point(2.000, 0.000, 0.000)
Point(0.000, 1.000, 0.000)
Point(1.000, 1.000, 0.000)
Point(2.000, 1.000, 0.000)
Point(0.0, 0.0, z=0.0)
Point(0.0, 1.0, z=0.0)
Point(1.0, 0.0, z=0.0)
Point(1.0, 1.0, z=0.0)
Point(2.0, 0.0, z=0.0)
Point(2.0, 1.0, z=0.0)
"""
points = [[None for j in range(array.NbRows())] for i in range(array.NbColumns())]
Expand Down Expand Up @@ -272,7 +272,7 @@ def array1_from_integers1(numbers: List[int]) -> TColStd_Array1OfInteger:
>>> from compas_occ.conversions import array1_from_integers1
>>> integers1 = [0, 1, 2]
>>> array1 = array1_from_integers1(integers1)
>>> array1
>>> array1 # doctest: +ELLIPSIS
<OCC.Core.TColStd.TColStd_Array1OfInteger; ... >
"""
Expand Down Expand Up @@ -303,7 +303,7 @@ def array1_from_floats1(numbers: List[float]) -> TColStd_Array1OfReal:
>>> from compas_occ.conversions import array1_from_floats1
>>> floats1 = [0.0, 1.0, 2.0]
>>> array1 = array1_from_floats1(floats1)
>>> array1
>>> array1 # doctest: +ELLIPSIS
<OCC.Core.TColStd.TColStd_Array1OfReal; ... >
"""
Expand Down Expand Up @@ -337,7 +337,7 @@ def array2_from_floats2(numbers: List[List[float]]) -> TColStd_Array2OfReal:
... [2.0, 0.0, 0.0],
... ]
>>> array2 = array2_from_floats2(floats2)
>>> array2
>>> array2 # doctest: +ELLIPSIS
<OCC.Core.TColStd.TColStd_Array2OfReal; ... >
"""
Expand Down Expand Up @@ -381,7 +381,7 @@ def floats2_from_array2(array: TColStd_Array2OfReal) -> List[List[Point]]:
>>> floats2 = floats2_from_array2(array2)
>>> floats2
[[0.0, 1.0, 2.0], [0.0, 1.0, 2.0]]
[(0.0, 0.0), (1.0, 1.0), (2.0, 2.0)]
"""
numbers = []
Expand Down
34 changes: 17 additions & 17 deletions src/compas_occ/conversions/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def compas_axis_to_occ_axis(axis: Tuple[Point, Vector]) -> gp_Ax1:
>>> from compas_occ.conversions import compas_axis_to_occ_axis
>>> point = Point(0, 0, 0)
>>> vector = Vector(1, 0, 0)
>>> axis = compas_axis_to_occ_axis((point, vector))
>>> compas_axis_to_occ_axis((point, vector))
<class 'gp_Ax1'>
"""
Expand Down Expand Up @@ -571,7 +571,7 @@ def compas_point_from_occ_point(
>>> from compas_occ.conversions import compas_point_from_occ_point
>>> point = gp_Pnt(0, 0, 0)
>>> compas_point_from_occ_point(point)
Point(0.000, 0.000, 0.000)
Point(0.0, 0.0, z=0.0)
"""
cls = cls or Point
Expand Down Expand Up @@ -605,7 +605,7 @@ def compas_point_from_occ_point2d(
>>> from compas_occ.conversions import compas_point_from_occ_point2d
>>> point = gp_Pnt2d(0, 0)
>>> compas_point_from_occ_point2d(point)
Point(0.000, 0.000, 0.000)
Point(0.0, 0.0, z=0.0)
"""
cls = cls or Point
Expand Down Expand Up @@ -641,7 +641,7 @@ def compas_vector_from_occ_vector(
>>> from compas_occ.conversions import compas_vector_from_occ_vector
>>> vector = gp_Vec(1, 0, 0)
>>> compas_vector_from_occ_vector(vector)
Vector(1.000, 0.000, 0.000)
Vector(x=1.0, y=0.0, z=0.0)
"""
cls = cls or Vector
Expand Down Expand Up @@ -677,7 +677,7 @@ def compas_vector_from_occ_vector2d(
>>> from compas_occ.conversions import compas_vector_from_occ_vector2d
>>> vector = gp_Vec2d(1, 0)
>>> compas_vector_from_occ_vector2d(vector)
Vector(1.000, 0.000, 0.000)
Vector(x=1.0, y=0.0, z=0.0)
"""
cls = cls or Vector
Expand Down Expand Up @@ -713,7 +713,7 @@ def compas_vector_from_occ_direction(
>>> from compas_occ.conversions import compas_vector_from_occ_direction
>>> vector = gp_Dir(1, 0, 0)
>>> compas_vector_from_occ_direction(vector)
Vector(1.000, 0.000, 0.000)
Vector(x=1.0, y=0.0, z=0.0)
"""
cls = cls or Vector
Expand Down Expand Up @@ -749,7 +749,7 @@ def compas_vector_from_occ_axis(
>>> from compas_occ.conversions import compas_vector_from_occ_axis
>>> axis = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))
>>> compas_vector_from_occ_axis(axis)
Vector(1.000, 0.000, 0.000)
Vector(x=1.0, y=0.0, z=0.0)
"""
return compas_vector_from_occ_direction(axis.Direction(), cls=cls)
Expand Down Expand Up @@ -777,7 +777,7 @@ def compas_axis_from_occ_axis(axis: gp_Ax1) -> Tuple[Point, Vector]:
>>> from compas_occ.conversions import compas_axis_from_occ_axis
>>> axis = gp_Ax1(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))
>>> compas_axis_from_occ_axis(axis)
(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000))
(Point(0.0, 0.0, z=0.0), Vector(x=1.0, y=0.0, z=0.0))
"""
point = compas_point_from_occ_point(axis.Location())
Expand Down Expand Up @@ -812,7 +812,7 @@ def compas_line_from_occ_line(
>>> from compas_occ.conversions import compas_line_from_occ_line
>>> line = gp_Lin(gp_Pnt(0, 0, 0), gp_Dir(1, 0, 0))
>>> compas_line_from_occ_line(line)
Line(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000))
Line(Point(0.0, 0.0, z=0.0), Point(1.0, 0.0, z=0.0))
"""
cls = cls or Line
Expand Down Expand Up @@ -848,7 +848,7 @@ def compas_plane_from_occ_plane(
>>> from compas_occ.conversions import compas_plane_from_occ_plane
>>> plane = gp_Pln(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1))
>>> compas_plane_from_occ_plane(plane)
Plane(Point(0.000, 0.000, 0.000), Vector(0.000, 0.000, 1.000))
Plane(point=Point(0.0, 0.0, z=0.0), normal=Vector(x=0.0, y=0.0, z=1.0))
"""
cls = cls or Plane
Expand Down Expand Up @@ -885,7 +885,7 @@ def compas_frame_from_occ_ax2(
>>> from compas_occ.conversions import compas_frame_from_occ_ax2
>>> ax2 = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> compas_frame_from_occ_ax2(ax2)
Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))
"""
cls = cls or Frame
Expand Down Expand Up @@ -923,7 +923,7 @@ def compas_frame_from_occ_ax3(
>>> from compas_occ.conversions import compas_frame_from_occ_ax3
>>> ax3 = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> compas_frame_from_occ_ax3(ax3)
Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))
"""
cls = cls or Frame
Expand Down Expand Up @@ -952,7 +952,7 @@ def compas_frame_from_occ_location(location: TopLoc_Location) -> Frame:
>>> from compas_occ.conversions import compas_frame_from_occ_location
>>> location = TopLoc_Location()
>>> compas_frame_from_occ_location(location)
Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0))
"""
t = location.Transformation()
Expand Down Expand Up @@ -994,7 +994,7 @@ def compas_circle_from_occ_circle(
>>> ax2 = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> circ = gp_Circ(ax2, 1)
>>> compas_circle_from_occ_circle(circ)
Circle(1.000, frame=Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Circle(radius=1.0, frame=Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=-0.0), yaxis=Vector(x=-0.0, y=1.0, z=0.0)))
"""
cls = cls or Circle
Expand Down Expand Up @@ -1033,7 +1033,7 @@ def compas_ellipse_from_occ_ellipse(
>>> ax2 = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> elips = gp_Elips(ax2, 1, 0.5)
>>> compas_ellipse_from_occ_ellipse(elips)
Ellipse(1.000, 0.500, frame=Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Ellipse(major=1.0, minor=0.5, frame=Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=0.0), yaxis=Vector(x=0.0, y=1.0, z=0.0)))
"""
cls = cls or Ellipse
Expand Down Expand Up @@ -1071,9 +1071,9 @@ def compas_cylinder_from_occ_cylinder(
>>> from OCC.Core.gp import gp_Pnt, gp_Dir, gp_Ax3, gp_Cylinder
>>> from compas_occ.conversions import compas_cylinder_from_occ_cylinder
>>> ax3 = gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0))
>>> cylinder = gp_Cylinder(ax3, 1, 1)
>>> cylinder = gp_Cylinder(ax3, 1)
>>> compas_cylinder_from_occ_cylinder(cylinder)
Cylinder(1.000, 1.000, frame=Frame(Point(0.000, 0.000, 0.000), Vector(1.000, 0.000, 0.000), Vector(0.000, 1.000, 0.000))
Cylinder(radius=1.0, height=1.0, frame=Frame(point=Point(0.0, 0.0, z=0.0), xaxis=Vector(x=1.0, y=0.0, z=-0.0), yaxis=Vector(x=-0.0, y=1.0, z=0.0)))
"""
cls = cls or Cylinder
Expand Down
3 changes: 0 additions & 3 deletions src/compas_occ/geometry/curves/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

@plugin(category="factories", requires=["compas_occ"])
def new_curve(cls, *args, **kwargs):
print("compas_occ.geometry.nurbs.new_curve")
# why is this not just OCCCurve()
return super(Curve, cls).__new__(cls)


@plugin(category="factories", requires=["compas_occ"])
def new_nurbscurve(cls, *args, **kwargs):
print("compas_occ.geometry.nurbs.new_nurbscurve")
# why is this not just OCCNurbsCurve()
return super(NurbsCurve, cls).__new__(cls)

Expand All @@ -28,7 +26,6 @@ def new_nurbscurve_from_parameters(cls, *args, **kwargs):

@plugin(category="factories", requires=["compas_occ"])
def new_nurbscurve_from_points(cls, *args, **kwargs):
print("compas_occ.geometry.nurbs.new_nurbscurve_from_points")
return OCCNurbsCurve.from_points(*args, **kwargs)


Expand Down
1 change: 0 additions & 1 deletion src/compas_occ/geometry/curves/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class OCCCurve(Curve):
_occ_curve: Geom_Curve

def __init__(self, occ_curve: Geom_Curve, name=None):
print("compas_occ.geometry.curve.__init__")
super().__init__(name=name)
self._dimension = 3
self.occ_curve = occ_curve
Expand Down
3 changes: 0 additions & 3 deletions src/compas_occ/geometry/curves/nurbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class OCCNurbsCurve(OCCCurve, NurbsCurve):
_occ_curve: Geom_BSplineCurve

def __init__(self, occ_curve: Geom_BSplineCurve, name: Optional[str] = None):
print("compas_occ.geometry.nurbs.__init__")
super(OCCNurbsCurve, self).__init__(occ_curve, name=name)
self.occ_curve = occ_curve

Expand Down Expand Up @@ -306,8 +305,6 @@ def from_points(cls, points: List[Point], degree: int = 3) -> "OCCNurbsCurve":
:class:`OCCNurbsCurve`
"""
print("compas_occ.geometry.nurbs.from_points")

p = len(points)
weights = [1.0] * p
degree = degree if p > degree else p - 1
Expand Down

0 comments on commit db5478a

Please sign in to comment.