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

Generic predicates should operate on proxy but not restore #251

Closed
lionel- opened this issue Mar 26, 2019 · 1 comment · Fixed by #432
Closed

Generic predicates should operate on proxy but not restore #251

lionel- opened this issue Mar 26, 2019 · 1 comment · Fixed by #432

Comments

@lionel-
Copy link
Member

lionel- commented Mar 26, 2019

They probably should always return an untyped bool.

new_cached_sum <- function(x = double(), sum = 0L) {
  new_vctr(x, sum = sum, class = "vctrs_cached_sum")
}
vec_restore.vctrs_cached_sum <- function(x, to, ..., i = NULL) {
  new_cached_sum(x, sum(x))
}
x <- new_cached_sum(runif(10))

is.finite(x)
#> <vctrs_cached_sum[10]>
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
@DavisVaughan
Copy link
Member

This might be rray specific, but still seems relevant. Should this return an untyped logical matrix? It seems useful to still return an rray because you might want to do other operations on it that require the overloads on + or * or whatever that perform broadcasting.

library(rray)
rray(1:2, c(2, 1)) > 1
#> <rray<lgl>[,1][2]>
#>       [,1]
#> [1,] FALSE
#> [2,]  TRUE

Created on 2019-06-19 by the reprex package (v0.2.1)

lionel- added a commit to lionel-/vctrs that referenced this issue Jun 19, 2019
lionel- added a commit to lionel-/vctrs that referenced this issue Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants