greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
518 stars 63 forks source link

Use "explaining variables" in `if` statements or other places #631

Open njtierney opened 1 month ago

njtierney commented 1 month ago

E.g.,

if (!(self$unique_name %in% names(dag$node_list))) {

I think self$unique_name %in% names(dag$node_list) is registered ? So then it would be:

not_registered <- !(self$unique_name %in% names(dag$node_list))

if (not_registered) {
# ...
}

Or even as a function, since this explaining variable is used in a few places in greta

is_registered <- function(self, dag) self$unique_name %in% names(dag$node_list)
registered <- is_registered(self, dag)
if (!registered) {
# ...
}