kuwisdelu / matter

Out-of-core statistical computing and signal processing
http://www.cardinalmsi.org
54 stars 4 forks source link

R session hangs when `data` is missing if `paths` is supplied to matter_mat() #3

Closed PeteHaitch closed 6 years ago

PeteHaitch commented 7 years ago

Hi Kyle,

This is a corner case, but it'd be nice if it resulted in an error rather than hanging the R session (similar to your suggestion in https://github.com/kuwisdelu/matter/issues/2#issuecomment-309103850)

library(matter)

x <- matter_mat(nrow = 5L, ncol = 2L, datamode = "integer")
# Works despite no `data` being supplied (I think because default values are filled in)
x[]
# Can update `x`
x[] <- matrix(1:10, ncol = 2)

paths <- tempfile(fileext = ".bin")
file.create(paths)
y <- matter_mat(nrow = 5L, ncol = 2L, paths = paths)
# Hangs because no data is created (I think because no default values are filled in)
y[]
y[] <- matrix(1:10, ncol = 2)

Thanks, Pete

kuwisdelu commented 7 years ago

Yep, it's on my todo list.

kuwisdelu commented 6 years ago

This is should now fail gracefully. Constructor defaults (including file creation and file mode) in general should be much improved now in >= v1.3.6.