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

datanames in vignettes #239

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

datanames in vignettes #239

wants to merge 22 commits into from

Conversation

gogonzo
Copy link
Contributor

@gogonzo gogonzo commented Dec 18, 2024

Refers to #338

  • Modified a documentation a little bit to emphasize inheritance from environment.
  • @averissimo I'm thinking to move description of eval_code, within, get_code away from details of qenv to a new section "Interacting with qenv".
  • I'm thinking also to use a term "qenv environment" instead of "qenv object" to emphasize it is an environment.

@gogonzo gogonzo added the core label Dec 18, 2024
@gogonzo gogonzo changed the title 338 datanames in vignettes datanames in vignettes Dec 18, 2024
Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • @averissimo I'm thinking to move description of eval_code, within, get_code away from details of qenv to a new section "Interacting with qenv".

Keeping it in @details makes it consistent with other R documentation and our own.

But I'm not opposed to this change if it improves the readability

R/qenv-eval_code.R Outdated Show resolved Hide resolved
R/qenv-constructor.R Outdated Show resolved Hide resolved
@gogonzo
Copy link
Contributor Author

gogonzo commented Dec 18, 2024

Keeping it in @details makes it consistent with other R documentation and our own.
But I'm not opposed to this change if it improves the readability

Yup, I think it is fine now. It was my first thought with the @details but right now sections looks better.

@gogonzo gogonzo marked this pull request as ready for review December 18, 2024 21:37
Copy link
Contributor

github-actions bot commented Dec 18, 2024

badge

Code Coverage Summary

Filename                         Stmts    Miss  Cover    Missing
-----------------------------  -------  ------  -------  ---------
R/qenv-c.R                          55       0  100.00%
R/qenv-class.R                      12       0  100.00%
R/qenv-concat.R                      7       0  100.00%
R/qenv-constructor.R                 1       0  100.00%
R/qenv-errors.R                      4       4  0.00%    6-9
R/qenv-eval_code.R                  57       2  96.49%   106, 115
R/qenv-extract.R                    30       0  100.00%
R/qenv-get_code.R                   24       0  100.00%
R/qenv-get_env.R                     3       1  66.67%   27
R/qenv-get_messages.r                5       0  100.00%
R/qenv-get_var.R                    26       0  100.00%
R/qenv-get_warnings.R                5       0  100.00%
R/qenv-join.R                        7       7  0.00%    137-151
R/qenv-length.R                      2       1  50.00%   2
R/qenv-show.R                       29      29  0.00%    19-50
R/qenv-within.R                      8       0  100.00%
R/utils-get_code_dependency.R      200       2  99.00%   160, 258
R/utils.R                           30       0  100.00%
TOTAL                              505      46  90.89%

Diff against main

Filename         Stmts    Miss  Cover
-------------  -------  ------  --------
R/qenv-show.R      +28     +28  +100.00%
TOTAL              +28     +28  -5.34%

Results for commit: a44e53c

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

Copy link
Contributor

github-actions bot commented Dec 18, 2024

Unit Tests Summary

  1 files   12 suites   3s ⏱️
151 tests 146 ✅ 5 💤 0 ❌
230 runs  225 ✅ 5 💤 0 ❌

Results for commit a44e53c.

♻️ This comment has been updated with latest results.

@gogonzo gogonzo requested a review from averissimo December 19, 2024 13:02
Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I've added a few comments

R/qenv-eval_code.R Outdated Show resolved Hide resolved
R/qenv-get_code.R Outdated Show resolved Hide resolved
R/qenv-within.R Outdated Show resolved Hide resolved
R/qenv-within.R Outdated Show resolved Hide resolved
R/qenv-eval_code.R Outdated Show resolved Hide resolved
R/qenv-within.R Outdated
#'
#' @section Using language objects with `within`:
#' Passing language objects to `expr` is generally not intended but can be achieved with `do.call`.
#' Only single `expression`s will work and substitution is not available. See examples.
#'
#' @param data (`qenv`)
#' @param expr (`expression`) to evaluate. Must be inline code, see `Using language objects...`
#' @param ... see `Details`
#' @param ... (`named`) argument value will substitute a symbol in the `expr` matched by the name.
#' For practical examples see the #usage.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#usage alone is not generating a link, the suggestion bellow creates it on pkgdown but not on the man page (those don't have HTML id in order for the anchor to work)

Suggested change
#' For practical examples see the #usage.
#' For practical examples see the [usage](#ref-usage) above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least in rstudio

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I meant For practical usage see the examples - changed but I don't know how to link Examples section. I don't think it is necessary but would be nice

Co-authored-by: André Veríssimo <[email protected]>
Signed-off-by: Dawid Kałędkowski <[email protected]>
R/qenv-show.R Outdated Show resolved Hide resolved
Copy link
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job with the custom print method, the grayed out names is a brilliant touch

I think it works great with most cases I can think of. It doesn't show the right class with rlang::missing_arg(), but that is a very special case

pkgload::load_all("teal.code", export_all = TRUE)
weird_classes <- qenv() |> 
  within({
    a <- 2
    b <- 5 + 1i
    c <- 10L
    .d_e <- new.env()
    data("miniACC", package = "MultiAssayExperiment", envir = .d_e)
    .d <- .d_e$miniACC
    e <- structure(list(1), class = c("yada", "bla"))
    .f <- iris
    ` a very !weird name` <- R6::R6Class("A", public = list(a = 1))
    an_r6_instance <- R6::R6Class("A Class", public = list(a = 1))$new()
    g <- structure(list(1), class = "override")
    class(g) <- 2
    h <- function(x) 1234
    x <- rlang::missing_arg()
    y <- quote(foo)
    z <- expression(1+1)
  })
weird_classes
#> <environment: 0x6132e7c2c728> [L]
#> Parent: <environment: package:MultiAssayExperiment> 
#> - ` a very !weird name`: [R6ClassGenerator]
#> - a: [numeric]
#> - an_r6_instance: [A Class]
#> - b: [complex]
#> - c: [integer]
#> - e: [yada]
#> - g: [2]
#> - h: [function]
#> - x: [name]
#> - y: [name]
#> - z: [expression]
#> - .d: [MultiAssayExperiment]
#> - .d_e: [environment]
#> - .f: [data.frame]
rlang::env_print(as.environment(weird_classes))
#> <environment: 0x6132e7c2c728> [L]
#> Parent: <environment: package:MultiAssayExperiment>
#> Bindings:
#> • x: <missing> [L]
#> • y: <sym> [L]
#> • z: <expression> [L]
#> • a: <dbl> [L]
#> • b: <cpl> [L]
#> • c: <int> [L]
#> • e: <yada> [L]
#> • an_r6_instance: <A Class> [L]
#> • g: <2> [L]
#> • h: <fn> [L]
#> • ` a very !weird name`: <R6ClssGn> [L]
#> • .d_e: <env> [L]
#> • .d: <MltAssyE> [L]
#> • .f: <df[,5]> [L]

Created on 2024-12-20 with reprex v2.1.1

- Bindings:
R/qenv-show.R Outdated Show resolved Hide resolved
sprintf(
"- %s: [%s]\n",
deparse(rlang::sym(x), backtick = TRUE),
class(object[[x]])[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about using pillar::type_sum to get the class type?

We would use the same naming as tidyverse and it would get some extra specificity/weird cases (numeric -> dbl, rlang::missing_arg/symbol/quote/name and I'm sure some others)

The loss here would be shorter names and an extra dependency just for the show.qenv method

(same to be applied to hidden class below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of changing original class names neither using extra dependency for it

Co-authored-by: André Veríssimo <[email protected]>
Signed-off-by: Dawid Kałędkowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants