Skip to content

Commit

Permalink
merge pr #105: transition to testthat 3e
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored May 9, 2022
2 parents 20ca144 + 663c78e commit 6a0a4e7
Show file tree
Hide file tree
Showing 20 changed files with 1,792 additions and 76 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Suggests:
ranger,
rmarkdown,
RSQLite,
testthat (>= 2.1.0),
testthat (>= 3.0.0),
xgboost,
yaml
VignetteBuilder:
Expand All @@ -49,3 +49,4 @@ Config/Needs/website:
tidyverse/tidytemplate
Encoding: UTF-8
RoxygenNote: 7.1.1.9000
Config/testthat/edition: 3
50 changes: 50 additions & 0 deletions tests/testthat/_snaps/cubist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Returns expected dplyr formula

Code
rlang::expr_text(tf)
Output
[1] "(ifelse(nox >= 0.668, -1.11 + crim * -0.02 + nox * 21.4 + rm * \n 0.1 + age * -0.003 + dis * 2.93 + ptratio * -0.13 + b * 0.008 + \n lstat * -0.33, 0) + ifelse(lstat >= 9.59 & nox < 0.668, 23.57 + \n crim * 0.05 + nox * -5.2 + rm * 3.1 + age * -0.048 + dis * \n -0.81 + rad * 0.02 + tax * -0.0041 + ptratio * -0.71 + b * \n 0.01 + lstat * -0.15, 0) + ifelse(lstat < 9.59 & rm < 6.226, \n 1.18 + crim * 3.83 + rm * 4.3 + age * -0.06 + dis * -0.09 + \n tax * -0.003 + ptratio * -0.08 + lstat * -0.11, 0) + \n ifelse(lstat < 9.59 & rm >= 6.226, -4.71 + crim * 2.22 + \n zn * 0.008 + nox * -1.7 + rm * 9.2 + age * -0.04 + dis * \n -0.71 + rad * 0.03 + tax * -0.0182 + ptratio * -0.72 + \n lstat * -0.83, 0) + ifelse(dis < 1.755 & lstat >= 5.12, \n 122.32 + crim * -0.29 + nox * -21.6 + rm * -3 + dis * -30.88 + \n rad * 0.02 + tax * -0.001 + b * -0.023 + lstat * -0.73, \n 0) + ifelse(rm < 6.545 & lstat >= 5.12, 27.8 + crim * -0.16 + \n zn * 0.007 + nox * -3.9 + rm * 2 + age * -0.035 + dis * -0.7 + \n rad * 0.28 + tax * -0.0135 + ptratio * -0.6 + b * 0.013 + \n lstat * -0.25, 0) + ifelse(rm >= 6.545 & lstat >= 5.12, 22.21 + \n crim * -0.04 + zn * 0.01 + indus * -0.02 + nox * -4 + rm * \n 4.7 + dis * -0.34 + rad * 0.11 + tax * -0.0248 + ptratio * \n -0.9 + b * 0.002 + lstat * -0.1, 0) + ifelse(lstat < 5.12 & \n rm < 8.034, -71.95 + rm * 17 + age * -0.06 + tax * -0.0112 + \n ptratio * -0.48 + lstat * -0.03, 0) + ifelse(rm >= 8.034 & \n dis >= 3.199, -32.79 + crim * -0.01 + zn * 0.005 + nox * \n -1.8 + rm * 12.9 + age * -0.117 + dis * -0.15 + rad * 0.04 + \n tax * -0.0246 + ptratio * -1.05 + lstat * -0.04, 0) + ifelse(lstat < \n 5.12 & dis < 3.199, 53.41 + rm * 1.6 + dis * -7.16 + tax * \n 0.0088 + lstat * -0.68, 0) + ifelse(nox >= 0.668, -36.31 + \n crim * 0.08 + nox * 48.4 + dis * 7.52 + b * 0.01 + lstat * \n -0.24, 0) + ifelse(lstat >= 9.53 & nox < 0.668, 28.04 + nox * \n -4.8 + rm * 2.9 + age * -0.051 + dis * -0.86 + rad * 0.01 + \n tax * -0.0019 + ptratio * -0.72 + lstat * -0.12, 0) + ifelse(lstat < \n 9.53, -26.05 + crim * 0.89 + nox * -2.3 + rm * 9.6 + dis * \n -0.17 + rad * 0.02 + tax * -0.0055 + ptratio * -0.12 + b * \n 0.001 + lstat * -0.74, 0) + ifelse(lstat < 9.53 & dis < 2.64, \n 136.67 + crim * 7.2 + nox * -96.6 + rm * 1.1 + tax * -0.0033 + \n ptratio * -3.31 + lstat * -0.1, 0))/3"

# Model can be saved and re-loaded

Code
tidypredict_fit(pm)
Output
(ifelse(nox >= 0.668, -1.11 + crim * -0.02 + nox * 21.4 + rm *
0.1 + age * -0.003 + dis * 2.93 + ptratio * -0.13 + b * 0.008 +
lstat * -0.33, 0) + ifelse(lstat >= 9.59 & nox < 0.668, 23.57 +
crim * 0.05 + nox * -5.2 + rm * 3.1 + age * -0.048 + dis *
-0.81 + rad * 0.02 + tax * -0.0041 + ptratio * -0.71 + b *
0.01 + lstat * -0.15, 0) + ifelse(lstat < 9.59 & rm < 6.226,
1.18 + crim * 3.83 + rm * 4.3 + age * -0.06 + dis * -0.09 +
tax * -0.003 + ptratio * -0.08 + lstat * -0.11, 0) +
ifelse(lstat < 9.59 & rm >= 6.226, -4.71 + crim * 2.22 +
zn * 0.008 + nox * -1.7 + rm * 9.2 + age * -0.04 + dis *
-0.71 + rad * 0.03 + tax * -0.0182 + ptratio * -0.72 +
lstat * -0.83, 0) + ifelse(dis < 1.755 & lstat >= 5.12,
122.32 + crim * -0.29 + nox * -21.6 + rm * -3 + dis * -30.88 +
rad * 0.02 + tax * -0.001 + b * -0.023 + lstat * -0.73,
0) + ifelse(rm < 6.545 & lstat >= 5.12, 27.8 + crim * -0.16 +
zn * 0.007 + nox * -3.9 + rm * 2 + age * -0.035 + dis * -0.7 +
rad * 0.28 + tax * -0.0135 + ptratio * -0.6 + b * 0.013 +
lstat * -0.25, 0) + ifelse(rm >= 6.545 & lstat >= 5.12, 22.21 +
crim * -0.04 + zn * 0.01 + indus * -0.02 + nox * -4 + rm *
4.7 + dis * -0.34 + rad * 0.11 + tax * -0.0248 + ptratio *
-0.9 + b * 0.002 + lstat * -0.1, 0) + ifelse(lstat < 5.12 &
rm < 8.034, -71.95 + rm * 17 + age * -0.06 + tax * -0.0112 +
ptratio * -0.48 + lstat * -0.03, 0) + ifelse(rm >= 8.034 &
dis >= 3.199, -32.79 + crim * -0.01 + zn * 0.005 + nox *
-1.8 + rm * 12.9 + age * -0.117 + dis * -0.15 + rad * 0.04 +
tax * -0.0246 + ptratio * -1.05 + lstat * -0.04, 0) + ifelse(lstat <
5.12 & dis < 3.199, 53.41 + rm * 1.6 + dis * -7.16 + tax *
0.0088 + lstat * -0.68, 0) + ifelse(nox >= 0.668, -36.31 +
crim * 0.08 + nox * 48.4 + dis * 7.52 + b * 0.01 + lstat *
-0.24, 0) + ifelse(lstat >= 9.53 & nox < 0.668, 28.04 + nox *
-4.8 + rm * 2.9 + age * -0.051 + dis * -0.86 + rad * 0.01 +
tax * -0.0019 + ptratio * -0.72 + lstat * -0.12, 0) + ifelse(lstat <
9.53, -26.05 + crim * 0.89 + nox * -2.3 + rm * 9.6 + dis *
-0.17 + rad * 0.02 + tax * -0.0055 + ptratio * -0.12 + b *
0.001 + lstat * -0.74, 0) + ifelse(lstat < 9.53 & dis < 2.64,
136.67 + crim * 7.2 + nox * -96.6 + rm * 1.1 + tax * -0.0033 +
ptratio * -3.31 + lstat * -0.1, 0))/3

7 changes: 7 additions & 0 deletions tests/testthat/_snaps/earth.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Model can be saved and re-loaded

Code
tidypredict_fit(pm)
Output
list()

9 changes: 9 additions & 0 deletions tests/testthat/_snaps/glm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Model can be saved and re-loaded

Code
tidypredict_fit(pm)
Output
1 - 1/(1 + exp(24.1453276 + (wt * -7.8977178) + (disp * -0.0269566) +
(ifelse(cyl == "cyl6", 1, 0) * 4.8670863) + (ifelse(cyl ==
"cyl8", 1, 0) * 10.9478336)))

12 changes: 12 additions & 0 deletions tests/testthat/_snaps/lm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Model can be saved and re-loaded

Code
tidypredict_fit(pm)
Output
41.1350198 + (wt * -0.6978035) + (disp * -0.1224733) + (ifelse(cyl ==
"cyl6", 1, 0) * -12.9466721) + (ifelse(cyl == "cyl8", 1,
0) * -17.0571646) + (wt * ifelse(cyl == "cyl6", 1, 0) * -3.1372923) +
(wt * ifelse(cyl == "cyl8", 1, 0) * -1.3253343) + (disp *
ifelse(cyl == "cyl6", 1, 0) * 0.1416155) + (disp * ifelse(cyl ==
"cyl8", 1, 0) * 0.1199615)

10 changes: 10 additions & 0 deletions tests/testthat/_snaps/party.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Model can be saved and re-loaded

Code
tidypredict_fit(pm)
Output
[[1]]
case_when(wt <= 2.32 ~ 29.0285714, wt <= 3.46 & wt > 2.32 ~ 19.8571429,
wt > 3.46 & wt > 2.32 ~ 14.7)

Loading

0 comments on commit 6a0a4e7

Please sign in to comment.