Skip to content

Commit cfc1d81

Browse files
jkseppanmdboom
authored andcommitted
Handle numpy array scalars in pdfRepr
1 parent 85e3d4b commit cfc1d81

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def pdfRepr(obj):
139139
# Floats. PDF does not have exponential notation (1.0e-10) so we
140140
# need to use %f with some precision. Perhaps the precision
141141
# should adapt to the magnitude of the number?
142-
elif isinstance(obj, float):
142+
elif isinstance(obj, (float, np.floating)):
143143
if not np.isfinite(obj):
144144
raise ValueError("Can only output finite numbers in PDF")
145145
r = ("%.10f" % obj).encode('ascii')
@@ -151,7 +151,7 @@ def pdfRepr(obj):
151151
return [b'false', b'true'][obj]
152152

153153
# Integers are written as such.
154-
elif isinstance(obj, (int, long)):
154+
elif isinstance(obj, (int, long, np.integer)):
155155
return ("%d" % obj).encode('ascii')
156156

157157
# Unicode strings are encoded in UTF-16BE with byte-order mark.

0 commit comments

Comments
 (0)