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 f903784 commit c6c8b11
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion npoExamples.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ graph = dag_create() %>%

graph %>% dag_render()
graph %>% dag_render(shortLabel = TRUE)
drawsDF = graph %>% dag_numpyro()
drawsDF = graph %>% dag_numpyro(mcmc = FALSE)
drawsDF %>% dagp_plot()

### greta example #5: Multiple Categorical Regression
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-dag_numpyroGamma.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
test_that("gamma Dist in Use", {
graph = dag_create() %>%
dag_node("Tree Height","x",
rhs = student(nu,mu,sigma),
data = trees$Height) %>%
dag_node("Degrees Of Freedom","nu",
rhs = gamma(2,0.1),
child = "x") %>%
dag_node("Avg Cherry Tree Height","mu",
rhs = normal(50,24.5),
child = "x") %>%
dag_node("StdDev of Observed Height","sigma",
rhs = uniform(0,50),
child = "x") %>%
dag_plate("Observation","i",
nodeLabels = "x")
mcmcCode = graph %>% dag_numpyro(mcmc = FALSE)
expect_type(mcmcCode, "character")
})

6 changes: 6 additions & 0 deletions tests/testthat/test-distributions.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ test_that("distributions have good output", {
expect_equal(uniformString, "dist.Uniform(0,8)")
studentString = causact::student(df=3,mu=8,sigma=7)
expect_equal(studentString, "dist.StudentT(3,8,7)")
poissonString = causact::poisson(lambda = 9)
expect_equal(poissonString, "dist.Poisson(9)")
logNorm = causact::lognormal(meanlog = 9, 10)
expect_equal(logNorm, "dist.LogNormal(9,10)")
binomStr = causact::binomial("numTrials","succProb")
expect_equal(binomStr, "dist.Binomial(numTrials,succProb)")
})

0 comments on commit c6c8b11

Please sign in to comment.