Skip to content

Commit 7b4f260

Browse files
authored
Merge pull request #716 from Mathics3/empty-LineBox-fix
Handle degenerate LineBox when there are no points
2 parents e2c5770 + 89ed622 commit 7b4f260

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)