traitecoevo / plant

Trait-Driven Models of Ecology and Evolution :evergreen_tree:
https://traitecoevo.github.io/plant
53 stars 20 forks source link

Environment Drivers Refactor + Documentation #340

Closed devmitch closed 2 years ago

devmitch commented 2 years ago

Since #334 abstracted ExtrinsicDrivers into its own class, we can now clean up the old driver API in Environment and replace all the methods with an exposed ExtrinsicDrivers object. #334 also included a smarter way to set up drivers, which is also included in this PR: Default (rainfall = 1):

env <- make_environment("FF16w")

Constant:

env <- make_environment("FF16w", rainfall=3.14)

Variable:

x_pts <- seq(0, 200, 1)
rain <- list(
  x = x_pts,
  y = 1 + sin(x_pts)
)
env <- make_environment("FF16w", rainfall=rain)

Evaluation is now done like this:

env$extrinsic_drivers$evaluate("rainfall", 5.634)
env$extrinsic_drivers$evaluate_range("rainfall", c(5, 1.2, 78.345))

These examples have also been included in a new vignette at vignettes/extrinsic_drivers.Rmd. It is only a draft as of now. I can't seem to knit R code or embed images (other vignettes use a figure/ directory, which I can't seem to find...). I would appreciate your input on the documentation!

codecov-commenter commented 2 years ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (develop@974b17b). Click here to learn what that means. The diff coverage is n/a.

@@            Coverage Diff             @@
##             develop     #340   +/-   ##
==========================================
  Coverage           ?   79.62%           
==========================================
  Files              ?       97           
  Lines              ?     8900           
  Branches           ?        0           
==========================================
  Hits               ?     7087           
  Misses             ?     1813           
  Partials           ?        0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

aornugent commented 2 years ago

This looks great @devmitch! I forget exactly the workflow for rebuilding the website, but can knit your vignette successfully.

dfalster commented 2 years ago

Hi @devmitch

Vignette is very good! I just added some minor changes. You can test rendering using

rmarkdown::render("vignettes//strategy_FF16.Rmd")

I've used another vignette above, as currently this branch isn't compiling. E.g. see

https://github.com/traitecoevo/plant/runs/7160778238?check_suite_focus=true

Can you follow up on the compilation?

dfalster commented 2 years ago

I'll post a separate issue about updating the vignettes in general. Bunch are out of date.

dfalster commented 2 years ago

Also, @devmitch

How does this branch relate to https://github.com/traitecoevo/plant/tree/doc-updates?

devmitch commented 2 years ago

Also, @devmitch

How does this branch relate to https://github.com/traitecoevo/plant/tree/doc-updates?

Pretty sure that branch contains an outdated and incomplete version of the vignette I have pushed on this branch.

Looking very good.

However, this branch is currently not compiling for me, or passing GH actions.

Hopefully everything should be compiling/passing now, I'm going to attempt the get_state changes on another branch/PR just to separate concerns. I'll merge this in once the GH actions pass...

dfalster commented 2 years ago

Feel free to merge