|  |  |  | @ -2,6 +2,7 @@ | 
			
		
	
		
			
				
					|  |  |  |  | import bz2 | 
			
		
	
		
			
				
					|  |  |  |  | import os | 
			
		
	
		
			
				
					|  |  |  |  | import sys | 
			
		
	
		
			
				
					|  |  |  |  | import math | 
			
		
	
		
			
				
					|  |  |  |  | import numbers | 
			
		
	
		
			
				
					|  |  |  |  | import dictdiffer | 
			
		
	
		
			
				
					|  |  |  |  | from collections import Counter | 
			
		
	
	
		
			
				
					|  |  |  | @ -82,10 +83,12 @@ def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=Non | 
			
		
	
		
			
				
					|  |  |  |  |       dd = dictdiffer.diff(msg1_dict, msg2_dict, ignore=ignore_fields) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |       # Dictdiffer only supports relative tolerance, we also want to check for absolute | 
			
		
	
		
			
				
					|  |  |  |  |       # TODO: add this to dictdiffer | 
			
		
	
		
			
				
					|  |  |  |  |       def outside_tolerance(diff): | 
			
		
	
		
			
				
					|  |  |  |  |         if diff[0] == "change": | 
			
		
	
		
			
				
					|  |  |  |  |           a, b = diff[2] | 
			
		
	
		
			
				
					|  |  |  |  |           if isinstance(a, numbers.Number) and isinstance(b, numbers.Number): | 
			
		
	
		
			
				
					|  |  |  |  |           finite = math.isfinite(a) and math.isfinite(b) | 
			
		
	
		
			
				
					|  |  |  |  |           if finite and isinstance(a, numbers.Number) and isinstance(b, numbers.Number): | 
			
		
	
		
			
				
					|  |  |  |  |             return abs(a - b) > max(tolerance, tolerance * max(abs(a), abs(b))) | 
			
		
	
		
			
				
					|  |  |  |  |         return True | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  |  | 
 |