qsbase / qs

Quick serialization of R objects
405 stars 19 forks source link

Failing save/read on an S4 class Raster #27

Closed eliotmcintire closed 4 years ago

eliotmcintire commented 4 years ago

Enjoying your package. The speeds are great! I have a reprex of a failing save/restore with qs. It requires raster package. Any chance this is fixable?

library(qs)
library(raster)

nx <- ny <- 100
N <- nx * ny
template <- raster(nrows = ny, ncols = nx, xmn = -nx / 2, xmx = nx / 2,
                   ymn = -ny / 2, ymx = ny / 2)

# Make dummy map
DEM <- raster(template)
DEM[] <- runif(N)
# Save and restore it
tf <- tempfile(fileext = ".qs"); 
qsave(DEM, file = tf)
DEM2 <- qread(tf)

all.equal(DEM@legend@names, DEM2@legend@names)
# [1] "Modes: logical, character"               "Lengths: 0, 1"                          
# [3] "target is logical, current is character"

# With RDS -- fine
tf <- tempfile(fileext = ".rds"); 
saveRDS(DEM, file = tf)
DEM3 <- readRDS(tf)

all.equal(DEM@legend@names, DEM3@legend@names)
# [1] TRUE
traversc commented 4 years ago

Thank you for the report. I see the issue and it will be fixed in the next CRAN release. 👍

traversc commented 4 years ago

Fixed on cran!