# Rstan expose\_stan\_functions and ODE stuff

**URL:** <https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185>\
**Category:** Developers\
**Created:** [December 29, 2016, 6:34pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185 "2016-12-29T18:34:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [December 29, 2016, 6:34pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185/1 "2016-12-29T18:34:46Z")

</div>

Hi!

I just stumbled in the expose\_stan\_functions.R code over these lines:

```
  # special cases
  ODE_lines <- grep("integrate_ode(", lines, fixed = TRUE)
  ODE_statements <- grep("integrate_ode(", lines, fixed = TRUE, value = TRUE)

```

I don’t quite get what is being done with the ODE stuff there. However, I think the regex should be expanded or changed as we have more integrate\_ode calls to cover:

- integrate\_ode
- integrate\_ode\_rk45
- integrate\_ode\_bdf

The last two exist in two flavors which are either in advanced or simple (advanced allows specification of tolerances); but I guess the flavors are irrelevant here. So I guess the right way to change the ODE handling code would be

```
  # special cases
  ODE_lines <- grep("integrate_ode", lines, fixed = TRUE)
  ODE_statements <- grep("integrate_ode", lines, fixed = TRUE, value = TRUE)

```

which would catch all cases.

Would be great if someone knowledgable (Ben?) could confirm this, then I am happy to file an issue and a fix for it.

Thanks!

Sebastian

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [December 29, 2016, 8:06pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185/2 "2016-12-29T20:06:23Z")

</div>

Yeah

---

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [January 1, 2017, 5:36pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185/3 "2017-01-01T17:36:00Z")

</div>

Ok. sounds easy… let me try a patch as outlined.

@Bob_Carpenter: Thanks much for creating the ticket in the stan repo to write a dedicated stan parser for generating the function definitions. I wish I could help with this, but I am not so sure as this parsing business is not quite where I am at home.

---

<div class="post-metadata">

**Author:** ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)\
**Post date:** [January 1, 2017, 5:43pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185/4 "2017-01-01T17:43:11Z")

</div>

I did it already. Might not have pushed yet.

---

<div class="post-metadata">

**Author:** ![wds15](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/wds15/32/908_2.png) [@wds15](https://discourse.mc-stan.org/u/wds15)\
**Post date:** [January 1, 2017, 5:50pm UTC](https://discourse.mc-stan.org/t/rstan-expose-stan-functions-and-ode-stuff/185/5 "2017-01-01T17:50:17Z")

</div>

Great… no its not yet on github, but no hurry; next time I file the patch straight away I suppose.
