I have an issue for comparing two files. Basically, what I want to do is a UNIX-like diff between two files, for example:
$ diff -u left-file right-file
However my two files contain floats; and because these files were generated on distinct architectures (but computing the same things), the floating values are not exactly the same (they may differ by, say, 1e-10). But what I seek by 'diffing' the files is to find what I consider to be significant differences (for example difference is more than 1e-4); while using the UNIX command diff, I get almost all my lines containing the floating values being different! That's my problem: how can I get a resulting diff like 'diff -u' provides, but with less restrictions regarding comparison of floats?
I thought I would write a Python's script to do that, and found out the module difflib which provides diff-like comparison. But the documentation I found explains how to use it as-is (through a single method), and explains the inner objects, but I cannot find anything regarding how to customize a difflib object to meet my needs (like rewriting only the comparison method or such)... I guess a solution could be to retrieve the unified difference, and parse it 'manually' to remove my 'false' differences, by this is not elegant; I would prefer to use the already existing framework.
So, does anybody know how to customize this lib so that I can do what I seek ? Or at least point me in the right direction... If not in Python, maybe a shell script could to the job?
Any help would be greatly appreciated! Thanks in advance for your answers!