Skip to content

Commit 2e3c088

Browse files
committed
Explicit error message if sage objects aren't assigned a name
1 parent 666b39f commit 2e3c088

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Text/Pandoc/Filter/Plot/Renderers/SageMath.hs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,14 @@ import sage.plot.plot3d.base as go3d
7575
import builtins
7676
# Try to concatenate 3D graphics objects first; if this doesn't work, then
7777
# concatenate all 2D graphic objects.
78-
__all_graphics = builtins.sum( (obj for obj in globals().values() if isinstance(obj, go3d.Graphics3d)), None)
79-
if __all_graphics is None:
80-
__all_graphics = builtins.sum(obj for obj in globals().values() if isinstance(obj, go.Graphics))
78+
__all_graphics = builtins.sum( (obj for obj in globals().values() if isinstance(obj, go3d.Graphics3d)))
79+
if not __all_graphics:
80+
__all_graphics = builtins.sum( (obj for obj in globals().values() if isinstance(obj, go.Graphics)))
81+
if not __all_graphics:
82+
raise RuntimeError(''.join([
83+
"No plotting objects detected. ",
84+
"Make sure that all of your plotting objects are named, e.g. `G = plot(...)` rather than just `plot(...)`. ",
85+
"This is a limitation specific to the interaction between sage and pandoc-plot."
86+
]))
8187
__all_graphics.save_image(r"#{fname}", dpi=#{dpi})
8288
|]

0 commit comments

Comments
 (0)