RobinHankin / spray

sparse arrays and fast multivariate polynomials
https://robinhankin.github.io/spray/
2 stars 2 forks source link

pure extraction and replacement methods #45

Closed RobinHankin closed 7 months ago

RobinHankin commented 7 months ago
library("spray")
#> 
#> Attaching package: 'spray'
#> The following objects are masked from 'package:base':
#> 
#>     pmax, pmin
set.seed(0)
(a <- rspray())
#>            val
#>  0 0 0  =    6
#>  2 1 0  =   15
#>  0 0 2  =    4
#>  2 2 0  =    3
#>  1 0 0  =    5
#>  0 2 2  =    2
#>  1 1 1  =   10
a[coeffs(a) > 5]
#> Error in `[.spray`(a, coeffs(a) > 5): incorrect number of dimensions specified
a[coeffs(a) < 10] <- 99
#> Error in `[<-.spray`(`*tmp*`, coeffs(a) < 10, value = 99): incorrect number of dimensions specified

Above we see two perfectly reasonable statements, one extraction and one replacement. Neither works but each has a perfectly reasonable interpretation. In any case, the error message is not very helpful.