From 2964dc42a000d2955a6321f52dd7974cb776cf5e Mon Sep 17 00:00:00 2001 From: "C. Regouby" Date: Sat, 28 Jun 2025 17:36:28 +0200 Subject: [PATCH 1/2] prevent vignette rendering when torch is not installed --- vignettes/aum_loss.qmd | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/vignettes/aum_loss.qmd b/vignettes/aum_loss.qmd index b31ab9a..e5d0c66 100644 --- a/vignettes/aum_loss.qmd +++ b/vignettes/aum_loss.qmd @@ -9,13 +9,16 @@ format: fig-width: 9 fig-height: 6 fig-cap-location: "top" -knitr: - opts_chunk: - collapse: true - comment: "#>" - eval: true --- +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>", + eval = torch::torch_is_installed() +) +``` + ```{r setup} library(tabnet) suppressPackageStartupMessages(library(tidymodels)) From 9878986196c2492e5041722528b2d3374eb2d06d Mon Sep 17 00:00:00 2001 From: "C. Regouby" Date: Mon, 30 Jun 2025 22:23:35 +0200 Subject: [PATCH 2/2] turn into ExamplesIf --- R/mask-type.R | 4 +++- cran-comments.md | 4 +--- man/entmax15.Rd | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/R/mask-type.R b/R/mask-type.R index af053dc..6385451 100644 --- a/R/mask-type.R +++ b/R/mask-type.R @@ -297,11 +297,13 @@ entmax_15_function <- torch::autograd_function( #' @return The projection result P of the same shape as input, such that #' \eqn{\sum_{dim} P = 1 \forall dim} elementwise. #' -#' @examples +#' @examplesIf torch::torch_is_installed() +#' \dontrun{ #' input <- torch::torch_randn(10,5, requires_grad = TRUE) #' # create a top3 alpha=1.5 entmax on last input dimension #' nn_entmax <- entmax15(dim=-1L, k = 3) #' result <- nn_entmax(input) +#' } #' @export entmax15 <- torch::nn_module( "entmax_15", diff --git a/cran-comments.md b/cran-comments.md index dcdbd93..0636d49 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -4,6 +4,4 @@ * This is a new release. -Note 1 : Package new submission after fixing the issues that led to archiving on 2025-04-01. - Misspelled words in description are names and have been added to package `inst/WORDLIST` -Note 2 : Example duration is inherent to fitting a model with the underlying torch framework. +Note 1 : Example duration is inherent to fitting a model with the underlying torch framework. diff --git a/man/entmax15.Rd b/man/entmax15.Rd index 565c727..6c04e65 100644 --- a/man/entmax15.Rd +++ b/man/entmax15.Rd @@ -31,8 +31,12 @@ Solves the optimization problem: where \eqn{H_{1.5}(P)} is the Tsallis alpha-entropy with \eqn{\alpha=1.5}. } \examples{ +\dontshow{if (torch::torch_is_installed()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +\dontrun{ input <- torch::torch_randn(10,5, requires_grad = TRUE) # create a top3 alpha=1.5 entmax on last input dimension nn_entmax <- entmax15(dim=-1L, k = 3) result <- nn_entmax(input) } +\dontshow{\}) # examplesIf} +}