8000 compare: Simplify and speed up sum of squares algorithm. · matplotlib/matplotlib@62a548d · GitHub
[go: up one dir, main page]

Skip to content

Commit 62a548d

Browse files
pelsonmgiuca-google
authored andcommitted
compare: Simplify and speed up sum of squares algorithm.
1 parent 4e12012 commit 62a548d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/testing/compare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def calculate_rms(expectedImage, actualImage):
263263
else:
264264
histogram = np.histogram(absDiffImage, bins=np.arange(257))[0]
265265

266-
sumOfSquares = sum(count*(i**2) for i, count in enumerate(histogram))
266+
sumOfSquares = np.sum(histogram * np.arange(len(histogram))**2)
267267
rms = np.sqrt(float(sumOfSquares) / num_values)
268268

269269
return rms

0 commit comments

Comments
 (0)
0