Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvanmele committed Nov 22, 2023
1 parent e99d01a commit e7f7f34
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/compas/tolerance.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,46 @@


class Tolerance(Data):
"""Tolerance settings for geometric operations."""
"""Tolerance settings for geometric operations.
Parameters
----------
unit : {"M", "MM"}, optional
The unit of the tolerance settings.
Attributes
----------
unit : {"M", "MM"}
The unit of the tolerance settings.
absolute : float
The absolute tolerance.
relative : float
The relative tolerance.
angle : float
The angle tolerance.
Examples
--------
>>> tol = Tolerance()
>>> tol.absolute
1e-06
>>> tol.relative
0.001
>>> tol.close(1, 1.000001)
True
>>> tol.close(1, 1.001)
True
>>> tol.close(1, 1.01)
False
>>> tol.zero(1e-07)
True
>>> tol.zero(1e-05)
False
"""

ABSOLUTE_TOLERANCE = 1e-6
"""float: Determines when a number is small enough to be considered zero.
Expand Down Expand Up @@ -54,7 +93,6 @@ def units(self, value):

@property
def absolute(self):
"""float: The absolute tolerance."""
if not self._absolute:
return self.ABSOLUTE_TOLERANCE
return self._absolute
Expand All @@ -65,7 +103,6 @@ def absolute(self, value):

@property
def relative(self):
"""float: The relative tolerance."""
if not self._relative:
return self.RELATIVE_TOLERANCE
return self._relative
Expand All @@ -76,7 +113,6 @@ def relative(self, value):

@property
def angle(self):
"""float: The angle tolerance."""
if not self._angle:
return self.ANGLE_TOLERANCE
return self._angle
Expand Down

0 comments on commit e7f7f34

Please sign in to comment.