Closed njtierney closed 2 months ago
Another round:
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
#> %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#> eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#> tapply
beta <- normal(0,1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
alpha <- normal(0, 1, truncation = c(0, Inf))
m <- model(alpha, beta)
draws <- mcmc(m)
#> running 4 chains simultaneously on up to 8 CPU cores
#>
#> warmup 0/1000 | eta: ?s warmup == 50/1000 | eta: 12s warmup ==== 100/1000 | eta: 7s warmup ====== 150/1000 | eta: 5s warmup ======== 200/1000 | eta: 4s warmup ========== 250/1000 | eta: 3s warmup =========== 300/1000 | eta: 3s warmup ============= 350/1000 | eta: 2s warmup =============== 400/1000 | eta: 2s warmup ================= 450/1000 | eta: 2s warmup =================== 500/1000 | eta: 2s warmup ===================== 550/1000 | eta: 1s warmup ======================= 600/1000 | eta: 1s warmup ========================= 650/1000 | eta: 1s warmup =========================== 700/1000 | eta: 1s warmup ============================ 750/1000 | eta: 1s warmup ============================== 800/1000 | eta: 1s warmup ================================ 850/1000 | eta: 0s warmup ================================== 900/1000 | eta: 0s warmup ==================================== 950/1000 | eta: 0s warmup ====================================== 1000/1000 | eta: 0s
#> sampling 0/1000 | eta: ?s sampling == 50/1000 | eta: 1s sampling ==== 100/1000 | eta: 1s sampling ====== 150/1000 | eta: 1s sampling ======== 200/1000 | eta: 1s sampling ========== 250/1000 | eta: 1s sampling =========== 300/1000 | eta: 1s sampling ============= 350/1000 | eta: 1s sampling =============== 400/1000 | eta: 1s sampling ================= 450/1000 | eta: 1s sampling =================== 500/1000 | eta: 1s sampling ===================== 550/1000 | eta: 1s sampling ======================= 600/1000 | eta: 0s sampling ========================= 650/1000 | eta: 0s sampling =========================== 700/1000 | eta: 0s sampling ============================ 750/1000 | eta: 0s sampling ============================== 800/1000 | eta: 0s sampling ================================ 850/1000 | eta: 0s sampling ================================== 900/1000 | eta: 0s sampling ==================================== 950/1000 | eta: 0s sampling ====================================== 1000/1000 | eta: 0s
# far too long
head(draws)
#> $`11`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 1.0098794 1.5652410
#> 2 0.8119695 -0.1817819
#> 3 1.1721394 -0.1764524
#> 4 0.5217709 -0.5796415
#> 5 0.7567756 -0.8293186
#> 6 0.7567756 -0.8293186
#> 7 1.6888979 -1.1752022
#>
#> $`12`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 0.8478702 0.04251455
#> 2 0.7490954 -1.36782292
#> 3 1.8757218 -0.66330474
#> 4 0.7332660 -1.16291451
#> 5 0.5350540 1.04544727
#> 6 1.3651053 1.11545433
#> 7 1.3963518 -0.54946304
#>
#> $`13`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 1.4183309 1.1003982
#> 2 1.4183309 1.1003982
#> 3 0.5230580 0.7105599
#> 4 0.5230580 0.7105599
#> 5 1.3432723 -0.7030401
#> 6 1.8612860 -0.9181379
#> 7 0.7488582 -0.9505341
#>
#> $`14`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 1.0579056 0.33659352
#> 2 0.7601833 1.29742984
#> 3 0.5520103 -0.28699120
#> 4 0.0418236 0.65613885
#> 5 0.1473088 -0.74730675
#> 6 0.6022979 1.16601827
#> 7 0.7895472 -0.01477612
#>
#> attr(,"class")
#> [1] "mcmc.list"
summary(draws)
#>
#> Iterations = 1:1000
#> Thinning interval = 1
#> Number of chains = 4
#> Sample size per chain = 1000
#>
#> 1. Empirical mean and standard deviation for each variable,
#> plus standard error of the mean:
#>
#> Mean SD Naive SE Time-series SE
#> alpha 0.77562 0.5781 0.009141 0.01493
#> beta -0.02144 1.0064 0.015912 0.05173
#>
#> 2. Quantiles for each variable:
#>
#> 2.5% 25% 50% 75% 97.5%
#> alpha 0.03253 0.3129 0.65606 1.1171 2.188
#> beta -1.99298 -0.7478 0.01208 0.7063 1.902
class(draws)
#> [1] "greta_mcmc_list" "mcmc.list"
print.greta_mcmc_list <- function(x, ...){
n_chain <- coda::nchain(draws)
n_iter <- coda::niter(draws)
n_thin <- coda::thin(draws)
cli::cli_h1("MCMC draws from {.pkg greta}")
cli::cli_bullets(
c(
"*" = "Iteration = {n_iter}",
"*" = "Chains = {n_chain}",
"*" = "Thinning = {n_thin}"
)
)
draws_head <- lapply(draws, head, n = 2)
cli::cli_h1("Chain 1 (first 3 iterations)")
flat_mat <- as.matrix(draws_head[[1]])
print(flat_mat)
cli::cli_alert_info(
c("To see the values from each chain, do:\n",
"{.run draws[[1]]}"
)
)
cli::cli_alert_info(
text = c("To print all draws, set:\n",
"{.run options(greta_max_draws_print = Inf)}")
)
}
draws
#>
#> ── MCMC draws from greta ───────────────────────────────────────────────────────
#> • Iteration = 1000
#> • Chains = 4
#> • Thinning = 1
#>
#> ── Chain 1 (first 3 iterations) ────────────────────────────────────────────────
#> alpha beta
#> [1,] 1.0098794 1.5652410
#> [2,] 0.8119695 -0.1817819
#> [3,] 1.1721394 -0.1764524
#> ℹ To see the values from each chain, do:
#> `draws[[1]]`
#> ℹ To print all draws, set:
#> `options(greta_max_draws_print = Inf)`
Created on 2024-05-14 with reprex v2.1.0
Some more thoughts/ideas / concerns about printing speed.
library(greta)
#>
#> Attaching package: 'greta'
#> The following objects are masked from 'package:stats':
#>
#> binomial, cov2cor, poisson
#> The following objects are masked from 'package:base':
#>
#> %*%, apply, backsolve, beta, chol2inv, colMeans, colSums, diag,
#> eigen, forwardsolve, gamma, identity, rowMeans, rowSums, sweep,
#> tapply
beta <- normal(0,1)
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
alpha <- normal(0, 1, truncation = c(0, Inf))
m <- model(alpha, beta)
draws <- mcmc(m)
#> running 4 chains simultaneously on up to 8 CPU cores
#>
#> warmup 0/1000 | eta: ?s warmup == 50/1000 | eta: 11s warmup ==== 100/1000 | eta: 6s warmup ====== 150/1000 | eta: 4s warmup ======== 200/1000 | eta: 4s warmup ========== 250/1000 | eta: 3s warmup =========== 300/1000 | eta: 2s warmup ============= 350/1000 | eta: 2s warmup =============== 400/1000 | eta: 2s warmup ================= 450/1000 | eta: 2s warmup =================== 500/1000 | eta: 1s warmup ===================== 550/1000 | eta: 1s warmup ======================= 600/1000 | eta: 1s warmup ========================= 650/1000 | eta: 1s warmup =========================== 700/1000 | eta: 1s warmup ============================ 750/1000 | eta: 1s warmup ============================== 800/1000 | eta: 0s warmup ================================ 850/1000 | eta: 0s warmup ================================== 900/1000 | eta: 0s warmup ==================================== 950/1000 | eta: 0s warmup ====================================== 1000/1000 | eta: 0s
#> sampling 0/1000 | eta: ?s sampling == 50/1000 | eta: 1s sampling ==== 100/1000 | eta: 1s sampling ====== 150/1000 | eta: 1s sampling ======== 200/1000 | eta: 1s sampling ========== 250/1000 | eta: 1s sampling =========== 300/1000 | eta: 1s sampling ============= 350/1000 | eta: 1s sampling =============== 400/1000 | eta: 1s sampling ================= 450/1000 | eta: 1s sampling =================== 500/1000 | eta: 1s sampling ===================== 550/1000 | eta: 1s sampling ======================= 600/1000 | eta: 0s sampling ========================= 650/1000 | eta: 0s sampling =========================== 700/1000 | eta: 0s sampling ============================ 750/1000 | eta: 0s sampling ============================== 800/1000 | eta: 0s sampling ================================ 850/1000 | eta: 0s sampling ================================== 900/1000 | eta: 0s sampling ==================================== 950/1000 | eta: 0s sampling ====================================== 1000/1000 | eta: 0s
summary(draws)
#>
#> Iterations = 1:1000
#> Thinning interval = 1
#> Number of chains = 4
#> Sample size per chain = 1000
#>
#> 1. Empirical mean and standard deviation for each variable,
#> plus standard error of the mean:
#>
#> Mean SD Naive SE Time-series SE
#> alpha 0.76714 0.5856 0.009259 0.01582
#> beta 0.04531 1.0095 0.015962 0.02495
#>
#> 2. Quantiles for each variable:
#>
#> 2.5% 25% 50% 75% 97.5%
#> alpha 0.02773 0.3009 0.66052 1.1153 2.194
#> beta -1.96152 -0.6379 0.06362 0.7134 2.052
class(draws)
#> [1] "greta_mcmc_list" "mcmc.list"
print.greta_mcmc_list <- function(x, ..., n = 3){
n_chain <- coda::nchain(x)
n_iter <- coda::niter(x)
n_thin <- coda::thin(x)
cli::cli_h1("MCMC draws from {.pkg greta}")
cli::cli_bullets(
c(
"*" = "Iteration = {n_iter}",
"*" = "Chains = {n_chain}",
"*" = "Thinning = {n_thin}"
)
)
n_print <- getOption("greta.print_max") %||% n
cli::cli_h1("Chain 1 (first {n_print} iterations)")
flat_mat <- as.matrix(x[[1]])
draws_head <- head(flat_mat, n = n_print)
remaining_draws <- n_iter - n_print
print(draws_head)
cli::cli_alert_info(
text = c(
"i" = "{remaining_draws} more draws\n",
"i" = "Use {.code print(n = ...)} to see more draws"
)
)
cli::cli_rule()
cli::cli_alert_info(
c("View {.pkg greta} draw chains with:\n",
"{.code greta_draws[[1]]}"
)
)
cli::cli_alert_info(
c("To see draws summary run:\n",
"{.code summary(greta_draws)}")
)
cli::cli_alert_info(
c("To see diagnostics, run:\n",
"")
)
}
print.greta_mcmc_list2 <- function(x, ..., n = 3){
n_chain <- coda::nchain(x)
n_iter <- coda::niter(x)
n_thin <- coda::thin(x)
cat("MCMC draws from `greta` \n")
cat(
sprintf(""),
sprintf("Iteration = %s \n", n_iter),
sprintf("Chains = %s \n",n_chain),
sprintf("Thinning = %s \n", n_thin)
)
n_print <- getOption("greta.print_max") %||% n
cat(
sprintf("\nChain 1 (first %s iterations)\n\n", n_print)
)
flat_mat <- as.matrix(x[[1]])
draws_head <- head(flat_mat, n = n_print)
cat(sprintf(""))
remaining_draws <- n_iter - n_print
print(draws_head)
cat(
sprintf(""),
sprintf("\ni: %s more draws\n", remaining_draws),
sprintf("i: Use `print(n = ...)` to see more draws\n")
)
cat(
sprintf(""),
sprintf("View `greta` draw chains with:\n"),
sprintf("`greta_draws[[1]]`")
)
}
draws_mcmc <- coda::as.mcmc.list(draws)
draws2 <- draws
class(draws2) <- c("greta_mcmc_list2", class(draws2))
draws
#>
#> ── MCMC draws from greta ───────────────────────────────────────────────────────
#> • Iteration = 1000
#> • Chains = 4
#> • Thinning = 1
#>
#> ── Chain 1 (first 3 iterations) ────────────────────────────────────────────────
#> alpha beta
#> [1,] 0.6815562 1.5431265
#> [2,] 0.3787658 0.5363900
#> [3,] 0.9252470 0.3406627
#> ℹ 997 more draws
#> Use `print(n = ...)` to see more draws
#> ────────────────────────────────────────────────────────────────────────────────
#> ℹ View greta draw chains with:
#> `greta_draws[[1]]`
#> ℹ To see draws summary run:
#> `summary(greta_draws)`
#> ℹ To see diagnostics, run:
draws2
#> MCMC draws from `greta`
#> Iteration = 1000
#> Chains = 4
#> Thinning = 1
#>
#> Chain 1 (first 3 iterations)
#>
#> alpha beta
#> [1,] 0.6815562 1.5431265
#> [2,] 0.3787658 0.5363900
#> [3,] 0.9252470 0.3406627
#>
#> i: 997 more draws
#> i: Use `print(n = ...)` to see more draws
#> View `greta` draw chains with:
#> `greta_draws[[1]]`
quiet_bm <- purrr::quietly(bench::mark)
bm <- quiet_bm(
greta = print.greta_mcmc_list(draws),
greta2 = print.greta_mcmc_list2(draws),
coda = print(draws_mcmc),
check = FALSE
)
bm$result
#> # A tibble: 3 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 greta 13.9ms 14ms 70.3 125.09KB 75.0
#> 2 greta2 104.6µs 109µs 8672. 27.48KB 14.6
#> 3 coda 20.9ms 21ms 44.6 9.92KB 0
plot(bm$result)
#> Loading required namespace: tidyr
summary(bm$result, relative = TRUE)
#> # A tibble: 3 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 greta 133. 128. 1.58 12.6 Inf
#> 2 greta2 1 1 194. 2.77 Inf
#> 3 coda 199. 192. 1 1 NaN
print.greta_mcmc_list(draws)
#>
#> ── MCMC draws from greta ───────────────────────────────────────────────────────
#> • Iteration = 1000
#> • Chains = 4
#> • Thinning = 1
#>
#> ── Chain 1 (first 3 iterations) ────────────────────────────────────────────────
#> alpha beta
#> [1,] 0.6815562 1.5431265
#> [2,] 0.3787658 0.5363900
#> [3,] 0.9252470 0.3406627
#> ℹ 997 more draws
#> Use `print(n = ...)` to see more draws
#> ────────────────────────────────────────────────────────────────────────────────
#> ℹ View greta draw chains with:
#> `greta_draws[[1]]`
#> ℹ To see draws summary run:
#> `summary(greta_draws)`
#> ℹ To see diagnostics, run:
print.greta_mcmc_list2(draws)
#> MCMC draws from `greta`
#> Iteration = 1000
#> Chains = 4
#> Thinning = 1
#>
#> Chain 1 (first 3 iterations)
#>
#> alpha beta
#> [1,] 0.6815562 1.5431265
#> [2,] 0.3787658 0.5363900
#> [3,] 0.9252470 0.3406627
#>
#> i: 997 more draws
#> i: Use `print(n = ...)` to see more draws
#> View `greta` draw chains with:
#> `greta_draws[[1]]`
# cutting this off for demo pruposes
print(head(draws_mcmc))
#> $`11`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 0.6815562 1.5431265
#> 2 0.3787658 0.5363900
#> 3 0.9252470 0.3406627
#> 4 1.0660587 -1.1876874
#> 5 1.0660587 -1.1876874
#> 6 0.9276765 -0.3032537
#> 7 0.7523860 -0.4157797
#>
#> $`12`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 1.20572213 1.3850561
#> 2 1.62266329 1.8091175
#> 3 0.46303666 1.7910581
#> 4 0.41465866 -0.8458950
#> 5 0.41465866 -0.8458950
#> 6 0.07696906 1.8992183
#> 7 0.66109078 0.2877945
#>
#> $`13`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 1.33663613 -1.1896738
#> 2 1.50322305 -0.4703715
#> 3 2.47498098 -0.1181150
#> 4 0.31774948 -0.4843053
#> 5 0.07900174 0.5481055
#> 6 0.07900174 0.5481055
#> 7 0.07900174 0.5481055
#>
#> $`14`
#> Markov Chain Monte Carlo (MCMC) output:
#> Start = 1
#> End = 7
#> Thinning interval = 1
#> alpha beta
#> 1 0.5895023 -0.8248683
#> 2 0.6440894 -0.8667017
#> 3 0.6440894 -0.8667017
#> 4 0.3676444 0.3384980
#> 5 1.1680652 -0.8176417
#> 6 0.2699316 -0.6854730
#> 7 2.0256743 1.1436656
#>
#> attr(,"class")
#> [1] "mcmc.list"
x <- 5
bm_prints <- quiet_bm(
paste0 = paste0("Iteration = ", x),
sprintf = sprintf("Iteration = %s", x)
)
bm_prints$result
#> # A tibble: 2 × 6
#> expression min median `itr/sec` mem_alloc `gc/sec`
#> <bch:expr> <bch:tm> <bch:tm> <dbl> <bch:byt> <dbl>
#> 1 paste0 1.44µs 1.56µs 582634. 0B 0
#> 2 sprintf 1.07µs 1.19µs 768384. 0B 0
## design considerations -
## * How does the print method handle many many parameters
## * Burn in/warmup information?
## *
Created on 2024-07-24 with reprex v2.1.0
Currently, if you have a long or wide greta array, the printing method takes up the whole console.
It would be great if we could work out a way to print the greta array objects so they don't clutter the whole console. Similar to the print method with data.table, which shows the head and tail, or how tibble has made the default printing 10 rows.
Created on 2022-01-14 by the reprex package (v2.0.1)
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.1.2 (2021-11-01) #> os macOS Big Sur 10.16 #> system x86_64, darwin17.0 #> ui X11 #> language (EN) #> collate en_AU.UTF-8 #> ctype en_AU.UTF-8 #> tz Australia/Brisbane #> date 2022-01-14 #> pandoc 2.14.0.3 @ /Applications/RStudio.app/Contents/MacOS/pandoc/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> backports 1.4.0 2021-11-23 [1] CRAN (R 4.1.0) #> base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.1.0) #> callr 3.7.0 2021-04-20 [1] CRAN (R 4.1.0) #> cli 3.1.0 2021-10-27 [1] CRAN (R 4.1.1) #> coda 0.19-4 2020-09-30 [1] CRAN (R 4.1.0) #> codetools 0.2-18 2020-11-04 [1] CRAN (R 4.1.2) #> crayon 1.4.2 2021-10-29 [1] CRAN (R 4.1.0) #> digest 0.6.29 2021-12-01 [1] CRAN (R 4.1.0) #> ellipsis 0.3.2 2021-04-29 [1] CRAN (R 4.1.0) #> evaluate 0.14 2019-05-28 [1] CRAN (R 4.1.0) #> fansi 1.0.0 2022-01-10 [1] CRAN (R 4.1.2) #> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.1.0) #> fs 1.5.2 2021-12-08 [1] CRAN (R 4.1.0) #> future 1.23.0 2021-10-31 [1] CRAN (R 4.1.0) #> globals 0.14.0 2020-11-22 [1] CRAN (R 4.1.0) #> glue 1.6.0 2021-12-17 [1] CRAN (R 4.1.0) #> greta * 0.4.0 2021-12-21 [1] local #> here 1.0.1 2020-12-13 [1] CRAN (R 4.1.0) #> highr 0.9 2021-04-16 [1] CRAN (R 4.1.0) #> hms 1.1.1 2021-09-26 [1] CRAN (R 4.1.0) #> htmltools 0.5.2 2021-08-25 [1] CRAN (R 4.1.0) #> jsonlite 1.7.2 2020-12-09 [1] CRAN (R 4.1.0) #> knitr 1.37 2021-12-16 [1] CRAN (R 4.1.0) #> lattice 0.20-45 2021-09-22 [1] CRAN (R 4.1.2) #> lifecycle 1.0.1 2021-09-24 [1] CRAN (R 4.1.0) #> listenv 0.8.0 2019-12-05 [1] CRAN (R 4.1.0) #> magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.1.0) #> Matrix 1.3-4 2021-06-01 [1] CRAN (R 4.1.2) #> parallelly 1.29.0 2021-11-21 [1] CRAN (R 4.1.0) #> pillar 1.6.4 2021-10-18 [1] CRAN (R 4.1.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.1.0) #> png 0.1-7 2013-12-03 [1] CRAN (R 4.1.0) #> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.1.0) #> processx 3.5.2 2021-04-30 [1] CRAN (R 4.1.0) #> progress 1.2.2 2019-05-16 [1] CRAN (R 4.1.0) #> ps 1.6.0 2021-02-28 [1] CRAN (R 4.1.0) #> purrr 0.3.4 2020-04-17 [1] CRAN (R 4.1.0) #> R.cache 0.15.0 2021-04-30 [1] CRAN (R 4.1.0) #> R.methodsS3 1.8.1 2020-08-26 [1] CRAN (R 4.1.0) #> R.oo 1.24.0 2020-08-26 [1] CRAN (R 4.1.0) #> R.utils 2.11.0 2021-09-26 [1] CRAN (R 4.1.0) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.1.0) #> Rcpp 1.0.7 2021-07-07 [1] CRAN (R 4.1.0) #> reprex 2.0.1 2021-08-05 [1] CRAN (R 4.1.0) #> reticulate 1.22 2021-09-17 [1] CRAN (R 4.1.0) #> rlang 0.4.12 2021-10-18 [1] CRAN (R 4.1.0) #> rmarkdown 2.11 2021-09-14 [1] CRAN (R 4.1.0) #> rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.1.0) #> rstudioapi 0.13 2020-11-12 [1] CRAN (R 4.1.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.1.1) #> stringi 1.7.6 2021-11-29 [1] CRAN (R 4.1.0) #> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.1.0) #> styler 1.6.2 2021-09-23 [1] CRAN (R 4.1.0) #> tensorflow 2.7.0 2021-11-09 [1] CRAN (R 4.1.0) #> tfruns 1.5.0 2021-02-26 [1] CRAN (R 4.1.0) #> tibble 3.1.6 2021-11-07 [1] CRAN (R 4.1.0) #> utf8 1.2.2 2021-07-24 [1] CRAN (R 4.1.0) #> vctrs 0.3.8 2021-04-29 [1] CRAN (R 4.1.0) #> whisker 0.4 2019-08-28 [1] CRAN (R 4.1.0) #> withr 2.4.3 2021-11-30 [1] CRAN (R 4.1.0) #> xfun 0.29 2021-12-14 [1] CRAN (R 4.1.0) #> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.1.0) #> #> [1] /Library/Frameworks/R.framework/Versions/4.1/Resources/library #> #> ─ Python configuration ─────────────────────────────────────────────────────── #> python: /Users/njtierney/Library/r-miniconda/envs/greta-env/bin/python #> libpython: /Users/njtierney/Library/r-miniconda/envs/greta-env/lib/libpython3.7m.dylib #> pythonhome: /Users/njtierney/Library/r-miniconda/envs/greta-env:/Users/njtierney/Library/r-miniconda/envs/greta-env #> version: 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 05:59:23) [Clang 11.1.0 ] #> numpy: /Users/njtierney/Library/r-miniconda/envs/greta-env/lib/python3.7/site-packages/numpy #> numpy_version: 1.16.4 #> tensorflow: /Users/njtierney/Library/r-miniconda/envs/greta-env/lib/python3.7/site-packages/tensorflow #> #> NOTE: Python version was forced by use_python function #> #> ────────────────────────────────────────────────────────────────────────────── ```It would also be neat to add the dimensions to the print method.
So the long and wide examples above might read as:
why?
Because the print methods sometimes take up the whole console, and sometimes that can be a bit annoying as we might lose other things in the console, or we might lose sight of what the structure of the data is in the first place. Additionally, this would also apply to greta arrays, which normally have
?
as their contents, and we don't necessarily need to see 100?
to understand it is 100 long or wide, etc.related issues
333 and #262