gavinsimpson/coenocliner

The argument names for response functions are getting silly...

Closed this issue · 2 comments

At the moment we have arg1 and arg2 for parameter arg along gradients 1 and 2 respectively. This is just not user friendly!

Instead, rewrite the response distribution functions Beta() and Gaussian() so that they have definition:

function(x, y = NULL, px, py = NULL)

where x and y are the first and second gradients respectively and px and py are each a list containing parameters for species on the first or second gradients. In the case of Gaussian() we would have names

  • opt
  • tol
  • h

and for Beta() we'd have names

  • A0 (or A - haven't quite decided how closely to follow notation in Minchin (1987) )
  • m
  • r
  • alpha
  • gamma

This way the parameters map to arguments without needing to have an indicator as to which gradient each pertains in the name.

Commit 3992a6c does the hard work of implementing this although things fail nastily in some cases if the parameter lists are not supplied with correct names. By nastily I mean the function runs but you get NAs, sometimes silently. Bad!

Hence before I close this out checks on argument names in Gaussian() and Beta() are needed.

7b4619f implements input checking in Gaussian() and Beta() and 16dfd1a implements a suite a unit tests to ensure failure with incorrect input.

I assume these unit tests won't cover every possible issue but they are good enough for now to close this issue.