danchaltiel / autoimport Goto Github PK
View Code? Open in Web Editor NEWA toolbox to automatically generate @importFrom roxygen tags from R files.
A toolbox to automatically generate @importFrom roxygen tags from R files.
A list of terms that should never get removed, like cli::qty
for instance
I've run autoimport()
on the code in https://github.com/mlverse/tabnet
and I get some unexpected insertion of R6 public methods as Roxygen #' @importFrom
autoimport()
the following code chunk uses view
and transpose
as public methods of the torch R6 object rho
https://github.com/mlverse/tabnet/blob/7186ba6048a6818283d05fb86c2af6ead862173b/R/sparsemax.R#L2-L10
idem for gather
https://github.com/mlverse/tabnet/blob/7186ba6048a6818283d05fb86c2af6ead862173b/R/sparsemax.R#L19
idem for clone
and squeeze
https://github.com/mlverse/tabnet/blob/7186ba6048a6818283d05fb86c2af6ead862173b/R/sparsemax.R#L41-L44
autoimport()
- autoimport()
add erroneously import from functions from exotic libraries, messing up the NAMESPACE
file and DESCRIPTION
file
Reproducible example
# git clone https://github.com/mlverse/tabnet
# cd tabnet
library(autoimport)
library(tidyverse)
autoimport(files = "R/sparsemax.R")
Either empty .R
file or empty NAMESPACE
Being inspired by the presentation at RR_2023 Avignon, I've run autoimport()
on the code in https://github.com/mlverse/tabnet
I'm impressed by the user interface but I get the following issue on few files where the first line of code in the file is the function definition (i.e. function without Roxygen skeleton )
autoimport()
file R/pretraining.R
is starting with the following lines :
train_batch_un <- function(network, optimizer, batch, config) {
# forward pass
autoimport()
file R/pretraining.R
is starting with the following lines :
train_batch_un <- function(network, optimizer, batch, config) {
#' @importFrom torch nn_utils_clip_grad_norm_
train_batch_un <- function(network, optimizer, batch, config) {
# forward pass
where we can see the function definition line is doubled around the Roxygen @importFrom
statement
see https://github.com/mlverse/tabnet/blob/9890314421526b2244433ea1f168078fd8feb447/R/dials.R#L1-L3
see https://github.com/mlverse/tabnet/blob/9890314421526b2244433ea1f168078fd8feb447/R/package.R#L1-L3
see https://github.com/mlverse/tabnet/blob/9890314421526b2244433ea1f168078fd8feb447/R/pretraining.R#L1-L3
Reproducible example
# git clone https://github.com/mlverse/tabnet
# cd tabnet
library(autoimport)
autoimport(files = "R/dials.R")
#> Error: './NAMESPACE' does not exist in current working directory ('/tmp/RtmpXgZklI/reprex-301dcf3b5c6d89-pure-tayra').
Created on 2023-06-25 with reprex v2.0.2
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0
locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8
[5] LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 LC_PAPER=fr_FR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
time zone: Europe/Paris
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] tabnet_0.4.0.9000 testthat_3.1.9 shiny_1.7.4 bit_4.0.5 autoimport_0.0.1.9000
[6] recipes_1.0.6 lubridate_1.9.2 forcats_1.0.0 stringr_1.5.0 dplyr_1.1.2
[11] purrr_1.0.1 readr_2.1.4 tidyr_1.3.0 tibble_3.2.1 ggplot2_3.4.2
[16] tidyverse_2.0.0 data.tree_1.0.0 data.table_1.14.8
loaded via a namespace (and not attached):
[1] remotes_2.4.2 rlang_1.1.1 magrittr_2.0.3 compiler_4.3.0 callr_3.7.3 vctrs_0.6.3
[7] profvis_0.3.8 pkgconfig_2.0.3 crayon_1.5.2 fastmap_1.1.1 backports_1.4.1 ellipsis_0.3.2
[13] utf8_1.2.3 promises_1.2.0.1 rmarkdown_2.22 prodlim_2023.03.31 sessioninfo_1.2.2 tzdb_0.4.0
[19] ps_1.7.5 torch_0.10.0 reprex_2.0.2 xfun_0.39 cachem_1.0.8 progress_1.2.2
[25] later_1.3.1 parallel_4.3.0 prettyunits_1.1.1 R6_2.5.1 stringi_1.7.12 parallelly_1.36.0
[31] pkgload_1.3.2 rpart_4.1.19 brio_1.1.3 Rcpp_1.0.10 knitr_1.43 future.apply_1.11.0
[37] usethis_2.2.1 httpuv_1.6.11 Matrix_1.5-4.1 splines_4.3.0 nnet_7.3-19 timechange_0.2.0
[43] tidyselect_1.2.0 yaml_2.3.7 rstudioapi_0.14 timeDate_4022.108 codetools_0.2-19 miniUI_0.1.1.1
[49] processx_3.8.1 listenv_0.9.0 pkgbuild_1.4.1 lattice_0.21-8 withr_2.5.0 evaluate_0.21
[55] desc_1.4.2 future_1.32.0 survival_3.5-5 urlchecker_1.0.1 diffviewer_0.1.1 pillar_1.9.0
[61] checkmate_2.2.0 generics_0.1.3 rprojroot_2.0.3 hms_1.1.3 munsell_0.5.0 scales_1.2.1
[67] coro_1.0.3 globals_0.16.2 xtable_1.8-4 bspm_0.5.1 class_7.3-22 glue_1.6.2
[73] clipr_0.8.0 tools_4.3.0 gower_1.0.1 fs_1.6.2 grid_4.3.0 ipred_0.9-14
[79] devtools_2.4.5 colorspace_2.1-0 cli_3.6.1 fansi_1.0.4 lava_1.7.2.1 gtable_0.3.3
[85] digest_0.6.31 htmlwidgets_1.6.2 memoise_2.0.1 htmltools_0.5.5 lifecycle_1.0.3 hardhat_1.3.0
[91] mime_0.12 bit64_4.0.5 MASS_7.3-60 ```
Try with crosstable
with this NAMESPACE
file
# Generated by roxygen2: do not edit by hand
S3method(as_flextable,crosstable)
S3method(as_gt,crosstable)
S3method(as_gt,default)
S3method(compact,crosstable)
S3method(compact,data.frame)
S3method(compact,default)
S3method(ct_compact,crosstable)
S3method(ct_compact,data.frame)
S3method(ct_compact,default)
S3method(t,crosstable)
export("%>%")
export(N)
export(af)
export(all_of)
export(any_of)
export(apply_labels)
export(as_flextable)
export(as_gt)
export(as_workbook)
export(body_add_crosstable)
export(body_add_crosstable_footnote)
export(body_add_crosstable_list)
export(body_add_figure_legend)
export(body_add_flextable_list)
export(body_add_gg2)
export(body_add_glued)
export(body_add_img2)
export(body_add_list)
export(body_add_list_item)
export(body_add_normal)
export(body_add_table_legend)
export(body_add_table_list)
export(body_add_title)
export(body_replace_text_at_bkms)
export(clean_names_with_labels)
export(compact)
export(confint_numeric)
export(contains)
export(copy_label_from)
export(cross_summary)
export(cross_to_flextable)
export(crosstable)
export(crosstable_effect_args)
export(crosstable_options)
export(crosstable_peek_options)
export(crosstable_reset_options)
export(crosstable_test_args)
export(ct_compact)
export(ctf)
export(diff_mean_auto)
export(diff_mean_boot)
export(diff_mean_student)
export(diff_median)
export(diff_median_boot)
export(display_effect)
export(display_test)
export(docx_bookmarks2)
export(effect_odds_ratio)
export(effect_relative_risk)
export(effect_risk_difference)
export(effect_survival_coxph)
export(ends_with)
export(everything)
export(format_fixed)
export(generate_autofit_macro)
export(get_label)
export(get_percent_pattern)
export(import_labels)
export(is.compacted_crosstable)
export(is.crosstable)
export(is.multiby_crosstable)
export(is.transposed_crosstable)
export(matches)
export(meanCI)
export(meansd)
export(mediqr)
export(minmax)
export(moystd)
export(na)
export(narm)
export(nna)
export(peek)
export(pivot_crosstable)
export(plim)
export(remove_label)
export(remove_labels)
export(rename_dataframe_with_labels)
export(rename_with_labels)
export(save_labels)
export(set_label)
export(starts_with)
export(test_correlation_auto)
export(test_summarize_auto)
export(test_summarize_linear_contrasts)
export(test_survival_logrank)
export(test_tabular_auto)
export(to_flextable)
export(transpose_crosstable)
export(write_and_open)
importFrom(checkmate,assert)
importFrom(checkmate,assert_character)
importFrom(dplyr,recode)
importFrom(dplyr,rename)
importFrom(dplyr,summarise)
importFrom(flextable,hline_top)
importFrom(flextable,set_header_df)
importFrom(flextable,set_header_labels)
importFrom(lifecycle,deprecated)
importFrom(lifecycle,is_present)
importFrom(methods,formalArgs)
importFrom(officer,body_add_fpar)
importFrom(officer,body_add_img)
importFrom(purrr,safely)
importFrom(purrr,walk)
importFrom(rlang,":=")
importFrom(rlang,as_function)
importFrom(rlang,as_string)
importFrom(rlang,is_named)
importFrom(rlang,is_null)
importFrom(stats,cor.test)
importFrom(stats,fisher.test)
importFrom(stats,glm)
importFrom(stats,kruskal.test)
importFrom(stats,lm)
importFrom(stats,median)
importFrom(stringr,str_starts)
importFrom(stringr,str_subset)
importFrom(stringr,str_wrap)
importFrom(tibble,add_row)
importFrom(tibble,as_tibble)
importFrom(tibble,column_to_rownames)
importFrom(tidyr,unite)
importFrom(tidyr,unpack)
importFrom(utils,browseURL)
TODO:
For instance, try this code:
f = function(){
2
}
#dummy function
# don't remove me please
I've run autoimport()
on the code in https://github.com/mlverse/tabnet
and I get some unexpected removal of existing and required Roxygen #' @importFrom
autoimport()
file R/plot.R
includes the following lines where importFrom in line 20 is used in line 45 of code:
https://github.com/mlverse/tabnet/blob/7186ba6048a6818283d05fb86c2af6ead862173b/R/plot.R#L20-L45
file R/parsnip.R
includes the following lines where importFrom in line 302 is used in line 303 of the code:
https://github.com/mlverse/tabnet/blob/7186ba6048a6818283d05fb86c2af6ead862173b/R/parsnip.R#L300-L307
autoimport()
Reproducible example
# git clone https://github.com/mlverse/tabnet
# cd tabnet
library(autoimport)
library(tidyverse)
autoimport(files = "R/plot.R")
autoimport(files = "R/parsnip.R")
Current situation
Being very inspired by the presentation at RR_2023 Avignon, I've run autoimport() on the code in https://github.com/mlverse/tabnet
I'm impressed by the user interface but the parsing is missing some explicit ::() statements in the code :
missing @ImportFrom have been manually added in a specific commit and can be seen in few locations like :
Reproducible example
# git clone https://github.com/mlverse/tabnet
# cd tabnet
library(autoimport)
autoimport(files = "R/tab-network.R")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.