pints icon indicating copy to clipboard operation
pints copied to clipboard

Explain in documentation what if forward model fails

Open chonlei opened this issue 6 years ago • 9 comments

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).

chonlei avatar Apr 18 '19 00:04 chonlei

Good point. Let's think about this :-)

MichaelClerx avatar Apr 18 '19 09:04 MichaelClerx

This was discussed in https://github.com/pints-team/pints/issues/251

MichaelClerx avatar Sep 24 '19 14:09 MichaelClerx

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

MichaelClerx avatar Sep 24 '19 14:09 MichaelClerx

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.

chonlei avatar Sep 24 '19 16:09 chonlei

That's right

MichaelClerx avatar Sep 24 '19 18:09 MichaelClerx

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

MichaelClerx avatar Sep 24 '19 18:09 MichaelClerx

@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

MichaelClerx avatar Nov 05 '19 11:11 MichaelClerx

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

martinjrobins avatar Nov 05 '19 16:11 martinjrobins

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?)

MichaelClerx avatar Nov 05 '19 18:11 MichaelClerx