-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
177be2f
commit 151e488
Showing
4 changed files
with
94 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# ml_formula() works | ||
|
||
Code | ||
ml_formula(am ~ mpg, mtcars) | ||
Output | ||
$label | ||
[1] "am" | ||
$features | ||
[1] "mpg" | ||
|
||
# ml_installed() works on simulated interactive session | ||
|
||
Code | ||
ml_installed() | ||
Message | ||
! Required Python libraries to run ML functions are missing | ||
Could not find: torch, torcheval, and scikit-learn | ||
Do you wish to install? (This will be a one time operation) | ||
|
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
test_that("ml_formula() works", { | ||
expect_snapshot(ml_formula(am ~ mpg, mtcars)) | ||
expect_error( | ||
ml_formula(am ~ mpg * cyl, mtcars), | ||
"Formula resulted in an invalid parameter set" | ||
) | ||
}) | ||
|
||
test_that("snake_to_camel() works", { | ||
expect_equal( | ||
snake_to_camel("var_one"), | ||
"varOne" | ||
) | ||
}) | ||
|
||
test_that("ml_connect_not_supported() works", { | ||
expect_silent( | ||
ml_connect_not_supported( | ||
args = list(), | ||
not_supported = c( | ||
"elastic_net_param", "reg_param", "threshold", | ||
"aggregation_depth", "fit_intercept", | ||
"raw_prediction_col", "uid", "weight_col" | ||
) | ||
) | ||
) | ||
|
||
expect_error( | ||
ml_connect_not_supported( | ||
args = list(reg_param = 1), | ||
not_supported = c( | ||
"elastic_net_param", "reg_param", "threshold", | ||
"aggregation_depth", "fit_intercept", | ||
"raw_prediction_col", "uid", "weight_col" | ||
), | ||
"The following argument(s) are not supported by Spark Connect:" | ||
) | ||
) | ||
}) | ||
|
||
test_that("ml_installed() works on simulated interactive session", { | ||
test_databricks_stump_env() | ||
withr::with_envvar( | ||
new = c("WORKON_HOME" = use_new_test_env()), | ||
{ | ||
local_mocked_bindings( | ||
check_interactive = function(...) TRUE, | ||
check_rstudio = function(...) TRUE, | ||
menu = function(...) { | ||
return(1) | ||
}, | ||
py_install = function(...) invisible() | ||
) | ||
expect_snapshot( | ||
ml_installed() | ||
) | ||
} | ||
) | ||
}) |