Skip to content

Commit 89ed622

Browse files
committed
Handle degenerate LineBox when there are no points
Something weird seems to be happening in LineBox generation for Asymptote when it handles TicksStyle = {}, the default TickStyle We get: draw(, rgb(0.6, 0.24, 0.56327)+linewidth(0.66667)); Because there are no points. Also TicksStyle handling seems weird since we shouldn't try to create LineBox in the first place.
1 parent 3b3bd94 commit 89ed622

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

mathics/builtin/box/graphics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,9 @@ def extent(self):
10341034

10351035

10361036
class LineBox(_Polyline):
1037-
# Boxing methods for a list of Line.
1037+
"""
1038+
Boxing methods for a list of Lines.
1039+
"""
10381040

10391041
def init(self, graphics, style, item=None, lines=None):
10401042
super(LineBox, self).init(graphics, item, style)

mathics/builtin/drawing/plot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,9 @@ def _apply_fn(self, f: Callable, x_value):
23482348

23492349
class ParametricPlot(_Plot):
23502350
"""
2351-
<url>:WMA link: https://reference.wolfram.com/language/ref/ParametricPlot.html</url>
2351+
<url>
2352+
:WMA link
2353+
: https://reference.wolfram.com/language/ref/ParametricPlot.html</url>
23522354
<dl>
23532355
<dt>'ParametricPlot[{$f_x$, $f_y$}, {$u$, $umin$, $umax$}]'
23542356
<dd>plots a parametric function $f$ with the parameter $u$ ranging from $umin$ to $umax$.

mathics/builtin/graphics.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,14 @@ def convert(content):
343343

344344

345345
class _Polyline(_GraphicsElementBox):
346+
"""
347+
A structure containing a list of line segments
348+
stored in ``self.lines`` created from
349+
a list of points.
350+
351+
Lines are formed by pairs of consecutive point.
352+
"""
353+
346354
def do_init(self, graphics, points):
347355
if not points.has_form("List", None):
348356
raise BoxExpressionError
@@ -356,6 +364,10 @@ def do_init(self, graphics, points):
356364
):
357365
elements = points.elements
358366
self.multi_parts = True
367+
elif len(points.elements) == 0:
368+
# Ensure there are no line segments if there are no points.
369+
self.lines = []
370+
return
359371
else:
360372
elements = [ListExpression(*points.elements)]
361373
self.multi_parts = False

0 commit comments

Comments
 (0)