Open njtierney opened 5 months ago
E.g., if you use nsim instead of nsims in calculate() you get this error:
nsim
nsims
calculate()
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 x <- normal(0,1) #> ℹ Initialising python and checking dependencies, this may take a moment. #> ✔ Initialising python and checking dependencies ... done! #> calculate(x, nsim = 5) #> $x #> , , 1 #> #> [,1] #> [1,] 0.7627844 #> [2,] -0.3615098 #> [3,] 1.0897698 #> [4,] -0.1584944 #> [5,] 0.6156224 calculate(x, nsims = 5) #> Error: `calculate()` arguments must be <greta_array>s #> The following object passed to `calculate()` is not a <greta array>: #> "nsims" #> Perhaps you forgot to explicitly name other arguments? m <- model(x) 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: 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: 0s sampling ================= 450/1000 | eta: 0s sampling =================== 500/1000 | eta: 0s sampling ===================== 550/1000 | eta: 0s 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 calculate(x, values = draws, nsim = 10) #> $x #> , , 1 #> #> [,1] #> [1,] 0.41497171 #> [2,] 1.36014557 #> [3,] -0.09084215 #> [4,] -1.34185781 #> [5,] 0.52032974 #> [6,] -0.20217775 #> [7,] -2.19990155 #> [8,] 0.51368269 #> [9,] -0.60101829 #> [10,] 1.05756474 calculate(x, values = draws, nsims = 10) #> Error: `calculate()` arguments must be <greta_array>s #> The following object passed to `calculate()` is not a <greta array>: #> "nsims" #> Perhaps you forgot to explicitly name other arguments?
Created on 2024-02-12 with reprex v2.1.0
I wonder if we could perhaps try and construct those errors a little bit more carefully so that they gave more instructive errors related to potential argument names? Like a suggestion that nsims should be nsim or something?
Perhaps https://github.com/r-lib/ellipsis could be of use
E.g., if you use
nsim
instead ofnsims
incalculate()
you get this error:Created on 2024-02-12 with reprex v2.1.0
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.2 (2023-10-31) #> os macOS Sonoma 14.0 #> system aarch64, darwin20 #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Australia/Hobart #> date 2024-02-12 #> pandoc 3.1.1 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-5 2016-07-21 [1] CRAN (R 4.3.0) #> backports 1.4.1 2021-12-13 [1] CRAN (R 4.3.0) #> base64enc 0.1-3 2015-07-28 [1] CRAN (R 4.3.0) #> callr 3.7.3 2022-11-02 [1] CRAN (R 4.3.0) #> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.1) #> coda 0.19-4.1 2024-01-31 [1] CRAN (R 4.3.1) #> codetools 0.2-19 2023-02-01 [1] CRAN (R 4.3.2) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.0) #> digest 0.6.34 2024-01-11 [1] CRAN (R 4.3.1) #> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.1) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.0) #> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.0) #> future 1.33.1 2023-12-22 [1] CRAN (R 4.3.1) #> globals 0.16.2 2022-11-21 [1] CRAN (R 4.3.0) #> glue 1.7.0 2024-01-09 [1] CRAN (R 4.3.1) #> greta * 0.4.4.9000 2024-02-06 [1] Github (njtierney/greta@db4154e) #> hms 1.1.3 2023-03-21 [1] CRAN (R 4.3.0) #> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.1) #> jsonlite 1.8.8 2023-12-04 [1] CRAN (R 4.3.1) #> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.1) #> lattice 0.21-9 2023-10-01 [1] CRAN (R 4.3.2) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.1) #> listenv 0.9.1 2024-01-29 [1] CRAN (R 4.3.1) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.0) #> Matrix 1.6-1.1 2023-09-18 [1] CRAN (R 4.3.2) #> parallelly 1.36.0 2023-05-26 [1] CRAN (R 4.3.0) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.0) #> png 0.1-8 2022-11-29 [1] CRAN (R 4.3.0) #> prettyunits 1.2.0 2023-09-24 [1] CRAN (R 4.3.1) #> processx 3.8.3 2023-12-10 [1] CRAN (R 4.3.1) #> progress 1.2.3 2023-12-06 [1] CRAN (R 4.3.1) #> ps 1.7.6 2024-01-18 [1] CRAN (R 4.3.1) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.0) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.0) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.0) #> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.3.1) #> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.3.1) #> R6 2.5.1 2021-08-19 [1] CRAN (R 4.3.0) #> Rcpp 1.0.12 2024-01-09 [1] CRAN (R 4.3.1) #> reprex 2.1.0 2024-01-11 [1] CRAN (R 4.3.1) #> reticulate 1.35.0 2024-01-31 [1] CRAN (R 4.3.1) #> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.3.1) #> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.1) #> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.3.0) #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.0) #> styler 1.10.2 2023-08-29 [1] CRAN (R 4.3.0) #> tensorflow 2.15.0 2024-01-31 [1] CRAN (R 4.3.1) #> tfautograph 0.3.2 2021-09-17 [1] CRAN (R 4.3.0) #> tfruns 1.5.2 2024-01-26 [1] CRAN (R 4.3.1) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.1) #> whisker 0.4.1 2022-12-05 [1] CRAN (R 4.3.0) #> withr 3.0.0 2024-01-16 [1] CRAN (R 4.3.1) #> xfun 0.42 2024-02-08 [1] CRAN (R 4.3.1) #> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.1) #> #> [1] /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library #> #> ─ Python configuration ─────────────────────────────────────────────────────── #> python: /Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2/bin/python #> libpython: /Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2/lib/libpython3.8.dylib #> pythonhome: /Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2:/Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2 #> version: 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:49:06) [Clang 14.0.6 ] #> numpy: /Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2/lib/python3.8/site-packages/numpy #> numpy_version: 1.23.2 #> tensorflow: /Users/nick/Library/r-miniconda-arm64/envs/greta-env-tf2/lib/python3.8/site-packages/tensorflow #> #> NOTE: Python version was forced by use_python() function #> #> ────────────────────────────────────────────────────────────────────────────── ```I wonder if we could perhaps try and construct those errors a little bit more carefully so that they gave more instructive errors related to potential argument names? Like a suggestion that
nsims
should bensim
or something?Perhaps https://github.com/r-lib/ellipsis could be of use