Skip to content

Commit

Permalink
Merge pull request #478 from lionel-/release-0-2-0
Browse files Browse the repository at this point in the history
Prepare release 0.2.0
  • Loading branch information
lionel- authored Jul 2, 2019
2 parents 9c39657 + 076c023 commit 5edf2c0
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 82 deletions.
10 changes: 9 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
Package: vctrs
Title: Vector Helpers
Version: 0.1.99.9000
Version: 0.2.0
Authors@R:
c(person(given = "Hadley",
family = "Wickham",
role = c("aut", "cre"),
email = "[email protected]"),
person(given = "Lionel",
family = "Henry",
role = "aut",
email = "[email protected]"),
person(given = "Davis",
family = "Vaughan",
role = "aut",
email = "[email protected]"),
person(given = "RStudio",
role = "cph"))
Description: Defines new notions of prototype and size that are
Expand Down
143 changes: 78 additions & 65 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# vctrs 0.1.99.9000
# vctrs 0.2.0

With the 0.2.0 release, many vctrs functions have been rewritten with
native C code to improve performance. Functions like `vec_c()` and
Expand All @@ -19,13 +19,11 @@ or possible cast.

## Breaking changes

* We have renamed the `type` particle to `ptype`:

- `vec_type()` => `vec_ptype()`
- `vec_type2()` => `vec_ptype2()`
- `vec_type_common()` => `vec_ptype_common()`

Consequently, `vec_ptype()` was renamed to `vec_ptype_show()`.
* Lossy casts now throw errors of type `vctrs_error_cast_lossy`.
Previously these were warnings. You can suppress these errors
selectively with `allow_lossy_cast()` to get the partial cast
results. To implement your own lossy cast operation, call the new
exported function `maybe_lossy_cast()`.

* `vec_c()` now fails when an input is supplied with a name but has
internal names or is length > 1:
Expand All @@ -52,21 +50,24 @@ or possible cast.
vec_c(foo = c(a = 1), .name_spec = ~ paste(.x, .y, sep = "_"))
```

* `vec_empty()` has been renamed to `vec_is_empty()`.

* `vec_dim()` and `vec_dims()` are no longer exported.

* `vec_na()` has been renamed to `vec_init()`, as the primary use case
is to initialize an output container.

* `vec_slice<-` is now type stable (#140). It always returns the same
type as the LHS. If needed, the RHS is cast to the correct type, but
only if both inputs are coercible. See examples in `?vec_slice`.

* Lossy casts now throw errors of type `vctrs_error_cast_lossy`. You
can suppress these errors selectively with `allow_lossy_cast()` to
get the partial cast results. To implement your own lossy cast
operation, call the new exported function `maybe_lossy_cast()`.
* We have renamed the `type` particle to `ptype`:

* `vec_empty()` has been renamed to `vec_is_empty()`.
- `vec_type()` => `vec_ptype()`
- `vec_type2()` => `vec_ptype2()`
- `vec_type_common()` => `vec_ptype_common()`

* `vec_dim()` and `vec_dims()` are no longer exported.
Consequently, `vec_ptype()` was renamed to `vec_ptype_show()`.


## New features
Expand Down Expand Up @@ -96,17 +97,28 @@ or possible cast.
If you inherit from `vctrs_vctr` or `vctrs_rcrd` you don't need to
implement `vec_proxy()`.

* `vec_slice()` now supports row names.
* `vec_c()`, `vec_rbind()`, and `vec_cbind()` gain a `.name_repair`
argument (#227, #229).

* `list_of()` now has an `as.character()` method. It uses
`vec_ptype_abbr()` to collapse complex objects into their type
representation (tidyverse/tidyr#654).
* `vec_c()`, `vec_rbind()`, `vec_cbind()`, and all functions relying
on `vec_ptype_common()` now have more informative error messages
when some of the inputs have nested data frames that are not
convergent:

```
df1 <- tibble(foo = tibble(bar = tibble(x = 1:3, y = letters[1:3])))
df2 <- tibble(foo = tibble(bar = tibble(x = 1:3, y = 4:6)))
vec_rbind(df1, df2)
#> Error: No common type for `..1$foo$bar$y` <character> and `..2$foo$bar$y` <integer>.
```

* `vec_cbind()` now turns named data frames to packed columns.

```r
data <- tibble::tibble(x = 1:3, y = letters[1:3])
data <- vec_cbind(data, packed = data)
data
# A tibble: 3 x 3
x y packed$x $y
<int> <chr> <int> <chr>
Expand All @@ -131,86 +143,87 @@ or possible cast.
We are planning to use this syntax more widely in the tidyverse.

* New `vec_is()` function to check whether a vector conforms to a
protopty and/or a size. Unlike `vec_assert()`, it doesn't throw
prototype and/or a size. Unlike `vec_assert()`, it doesn't throw
errors but returns `TRUE` or `FALSE` (#79).
Called without a specific type or size, it tests whether an object
is a data vector or a scalar. S3 lists are treated as scalars by
default. Implement a `vec_is_vector()` for your class to override
this property (or derive from `vctrs_vctr`).
Called without a specific type or size, `vec_assert()` tests whether
an object is a data vector or a scalar. S3 lists are treated as
scalars by default. Implement a `vec_is_vector()` for your class to
override this property (or derive from `vctrs_vctr`).
* New `vec_split(x, by)` is a generalisation of `split()` that can divide
a vector into groups formed by the unique values of another vector. Returns
a two-column data frame containing unique values of `by` aligned with
matching `x` values (#196).
* `vec_init()` checks input is a vector.
* New `vec_order()` and `vec_sort()` for ordering and sorting
generalised vectors.
* New `.names_to` parameter for `vec_rbind()`. If supplied, this
should be the name of a column where the names of the inputs are
copied. This is similar to the `.id` parameter of
`dplyr::bind_rows()`.
* `vec_c()`, `vec_rbind()`, and `vec_cbind()` gain a `.name_repair`
argument (#227, #229).
* New `vec_seq_along()` and `vec_init_along()` create useful sequences (#189).
* `vec_slice()` now preserves character row names, if present.
* New `vec_split(x, by)` is a generalisation of `split()` that can divide
a vector into groups formed by the unique values of another vector. Returns
a two-column data frame containing unique values of `by` aligned with
matching `x` values (#196).
## Other features and bug fixes
* Using classed errors of class `"vctrs_error_assert"` for failed
assertions, and of class `"vctrs_error_incompatible"` (with
subclasses `_type`, `_cast` and `_op`) for errors on incompatible
types (#184).
* Character indexing is now only supported for named objects, an error
is raised for unnamed objects (#171).
* Predicate generics now consistently return logical vectors when
passed a `vctrs_vctr` class. They used to restore the output to
their input type (#251).
* `list_of()` now has an `as.character()` method. It uses
`vec_ptype_abbr()` to collapse complex objects into their type
representation (tidyverse/tidyr#654).
* New `stop_incompatible_size()` to signal a failure due to mismatched sizes.
* `vec_slice<-` now has a `vec_assign()` alias. Use `vec_assign()`
when you don't want to modify the original input.
* New `validate_list_of()` (#193).
* `vec_slice()` now calls `vec_restore()` automatically. Unlike the
default `[` method from base R, attributes are preserved by default.
* `vec_arith()` is consistent with base R when combining `difftime`
and `date`, with a warning if casts are lossy (#192).
* `vec_size()` now works with positive short row names. This fixes
issues with data frames created with jsonlite (#220).
* `vec_c()` and `vec_rbind()` now handle data.frame columns properly
(@yutannihilation, #182).
* New `validate_list_of()` (#193).
* `vec_cast(x, data.frame())` preserves the number of rows in `x`.
* `vec_equal()` now handles missing values symmetrically (#204).
* `vec_equal_na()` now returns `TRUE` for data frames and records when
every component is missing, not when _any_ component is missing
(#201).
* `vec_init()` checks input is a vector.
* `vec_proxy_compare()` gains an experimental `relax` argument, which
allows data frames to be orderable even if all their columns are not
(#210).
* New `vec_order()` and `vec_sort()` for ordering and sorting
generalised vectors.
* `vec_size()` now works with positive short row names. This fixes
issues with data frames created with jsonlite (#220).
* New `vec_repeat()` for repeating each element of a vector the same number
of times.
* `vec_slice<-` now has a `vec_assign()` alias. Use `vec_assign()`
when you don't want to modify the original input.

* `vec_slice()` can correct slice 0-row data frames (#179).
* `vec_slice()` now calls `vec_restore()` automatically. Unlike the
default `[` method from base R, attributes are preserved by default.

* New `vec_seq_along()` and `vec_init_along()` create useful sequences (#189).
* `vec_slice()` can correct slice 0-row data frames (#179).

* `vec_equal_na()` now returns `TRUE` for data frames and records when
every component is mising, not when _any_ component is missing
(#201).
* New `vec_repeat()` for repeating each element of a vector the same number
of times.

* `vec_type2(x, data.frame())` ensures that the returned object has
names that are a length-0 character vector.

* `vec_cast(x, data.frame())` preserves the number of rows in the `x`.

* Added a `NEWS.md` file to track changes to the package.

* Using classed errors of class `"vctrs_error_assert"` for failed
assertions, and of class `"vctrs_error_incompatible"` (with
subclasses `_type`, `_cast` and `_op`) for errors on incompatible
types (#184).

* Character indexing is now only supported for named objects, an error
is raised for unnamed objects (#171).

* `vec_c()` and `vec_rbind()` now handle data.frame columns properly
(@yutannihilation, #182).

* `vec_arith()` is consistent with base R when combining `difftime`
and `date`, with a warning if casts are lossy (#192).
2 changes: 1 addition & 1 deletion R/type-unspecified.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' A 1d vector of unspecified type
#'
#' This is a [partial type](new_partial) used to represent logical vectors
#' This is a [partial type][new_partial] used to represent logical vectors
#' that only contain `NA`. These require special handling because we want to
#' allow `NA` to specify missingness without requiring a type.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/type.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' successively calls [vec_ptype2()] to find a common type.
#'
#' @section Prototype:
#' A prototype is [size](vec_size) 0 vector containing attributes, but no
#' A prototype is [size][vec_size] 0 vector containing attributes, but no
#' data. Generally, this is just `vec_slice(x, 0L)`, but some inputs
#' require special handling.
#'
Expand Down
39 changes: 36 additions & 3 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,43 @@ reference:
- vec_data
- vec_ptype
- vec_size
- vec_is
- vec_assert

- title: Casting and combining
contents:
- vec_c
- vec_cbind

- title: Matching
- title: Slicing and recycling
contents:
- vec_init
- vec_slice
- vec_assign
- vec_recycle

- title: Equality and ordering
contents:
- vec_equal
- vec_compare

- title: Sorting
contents:
- vec_sort
- vec_order

- title: Matching and splitting
contents:
- vec_count
- vec_duplicate
- vec_unique
- vec_in
- vec_split

- title: Sequences and repetitions
contents:
- vec_repeat
- vec_seq_along

- title: New classes
contents:
Expand All @@ -28,12 +53,20 @@ reference:
- vctr
- vec_cast
- vec_list_cast
- vec_type2
- vec_grp_compare
- vec_ptype2
- vec_proxy_compare
- vec_proxy_equal
- vec_ptype_full
- vec_ptype_finalise
- "vctrs-conditions"
- rcrd
- fields
- s3_register
- vec_resize
- vec_arith
- vec_math
- unspecified
- vec_default_cast
- vec_default_ptype2
- vec_as_names
- vec_as_index
20 changes: 11 additions & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
This is a resubmission, fixing an obvious problem in the description.

---

## Test environments
* local OS X install, R 3.5.1
* ubuntu 14.04 (on travis-ci), R 3.5.1
* win-builder (devel and release)

* local macOS: release
* Travis Ubuntu: 3.2, 3.3, oldrel, release, devel
* win-builder: release, devel
* R-Hub: UBSAN, rchk, and valgrind builds

## R CMD check results

0 errors | 0 warnings | 1 note
0 errors | 0 warnings | 0 notes

There are 3 reverse dependencies, two of which are broken by this
vctrs release (evaluator and probably).

* This is a new release.
- We will send an update of {probably} shortly.
- We have notified the maintainer of {evaluator} of the failure.
2 changes: 1 addition & 1 deletion man/unspecified.Rd

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

6 changes: 6 additions & 0 deletions man/vctrs-package.Rd

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

2 changes: 1 addition & 1 deletion man/vec_ptype.Rd

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

0 comments on commit 5edf2c0

Please sign in to comment.