Skip to content
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

autotest parses examples incorrectly #79

Open
santikka opened this issue Aug 26, 2022 · 0 comments
Open

autotest parses examples incorrectly #79

santikka opened this issue Aug 26, 2022 · 0 comments

Comments

@santikka
Copy link

The main function dosearch of the dosearch package has 7 examples that are not wrapped in \dontrun, but if understand the output correctly, autotest thinks that there is only 1 example. This is what I get from examples_to_yaml

#>  [1] "package: dosearch"                                                                                                                                                                                                                                                            
#>  [2] "functions:"                                                                                                                                                                                                                                                                   
#>  [3] "    - dosearch:"                                                                                                                                                                                                                                                              
#>  [4] "        - preprocess:"                                                                                                                                                                                                                                                        
#>  [5] "            - 'data1 <- \"P(x,y,z)\"'"                                                                                                                                                                                                                                        
#>  [6] "            - 'query1 <- \"P(y|do(x))\"'"                                                                                                                                                                                                                                     
#>  [7] "            - 'graph1 <- \"  x -> y  z -> x  z -> y \"'"                                                                                                                                                                                                                      
#>  [8] "            - 'data2 <- \"P(x,y,z)\"'"                                                                                                                                                                                                                                        
#>  [9] "            - 'query2 <- \"P(y|do(x))\"'"                                                                                                                                                                                                                                     
#> [10] "            - 'graph2 <- \"  x -> z  z -> y  x <-> y \"'"                                                                                                                                                                                                                     
#> [11] "            - 'data <- \"  p(x,z,y|s)  p(y,z|t,do(x)) \"'"                                                                                                                                                                                                                    
#> [12] "            - 'query <- \"p(y|do(x))\"'"                                                                                                                                                                                                                                      
#> [13] "            - 'graph <- \"  x -> z  z -> y  x -> s  t -> z  x <-> y \"'"                                                                                                                                                                                                      
#> [14] "            - 'data <- \"  p(x*,y*,r_x,r_y)  p(y) \"'"                                                                                                                                                                                                                        
#> [15] "            - 'graph <- \"  x -> y  y -> r_y  r_y -> r_x \"'"                                                                                                                                                                                                                 
#> [16] "            - 'md <- \"r_x : x, r_y : y\"'"                                                                                                                                                                                                                                   
#> [17] "            - 'if (requireNamespace(\"igraph\", quietly = TRUE)) { g_igraph <- igraph::graph.formula( x -+ z, z -+ y, x -+ y, y -+ x, simplify = FALSE ); g_igraph <- igraph::set.edge.attribute(g_igraph, \"description\", 3:4, \"U\"); dosearch(data2, query2, g_igraph) }'"
#> [18] "            - 'if (requireNamespace(\"dagitty\", quietly = TRUE)) { g_dagitty <- dagitty::dagitty(\"dag{x -> z -> y; x <-> y}\"); dosearch(data2, query2, g_dagitty) }'"                                                                                                      
#> [19] "        - parameters:"                                                                                                                                                                                                                                                        
#> [20] "            - data: data2"                                                                                                                                                                                                                                                    
#> [21] "            - query: query2"                                                                                                                                                                                                                                                  
#> [22] "            - graph: g_igraph"                                                                                                                                                                                                                                                
#> [23] "            - control: list()"                                                                                                                                                                                                                                                
#> [24] "        - classes:"                                                                                                                                                                                                                                                           
#> [25] "            - control: function"                                                                                                                                                                                                                                              
#> [26] "            - control: function"                                                                                                                                                                                                                                              
#> [27] "        - class:"                                                                                                                                                                                                                                                             
#> [28] "            - data: character"                                                                                                                                                                                                                                                
#> [29] "            - query: character"                                                                                                                                                                                                                                               
#> [30] "            - graph: dagitty"                                                                                                                                                                                                                                                 
#> [31] "    - dosearch:"                                                                                                                                                                                                                                                              
#> [32] "        - preprocess:"                                                                                                                                                                                                                                                        
#> [33] "            - 'data1 <- \"P(x,y,z)\"'"                                                                                                                                                                                                                                        
#> [34] "            - 'query1 <- \"P(y|do(x))\"'"                                                                                                                                                                                                                                     
#> [35] "            - 'graph1 <- \"  x -> y  z -> x  z -> y \"'"                                                                                                                                                                                                                      
#> [36] "            - 'data2 <- \"P(x,y,z)\"'"                                                                                                                                                                                                                                        
#> [37] "            - 'query2 <- \"P(y|do(x))\"'"                                                                                                                                                                                                                                     
#> [38] "            - 'graph2 <- \"  x -> z  z -> y  x <-> y \"'"                                                                                                                                                                                                                     
#> [39] "            - 'data <- \"  p(x,z,y|s)  p(y,z|t,do(x)) \"'"                                                                                                                                                                                                                    
#> [40] "            - 'query <- \"p(y|do(x))\"'"                                                                                                                                                                                                                                      
#> [41] "            - 'graph <- \"  x -> z  z -> y  x -> s  t -> z  x <-> y \"'"                                                                                                                                                                                                      
#> [42] "            - 'data <- \"  p(x*,y*,r_x,r_y)  p(y) \"'"                                                                                                                                                                                                                        
#> [43] "            - 'graph <- \"  x -> y  y -> r_y  r_y -> r_x \"'"                                                                                                                                                                                                                 
#> [44] "            - 'md <- \"r_x : x, r_y : y\"'"                                                                                                                                                                                                                                   
#> [45] "            - 'if (requireNamespace(\"igraph\", quietly = TRUE)) { g_igraph <- igraph::graph.formula( x -+ z, z -+ y, x -+ y, y -+ x, simplify = FALSE ); g_igraph <- igraph::set.edge.attribute(g_igraph, \"description\", 3:4, \"U\"); dosearch(data2, query2, g_igraph) }'"
#> [46] "            - 'if (requireNamespace(\"dagitty\", quietly = TRUE)) { g_dagitty <- dagitty::dagitty(\"dag{x -> z -> y; x <-> y}\"); dosearch(data2, query2, g_dagitty) }'"                                                                                                      
#> [47] "        - parameters:"                                                                                                                                                                                                                                                        
#> [48] "            - data: data2"                                                                                                                                                                                                                                                    
#> [49] "            - query: query2"                                                                                                                                                                                                                                                  
#> [50] "            - graph: g_dagitty"                                                                                                                                                                                                                                               
#> [51] "            - control: list()"                                                                                                                                                                                                                                                
#> [52] "        - classes:"                                                                                                                                                                                                                                                           
#> [53] "            - control: function"                                                                                                                                                                                                                                              
#> [54] "            - control: function"                                                                                                                                                                                                                                              
#> [55] "        - class:"                                                                                                                                                                                                                                                             
#> [56] "            - data: character"                                                                                                                                                                                                                                                
#> [57] "            - query: character"                                                                                                                                                                                                                                               
#> [58] "            - graph: dagitty"                                                                                                                                                                                                                                                 

It seems that for some reason the examples are combined together and the preprocess-elements contain setup variables from different examples. For example, the first example in the package documentation only uses data1, query1 and graph1.

Session info
library(autotest)
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.1 (2022-06-23 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  Finnish_Finland.utf8
#>  ctype    Finnish_Finland.utf8
#>  tz       Europe/Helsinki
#>  date     2022-08-26
#>  pandoc   2.17.1.1 @ C:/Program Files/RStudio/bin/quarto/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version   date (UTC) lib source
#>  autotest    * 0.0.2.196 2022-08-26 [1] Github (ropensci-review-tools/autotest@382e92f)
#>  cachem        1.0.6     2021-08-19 [1] CRAN (R 4.1.3)
#>  cli           3.3.0     2022-04-25 [1] CRAN (R 4.1.3)
#>  digest        0.6.29    2021-12-01 [1] CRAN (R 4.1.3)
#>  evaluate      0.16      2022-08-09 [1] CRAN (R 4.1.3)
#>  fansi         1.0.3     2022-03-24 [1] CRAN (R 4.1.3)
#>  fastmap       1.1.0     2021-01-25 [1] CRAN (R 4.1.3)
#>  fs            1.5.2     2021-12-08 [1] CRAN (R 4.1.3)
#>  glue          1.6.2     2022-02-24 [1] CRAN (R 4.1.3)
#>  highr         0.9       2021-04-16 [1] CRAN (R 4.1.3)
#>  htmltools     0.5.3     2022-07-18 [1] CRAN (R 4.1.3)
#>  knitr         1.40      2022-08-24 [1] CRAN (R 4.2.1)
#>  lifecycle     1.0.1     2021-09-24 [1] CRAN (R 4.1.3)
#>  magrittr      2.0.3     2022-03-30 [1] CRAN (R 4.1.3)
#>  memoise       2.0.1     2021-11-26 [1] CRAN (R 4.1.3)
#>  pillar        1.8.1     2022-08-19 [1] CRAN (R 4.2.1)
#>  pkgconfig     2.0.3     2019-09-22 [1] CRAN (R 4.1.3)
#>  purrr         0.3.4     2020-04-17 [1] CRAN (R 4.1.3)
#>  R.cache       0.16.0    2022-07-21 [1] CRAN (R 4.1.3)
#>  R.methodsS3   1.8.2     2022-06-13 [1] CRAN (R 4.1.3)
#>  R.oo          1.25.0    2022-06-12 [1] CRAN (R 4.1.3)
#>  R.utils       2.12.0    2022-06-28 [1] CRAN (R 4.1.3)
#>  reprex        2.0.2     2022-08-17 [1] CRAN (R 4.2.1)
#>  rlang         1.0.4     2022-07-12 [1] CRAN (R 4.1.3)
#>  rmarkdown     2.16      2022-08-24 [1] CRAN (R 4.2.1)
#>  rstudioapi    0.14      2022-08-22 [1] CRAN (R 4.2.1)
#>  sessioninfo   1.2.2     2021-12-06 [1] CRAN (R 4.1.3)
#>  stringi       1.7.8     2022-07-11 [1] CRAN (R 4.1.2)
#>  stringr       1.4.1     2022-08-20 [1] CRAN (R 4.2.1)
#>  styler        1.7.0     2022-03-13 [1] CRAN (R 4.1.3)
#>  tibble        3.1.8     2022-07-22 [1] CRAN (R 4.1.3)
#>  utf8          1.2.2     2021-07-24 [1] CRAN (R 4.1.3)
#>  vctrs         0.4.1     2022-04-13 [1] CRAN (R 4.1.3)
#>  withr         2.5.0     2022-03-03 [1] CRAN (R 4.1.3)
#>  xfun          0.32      2022-08-10 [1] CRAN (R 4.1.3)
#>  yaml          2.3.5     2022-02-21 [1] CRAN (R 4.1.2)
#> 
#>  [1] C:/devel/R/library
#> 
#> ──────────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant