manodeep / Corrfunc

⚡️⚡️⚡️Blazing fast correlation functions on the CPU.
https://corrfunc.readthedocs.io
MIT License
166 stars 51 forks source link

Change tests to better compare floats #94

Closed manodeep closed 8 years ago

manodeep commented 8 years ago

Currently, the tests report the result of diff -q between two files, one known correct and another generated by the code being tested. While convenient, this also checks the white-space changes.

For instance, now the output column order from the command-line version of the codes is different from what used to be the case. The tests get around this column order by rewriting temporary text files with the column order from the "known correct" files.

The updated tests should read in the "known correct" files, and compare integer fields exactly and the floating point fields appropriately. Thus, rmin, rmax, ravg fields and the wp, xi, pN fields should be compared different than the npairs fields. New function required in utils.c for the floating comparison (already exists in other versions of utils.c) @lgarrison do you mind updating the tests for the weighted functions accordingly? I will update the rest of the tests.

Sidenote: All floating point fields that currently exist could be compared with an absolute offset method; however, in the future, we might start comparing numbers close to 0 (in pN, for instance). Thus, in keeping with the future-compatible principle of Corrfunc, it is better to use both the relative and absolute floating point comparisons now.