Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Fleischhacker authored and Adam Fleischhacker committed Aug 9, 2023
1 parent c6c8b11 commit f762bd2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ _Accelerate Bayesian analytics workflows_ in R through interactive modelling, vi
> All introductory Bayesian models and many advanced models are well-supported in the `causact` package; using multi-variate distributions like the multi-variate normal, multi-nomial, or dirichlet distribution are harder to implement as is using directed acyclic graphs with nested or overlapping plates. Improvements to model construction for those more complex models is forthcoming.
```{r demoGif, out.width = "40%", echo = FALSE, fig.align = "center"}
knitr::include_graphics("man/figures/causactDemo.gif")
knitr::include_graphics("man/figures/introScreenshot.png")
```

This package is solely R-based, but behind the scenes, it relies on the `numpyro` Python package for Bayesian inference.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Bayesian inference.
> acyclic graphs with nested or overlapping plates. Improvements to
> model construction for those more complex models is forthcoming.
<img src="man/figures/causactDemo.gif" width="40%" style="display: block; margin: auto;" />
<img src="man/figures/introScreenshot.png" width="40%" style="display: block; margin: auto;" />

This package is solely R-based, but behind the scenes, it relies on the
`numpyro` Python package for Bayesian inference.
Expand Down
Binary file added man/figures/introScreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions npoExamples.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
### Script contains five examples from
### https://greta-stats.org/articles/example_models.html

library(tidyverse)
library(causact)

graph = dag_create() %>%
Expand All @@ -21,6 +17,9 @@ graph = dag_create() %>%
graph %>% dag_render()
drawsDF = graph %>% dag_numpyro()
drawsDF %>% dagp_plot()



drawsDF %>% dagp_plot(abbrevLabels = TRUE)
drawsDF %>% dagp_plot(densityPlot = TRUE)
drawsDF %>% dagp_plot(densityPlot = TRUE, abbrevLabels = TRUE)
Expand Down
24 changes: 24 additions & 0 deletions tests/testthat/test-dag_render2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
test_that("double plate graph can be rendered", {
renderGraph = dag_create() %>%
dag_node("# of Hot Day Beachgoers") %>%
dag_node(c("Rent by Location",
"Beachgoer Location Probability"),
obs = TRUE) %>%
dag_node(c("Revenue","Expenses","Profit"),
det = TRUE) %>%
dag_node("Bathhouse Location",
dec = TRUE) %>%
dag_edge(from = c("# of Hot Day Beachgoers",
"Beachgoer Location Probability",
"Bathhouse Location"),
to = "Revenue") %>%
dag_edge(from = c("Bathhouse Location",
"Rent by Location"),
to = "Expenses") %>%
dag_edge(from = c("Revenue","Expenses"),
to = "Profit") %>%
dag_plate("plate1","plate1",nodeLabels = "Revn") %>%
dag_plate("plate2","plate2",nodeLabels = "Expn") %>%
dag_render()
expect_type(renderGraph, "list")
})

0 comments on commit f762bd2

Please sign in to comment.