From e7f7f34312e400fc3433b937f322506d5d868453 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Wed, 22 Nov 2023 11:37:08 +0100 Subject: [PATCH] add example --- src/compas/tolerance.py | 44 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/compas/tolerance.py b/src/compas/tolerance.py index 1e2c0505c1e0..73eac94b73d8 100644 --- a/src/compas/tolerance.py +++ b/src/compas/tolerance.py @@ -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. @@ -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 @@ -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 @@ -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