>From 309c93c2e71a7ef8d70deaf1f4d0c6adc77a0472 Mon Sep 17 00:00:00 2001 From: Michael Welter Date: 2012年8月26日 10:10:46 +0200 Subject: [PATCH 1/2] fixed: compare_images for older numpy versions. added: backend_pdf allows numpy.float32 in pdfRepr --- lib/matplotlib/backends/backend_pdf.py | 2 +- lib/matplotlib/testing/compare.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/backends/backend_pdf.py b/lib/matplotlib/backends/backend_pdf.py index 4cd8308..7acaddd 100644 --- a/lib/matplotlib/backends/backend_pdf.py +++ b/lib/matplotlib/backends/backend_pdf.py @@ -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.float32)): if not np.isfinite(obj): raise ValueError("Can only output finite numbers in PDF") r = ("%.10f" % obj).encode('ascii') diff --git a/lib/matplotlib/testing/compare.py b/lib/matplotlib/testing/compare.py index abd4f4f..8563147 100644 --- a/lib/matplotlib/testing/compare.py +++ b/lib/matplotlib/testing/compare.py @@ -308,8 +308,8 @@ def compare_images( expected, actual, tol, in_decorator=False ): h1p = expectedImage[:,:,i] h2p = actualImage[:,:,i] - h1h = np.histogram(h1p, bins=bins)[0] - h2h = np.histogram(h2p, bins=bins)[0] + h1h = np.histogram(h1p, bins=ns)[0] + h2h = np.histogram(h2p, bins=ns)[0] rms += np.sum(np.power((h1h-h2h), 2)) -- 1.7.4.1

AltStyle によって変換されたページ (->オリジナル) /