Skip to content

Commit f3442b7

Browse files
committed
Use .8g format for reals to avoid spurious diffs
1 parent 1d96285 commit f3442b7

36 files changed

+30049
-30045
lines changed

mathics/core/util.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from platform import python_implementation
1010
from typing import Optional
1111

12-
from mathics.core.atoms import NumericArray
12+
from mathics.core.atoms import NumericArray, MachineReal
1313
from mathics.core.symbols import Symbol
1414

1515
IS_PYPY = python_implementation() == "PyPy"
@@ -129,7 +129,11 @@ def print_expression_tree(expr, indent="", marker=lambda expr: "", file=None):
129129
if isinstance(expr, Symbol):
130130
print(f"{indent}{marker(expr)}{expr}", file=file)
131131
elif not hasattr(expr, "elements"):
132-
print(f"{indent}{marker(expr)}{expr.get_head()} {expr}", file=file)
132+
if isinstance(expr, MachineReal):
133+
value = f"{expr.value:.8g}"
134+
else:
135+
value = str(expr)
136+
print(f"{indent}{marker(expr)}{expr.get_head()} {value}", file=file)
133137
if isinstance(expr, NumericArray):
134138
# numpy provides an abbreviated version of the array
135139
na_str = str(expr.value)

test/builtin/drawing/test_plot_detail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ def run_tests():
170170
except AssertionError:
171171
print("FAIL")
172172

173-
# make_ref_files()
173+
#make_ref_files()
174174
run_tests()

test/builtin/drawing/test_plot_detail_ref/barchart-cls-def.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,51 @@ System`Graphics
88
System`Style
99
System`Rectangle
1010
System`List
11-
System`Real 0.15999999999999998
11+
System`Real 0.16
1212
System`Integer 0
1313
System`List
1414
System`Real 1.06
15-
System`Real 3.0
15+
System`Real 3
1616
System`RGBColor
17-
System`Real 0.4470588235294118
18-
System`Real 0.792156862745098
19-
System`Real 0.8666666666666667
17+
System`Real 0.44705882
18+
System`Real 0.79215686
19+
System`Real 0.86666667
2020
System`Style
2121
System`Rectangle
2222
System`List
2323
System`Real 1.12
2424
System`Integer 0
2525
System`List
2626
System`Real 2.02
27-
System`Real 5.0
27+
System`Real 5
2828
System`RGBColor
29-
System`Real 0.4470588235294118
30-
System`Real 0.792156862745098
31-
System`Real 0.8666666666666667
29+
System`Real 0.44705882
30+
System`Real 0.79215686
31+
System`Real 0.86666667
3232
System`Style
3333
System`Rectangle
3434
System`List
3535
System`Real 2.08
3636
System`Integer 0
3737
System`List
3838
System`Real 2.98
39-
System`Real 2.0
39+
System`Real 2
4040
System`RGBColor
41-
System`Real 0.4470588235294118
42-
System`Real 0.792156862745098
43-
System`Real 0.8666666666666667
41+
System`Real 0.44705882
42+
System`Real 0.79215686
43+
System`Real 0.86666667
4444
System`Style
4545
System`Rectangle
4646
System`List
4747
System`Real 3.04
4848
System`Integer 0
4949
System`List
5050
System`Real 3.94
51-
System`Real 7.0
51+
System`Real 7
5252
System`RGBColor
53-
System`Real 0.4470588235294118
54-
System`Real 0.792156862745098
55-
System`Real 0.8666666666666667
53+
System`Real 0.44705882
54+
System`Real 0.79215686
55+
System`Real 0.86666667
5656
System`Line
5757
System`List
5858
System`List
@@ -69,10 +69,10 @@ System`Graphics
6969
System`Line
7070
System`List
7171
System`List
72-
System`Real 0.15999999999999998
72+
System`Real 0.16
7373
System`Integer 0
7474
System`List
75-
System`Real 0.15999999999999998
75+
System`Real 0.16
7676
System`Real -0.2
7777
System`Line
7878
System`List
@@ -157,7 +157,7 @@ System`Graphics
157157
System`List
158158
System`Rule
159159
System`ImageMargins
160-
System`Real 0.0
160+
System`Real 0
161161
System`Rule
162162
System`ImagePadding
163163
System`All
@@ -184,7 +184,7 @@ System`Graphics
184184
System`Real 3.94
185185
System`List
186186
System`Integer 0
187-
System`Real 7.0
187+
System`Real 7
188188
System`Rule
189189
System`PlotRangeClipping
190190
System`False

test/builtin/drawing/test_plot_detail_ref/barchart-cls-opt.txt

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,51 +8,51 @@ System`Graphics
88
System`Style
99
System`Rectangle
1010
System`List
11-
System`Real 0.15999999999999998
11+
System`Real 0.16
1212
System`Integer 0
1313
System`List
1414
System`Real 1.06
15-
System`Real 3.0
15+
System`Real 3
1616
System`RGBColor
17-
System`Real 0.4470588235294118
18-
System`Real 0.792156862745098
19-
System`Real 0.8666666666666667
17+
System`Real 0.44705882
18+
System`Real 0.79215686
19+
System`Real 0.86666667
2020
System`Style
2121
System`Rectangle
2222
System`List
2323
System`Real 1.12
2424
System`Integer 0
2525
System`List
2626
System`Real 2.02
27-
System`Real 5.0
27+
System`Real 5
2828
System`RGBColor
29-
System`Real 0.4470588235294118
30-
System`Real 0.792156862745098
31-
System`Real 0.8666666666666667
29+
System`Real 0.44705882
30+
System`Real 0.79215686
31+
System`Real 0.86666667
3232
System`Style
3333
System`Rectangle
3434
System`List
3535
System`Real 2.08
3636
System`Integer 0
3737
System`List
3838
System`Real 2.98
39-
System`Real 2.0
39+
System`Real 2
4040
System`RGBColor
41-
System`Real 0.4470588235294118
42-
System`Real 0.792156862745098
43-
System`Real 0.8666666666666667
41+
System`Real 0.44705882
42+
System`Real 0.79215686
43+
System`Real 0.86666667
4444
System`Style
4545
System`Rectangle
4646
System`List
4747
System`Real 3.04
4848
System`Integer 0
4949
System`List
5050
System`Real 3.94
51-
System`Real 7.0
51+
System`Real 7
5252
System`RGBColor
53-
System`Real 0.4470588235294118
54-
System`Real 0.792156862745098
55-
System`Real 0.8666666666666667
53+
System`Real 0.44705882
54+
System`Real 0.79215686
55+
System`Real 0.86666667
5656
System`Line
5757
System`List
5858
System`List
@@ -69,10 +69,10 @@ System`Graphics
6969
System`Line
7070
System`List
7171
System`List
72-
System`Real 0.15999999999999998
72+
System`Real 0.16
7373
System`Integer 0
7474
System`List
75-
System`Real 0.15999999999999998
75+
System`Real 0.16
7676
System`Real -0.2
7777
System`Line
7878
System`List
@@ -159,7 +159,7 @@ System`Graphics
159159
System`List
160160
System`Rule
161161
System`ImageMargins
162-
System`Real 0.0
162+
System`Real 0
163163
System`Rule
164164
System`ImagePadding
165165
System`All
@@ -189,7 +189,7 @@ System`Graphics
189189
System`Real 3.94
190190
System`List
191191
System`Integer 0
192-
System`Real 7.0
192+
System`Real 7
193193
System`Rule
194194
System`PlotRangeClipping
195195
System`False

test/builtin/drawing/test_plot_detail_ref/complexplot-vec-def.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ System`Graphics
9191
System`List
9292
System`Rule
9393
System`ImageMargins
94-
System`Real 0.0
94+
System`Real 0
9595
System`Rule
9696
System`ImagePadding
9797
System`All

test/builtin/drawing/test_plot_detail_ref/complexplot-vec-opt.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ System`Graphics
351351
System`List
352352
System`Rule
353353
System`ImageMargins
354-
System`Real 0.0
354+
System`Real 0
355355
System`Rule
356356
System`ImagePadding
357357
System`All

test/builtin/drawing/test_plot_detail_ref/complexplot3d-vec-def.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ System`Graphics3D
124124
System`List
125125
System`Rule
126126
System`ImageMargins
127-
System`Real 0.0
127+
System`Real 0
128128
System`Rule
129129
System`ImagePadding
130130
System`All
@@ -196,7 +196,7 @@ System`Graphics3D
196196
System`List
197197
System`Real 1.3
198198
System`Real -2.4
199-
System`Real 2.0
199+
System`Real 2
200200
System`Rule
201201
System`ViewProjection
202202
System`Automatic

test/builtin/drawing/test_plot_detail_ref/complexplot3d-vec-opt.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ System`Graphics3D
836836
System`List
837837
System`Rule
838838
System`ImageMargins
839-
System`Real 0.0
839+
System`Real 0
840840
System`Rule
841841
System`ImagePadding
842842
System`All
@@ -908,7 +908,7 @@ System`Graphics3D
908908
System`List
909909
System`Real 1.3
910910
System`Real -2.4
911-
System`Real 2.0
911+
System`Real 2
912912
System`Rule
913913
System`ViewProjection
914914
System`Automatic

0 commit comments

Comments
 (0)