diff --git a/R/calculate.R b/R/calculate.R index 4f6efe0b..5f3252f9 100644 --- a/R/calculate.R +++ b/R/calculate.R @@ -390,7 +390,6 @@ calculate_greta_mcmc_list <- function(target, } calculate_list <- function(target, values, nsim, tf_float, env) { - ### browser() fixed_greta_arrays <- list() values_exist <- !identical(values, list()) @@ -409,7 +408,6 @@ calculate_list <- function(target, values, nsim, tf_float, env) { dag <- dag_class$new(all_greta_arrays, tf_float = tf_float) stochastic <- !is.null(nsim) - ### browser() if (stochastic) { check_if_unsampleable_and_unfixed(fixed_greta_arrays, dag) @@ -459,7 +457,6 @@ calculate_target_tensor_list <- function( nsim ) { # define the dag and TF graph - ### browser() # change dag mode to sampling dag$mode <- "all_sampling" @@ -498,18 +495,12 @@ calculate_target_tensor_list <- function( # approaches (in as_tf_function + generate_log_prob_function) dag$define_tf(target_nodes = target_nodes) - # browser() # look up the tf names of the target greta arrays (under sampling) # create an object in the environment that's a list of these, and sample that target_nodes <- lapply(target, get_node) target_names_list <- lapply(target_nodes, dag$tf_name) - ## TF1/2 OK so the error with Wishart and cholesky is happening here - ## I feel as thought this isn't the "problem" per se, but it is where the - ## matrix of 1s is returned. So seems to me we first expose the problem here target_tensor_list <- lapply(target_names_list, get, envir = tfe) - ## It looks like it is getting all_sampling_operation_2 and not - ## all_sampling_operation_1 target_tensor_list_array <- lapply(target_tensor_list, as.array) return(target_tensor_list_array) diff --git a/R/dag_class.R b/R/dag_class.R index 47bb899d..b0d3d65a 100644 --- a/R/dag_class.R +++ b/R/dag_class.R @@ -21,7 +21,6 @@ dag_class <- R6Class( initialize = function(target_greta_arrays, tf_float = "float32", compile = FALSE) { - # browser() # build the dag self$build_dag(target_greta_arrays) @@ -171,7 +170,6 @@ dag_class <- R6Class( # if it's an operation, see if it has a distribution (for lkj and # wishart) and get mode based on whether the parent has a free state if (node_type == "operation") { - # browser() parent_name <- node$parents[[1]]$unique_name parent_stateless <- parent_name %in% stateless_names to_sample <- has_distribution(node) & parent_stateless @@ -345,9 +343,7 @@ dag_class <- R6Class( } # define all nodes in the environment and on the graph - ## HERE lapply(target_nodes, function(x){ - # browser() x$define_tf(self) }) diff --git a/R/node_class.R b/R/node_class.R index 09524f51..3757adb9 100644 --- a/R/node_class.R +++ b/R/node_class.R @@ -15,7 +15,6 @@ node <- R6Class( dim = NA, distribution = NULL, initialize = function(dim = NULL, value = NULL) { - ## browser() dim <- dim %||% c(1,1) # coerce dim to integer @@ -36,8 +35,6 @@ node <- R6Class( # recursively register self and family register_family = function(dag) { - ## TF1/2 - ## Rename with an explaining variable ## TODO add explaining variable if (!(self$unique_name %in% names(dag$node_list))) { @@ -75,9 +72,6 @@ node <- R6Class( node$remove_child(self) }, list_parents = function(dag) { - ## TF1/2 - ## tf_cholesky - ## is there a way here to add some check for cholesky? parents <- self$parents # if this node is being sampled and has a distribution, consider @@ -200,7 +194,6 @@ node <- R6Class( lapply( parents[which(!parents_defined)], function(x){ - # browser() x$define_tf(dag) } ) diff --git a/R/node_types.R b/R/node_types.R index 3899c082..7b633877 100644 --- a/R/node_types.R +++ b/R/node_types.R @@ -3,7 +3,6 @@ data_node <- R6Class( inherit = node, public = list( initialize = function(data) { - ## browser() # coerce to an array with 2+ dimensions data <- as_2d_array(data) @@ -150,26 +149,7 @@ operation_node <- R6Class( mode <- dag$how_to_define(self) # if sampling get the distribution constructor and sample this if (mode == "sampling") { - # browser() tensor <- dag$draw_sample(self$distribution) - - # if (has_representation(self, "cholesky")) { - # browser() - # cholesky_tensor <- tf_chol(tensor) - # # cholesky_tf_name <- dag$tf_name(self$representation$cholesky) - # cholesky_node <- get_node(representation(self, "cholesky")) - # cholesky_tf_name <- dag$tf_name(cholesky_node) - # assign(cholesky_tf_name, cholesky_tensor, envir = tfe) - ## TF1/2 - ## This assignment I think is supposed to be passed down to later on - ## in the script, as `cholesky_tf_name` gets overwritten - # cholesky_tf_name <- dag$tf_name(self) - # tf_name <- cholesky_tf_name - # tensor <- cholesky_tensor - # cholesky_tensor <- tf_chol(tensor) - # cholesky_tf_name <- dag$tf_name(self$representation$cholesky) - # assign(cholesky_tf_name, cholesky_tensor, envir = dag$tf_environment) - # } } if (mode == "forward") { @@ -188,11 +168,9 @@ operation_node <- R6Class( operation <- eval(parse(text = self$operation), envir = self$tf_function_env ) - # browser() tensor <- do.call(operation, tf_args) } - # browser() # assign it in the environment assign(tf_name, tensor, envir = dag$tf_environment) } @@ -212,7 +190,6 @@ variable_node <- R6Class( upper = Inf, dim = NULL, free_dim = prod(dim)) { - ## browser() check_if_lower_upper_numeric(lower, upper) # replace values of lower and upper with finite values for dimension @@ -283,33 +260,24 @@ variable_node <- R6Class( mode <- dag$how_to_define(self) if (mode == "sampling") { - # browser() distrib_node <- self$distribution if (is.null(distrib_node)) { # does it have an anti-representation where it is the cholesky? # the antirepresentation of cholesky is chol2symm - # if it does, we will take the antirepresentation and get it to `tf` itself - # then we need to get the tf_name + # if yes, we take antirep and get it to `tf`, then get the tf_name chol2symm_ga <- self$anti_representations$chol2symm chol2symm_existing <- !is.null(chol2symm_ga) + if (chol2symm_existing) { + chol2symm_node <- get_node(chol2symm_ga) chol2symm_name <- dag$tf_name(chol2symm_node) chol2symm_tensor <- get(chol2symm_name, envir = dag$tf_environment) tensor <- tf_chol(chol2symm_tensor) + } - # chol2symm_ga$define_tf(dag) - # } else { - # - # # if the variable has no distribution create a placeholder instead - # # (the value must be passed in via values when using simulate) - # shape <- to_shape(c(1, self$dim)) - # # TF1/2 check - # # need to change the placeholder approach here. - # # NT: can we change this to be a tensor of the right shape with 1s? - # tensor <- tensorflow::as_tensor(1L, shape = shape, dtype = tf_float()) } else { tensor <- dag$draw_sample(self$distribution) } @@ -432,10 +400,8 @@ distribution_node <- R6Class( discrete = FALSE, multivariate = FALSE, truncatable = TRUE) { - ## browser() super$initialize(dim) - ## browser() # for all distributions, set name, store dims, and set whether discrete self$distribution_name <- name self$discrete <- discrete @@ -462,7 +428,6 @@ distribution_node <- R6Class( # create a target variable node (unconstrained by default) create_target = function(truncation) { - ##browser() vble(truncation, dim = self$dim) }, list_parents = function(dag) { @@ -494,7 +459,6 @@ distribution_node <- R6Class( # create target node, add as a parent, and give it this distribution add_target = function(new_target) { - ##browser() # add as target and as a parent self$target <- new_target self$add_parent(new_target) @@ -621,7 +585,6 @@ node_classes_module <- module( # shorthand for distribution parameter constructors distrib <- function(distribution, ...) { - ##browser() check_tf_version("error") # get and initialize the distribution, with a default value node diff --git a/R/probability_distributions.R b/R/probability_distributions.R index b33b88ce..1f1c35ba 100644 --- a/R/probability_distributions.R +++ b/R/probability_distributions.R @@ -50,7 +50,6 @@ normal_distribution <- R6Class( inherit = distribution_node, public = list( initialize = function(mean, sd, dim, truncation) { - ## browser() mean <- as.greta_array(mean) sd <- as.greta_array(sd) @@ -1051,10 +1050,6 @@ wishart_distribution <- R6Class( input_output_cholesky = TRUE ) - ## TF1/2 - ## The issue with getting the cholesky part of the Wishart - ## isn't happening here, - ## This produces something that looks about right chol_draws <- chol_distrib$sample(seed = seed) # equivalent to (but faster than) tf_chol2symm(tf_transpose(chol_draws)) @@ -1404,7 +1399,6 @@ uniform <- function(min, max, dim = NULL) { #' @rdname distributions #' @export normal <- function(mean, sd, dim = NULL, truncation = c(-Inf, Inf)) { - ##browser() distrib("normal", mean, sd, dim, truncation) } diff --git a/R/unknowns_class.R b/R/unknowns_class.R index 4c2b3b56..345d4f18 100644 --- a/R/unknowns_class.R +++ b/R/unknowns_class.R @@ -29,8 +29,6 @@ print.unknowns <- function(x, ..., n = 10) { # set NA values to ? for printing x[is.na(x)] <- " ?" - # browser() - n_print <- getOption("greta.print_max") %||% n n_unknowns <- length(x) diff --git a/R/write-logfiles.R b/R/write-logfiles.R index dbcfa165..65d772c2 100644 --- a/R/write-logfiles.R +++ b/R/write-logfiles.R @@ -37,7 +37,7 @@ write_greta_install_log <- function(path = greta_logfile) {

Greta installation logfile

Created: {{sys_date}}

Use this logfile to explore potential issues in installation with greta

-

Try opening this in a browser and searching the text for "error" with Cmd/Ctrl+F

+

Try opening this in a HTML browser and searching the text for "error" with Cmd/Ctrl+F

Miniconda

@@ -142,7 +142,7 @@ sys_get_env <- function(envvar){ #' Read a greta logfile #' #' This is a convenience function to facilitate reading logfiles. It opens -#' a browser using [utils::browseURL()]. It will search for +#' a HTML browser using [utils::browseURL()]. It will search for #' the environment variable "GRETA_INSTALLATION_LOG" or default to #' `tools::R_user_dir("greta")`. To set #' "GRETA_INSTALLATION_LOG" you can use @@ -150,7 +150,7 @@ sys_get_env <- function(envvar){ #' [greta_set_install_logfile()] to set the path, e.g., #' `greta_set_install_logfile('path/to/logfile.html')`. #' -#' @return opens a URL in your default browser +#' @return opens a URL in your default HTML browser. #' @export open_greta_install_log <- function(){ diff --git a/man/open_greta_install_log.Rd b/man/open_greta_install_log.Rd index 1c7a58e3..eff46565 100644 --- a/man/open_greta_install_log.Rd +++ b/man/open_greta_install_log.Rd @@ -7,11 +7,11 @@ open_greta_install_log() } \value{ -opens a URL in your default browser +opens a URL in your default HTML browser. } \description{ This is a convenience function to facilitate reading logfiles. It opens -a browser using \code{\link[utils:browseURL]{utils::browseURL()}}. It will search for +a HTML browser using \code{\link[utils:browseURL]{utils::browseURL()}}. It will search for the environment variable "GRETA_INSTALLATION_LOG" or default to \code{tools::R_user_dir("greta")}. To set "GRETA_INSTALLATION_LOG" you can use diff --git a/tests/testthat/test_posteriors_geweke.R b/tests/testthat/test_posteriors_geweke.R index 55df20e4..ef810518 100644 --- a/tests/testthat/test_posteriors_geweke.R +++ b/tests/testthat/test_posteriors_geweke.R @@ -1,7 +1,5 @@ Sys.setenv("RELEASE_CANDIDATE" = "false") -## TF1/2 - method for this test needs to be updated for TF2 -## See https://github.com/greta-dev/greta/issues/720 test_that("samplers pass geweke tests", { skip_if_not(check_tf_version()) diff --git a/tests/testthat/test_posteriors_standard_uniform.R b/tests/testthat/test_posteriors_standard_uniform.R index 80d29674..fb8232d0 100644 --- a/tests/testthat/test_posteriors_standard_uniform.R +++ b/tests/testthat/test_posteriors_standard_uniform.R @@ -1,6 +1,5 @@ Sys.setenv("RELEASE_CANDIDATE" = "true") -## TF1/2 this sampler fails test_that("samplers are unbiased for standard uniform", { skip_if_not(check_tf_version())