flr / FLXSA

The FLXSA package
http://flr-project.org/FLXSA
2 stars 3 forks source link

Fix bug when iterations exist but do not start with 1. #9

Closed shfischer closed 3 years ago

shfischer commented 3 years ago

FLXSA fails if >1 iterations exist but dimnames for iterations do not start with "1".

A minimal reproducible example:

library(FLXSA)
data("ple4")
data("ple4.index")
stk <- propagate(ple4, 10)
idx <- propagate(ple4.index, 10)
FLXSA(iter(stk, 6:10), iter(idx, 6:10), diag.flag = FALSE)
# Error in x@.Data[i, j, k, l, m, n, drop = FALSE] : 
#   subscript out of bounds

because the loop in https://github.com/flr/FLXSA/blob/e50a08af3d5853b2f36c3bd0ecad48418e2ada17/R/flxsa.R#L286 always starts with "2" (which might not exist) instead of 2.

iagomosqueira commented 3 years ago

Thanks for this. I have fixed it but it a way that the updated stock after FLStock + FLXSA has the correct dimnames for iter in all slots. Now pushed at https://github.com/flr/FLXSA/commit/5df860dc6dea7efe5dc5576714d3cc23260f15c8