RobinHankin / spray

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

`str()` behaves strangely #42

Open RobinHankin opened 1 year ago

RobinHankin commented 1 year ago

Following issue #40, str() behaves strangely:

suppressMessages(library("spray"))
a1 <- spray(matrix(c(0,2,1,2,2,2),ncol=2),c(1,1,-2))
a2 <- spray(matrix(c(2,1,1,1),ncol=2),c(-2,2))
a1
#>          val
#>  1 2  =   -2
#>  2 2  =    1
#>  0 2  =    1
a2
#>          val
#>  1 1  =    2
#>  2 1  =   -2
str(a1)
#> Class 'spray'  hidden list of 2
#>  $ index: int [1:3, 1:2] 1 2 0 2 2 2
#>  $ value: num [1:3] -2 1 1
str(a2)
#> List of 2
#>  $ index: int [1:2, 1:2] 1 2 1 1
#>  $ value: num [1:2] 2 -2
#>  - attr(*, "class")= chr "spray"

Created on 2023-07-03 with reprex v2.0.2

Above we see that sometimes str() returns a "Class 'spray' hidden list of 2" [as for a1] and sometimes returns a "List of 2" [as for a2] and it is not clear why.