File tree Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Expand file tree Collapse file tree 3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 55from compas .files import GLTFContent
66from compas .tolerance import TOL
77
8+ # Temporary change the global precision in the TOL class to 12
89TOL .precision = 12
910
1011BASE_FOLDER = os .path .dirname (__file__ )
@@ -175,3 +176,7 @@ def test_gltf_content():
175176 assert len (node_0 .children ) == 0
176177 assert len (content .nodes ) == 1
177178 assert len (scene .nodes ) == 1
179+
180+
181+ # Reset the precision to its default value
182+ TOL .precision = TOL .PRECISION
Original file line number Diff line number Diff line change 55from compas .files import STL
66from compas .tolerance import TOL
77
8+ # Temporary change the global precision in the TOL class to 12
89TOL .precision = 12
910
1011BASE_FOLDER = os .path .dirname (__file__ )
@@ -43,3 +44,7 @@ def test_binary_read_write_fidelity():
4344 mesh_2 = Mesh .from_stl (fp )
4445 assert mesh .adjacency == mesh_2 .adjacency
4546 assert mesh .vertex == mesh_2 .vertex
47+
48+
49+ # Reset the precision to its default value
50+ TOL .precision = TOL .PRECISION
Original file line number Diff line number Diff line change 1+ from compas .tolerance import TOL
2+ from compas .tolerance import Tolerance
3+ from compas .geometry import Point
4+
5+
6+ def test_tolerance_default_tolerance ():
7+ assert TOL .precision == Tolerance .PRECISION
8+ assert TOL .precision == 3
9+
10+
11+ def test_tolerance_format_number ():
12+ assert TOL .format_number (0 , precision = 3 ) == "0.000"
13+ assert TOL .format_number (0.5 , precision = 3 ) == "0.500"
14+ assert TOL .format_number (float (0 ), precision = 3 ) == "0.000"
15+
16+
17+ def test_tolerance_format_number_with_default_precision ():
18+ assert TOL .format_number (0 ) == "0.000"
19+ assert TOL .format_number (0.5 ) == "0.500"
20+ assert TOL .format_number (float (0 )) == "0.000"
21+
22+
23+ def test_tolerance_format_point ():
24+ point = Point (0 , 0 , 0 )
25+ assert str (point ) == "Point(x=0.000, y=0.000, z=0.000)"
You can’t perform that action at this time.
0 commit comments