line numbers / node names in error messages

119 views
Skip to first unread message

Tomas T.

unread,
Dec 22, 2021, 9:45:40 AM12/22/21
to nimble-users
Dear nimble developers, dear users,

I encountered another error which I am completely clueless about:

Defining model
Error in BUGSdecl$targetIndexNamePieces[[iDim]] : subscript out of bounds

It's gonna be something with the indices, but my code is more than hundred lines long, and contains a lot of indexed arrays. How am I supposed to find where the problem is from this message? This frustration reminds me old times with WinBUGS and the infamous Trap 66 :-)) I really appreciate the helpfulness of the authors here in the forum, but I cannot be sending code here every time I get an error. I am trying to find for myself a sustainable way to develop models in Nimble. How are other users coping with this? Nimble is out for 7+ years, right? How come no one became frustrated enough yet to invest time in this? Wouldn't it save development time in the end?

Would it be difficult to implement, to report line numbers and node names? 

I am C++ & R developer myself, so I think it might save me time and nerves to contribute this to Nimble myself. Note that for some errors, not only line numbers but also node names would be very helpful (see e.g. the infamous "Invalid parent values" in JAGS, frustrated me enough that I once patched my JAGS to report more details on this).

Thank you and wish you beautiful advent time.

Tomas

Perry de Valpine

unread,
Dec 22, 2021, 12:42:46 PM12/22/21
to Tomas T., nimble-users
Dear Tomas,

Thanks for sharing your experience here.

As a short-term approach for you, I suggest doing:

options(error = recover)
# Run the nimbleModel call giving the error
# Select what appears to be the most relevant frame in the call stack (can be a bit tricky: you want one of the most recent ones and can try a few if it's not easy to see which one is best)
# Check if you have found a place in the call stack with the BUGSdecl object.  Try inspecting it, such as
BUGSdecl$code # should be something resembling an original line of model code

I hope that helps.
Perry


--
You received this message because you are subscribed to the Google Groups "nimble-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nimble-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nimble-users/CAGy9Uw_A-jQmNRDJDuRQmcviNNj5ZJEZS8wTpSc86%2BbkXWR70Q%40mail.gmail.com.

Chris Paciorek

unread,
Dec 27, 2021, 12:11:29 PM12/27/21
to Tomas T., nimble-users
Hi Tomas,

In cases where NIMBLE traps an error, we generally try to report information about the problematic code, though I can't say we're perfect about it. In this case, the error is being reported by R, which means we haven't trapped it ourselves; i.e., something is going wrong that we haven't anticipated. If you're able to find the problematic line in your case, please report it to us (ideally as a reproducible example) so that we can add informative error trapping for the case you're encountering.

-chris

Reply all
Reply to author
Forward
0 new messages