pints
pints copied to clipboard
Explain in documentation what if forward model fails
Add a sentence in doc saying what PINTS expect the model to return if it cannot solve the given set of parameters. E.g. it is expecting None or np.NaN or something else. An example would even be better, e.g. maybe just say one can do return np.full((len(times), self.n_output()), np.inf).
Good point. Let's think about this :-)
This was discussed in https://github.com/pints-team/pints/issues/251
Things to do:
- [ ] Update docs to mention models must return time series of correct size, or decided they can do something like return NaN or Inf
- [ ] Update docs of problem accordingly
- [ ] Make sure all error measures return +inf, loglikelihoods return -inf if this occurs
In fact, on that note (https://github.com/pints-team/pints/issues/794#issuecomment-534581881)
or decided they can do something like return NaN or Inf
If the bit of code handling this hasn't changed in PINTS, then returning simply NaN or Inf will throw an error -- I can't remember on top of my head, but it would be something like size/shape mismatch. So even if the model is going to return NaN or Inf, it needs to be a time series of correct size of NaNs or Infs.
That's right
If we want to give models the option to do something other than return the expected time series, that should be raising some kind of exception, I guess. Not returning an object of a different type
@martinjrobins @ben18785 what do you think, should we require forward models to return an array of infs? The alternative would be to let them raise a special exception which we'd then have to catch in all the errors & likelihoods
why infs? Wouldn't an array of nan's be more suitable. Is this so you don't have to have any special handling code in PINTS? I'm leaning towards an array of nan's of infs, so you can adequitly describe solutions where the solve failed after some time point t0
Nans are fine too.
I'm wondering if it wouldn't be better to add try/catch blocks to all our call and evaluateS1() methods, so that users don't have to generate an array of nans (plus matrix of nan derivatives?)