HISKP-LQCD/hadron

“cf” is a type, a variable name and a member

Closed this issue · 3 comments

We have four places in the code where we use cf:

  1. In the cf class and its constructor cf().
  2. As the data member x$cf of the cf class which contains the original measurements.
  3. As function parameter where a correlation function is expected.
  4. As a data frame in matrixfit, albeit named CF there.

This has been very confusing for people new to the code.

I believe that Item 3 can be fixed with reasonable effort by doing a search-replace of \bcf\b (or \<cf\> in Vim) with say corr. Item 2 will be harder as a lot of user code depends on the name of this data member.

And then there is also CF in matrixfit which is a data frame with the correlation function (mean value).

Let's rename everything that is not the container. I.e. cf$cf should be cf$data. CF should be val or value. Err should be dval, dvalue or err if preferred. Personally I like the option of having a possible hierarchy val -> dval -> ddval.

Is there any way that we can make sure that it works after the refactoring? Replacing (regex) \$cf\b with $data sounds straightforward, but I fear that something breaks. Ideally we would have unit tests with full coverage (measured with say covr). From the package README I have the impression that the examples are not part of the covering.

Also users might use cf$cf directly in their functions. Can we accept this API break?

The d-prefix is fine with me.