RobinHankin / stokes

methods for exterior calculus
https://robinhankin.github.io/stokes/
3 stars 0 forks source link

bug in replacement method #84

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)
(p <- 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 <- p
coeffs(a)[coeffs(a) < 5] <- 999
a
#>            val
#>  1 1 1  =   10
#>  0 2 2  =  999
#>  1 0 0  =    5
#>  2 2 0  =  999
#>  0 0 2  =  999
#>  2 1 0  =   15
#>  0 0 0  =    6

a <- p
coeffs(a)[coeffs(a) < 100] <- 999
#> Error in `coeffs<-.spray`(`*tmp*`, value = c(999, 999, 999, 999, 999, : length(value) == 1 is not TRUE

Above we see two replacement lines. The first one works fine but the second one does not, even though it has a clear interpretation (viz, change all coefficients to 999). NB: the following extraction works fine:

library("spray")
#> 
#> Attaching package: 'spray'
#> The following objects are masked from 'package:base':
#> 
#>     pmax, pmin
set.seed(0)
p <- rspray()
coeffs(p)[coeffs(p) < 100] 
#> A disord object with hash 2c05f1942b89cf701f630e344423363fb03bc5e4 and elements
#> [1]  6 15  4  3  5  2 10
#> (in some order)

Created on 2024-01-29 with reprex v2.1.0

RobinHankin commented 7 months ago

Put this in the wrong repo, it is a spray issue:

https://github.com/RobinHankin/spray/issues/45