-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
97 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# evaluate_smooths errors appropriately | ||
|
||
Can only evaluate smooths from greta arrays created with `greta.gam::smooths()` | ||
Code | ||
evaluate_smooths("thing") | ||
Condition | ||
Error in `evaluate_smooths()`: | ||
! Can only evaluate smooths from greta arrays created with `greta.gam::smooths()` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
# stop_when_dummy_in_data errors appropriately | ||
|
||
Data cannot already contain column named `dummy` | ||
i Rename existing column, perhaps to `dummy1` | ||
Code | ||
stop_when_dummy_in_data(test_df) | ||
Condition | ||
Error: | ||
! Data cannot already contain column named `dummy` | ||
i Rename existing column, perhaps to `dummy1` | ||
|
||
--- | ||
|
||
Code | ||
smooths(~ s(dummy), data = data.frame(dummy = x)) | ||
Condition | ||
Error in `jagam2greta()`: | ||
! Data cannot already contain column named `dummy` | ||
i Rename existing column, perhaps to `dummy1` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
test_that("check_if_formula works", { | ||
expect_snapshot( | ||
error = TRUE, | ||
check_if_formula("potato") | ||
) | ||
expect_snapshot( | ||
error = TRUE, | ||
check_if_formula("y~x") | ||
) | ||
expect_success( | ||
check_if_formula(y~x) | ||
) | ||
expect_success( | ||
check_if_formula(y~s(x)) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
n <- 30 | ||
x <- runif(n, 0, 10) | ||
f <- function(x) { | ||
sin(x * 2) + 1.6 * (x < 3) - 1.4 * (x > 7) | ||
} | ||
y <- f(x) + rnorm(n, 0, 0.3) | ||
x_plot <- seq(0, 10, length.out = 200) | ||
|
||
z <- smooths(~ s(x), data = data.frame(x = x)) | ||
|
||
distribution(y) <- normal(z, 0.3) | ||
|
||
test_that("evaluate_smooths errors appropriately", { | ||
expect_snapshot_error( | ||
expect_snapshot( | ||
error = TRUE, | ||
evaluate_smooths("thing") | ||
) | ||
expect_no_error( | ||
z_pred <- evaluate_smooths(z, newdata = data.frame(x = x_plot)) | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters