Skip to content

Commit

Permalink
Merge pull request #243 from r-lib/rc-0.1.0
Browse files Browse the repository at this point in the history
Rc 0.1.0
  • Loading branch information
DavisVaughan authored Jul 24, 2019
2 parents 058da6f + 9a101c8 commit 68c005f
Show file tree
Hide file tree
Showing 102 changed files with 503 additions and 390 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
^LICENSE\.md$
^rray\.Rproj$
^\.Rproj\.user$
^cran-comments\.md$
^CRAN-RELEASE$
2 changes: 2 additions & 0 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This package was submitted to CRAN on 2019-07-19.
Once it is accepted, delete this file and tag the release (commit cdf05338c3).
6 changes: 2 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: rray
Title: Simple Arrays
Version: 0.0.0.9000
Version: 0.1.0
Authors@R:
c(person(given = "Davis",
family = "Vaughan",
Expand All @@ -21,7 +21,7 @@ Imports:
Rcpp (>= 1.0.1),
rlang (>= 0.4.0),
utils,
vctrs
vctrs (>= 0.2.0)
Suggests:
covr,
knitr,
Expand All @@ -31,8 +31,6 @@ Suggests:
LinkingTo:
Rcpp,
xtensor (>= 0.11.1-0)
Remotes:
r-lib/vctrs
VignetteBuilder:
knitr
Encoding: UTF-8
Expand Down
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# rray 0.1.0

* Added a `NEWS.md` file to track changes to the package.
5 changes: 5 additions & 0 deletions R/arith.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
#' been exported, such as `%b+%`, which will perform addition with
#' broadcasting no matter what type the input is.
#'
#' @return
#'
#' The value of the arithmetic operation, with dimensions identical to the
#' common dimensions of the input.
#'
#' @param x,y A pair of vectors.
#'
#' @examples
Expand Down
9 changes: 6 additions & 3 deletions R/broadcast.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#' ```
#'
#' You can broadcast to higher dimensions too. If you go from a 5x2 to a
#' 5x2x3 array, then the 5x2 matrix implicitely gets a 1 appended as another
#' 5x2x3 array, then the 5x2 matrix implicitly gets a 1 appended as another
#' dimension (i.e. 5x2x1)
#'
#'
Expand All @@ -49,6 +49,10 @@
#' @param x The object to broadcast.
#' @param dim An integer vector. The dimension to broadcast to.
#'
#' @return
#'
#' `x` broadcast to the new dimensions.
#'
#' @examples
#'
#' # From 5x1 ...
Expand All @@ -66,8 +70,7 @@
#' rray_broadcast(x, c(5, 2, 3))
#'
#' # You cannot broadcast down in dimensions
#' # rray_broadcast(x, 5)
#' # > Error: Cannot decrease dimensions of `x`
#' try(rray_broadcast(x, 5))
#'
#' @export
rray_broadcast <- function(x, dim) {
Expand Down
4 changes: 4 additions & 0 deletions R/clip.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
#' @param high A single value. The upper bound. `high` is cast to the
#' inner type of `x`.
#'
#' @return
#'
#' `x` bounded by `low` and `high`.
#'
#' @examples
#'
#' # bound `x` between 1 and 5
Expand Down
12 changes: 12 additions & 0 deletions R/coercion.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#' @param x An object to coerce to an array.
#' @param ... Objects passed on to methods.
#'
#' @return
#'
#' An array.
#'
#' @seealso [as_matrix()]
#'
#' @examples
Expand Down Expand Up @@ -70,6 +74,10 @@ as.array.vctrs_rray <- as_array.vctrs_rray
#' @param x An object to coerce to a matrix.
#' @param ... Objects passed on to methods.
#'
#' @return
#'
#' A matrix.
#'
#' @seealso [as_array()]
#'
#' @examples
Expand Down Expand Up @@ -160,6 +168,10 @@ validate_matrix_coercible_dim <- function(dim) {
#'
#' @param x An object to coerce to an rray.
#'
#' @return
#'
#' An rray.
#'
#' @examples
#'
#' as_rray(1)
Expand Down
5 changes: 5 additions & 0 deletions R/compare.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
#' method is used and a warning is thrown. There is nothing we can do about
#' this. See `?groupGeneric` for more information on this.
#'
#' @return
#'
#' The value of the comparison, with dimensions identical to the common
#' dimensions of the inputs.
#'
#' @examples
#' x <- rray(1:12, c(2, 2, 3))
#' y <- matrix(1:2)
Expand Down
4 changes: 4 additions & 0 deletions R/compat-vctrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#' @param ... Used to pass along error message information.
#' @inheritParams vec_ptype2
#'
#' @return
#'
#' See the corresponding vctrs function for the exact return value.
#'
#' @name vctrs-compat
#'
NULL
Expand Down
15 changes: 5 additions & 10 deletions R/container-cast.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,21 @@
#' @examples
#'
#' # Upcasting to an rray. Still a logical
#' # vec_cast_container(TRUE, rray(1))
#' vec_cast_container(TRUE, rray(1))
#'
#' # Downcasting to a double, no longer an rray
#' # (the "container" here is just a base R object)
#' # vec_cast_container(rray(1), TRUE)
#' vec_cast_container(rray(1), TRUE)
#'
#' # Shape of `x` is kept
#' # vec_cast_container(matrix(1:5), rray(1))
#' vec_cast_container(matrix(1:5), rray(1))
#'
#' # Dim names of `x` are kept
#' x <- rray(1:2, dim_names = list(c("r1", "r2")))
#' # vec_cast_container(x, 1)
#' vec_cast_container(x, 1)
#'
#' @keywords internal
#' @noRd
vec_cast_container <- function(x, to) {

if (is.null(x) || is.null(to)) {
Expand All @@ -58,14 +59,12 @@ vec_cast_container <- function(x, to) {

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container.default <- function(x, to) {
stop_incompatible_cast(x, to)
}

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container.logical <- function(x, to) {
UseMethod("vec_cast_container.logical")
}
Expand All @@ -92,7 +91,6 @@ vec_cast_container.logical.vctrs_rray <- function(x, to) {

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container.double <- function(x, to) {
UseMethod("vec_cast_container.double")
}
Expand All @@ -119,7 +117,6 @@ vec_cast_container.double.vctrs_rray <- function(x, to) {

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container.integer <- function(x, to) {
UseMethod("vec_cast_container.integer")
}
Expand All @@ -146,7 +143,6 @@ vec_cast_container.integer.vctrs_rray <- function(x, to) {

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container.vctrs_rray <- function(x, to) {
UseMethod("vec_cast_container.vctrs_rray")
}
Expand All @@ -170,7 +166,6 @@ vec_cast_container.vctrs_rray.vctrs_rray <- function(x, to) {

# ------------------------------------------------------------------------------

#' @rdname vec_cast_container
vec_cast_container_common <- function(..., .to = NULL) {
args <- list2(...)
container <- vec_ptype_container_common(!!!args, .ptype = .to)
Expand Down
10 changes: 5 additions & 5 deletions R/container-type.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@
#'
#' @examples
#' # The container of base R atomics is just logical()
#' # vec_ptype_container(1)
#' vec_ptype_container(1)
#'
#' # The container of an rray is an empty logical rray
#' # vec_ptype_container(rray(1))
#' vec_ptype_container(rray(1))
#'
#' # Find the common container of multiple types
#' # (the rray type is more complex here, and becomes the common container)
#' # vec_ptype_container_common(1, TRUE, rray(1L))
#' vec_ptype_container_common(1, TRUE, rray(1L))
#'
#' # Not an error!
#' # vec_ptype_container_common(character(), logical())
#' vec_ptype_container_common(character(), logical())
#'
#' @keywords internal
#' @noRd
vec_ptype_container <- function(x) {

if (is.null(x)) {
Expand Down Expand Up @@ -84,7 +85,6 @@ vec_ptype_container.vctrs_unspecified <- vec_ptype_container.integer

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container
vec_ptype_container_common <- function(..., .ptype = NULL) {

if (!is.null(.ptype)) {
Expand Down
11 changes: 3 additions & 8 deletions R/container-type2.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
#'
#' @examples
#'
#' # vec_ptype_container2(1, 2L)
#' vec_ptype_container2(1, 2L)
#'
#' # vec_ptype_container2(1, rray(2L))
#' vec_ptype_container2(1, rray(2L))
#'
#' @keywords internal
#' @noRd
vec_ptype_container2 <- function(x, y) {

if (is.null(x)) {
Expand All @@ -29,14 +30,12 @@ vec_ptype_container2 <- function(x, y) {

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.default <- function(x, y) {
stop_incompatible_type(x, y)
}

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.logical <- function(x, y) {
UseMethod("vec_ptype_container2.logical")
}
Expand All @@ -61,7 +60,6 @@ vec_ptype_container2.logical.vctrs_rray <- function(x, y) {

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.integer <- function(x, y) {
UseMethod("vec_ptype_container2.integer")
}
Expand All @@ -82,7 +80,6 @@ vec_ptype_container2.integer.vctrs_rray <- vec_ptype_container2.logical.vctrs_rr

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.double <- function(x, y) {
UseMethod("vec_ptype_container2.double")
}
Expand All @@ -103,7 +100,6 @@ vec_ptype_container2.double.vctrs_rray <- vec_ptype_container2.logical.vctrs_rra

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.character <- function(x, y) {
UseMethod("vec_ptype_container2.character")
}
Expand All @@ -124,7 +120,6 @@ vec_ptype_container2.character.vctrs_rray <- vec_ptype_container2.logical.vctrs_

# ------------------------------------------------------------------------------

#' @rdname vec_ptype_container2
vec_ptype_container2.vctrs_rray <- function(x, y) {
UseMethod("vec_ptype_container2.vctrs_rray")
}
Expand Down
4 changes: 4 additions & 0 deletions R/diagonal.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#' @param offset A single integer specifying the offset from the diagonal to
#' place `x`. This can be positive or negative.
#'
#' @return
#'
#' A matrix, with `x` on the diagonal.
#'
#' @examples
#' # Creates a diagonal matrix
#' rray_diag(1:5)
Expand Down
4 changes: 4 additions & 0 deletions R/dim-n.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#' `dim()` defines a method for data frames that would imply a dimensionality
#' of 2.
#'
#' @return
#'
#' An integer vector containing the number of dimensions of `x`.
#'
#' @examples
#' x_1_by_4 <- rray(c(1, 2, 3, 4), c(1, 4))
#'
Expand Down
4 changes: 4 additions & 0 deletions R/dim-names-common.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
#'
#' @param x,y,... Objects to find common dimensions for.
#'
#' @return
#'
#' A list of the common dimension names of the inputs.
#'
#' @examples
#' library(magrittr)
#'
Expand Down
6 changes: 6 additions & 0 deletions R/dim-names.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
#' @param meta A single character representing an optional "meta" name
#' assigned to the `axis` names. If `NULL`, the current meta name is kept.
#'
#' @return
#'
#' `rray_dim_names()` returns a list of dimension names. The other names
#' functions return character vectors, or `NULL`, corresponding to the
#' names of a particular axis.
#'
#' @name dim-names
#'
#' @examples
Expand Down
4 changes: 4 additions & 0 deletions R/dim.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#'
#' @param ... Objects to find common dimensions for.
#'
#' @return
#'
#' An integer vector containing the common dimensions.
#'
#' @seealso [rray_dim_n()]
#'
#' @examples
Expand Down
5 changes: 5 additions & 0 deletions R/dot.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
#'
#' @param x,y Arrays or rrays that are either 1D or 2D.
#'
#' @return
#'
#' The result of the matrix multiplication of `x` and `y`. See `%*%` for the
#' exact details. The common type of `x` and `y` will be preserved.
#'
#' @examples
#' rray_dot(1:5, 1:5)
#'
Expand Down
Loading

0 comments on commit 68c005f

Please sign in to comment.