Skip to content

Commit

Permalink
Merge pull request #65 from r-lib/RC-0.1.0
Browse files Browse the repository at this point in the history
Release Candidate 0.1.0
  • Loading branch information
EmilHvitfeldt authored May 31, 2024
2 parents 633175d + 6c4a039 commit 10dce2a
Show file tree
Hide file tree
Showing 28 changed files with 90 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@
^codecov\.yml$
^\.vscode$
^debug$
^cran-comments\.md$
^CRAN-SUBMISSION$
15 changes: 9 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Package: sparsevctrs
Title: Sparse Vectors for Use in Data Frames
Version: 0.0.0.9000
Version: 0.1.0.9000
Authors@R: c(
person("Emil", "Hvitfeldt", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-0679-1945")),
person("Davis", "Vaughan", , "[email protected]", role = "ctb"),
person("Posit Software, PBC", role = c("cph", "fnd"))
)
Description: Provides sparse vectors powered by ALTREP that behave like
regular vectors, and can thus be used in data frames. Also provides
tools to convert between sparse matrices and data frames with sparse
columns and functions to interact with sparse vectors.
Description: Provides sparse vectors powered by ALTREP (Alternative
Representations for R Objects) that behave like regular vectors, and
can thus be used in data frames. Also provides tools to convert
between sparse matrices and data frames with sparse columns and
functions to interact with sparse vectors.
License: MIT + file LICENSE
URL: https://github.com/r-lib/sparsevctrs,
https://r-lib.github.io/sparsevctrs/
Expand All @@ -30,7 +32,8 @@ Suggests:
withr
VignetteBuilder:
knitr
Config/Needs/website: tidyverse/tidytemplate, rmarkdown, lobstr, ggplot2, bench, tidyr, ggbeeswarm
Config/Needs/website: tidyverse/tidytemplate, rmarkdown, lobstr, ggplot2,
bench, tidyr, ggbeeswarm
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# sparsevctrs (development version)

# sparsevctrs 0.1.0

* Initial CRAN submission.
2 changes: 2 additions & 0 deletions R/coerce-vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#'
#' The values of `x` must be double or integer. It must not contain any `Inf` or
#' `NaN` values.
#'
#' @return sparse vectors
#'
#' @examples
#' x_dense <- c(3, 0, 2, 0, 0, 0, 4, 0, 0, 0)
Expand Down
6 changes: 6 additions & 0 deletions R/coerce.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' columns or not. Thus it works with any data frame. Needless to say, creating
#' a sparse matrix out of a dense data frame is not ideal.
#'
#' @return sparse matrix
#'
#' @seealso [coerce_to_sparse_data_frame()] [coerce_to_sparse_tibble()]
#' @examplesIf rlang::is_installed("Matrix")
#' sparse_tbl <- lapply(1:10, function(x) sparse_double(x, x, length = 10))
Expand Down Expand Up @@ -78,6 +80,8 @@ coerce_to_sparse_matrix <- function(x) {
#' @details
#' The only requirement from the sparse matrix is that it contains column names.
#'
#' @return tibble with sparse columns
#'
#' @seealso [coerce_to_sparse_data_frame()] [coerce_to_sparse_matrix()]
#' @examplesIf rlang::is_installed("tibble")
#' set.seed(1234)
Expand Down Expand Up @@ -126,6 +130,8 @@ coerce_to_sparse_tibble <- function(x) {
#' @details
#' The only requirement from the sparse matrix is that it contains column names.
#'
#' @return data.frame with sparse columns
#'
#' @seealso [coerce_to_sparse_tibble()] [coerce_to_sparse_matrix()]
#' @examplesIf rlang::is_installed("Matrix")
#' set.seed(1234)
Expand Down
2 changes: 2 additions & 0 deletions R/extractors.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#' @details
#' for ease of use, these functions also works on non-sparse variables.
#'
#' @return vectors of requested attributes
#'
#' @examples
#' x_sparse <- sparse_double(c(pi, 5, 0.1), c(2, 5, 10), 10)
#' x_dense <- c(0, pi, 0, 0, 0.5, 0, 0, 0, 0, 0.1)
Expand Down
2 changes: 2 additions & 0 deletions R/sparse_character.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#' setting `options("sparsevctrs.verbose_materialize" = TRUE)` will print a
#' message each time a sparse vector has been forced to materialize.
#'
#' @return sparse character vector
#'
#' @seealso [sparse_double()] [sparse_integer()]
#'
#' @examples
Expand Down
2 changes: 2 additions & 0 deletions R/sparse_double.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#' setting `options("sparsevctrs.verbose_materialize" = TRUE)` will print a
#' message each time a sparse vector has been forced to materialize.
#'
#' @return sparse double vector
#'
#' @seealso [sparse_integer()] [sparse_character()]
#'
#' @examples
Expand Down
2 changes: 2 additions & 0 deletions R/sparse_integer.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#' setting `options("sparsevctrs.verbose_materialize" = TRUE)` will print a
#' message each time a sparse vector has been forced to materialize.
#'
#' @return sparse integer vector
#'
#' @seealso [sparse_double()] [sparse_character()]
#'
#' @examples
Expand Down
2 changes: 2 additions & 0 deletions R/sparse_logical.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#' setting `options("sparsevctrs.verbose_materialize" = TRUE)` will print a
#' message each time a sparse vector has been forced to materialize.
#'
#' @return sparse logical vector
#'
#' @seealso [sparse_double()] [sparse_integer()] [sparse_character()]
#'
#' @examples
Expand Down
2 changes: 2 additions & 0 deletions R/type-predicates.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#' more specific functions that only detects the type. `is_sparse_numeric()`
#' matches both sparse integers and doubles.
#'
#' @return single logical value
#'
#' @examples
#' x_sparse <- sparse_double(c(pi, 5, 0.1), c(2, 5, 10), 10)
#' x_dense <- c(0, pi, 0, 0, 0.5, 0, 0, 0, 0, 0.1)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ x_dense[7] <- 1
x_dense[15] <- 10

obj_size(x_sparse)
#> 1.24 kB
#> 1.35 kB
obj_size(x_dense)
#> 8.05 kB

Expand All @@ -64,11 +64,11 @@ x_sparse_1000 <- sparse_double(numeric(), integer(), length = 1000)
x_sparse_1000000 <- sparse_double(numeric(), integer(), length = 10000000)

obj_size(x_sparse_0)
#> 1.19 kB
#> 1.30 kB
obj_size(x_sparse_1000)
#> 1.19 kB
#> 1.30 kB
obj_size(x_sparse_1000000)
#> 1.19 kB
#> 1.30 kB

x_dense_0 <- numeric(0)
x_dense_1000 <- numeric(1000)
Expand Down
10 changes: 10 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## Submission comments

- Expanded ALTREP acronym in description field.
- No known references that needs added.

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.
3 changes: 3 additions & 0 deletions man/coerce-vector.Rd

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

3 changes: 3 additions & 0 deletions man/coerce_to_sparse_data_frame.Rd

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

3 changes: 3 additions & 0 deletions man/coerce_to_sparse_matrix.Rd

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

3 changes: 3 additions & 0 deletions man/coerce_to_sparse_tibble.Rd

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

3 changes: 3 additions & 0 deletions man/extractors.Rd

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

3 changes: 3 additions & 0 deletions man/sparse_character.Rd

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

3 changes: 3 additions & 0 deletions man/sparse_double.Rd

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

3 changes: 3 additions & 0 deletions man/sparse_integer.Rd

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

3 changes: 3 additions & 0 deletions man/sparse_logical.Rd

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

3 changes: 2 additions & 1 deletion man/sparsevctrs-package.Rd

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

3 changes: 3 additions & 0 deletions man/type-predicates.Rd

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

4 changes: 2 additions & 2 deletions src/altrep-sparse-double.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SEXP alrep_sparse_double_Materialize(SEXP x) {
// ALTVEC

void* altrep_sparse_double_Dataptr(SEXP x, Rboolean writeable) {
return STDVEC_DATAPTR(alrep_sparse_double_Materialize(x));
return DATAPTR(alrep_sparse_double_Materialize(x));
}

const void* altrep_sparse_double_Dataptr_or_null(SEXP x) {
Expand All @@ -67,7 +67,7 @@ const void* altrep_sparse_double_Dataptr_or_null(SEXP x) {
if (out == R_NilValue) {
return NULL;
} else {
return STDVEC_DATAPTR(out);
return DATAPTR(out);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/altrep-sparse-integer.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SEXP alrep_sparse_integer_Materialize(SEXP x) {
// ALTVEC

void* altrep_sparse_integer_Dataptr(SEXP x, Rboolean writeable) {
return STDVEC_DATAPTR(alrep_sparse_integer_Materialize(x));
return DATAPTR(alrep_sparse_integer_Materialize(x));
}

const void* altrep_sparse_integer_Dataptr_or_null(SEXP x) {
Expand All @@ -67,7 +67,7 @@ const void* altrep_sparse_integer_Dataptr_or_null(SEXP x) {
if (out == R_NilValue) {
return NULL;
} else {
return STDVEC_DATAPTR(out);
return DATAPTR(out);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/altrep-sparse-logical.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ SEXP alrep_sparse_logical_Materialize(SEXP x) {
// ALTVEC

void* altrep_sparse_logical_Dataptr(SEXP x, Rboolean writeable) {
return STDVEC_DATAPTR(alrep_sparse_logical_Materialize(x));
return DATAPTR(alrep_sparse_logical_Materialize(x));
}

const void* altrep_sparse_logical_Dataptr_or_null(SEXP x) {
Expand All @@ -67,7 +67,7 @@ const void* altrep_sparse_logical_Dataptr_or_null(SEXP x) {
if (out == R_NilValue) {
return NULL;
} else {
return STDVEC_DATAPTR(out);
return DATAPTR(out);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/altrep-sparse-string.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SEXP alrep_sparse_string_Materialize(SEXP x) {
// ALTVEC

void* altrep_sparse_string_Dataptr(SEXP x, Rboolean writeable) {
return STDVEC_DATAPTR(alrep_sparse_string_Materialize(x));
return DATAPTR(alrep_sparse_string_Materialize(x));
}

const void* altrep_sparse_string_Dataptr_or_null(SEXP x) {
Expand All @@ -66,7 +66,7 @@ const void* altrep_sparse_string_Dataptr_or_null(SEXP x) {
if (out == R_NilValue) {
return NULL;
} else {
return STDVEC_DATAPTR(out);
return DATAPTR(out);
}
}

Expand Down

0 comments on commit 10dce2a

Please sign in to comment.