-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Milestone
Description
default expected behavior for arrays (i.e., array-args to [ return a vector of entries in the array) does not carry over to tf-vectors:
library(tf)
x <- tf_rgp(5, arg = 1:5)
# to extract function values at specific args for each function, we need:
as.matrix(x)[cbind(1:5, 1:5)]
#> [1] -0.3721783 0.6235588 1.3563847 -1.4085395 1.1629906
# .. and more complicated code to match arg-values to array-column-indices in general...
# default behavior for arrays does not carry over to tf-vectors:
x[cbind(1:5, 1:5)] # treats array arg as a vector :(
#> tfd[10] on (1,5) based on 5 evaluations each
#> interpolation by tf_approx_linear
#> [1]: (1, -0.4);(2, -1.0);(3, 0.8); ...
#> [2]: (1, -0.8);(2, 0.6);(3, 0.3); ...
#> [3]: (1, 1.9);(2, 0.6);(3, 1.4); ...
#> [4]: (1, -2.5);(2, -1.0);(3, -0.6); ...
#> [5]: (1,-0.07);(2, 0.91);(3,-0.63); ...
#> [6]: (1, -0.4);(2, -1.0);(3, 0.8); ...
#> [7]: (1, -0.8);(2, 0.6);(3, 0.3); ...
#> [8]: (1, 1.9);(2, 0.6);(3, 1.4); ...
#> [9]: (1, -2.5);(2, -1.0);(3, -0.6); ...
#> [10]: (1,-0.07);(2, 0.91);(3,-0.63); ...
x <- tf_rgp(5)
x[cbind(1:5, runif(5))] # fails because i-arg does not check for array-type :(
#> Error in `[.tf`(x, cbind(1:5, runif(5))): Assertion on 'i' failed: Must be of type 'integerish', but element 6 is not close to an integer.Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request