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

Inherit from the base type by default in new_vctr() #1213

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# vctrs (development version)

* `new_vctr()` now inherits from the base type of its input by
default.

* New performant `data_frame()` constructor for creating data frames in a way
that follows tidyverse semantics. Among other things, inputs are recycled
using tidyverse recycling rules, strings are never converted to factors,
Expand Down
12 changes: 2 additions & 10 deletions R/type-vctr.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
new_vctr <- function(.data,
...,
class = character(),
inherit_base_type = NULL) {
inherit_base_type = TRUE) {
if (!is_vector(.data)) {
abort("`.data` must be a vector type.")
}
Expand All @@ -78,19 +78,11 @@ new_vctr <- function(.data,
if (is.data.frame(.data)) {
abort("`.data` can't be a data frame.")
}

if (is.null(inherit_base_type)) {
inherit_base_type <- TRUE
} else if (is_false(inherit_base_type)) {
if (is_false(inherit_base_type)) {
abort("List `.data` must inherit from the base type.")
}
}

# Default to `FALSE` in all cases except lists
if (is.null(inherit_base_type)) {
inherit_base_type <- FALSE
}

class <- c(class, "vctrs_vctr", if (inherit_base_type) typeof(.data))
attrib <- list(names = nms, ..., class = class)

Expand Down
2 changes: 1 addition & 1 deletion man/new_vctr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions revdep/vctrs/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Revdeps

## Failed to check (1)
## Failed to check (4)

|package |version |error |warning |note |
|:-------|:-------|:-----|:-------|:----|
|drake |? | | | |
|package |version |error |warning |note |
|:-----------|:-------|:-----|:-------|:----|
|codebook |? | | | |
|drake |? | | | |
|evaluator |? | | | |
|salesforcer |? | | | |

## New problems (1)

|package |version |error |warning |note |
|:--------------------------|:-------|:-----|:-------|:----|
|[dplyr](problems.md#dplyr) |1.0.1 | |__+3__ |1 |

237 changes: 236 additions & 1 deletion revdep/vctrs/failures.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
# codebook

<details>

* Version: 0.9.2
* Source code: https://github.com/cran/codebook
* URL: https://github.com/rubenarslan/codebook
* BugReports: https://github.com/rubenarslan/codebook/issues
* Date/Publication: 2020-06-06 23:40:03 UTC
* Number of recursive dependencies: 192

Run `cloud_details(, "codebook")` for more info

</details>

## Error before installation

### Devel

```
* using log directory ‘/tmp/workdir/codebook/new/codebook.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘codebook/DESCRIPTION’ ... OK
* this is package ‘codebook’ version ‘0.9.2’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: ‘psych’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
### CRAN

```
* using log directory ‘/tmp/workdir/codebook/old/codebook.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘codebook/DESCRIPTION’ ... OK
* this is package ‘codebook’ version ‘0.9.2’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: ‘psych’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
# drake

<details>
Expand All @@ -7,7 +84,7 @@
* URL: https://github.com/ropensci/drake, https://docs.ropensci.org/drake, https://books.ropensci.org/drake/
* BugReports: https://github.com/ropensci/drake/issues
* Date/Publication: 2020-06-29 17:20:03 UTC
* Number of recursive dependencies: 141
* Number of recursive dependencies: 142

Run `cloud_details(, "drake")` for more info

Expand Down Expand Up @@ -74,4 +151,162 @@ Status: 1 ERROR



```
# evaluator

<details>

* Version: 0.4.2
* Source code: https://github.com/cran/evaluator
* URL: https://evaluator.tidyrisk.org
* BugReports: https://github.com/davidski/evaluator/issues
* Date/Publication: 2020-04-16 09:20:09 UTC
* Number of recursive dependencies: 136

Run `cloud_details(, "evaluator")` for more info

</details>

## Error before installation

### Devel

```
* using log directory ‘/tmp/workdir/evaluator/new/evaluator.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘evaluator/DESCRIPTION’ ... OK
* this is package ‘evaluator’ version ‘0.4.2’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: ‘psych’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
### CRAN

```
* using log directory ‘/tmp/workdir/evaluator/old/evaluator.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘evaluator/DESCRIPTION’ ... OK
* this is package ‘evaluator’ version ‘0.4.2’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: ‘psych’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
# salesforcer

<details>

* Version: 0.2.0
* Source code: https://github.com/cran/salesforcer
* URL: https://github.com/StevenMMortimer/salesforcer
* BugReports: https://github.com/StevenMMortimer/salesforcer/issues
* Date/Publication: 2020-07-21 20:40:03 UTC
* Number of recursive dependencies: 87

Run `cloud_details(, "salesforcer")` for more info

</details>

## Error before installation

### Devel

```
* using log directory ‘/tmp/workdir/salesforcer/new/salesforcer.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘salesforcer/DESCRIPTION’ ... OK
* this is package ‘salesforcer’ version ‘0.2.0’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package required but not available: ‘XML’

Package suggested but not available: ‘RForcecom’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
### CRAN

```
* using log directory ‘/tmp/workdir/salesforcer/old/salesforcer.Rcheck’
* using R version 3.6.3 (2020-02-29)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using options ‘--no-manual --no-build-vignettes’
* checking for file ‘salesforcer/DESCRIPTION’ ... OK
* this is package ‘salesforcer’ version ‘0.2.0’
* package encoding: UTF-8
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package required but not available: ‘XML’

Package suggested but not available: ‘RForcecom’

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

See section ‘The DESCRIPTION file’ in the ‘Writing R Extensions’
manual.
* DONE
Status: 1 ERROR






```
42 changes: 41 additions & 1 deletion revdep/vctrs/problems.md
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
*Wow, no problems at all. :)*
# dplyr

<details>

* Version: 1.0.1
* Source code: https://github.com/cran/dplyr
* URL: https://dplyr.tidyverse.org, https://github.com/tidyverse/dplyr
* BugReports: https://github.com/tidyverse/dplyr/issues
* Date/Publication: 2020-07-31 07:00:05 UTC
* Number of recursive dependencies: 75

Run `cloud_details(, "dplyr")` for more info

</details>

## Newly broken

* checking whether package ‘dplyr’ can be installed ... WARNING
```
Found the following significant warnings:
Warning: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
See ‘/tmp/workdir/dplyr/new/dplyr.Rcheck/00install.out’ for details.
```

* checking Rd files ... WARNING
```
prepare_Rd: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
```

* checking for unstated dependencies in examples ... WARNING
```
Warning: replacing previous import ‘vctrs::data_frame’ by ‘tibble::data_frame’ when loading ‘dplyr’
```

## In both

* checking data for non-ASCII characters ... NOTE
```
Note: found 4 marked UTF-8 strings
```

4 changes: 1 addition & 3 deletions src/c.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,7 @@ bool needs_vec_c_fallback(SEXP ptype) {

// Suboptimal: Prevent infinite recursion through `vctrs_vctr` method
SEXP class = PROTECT(Rf_getAttrib(ptype, syms_fallback_class));
class = r_chr_get(class, r_length(class) - 1);

if (class == strings_vctrs_vctr) {
if (r_chr_has_string(class, strings_vctrs_vctr)) {
UNPROTECT(1);
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-type-vctr.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ context("test-type-vctr")

test_that("constructor sets attributes", {
x <- new_vctr(1:4, class = "x", x = 1)
expect_equal(x, structure(1:4, class = c("x", "vctrs_vctr"), x = 1))

x <- new_vctr(1:4, class = "x", x = 1, inherit_base_type = TRUE)
expect_equal(x, structure(1:4, class = c("x", "vctrs_vctr", "integer"), x = 1))

x <- new_vctr(1:4, class = "x", x = 1, inherit_base_type = FALSE)
expect_equal(x, structure(1:4, class = c("x", "vctrs_vctr"), x = 1))
})

test_that(".data must be a vector", {
Expand Down