33Unit tests from mathics.builtin.drawing.plot
44"""
55
6- from mathics .core .util import print_expr_tree
76from test .helper import check_evaluation , session
87
98import pytest
109
10+ from mathics .core .util import print_expr_tree
11+
1112
1213def test__listplot ():
1314 """tests for module builtin.drawing.plot._ListPlot"""
@@ -203,23 +204,28 @@ def test_plot(str_expr, msgs, str_expected, fail_msg):
203204 expected_messages = msgs ,
204205 )
205206
207+
206208#
207209# Call plotting functions and examine the structure of the output
208210# TODO: check_structure is a little fragile and a little hard to debug. Imrovements:
209211# some indication of where in the structure the error is occurring - e.g. tree coordinates?
210- #
212+ #
211213#
212214
213215
214216def check_structure (result , expected ):
215217 """Check that expected is a prefix of result at every node"""
216- #print_expr_tree(result)
217- #print_expr_tree(expected)
218+ # print_expr_tree(result)
219+ # print_expr_tree(expected)
218220 assert result .get_head () == expected .get_head (), "heads must match"
219- assert hasattr (result , "elements" ) == hasattr (expected , "elements" ), "either both or none must have elements"
221+ assert hasattr (result , "elements" ) == hasattr (
222+ expected , "elements"
223+ ), "either both or none must have elements"
220224 if hasattr (expected , "elements" ):
221225 for i , e in enumerate (expected .elements ):
222- assert len (result .elements ) > i , f"expected at least { i } elements, found only { len (result .elements )} "
226+ assert (
227+ len (result .elements ) > i
228+ ), f"expected at least { i } elements, found only { len (result .elements )} "
223229 check_structure (result .elements [i ], e )
224230 else :
225231 assert str (result ) == str (expected ), f"leaves don't match"
@@ -237,7 +243,8 @@ def check_structure(result, expected):
237243 PlotPoints->{2,2},
238244 MaxRecursion->0
239245 ]
240- """ , """
246+ """ ,
247+ """
241248 Graphics3D[
242249 {
243250 Polygon[{{0.0,0.0,0.0}, {0.0,0.5,0.5}, {0.5,0.0,0.5}}],
@@ -254,7 +261,7 @@ def check_structure(result, expected):
254261 PlotRangePadding -> Automatic,
255262 TicksStyle -> {}
256263 ]
257- """
264+ """ ,
258265 ),
259266 # Plot3D, all non-default options
260267 (
@@ -275,7 +282,8 @@ def check_structure(result, expected):
275282 PlotRangePadding -> {1,2},
276283 TicksStyle -> {Purple,White}
277284 ]
278- """ , """
285+ """ ,
286+ """
279287 Graphics3D[
280288 {
281289 Polygon[{{0.0,0.0,0.0}, {0.0,0.5,0.5}, {0.5,0.0,0.5}}],
@@ -292,9 +300,9 @@ def check_structure(result, expected):
292300 PlotRangePadding -> {1,2},
293301 TicksStyle -> {RGBColor[0.5,0,0.5],GrayLevel[1]}
294302 ]
295- """
303+ """ ,
296304 ),
297- ]
305+ ],
298306)
299307def test_plot_structure (str_expr , str_expected ):
300308 expr = session .parse (str_expr )
0 commit comments