Skip to content

Commit

Permalink
Handle numpy array scalars in pdfRepr
Browse files Browse the repository at this point in the history
  • Loading branch information
jkseppan authored and mdboom committed Aug 28, 2012
1 parent 85e3d4b commit cfc1d81
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/matplotlib/backends/backend_pdf.py
Expand Up @@ -139,7 +139,7 @@ def pdfRepr(obj):
# Floats. PDF does not have exponential notation (1.0e-10) so we
# need to use %f with some precision. Perhaps the precision
# should adapt to the magnitude of the number?
elif isinstance(obj, float):
elif isinstance(obj, (float, np.floating)):
if not np.isfinite(obj):
raise ValueError("Can only output finite numbers in PDF")
r = ("%.10f" % obj).encode('ascii')
Expand All @@ -151,7 +151,7 @@ def pdfRepr(obj):
return [b'false', b'true'][obj]

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

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

0 comments on commit cfc1d81

Please sign in to comment.