Tolerance
- class compas.tolerance.Tolerance[source]
Bases:
DataTolerance settings for geometric operations.
- Parameters:
- unit{“M”, “MM”}, optional
The unit of the tolerance settings.
- absolutefloat, optional
The absolute tolerance. Default is
ABSOLUTE.- relativefloat, optional
The relative tolerance. Default is
RELATIVE.- angularfloat, optional
The angular tolerance. Default is
ANGULAR.- approximationfloat, optional
The tolerance used in approximation processes. Default is
APPROXIMATION.- precisionint, optional
The precision used when converting numbers to strings. Default is
PRECISION.- lineardeflectionfloat, optional
The maximum distance between a curve/surface and its polygonal approximation. Default is
LINEARDEFLECTION.- angulardeflectionfloat, optional
The maximum curvature deviation. Default is
ANGULARDEFLECTION.- namestr, optional
The name of the tolerance settings.
- Attributes:
- unit{“M”, “MM”}
The unit of the tolerance settings.
- absolutefloat
The absolute tolerance.
- relativefloat
The relative tolerance.
- angularfloat
The angular tolerance.
- approximationfloat
The tolerance used in approximation processes.
- precisionint
The precision used when converting numbers to strings. Positive numbers correspond to the number of digits after the decimal point. Negative numbers correspond to the number of digits before the decimal point. Zero corresponds to integer precision. Therefore, the higher the number the higher the precision.
- lineardeflectionfloat
The maximum distance between a curve or surface and its polygonal approximation.
Notes
The absolute tolerance is used to determine when a number is small enough to be considered zero. The relative tolerance determines the allowable deviation between two values for the values to be considered equal. The relative tolerance is defined as a fraction of one of the two values. This value is called the “true value”. By convention, the second value is considered the “true value” by the comparison functions of this class.
Each call to
Tolerance(...)creates an independent instance. To modify the global tolerance settings used throughout COMPAS, use the explicit methods onTOL:TOL.update(...)- Update specific tolerance valuesTOL.reset()- Reset all values to defaultsTOL.temporary(...)- Context manager for temporary changes
Examples
Create an independent tolerance instance:
>>> tol = Tolerance(absolute=0.01) >>> tol.absolute 0.01
The global TOL is separate:
>>> from compas.tolerance import TOL >>> TOL.absolute # unchanged 1e-09
Modify global state explicitly:
>>> TOL.update(absolute=0.001) >>> TOL.absolute 0.001 >>> TOL.reset()
Methods
Compare two values.
Format a number as a string.
Compute the geometric key of a point.
Compute the geometric key of a point in the XY plane.
Check if two lists of values are element-wise close enough to be considered equal.
Check if an angle is close enough to zero to be considered zero.
Check if two angles are close enough to be considered equal.
Check if a value is between two other values.
Check if two values are close enough to be considered equal.
Check if a value can be considered a strictly negative number.
Check if a value can be considered a strictly positive number.
Check if a value is close enough to zero to be considered zero.
Compute the precision from a given tolerance.
Reset all precision settings to their default values.
Context manager for temporarily changing tolerance settings.
Compute the tolerance for a comparison.
Update tolerance settings.
Update the tolerance from the key-value pairs found in a dict.
Inherited Methods
Converts the instance to a string.
Make an independent copy of the data object.
Construct an object of this type from a JSON file.
Construct an object of this type from a JSON string.
Compute a hash of the data for comparison during version control using the sha256 algorithm.
Convert an object to its native data representation and save it to a JSON file.
Convert an object to its native data representation and save it to a JSON string.
Validate the data against the object's data schema.