Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Svg rasterize (rebased) #2044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 24, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fixed: compare_images for older numpy versions. added: backend_pdf al…
…lows numpy.float32 in pdfRepr
  • Loading branch information
Michael Welter authored and mdboom committed May 24, 2013
commit c39d9dc0932eaaa271225a611d48780a14391dcc
30 changes: 30 additions & 0 deletions lib/matplotlib/testing/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,36 @@ def compare_images( expected, actual, tol, in_decorator=False ):
expectedImage = expectedImage.astype(np.int16)
actualImage = actualImage.astype(np.int16)

# compare the resulting image histogram functions
expected_version = version.LooseVersion("1.6")
found_version = version.LooseVersion(np.__version__)

# On Numpy 1.6, we can use bincount with minlength, which is much faster than
# using histogram
if found_version >= expected_version:
rms = 0

for i in xrange(0, 3):
h1p = expectedImage[:,:,i]
h2p = actualImage[:,:,i]

h1h = np.bincount(h1p.ravel(), minlength=256)
h2h = np.bincount(h2p.ravel(), minlength=256)

rms += np.sum(np.power((h1h-h2h), 2))
else:
rms = 0
ns = np.arange(257)

for i in xrange(0, 3):
h1p = expectedImage[:,:,i]
h2p = actualImage[:,:,i]

h1h = np.histogram(h1p, bins=ns)[0]
h2h = np.histogram(h2p, bins=ns)[0]

rms += np.sum(np.power((h1h-h2h), 2))

rms = calculate_rms(expectedImage, actualImage)

diff_image = make_test_filename(actual, 'failed-diff')
Expand Down