-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Greta array print 480 #644
Greta array print 480 #644
Conversation
…e shorter and more informative. (greta-dev#644)
devtools::load_all(".")
#> ℹ Loading greta
#> ℹ Initialising python and checking dependencies, this may take a moment.
#>
#> ✔ Initialising python and checking dependencies ... done!
print_h1.greta_array(normal(0, 1, dim = 15))
#>
#> ── greta array <variable following a normal distribution> ──────────────────────
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
#> ℹ 5 more values
#> Use `print(n = ...)` to see more values
print_h2.greta_array(normal(0, 1, dim = 15))
#>
#> ── greta array <variable following a normal distribution> ──
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
#> ℹ 5 more values
#> Use `print(n = ...)` to see more values
print_h3.greta_array(normal(0, 1, dim = 15))
#>
#> ── greta array <variable following a normal distribution>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
#> ℹ 5 more values
#> Use `print(n = ...)` to see more values
print(normal(0, 1, dim = 15))
#> greta array <variable following a normal distribution>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
#> ℹ 5 more values
#> Use `print(n = ...)` to see more values Created on 2024-07-29 with reprex v2.1.0
|
04d4147
to
e614030
Compare
There is also some opportunity here to add more text highlighting for the different nodes:
Which might be nice. |
So nice in fact that I got really deep into a cli formatting rabbithole. Behold! 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
ga_data <- as_data(matrix(1:9, nrow = 3))
#> ℹ Initialising python and checking dependencies, this may take a moment.
#> ✔ Initialising python and checking dependencies ... done!
#>
ga_stochastic <- normal(0, 1)
ga_operation <- ga_data * ga_stochastic
ga_data
#> greta array <data>
#> [,1] [,2] [,3]
#> [1,] 1 4 7
#> [2,] 2 5 8
#> [3,] 3 6 9
ga_stochastic
#> greta array <variable following a normal distribution>
#> [,1]
#> [1,] ?
#>
ga_operation
#> greta array <operation>
#> [,1] [,2] [,3]
#> [1,] ? ? ?
#> [2,] ? ? ?
#> [3,] ? ? ?
#>
normal(0, 1, dim = 10)
#> greta array <variable following a normal distribution>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
normal(0, 1, dim = 15)
#> greta array <variable following a normal distribution>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#>
#> ℹ 5 more values
#> Use `print(n = ...)` to see more values
print(normal(0, 1, dim = 15), n = 15)
#> greta array <variable following a normal distribution>
#>
#> [,1]
#> [1,] ?
#> [2,] ?
#> [3,] ?
#> [4,] ?
#> [5,] ?
#> [6,] ?
#> [7,] ?
#> [8,] ?
#> [9,] ?
#> [10,] ?
#> [11,] ?
#> [12,] ?
#> [13,] ?
#> [14,] ?
#> [15,] ?
#> Created on 2024-07-29 with reprex v2.1.0
|
Any of these are a big improvement on existing - I'm all for anything that reduced the need to use |
… to do this that is more elegant but this will work for the time being
pretty CLI comparisonBefore
|
This PR would improve print methods for MCMC and for greta arrays.
This will resolve #480
Keen to get some user input, will post examples in this PR thread.