mrc-ide / odin

ᚩ A DSL for describing and solving differential equations in R
https://mrc-ide.github.io/odin
Other
104 stars 13 forks source link

Add new debug print syntax #282

Closed richfitz closed 1 year ago

richfitz commented 1 year ago

This PR adds a new syntax for getting debugging information out of an odin model by printing internal variables as the model runs.

There's quite a bit of checking still to add here - it would be fairly easy to provide a print() statement that can't be satisfied or can't compile. But that's just a case of accumulating bad cases and putting in some protection - given this is already big (and useful in scope) it's probably worth holding off on for a bit.

The main use I have for this is calling from odin.dust, so the main focus here is making sure that we get something sensible included into the intermediate model representation. Actually wiring it up is fairly straightforward. I've added a vignette at the same time as the implementation (which does make this a bit bigger) but at least provides some background for the idea. The corresponding odin.dust implementation is here: https://github.com/mrc-ide/odin.dust/pull/125

This is not implemented for the js target yet, as there is not a native sprintf that we can use - because this might be useful from wodin I'll have a separate think about that

codecov[bot] commented 1 year ago

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage :thumbsup:

Coverage data is based on head (fc50393) compared to base (fa7b074). Patch coverage: 100.00% of modified lines in pull request are covered.

:exclamation: Current head fc50393 differs from pull request most recent head 5bdb6f7. Consider uploading reports for the commit 5bdb6f7 to get more accurate results

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #282 +/- ## ========================================== Coverage 100.00% 100.00% ========================================== Files 45 46 +1 Lines 5253 5399 +146 ========================================== + Hits 5253 5399 +146 ``` | [Impacted Files](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide) | Coverage Δ | | |---|---|---| | [R/debug.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9kZWJ1Zy5S) | `100.00% <100.00%> (ø)` | | | [R/generate\_c.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9nZW5lcmF0ZV9jLlI=) | `100.00% <100.00%> (ø)` | | | [R/generate\_c\_compiled.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9nZW5lcmF0ZV9jX2NvbXBpbGVkLlI=) | `100.00% <100.00%> (ø)` | | | [R/generate\_r.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9nZW5lcmF0ZV9yLlI=) | `100.00% <100.00%> (ø)` | | | [R/ir\_deserialise.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9pcl9kZXNlcmlhbGlzZS5S) | `100.00% <100.00%> (ø)` | | | [R/ir\_parse.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9pcl9wYXJzZS5S) | `100.00% <100.00%> (ø)` | | | [R/ir\_serialise.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9pcl9zZXJpYWxpc2UuUg==) | `100.00% <100.00%> (ø)` | | | [R/misc.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9taXNjLlI=) | `100.00% <100.00%> (ø)` | | | [R/odin.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9vZGluLlI=) | `100.00% <100.00%> (ø)` | | | [R/odin\_options.R](https://codecov.io/gh/mrc-ide/odin/pull/282?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide#diff-Ui9vZGluX29wdGlvbnMuUg==) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=mrc-ide)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.