epiverse-trace / quickfit

[SUSPENDED] Toolbox of model fitting helper functions
https://epiverse-trace.github.io/quickfit/
Other
2 stars 1 forks source link

Add functions to check fn req args #18

Closed pratikunterwegs closed 7 months ago

pratikunterwegs commented 7 months ago

This PR adds two helper functions test_fn_req_args() and test_fn_num_out() to check that a function has the expected number of required arguments, and that a function returns numeric output of the same length as the input, respectively. Documentation and tests are included.

These function are borrowed from the implementation in {cfr}, but differ:

  1. The dependency on {checkmate} is removed;
  2. test_fn_num_out() errors when the input argument fn is not a function (the {cfr} implementation instead returns FALSE). This has to do with the convenience of storing the output of fn(<vector>) before testing other conditions on this output.
joshwlambert commented 7 months ago

Looks great, thanks for adding these functions. Just a couple of small comments.