Skip to content

Commit

Permalink
Can read 'n_neurons_in_latent_layer' from 'gcae_experiment_params'
Browse files Browse the repository at this point in the history
  • Loading branch information
richelbilderbeek committed Jun 14, 2022
1 parent 677b9d1 commit 66225df
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export(has_cloned_gcae_repo)
export(install_gcae)
export(install_gcae_requirements)
export(is_equal_json)
export(is_gcae_experiment_params)
export(is_gcae_installed)
export(is_gcae_repo_cloned)
export(is_gcae_script_fixed)
Expand Down
2 changes: 1 addition & 1 deletion R/get_n_neurons_in_latent_layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ get_n_neurons_in_latent_layer <- function(x) {
gcaer::get_n_neurons_in_latent_layer_from_model(model = x)
)
}
if (gcaer::is_gcae_experiment_params()) {
if (gcaer::is_gcae_experiment_params(x)) {
return(
gcaer::get_n_neurons_in_latent_layer_from_gcae_experiment_params(
gcae_experiment_params = x
Expand Down
25 changes: 25 additions & 0 deletions R/get_n_neurons_in_latent_layer_from_gcae_experiment_params.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#' Get the number of neurons in the layent layer from a `gcae_experiment_params`
#'
#' Get the number of neurons in the layent layer from a `gcae_experiment_params`
#' @inheritParams default_params_doc
#' @return the number of neurons in the latent layer
#' @seealso use \link{get_n_neurons_in_latent_layer}
#' to get the number of neurons in the latent layer
#' for different input arguments
#' @examples
#' get_n_neurons_in_latent_layer_from_gcae_experiment_params(
#' create_test_gcae_experiment_params()
#' )
#' @author Richèl J.C. Bilderbeek
#' @export
get_n_neurons_in_latent_layer_from_gcae_experiment_params <- function( # nolint indeed a long function name
gcae_experiment_params
) {
gcaer::check_gcae_experiment_params(gcae_experiment_params)
model_filename <- gcaer::get_gcae_model_filename(
model_id = gcae_experiment_params$gcae_setup$model_id,
gcae_options = gcae_experiment_params$gcae_options
)
model <- read_model_file(model_filename = model_filename)
gcaer::get_n_neurons_in_latent_layer_from_model(model = model)
}
29 changes: 29 additions & 0 deletions R/is_gcae_experiment_params.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Determine if the `gcae_experiment_params` is indeed a `gcae_experiment_params`
#' @inheritParams default_params_doc
#' @return \link{TRUE} if the `gcae_experiment_params` is indeed a `gcae_experiment_params`
#' @examples
#' # TRUE
#' is_gcae_experiment_params(create_test_gcae_experiment_params())
#'
#' # FALSE
#' is_gcae_experiment_params(gcae_experiment_params = "nonsense")
#' is_gcae_experiment_params("nonsense", verbose = TRUE)
#' @author Richèl J.C. Bilderbeek
#' @export
is_gcae_experiment_params <- function(
gcae_experiment_params,
verbose = FALSE
) {
plinkr::check_verbose(verbose)
result <- FALSE
tryCatch({
gcaer::check_gcae_experiment_params(
gcae_experiment_params = gcae_experiment_params
)
result <- TRUE
}, error = function(e) {
if (verbose) message(e$message)
}
)
result
}
35 changes: 35 additions & 0 deletions man/is_gcae_experiment_params.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/testthat/test-get_n_neurons_in_latent_layer.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ test_that("M0, from model", {
})

test_that("M0, from gcae_experiment_params", {
skip("nsphs_ml_qt #55")
gcae_experiment_params <- create_test_gcae_experiment_params()
expect_equal("M0", gcae_experiment_params$gcae_setup$model_id)
n_neurons <- get_n_neurons_in_latent_layer(gcae_experiment_params)
Expand Down

0 comments on commit 66225df

Please sign in to comment.