spatial-ews / spatialwarnings

An R package to compute spatial early-warning signals of ecosystem degradation
Other
14 stars 4 forks source link

Cryptic error when plotting patchdistr_spews object with bogus data #74

Closed alexgenin closed 4 years ago

alexgenin commented 6 years ago

When used on pathological data (like when there is only one patch size), patchdistr_spews will use the data without trouble, but plotting will return a cryptic error:

E.g.:

a <- matrix(FALSE, ncol = 10, nrow = 10) 
a[1,1] <- TRUE
a <- list(a, a, a, a)
p <- patchdistr_spews(a)
plot(p)
Error in sum(type_freqs) : invalid 'type' (list) of argument

There is a probably a better way to handle this (e.g.. by producing a warning in patchdistr_spews or an error in its plot method).

alexgenin commented 4 years ago

This is now fixed: we display a warning when all data is missing and plot nothing.