Skip to content

Commit

Permalink
A realization.
Browse files Browse the repository at this point in the history
  • Loading branch information
kondziu committed Jul 22, 2021
1 parent 231ec5e commit 81df193
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ufovectors/R/operators.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ ufo_subscript <- function(x, subscript, min_load_count=0) {
# when we do, I think.# Unless we really dig into it and re-create it from
# scratch. This would perhaps be nicer, but subset assign works out of the box,
# provided the subscript is small enough. If the subscript is big, there is
# v[ufo_subscript(v, i)] <- v as a potential workaround. Another alternative is
# to explicitly mutate in-place with ufo_mutate.
# v[ufo_subscript(v, i)] <- v as a potential workaround, but it will cause the
# subscript to be re-created anyway, to change to 0-indexing, so... Another
# alternative is to explicitly mutate in-place with ufo_mutate.

# Warnign: buggy.
ufo_mutate <- function(x, subscript, values, ..., drop=FALSE, min_load_count=0) { # drop ignored for ordinary vectors, it seems?
Expand Down
4 changes: 2 additions & 2 deletions ufovectors/tests/testthat/test-assign.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ test_ufo_assign <- function (data, subscript, ufo_constructor) {
ufo <- ufo_constructor(length(data))
#ufo[seq_len(length(data))] <- data

#ufo[subscript] <- new_data
ufo[ufo_subscript(ufo, subscript)] <- new_data
ufo[subscript] <- new_data
#ufo[ufo_subscript(ufo, subscript)] <- new_data

reference_vector <- vector(typeof(ufo), length(data))
reference_vector[subscript] <- new_data
Expand Down

0 comments on commit 81df193

Please sign in to comment.