8000 Replace pgf image-streaming warning by error. · matplotlib/matplotlib@9ff8910 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ff8910

Browse files
committed
Replace pgf image-streaming warning by error.
Saving a pgf file with images to an in-memory buffer (`import io; imshow([[1, 2]]); savefig(io.BytesIO(), format="pgf")`) currently warns that this is not possible (because the image needs to be written to the filesyste), but in fact an exception gets raised immediately after when trying to construct `Path(self.fh.name)`, so we may as well replace the original warning by an exception.
1 parent de2ea8b commit 9ff8910

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/matplotlib/backends/backend_pgf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,9 +624,9 @@ def draw_image(self, gc, x, y, im, transform=None):
624624
return
625625

626626
if not os.path.exists(getattr(self.fh, "name", "")):
627-
_api.warn_external(
627+
raise ValueError(
628628
"streamed pgf-code does not support raster graphics, consider "
629-
"using the pgf-to-pdf option.")
629+
"using the pgf-to-pdf option")
630630

631631
# save the images to png files
632632
path = pathlib.Path(self.fh.name)

0 commit comments

Comments
 (0)
0